Hi, Does anyone know is there some ruby configurations that can be done to make ruby act a little more like a statically typed languageâ?¦â?¦â?¦I love its dynamic nature, but miss the safety that comes from statically typed languages like javaâ?¦â?¦. Cheers in advance -- View this message in context: http://www.nabble.com/Ducktyping-ruby-t1519743.html#a4126192 Sent from the RubyOnRails Users forum at Nabble.com.
on 2006-04-27 20:18
on 2006-04-27 23:51
JackBrody wrote: > Hi, > Does anyone know is there some ruby configurations that can be done to > make > ruby act a little more like a statically typed languageâ?¦â?¦â?¦I love its > dynamic > nature, but miss the safety that comes from statically typed languages > like > javaâ?¦â?¦. Hi jack, Can you elucidate a little ? What kinds of things do you feel are less safe in your ruby code than in your java code ? If it's about the type of args, I suppose you could check that an object passed in responds to all the messages you're planning to send, and raise early. I don't *think* you can statically check that kind of stuff prior to runtime, but could be wrong. You might be better in the ruby-talk list as this is more ruby-ish question, than a rails question. For my own part, I too was nervous, until I realised that I never got compile errors (due to incorrect types) in my Java, so didn't miss them in Ruby. The only place I did get occasional errors was in the monumental XML config required for our Spring/iBATIS app. That XML config meant I wasn't informed about type errors until runtime, just like Ruby. So, occasional type errors, not discovered until runtime was equally true in Java and Ruby for me. YMMV, of course, but it's worth asking the last time the compiler caught a typing bug for you. A.