3 ms·
The difference between JS and Swift is that Swift compiles everything with static types. So JS just plods along and does one of it's funky things with types whe
by dep_b 10y ago
The difference between JS and Swift is that Swift compiles everything with static types. So JS just plods along and does one of it's funky things with types when encountering the next instruction, but Swift actually needs hard types to be able to compile and run at all. So you need to provide them, or it figures them out by itself. There used to be this famous error about "too complex" statements. They still exist but got a lot less:
"swift expression was too complex to be solved"
http://stackoverflow.com/questions/29707622/bizarre-swift-compiler-error-expression-too-complex-on-a-string-concatenation http://stackoverflow.com/questions/29707622/bizarre-swift-co...
Also check the second answer, it's actually the best.
- seanmcdirmid 10y agoI'm pretty well versed in static vs. dynamic typing. In that example, they aren't inferring through a generic + type, but are rather doing it in a brute force manner, forking the world each time they have to consider an alternative. I guess this pitfall is why experienced type system designers make the big bucks.