by ruddct · 11y ago · 0 comments
Really the only thing that's missing as a language feature is some kind of concurrency support, though I'm hopeful future iterations will include this. In the mean time, it might be a bit of a blocker for serious server-side adoption.
There's a line somewhere between excessive verbosity and dumb trust (like the YAML snafu). I haven't seen great syntax yet, though.
@untyped func parse(json: AnyObject) -> String? { /* code here is not type checked, if returned value is not type String then value will become nil */ }
E.g. most JSON APIs don't send arrays of primitive types (numbers, strings) around, but allowing for them makes implementing JSON nicely in non-JS languages decidedly uglier. JSON's quoting of symbols is just inefficient (it's not any other language's fault that Javascript's set of reserved words is bizarre, and in any case no-one should be "eval"ing JSON these days.)
Reflection doesn't get in the way of type safety (in fact, it's generally supported by it) and "ease of optimization" and "performance" is just BS. Ya, sure, sometimes reflection slows things down but web devs who use ruby for 90% of projects don't care about that. I'd love to hear you try and explain how reflection tarnishes "ease of optimization" and why it's so "ugly"
Perhaps my terminology was incorrect there. It's more that it gets in the way of static verification, and makes it much harder to refactor code with confidence.
For example, I am working on a Java project at the moment, for which many constructors and methods are apparently (to the IDE's static analysis) unused. I could quite merrily delete them or change their signatures, only to have the program it break unexpectedly at runtime due to reflection expecting them to exist at the opposite end of the codebase. That is the power of static types - and reflection breaks those guarantees.
Ruby is not a statically typed language and has nothing to do with type safety or ease of optimization. Reflection for a dynamic language is hardly the same as reflection for static language.
It's like saying multiplication makes things hard to understand...
You could write things 15 x 3 or 15 + 15 + 15, I dislike having programmers who like to do the latter on my team, or languages that make you do things like: Integer(15).multiply(Integer(3))
I'm sure that using reflection or higher order programming does cut out some people that you probably don't want anyway.
Leveraging the type system for COMPILE TIME dynamic programming is not only safer, but more runtime-efficient. Wanna be clever? Here you go, be type-safely clever:
https://vimeo.com/channels/flatmap2015/128466887
http://www.haskellforall.com/2012/06/you-could-have-invented...
With a good type system, you won't need reflection. If it compiles, it will work.
And give me a break on the "cut out the dumb people" part, I heard it many times from people right before they shoot themselves on a foot. Repeatedly.
As engineers, it's our job to solve problem and reduce complexity. Fail at either of the two, you have been a shit engineer.
When working in swift it's as if someone rewrote the thing in Java. As obnoxious as eclipse can be, it at least code completes in a reasonable time.