News for hackers. Stuff that matters.
Re:JavaScript for squares: The incredible rise of TypeScript by draw_down on Tuesday July 25, 2017 @07:11PM (#14852635)
I came to JS after spending years in C# and Java, and so I liked the dynamically-typed nature of the language. It feels a lot freer, to me. Of course I understand why people think static typing is important, but going back to that way of denoting what everything is just seems so onerous.

But even regardless of that, what I really hate is how these typed JS variants introduce so much extra syntax and -- sorry for my phraseology -- crap into the language.

Here is an example of Flow:

    declare function isMap(m: mixed): boolean %checks(m instanceof Map);
You can call that whatever you want, but JavaScript it ain't.
Re:JavaScript for squares: The incredible rise of TypeScript by girvo on Tuesday July 25, 2017 @09:37PM (#14853189)
Sure, but that isn't JavaScript and isn't needed at runtime anyway. It's literally stripped out, not even compiled (unlike TS)!

Flows type system is amazingly powerful, too, which I adore. So I'm biased; being able to emulate HKTs with real type checking gives me the dynamic power of JS with the type safety I want; and it's an easier sell than Purescript ;)

Re:JavaScript for squares: The incredible rise of TypeScript by shakna on Tuesday July 25, 2017 @08:18PM (#14852929)
Type deduction isn't a terrible hardship, and should make the code look dynamic.

A simple debugging output can attach the types visibly.

So... My question is why these statically typed JSs add such verbose syntax?

Even C++ has had auto to avoid irritating boilerplate.

Re:JavaScript for squares: The incredible rise of TypeScript by girvo on Tuesday July 25, 2017 @09:41PM (#14853200)
Flow doesn't require you to write what's above at all for the most part, and it's type inference and flow analysis is amazing. Your applications code will have few type hints if that's what you want, and your core libraries can have the extremely specific types as what's show in the parent post. I dunno, I like TS and Flow, and gradual typing with excellent inference means it rarely gets in my way, even when calling out to JS libraries that are as dynamic and loose as you can get.