Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Well Node.js(+Framework) is an entirely different beast from Swift(+Framework), RoR, Python+Django, etc. As for Swift(+Framework) vs Python+Django, RoR, etc, Swift would have to be faster and introduce some amazing new feature for it to replace anything. I dont personally like how Swift is statically typed but does type inference. If i dont specify a type for my variable i should be able to change my variable's value to whatever type i want.


> If i dont specify a type for my variable i should be able to change my variable's value to whatever type i want.

You mean you want to assign a string to a variable and then re-assign it to something else entirely such as a number?

Just reassigning at all is dubious in my opinion, and seeing a reassignment with a completely different type would make me flip the table in review.

If you ever want a "catch all" variable you can then explicitly type it as a base type like "object", and assign what you want. But that should be very rare, so it's perfectly natural that type inference assigns a static type to the field.

The only time you get bad inference is if you have subtypes and the first assignment is too narrow, e.g

Apple GetApple() { ... } var myFruit = GetApple(); // type is Apple if (cond) myFruit = GetOrange(); // can't assign orange

In this scenario you have to declare explicitly as Fruit. But again: this is rare, and all reassignment should be rare! Always have good reason before mutating anything.


Stupidest argument i've ever heard in favor of javascript.

> If i dont specify a type for my variable i should be able to change my variable's value to whatever type i want.


Not really.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: