A ruby question...
Mar 12, 05:14 PM
I have a strange attraction to new programming languages. There’s something about a new language when it is simple and clean that holds a lot of promise. Perhaps it hasn’t yet been pushed and therfore has not had to make any compromises, or perhaps when I learn a new language I overlook the details that snag me up… Either way, Ruby is my new interest.
Recently, I was reading through Alex’s Rules for Surviving Software Development Projects which I think is a pretty interesting idea. One of my rules is: always favor compile time checking.
Now I’ve programmed in the usuals: Perl, PHP, C, C#,C++, Java etc… but other than a web development job I had right out of college, It has been mostly compiled languages, a lot of embedded/handheld programming and some J2EE messaging systems. I fully understand the appeal of dynamic languages. It does annoy me that in order to check if my Java/XMLC compiled code is working, I have to actually compile it. However, I find that the compile time type checking catches lots of bugs that I would have had to click through my site to even expose. Add Eclipse to the mix and I actually get warnings about how my code changes are affecting other modules, as I change them.
This brings me to another one of my rules: If you haven’t properly handled a bug make sure it crashes the whole system. This probably comes from my background in handhelds where rebooting the application isn’t an option as many embedded apps dont even include shutdown code. Once the application is in an unhandled state, I would prefer it to shut down rather than continue forward doing who-knows-what to who-knows-where. That’s a nightmare debugging session.
Static typing helps ensure that an incompatable modification in one section breaks the code in others and forces you to address the issue. I see this as a sort of compile time exception; Instant checking of code compatability without JUnit tests, or running it to ensure something didnt break.
So my question to other programmers (espcially Ruby programmers) is: What feature of Ruby or other dynamic, non-typed languages helps to ensure that a change in one section of code is is not going to break another? Should I throw away my concerns of type safety and just trust it? Is the pradigm so different that those concerns are not needed here?
edit: I found this article on types in ruby in the rubygarden which seems to be trying to answer the question. Unfortunately, the answer is a little lacking. It seems to be saying, “write unit tests.” That’s all well and good however, you can do that in strongly typed languages too. You get the compiler checking for free. The difference between Classes and Types is interesting though.
Breathe Video << - >> New server, new domain
