|
|
|
|
|
by osdev
2001 days ago
|
|
I’m not too familiar with ruby but I’m curious why they didn’t just add optional types after the variable names. Such as in Kotlin, Scala, Swift like “var x:Int”? I thought this is how Python was adding types to its language. I could see this though fundamentally changing the philosophy/design of the language but I think dynamic languages are heading toward type safety anyway. |
|
These half typed approached are IMHO ultimately disappointing. It gets you some of the advantages of a type system but not the full robustness of a proper type system. Some languages do it better than others e.g. typescript is a bit more strongly typed than python 3. But ultimately you end up with a lot of compromises to allow legacy untyped code to still work. I think of this as a stepping stone for finding your way to a language with a proper type system. Once you get it and like it, you'll crave more and more is readily available in other languages.
I think the trend of type inference has sort of broken the "typing is too verbose for my taste" argument. I've converted a fair bit of javascript to typescript and you generally don't end up with more lines of code or less readable code (rather the opposite I would argue). And you do end up finding and fixing obvious type issues, glaring design flaws, etc. So, it clearly adds value at an arguably very reasonable cost. And that's before you consider IDE tooling and things like auto-complete, which add a lot of value in day to day use. Typescript in strict mode just feels like a better language than Javascript. I'm currently doing frontend development with Kotlin-js and the Fritz2 framework, which is awesome. It does feel like a step up from typescript + react but definitely not for the faint of heart if you are squeamish about early adopter stuff.
This new ruby typing system looks like an attempt to keep the language fresh and relevant in the same way. It looks like it is a necessary step at this point. I guess it's a valuable tool if you manage a large ruby code base none the less. Not one of my problems luckily. I haven't used it in years and at this point it's not an obvious choice for me for anything new.