3 ms·
I've been tempted by this one several times. I may have to play around with it and SDL2. One thing that gets me, though, is the var keyword in a statically typ
by atrilumen 13y ago
I've been tempted by this one several times. I may have to play around with it and SDL2.
One thing that gets me, though, is the var keyword in a statically typed language. Why say "var thing: string" instead of "string thing"?
I think that consistent, explicit declaration of types is much cleaner and easier to read than this recurring mixture of type inference and annotation.
- eropple 13y agoIn this language, I don't think it makes sense. (Then again, I think little of this language makes sense. Neat hack, but still in the "if I want GC I'll use the JVM" bucket that a lot of these fall into.) In something like Scala, you can end up with some fairly hairy eyesores of variable declarations and the type is often not that important when you and everyone else have the ability to hover over a variable name and see the computed type immediately. Wouldn't work for a vim-driven language, but works well in an IDE.
- twotwotwo 13y agoOne point in favor of inference is that it gives you less to read, and what the compiler can infer, the reader usually can, too. On the other side, you could say you shouldn't have to infer while you read and having types in front of you reduces cognitive load. I bet the folks building these languages with inference probably and wouldn't mind having fewer annotations (and being more consistent, in a sense) if they could. It's just that to get rid of some of these annotations you have to make deep changes to the language, like OCaml's polymorphic functions, and that may be inconsistent with their design goals or just hard. Obviously folks won't agree on whether inference is a great thing or not. Whatever one's used to usually seems easier to read. I've worked more in dynamically typed langauges than statically, and (so) languages with inference feel more like home.
- zahary 13y agoWell, Nimrod is built around type-infernce. Most of the time you should just say "var thing = somethingStringy()".