News for hackers. Stuff that matters.
Re:Returning to JavaScript After 5 Years by ClayFerguson on Saturday January 07, 2017 @05:51PM (#13347151)
TypeScript is the modern way to 'do' JavaScript. It solves every problem that JavaScript ever had.
Re:Returning to JavaScript After 5 Years by automatwon on Saturday January 07, 2017 @06:31PM (#13347309)
It does not solve every problem JavaScript ever had. By definition of being a superset, it's still JavaScript. It just induces a prescription to mitigate symptoms of type unsafeness.

Null AND Undefined still coexist, though type safety helps. There's an idiomatic way to specify classes, as opposed to using a pattern of object returning closure function for instance. There's still both the == and === operators.

A problem beyond type-safety is the confusing semantics of 'this': https://github.com/Microsoft/TypeScript/wiki/'this'-in-TypeS...

Re:Returning to JavaScript After 5 Years by pluma on Saturday January 07, 2017 @06:43PM (#13347357)
The semantics of 'this' in TS are the same as in JS and they're only a problem if you expect TS to be Java rather than JS.
Re:Returning to JavaScript After 5 Years by ClayFerguson on Sunday January 08, 2017 @01:35AM (#13348627)
I use the '=>' operator to get a 'this' reference that does what you'd expect (like in Java) by getting whatever object is running rather than the typical JS 'this' of the function. Trivial example is here:

https://github.com/Clay-Ferguson/meta64/blob/master/src/main...

Re:Returning to JavaScript After 5 Years by ClayFerguson on Sunday January 08, 2017 @01:32AM (#13348616)
If you want to trade contrarian jabs, I can play that game: TypeScript does far more than 'mitigate symptoms of type unsafeness' it is a fully type-safe language that will get proper compile-time errors if you use the wrong type. It doesn't "mitigate" unsafeness. It ELIMINATES unsafeness.
Re:Returning to JavaScript After 5 Years by automatwon on Sunday January 08, 2017 @05:57AM (#13349203)
When comparing the types of function parameters, assignment succeeds if either the source parameter is assignable to the target parameter, or vice versa. This is UNSOUND because a caller might end up being given a function that takes a more specialized type, but invokes the function with a less specialized type.

A Google query for the definition of unsound: "not safe or robust"

https://www.typescriptlang.org/docs/handbook/type-compatibil...

You're portraying TypeScript as if it's perfect. Typescript is is permissive and structurally, rather than nominally typed. This is not TypeScript's fault. There will always be tradeoffs. Among other things in the FAQ, there is a section on how to prevent two types from being structurally incompatible. "A possible FIX if you really want two types to be incompatible is to add a 'brand' member"...

https://github.com/Microsoft/TypeScript/wiki/FAQ#type-system...

Re:Returning to JavaScript After 5 Years by ClayFerguson on Sunday January 08, 2017 @11:53AM (#13350586)
The 'assignability rules' of TS catches type-errors in a way that 'solves' all the problems JS ever had. You can critique the nature of that solution if you want (after all, there are an infinite number of solutions in the solution-set), but I think it's a perfect solution.

Give any good developer TS to code in, and he'll know how to use it to check every type in every variable, class, or method parameter, and the checking will be 100% perfectly reliable. That's what I mean by "problem solved".

Re:Returning to JavaScript After 5 Years by automatwon on Sunday January 08, 2017 @06:32PM (#13352782)
Google's closure compiler already addressed that
Re:Returning to JavaScript After 5 Years by ClayFerguson on Sunday January 08, 2017 @11:09PM (#13353942)
Yeah, that's what I just said.
Re:Returning to JavaScript After 5 Years by millstone on Saturday January 07, 2017 @11:23PM (#13348236)
I like TypeScript but it doesn't come close to solving every problem. You still have floating-point only numerics, bizarre array semantics, crappy Unicode support, nigh-unusable threading, perf optimization is hard, lots more.
Re:Returning to JavaScript After 5 Years by ClayFerguson on Sunday January 08, 2017 @01:52AM (#13348668)
If you took a poll of developers about what the problems with JavaScript really are, the things you mentioned wouldn't even make it onto the list.

Imagine how much of a disaster the web would be today if JavaScript allowed threading all these years. All the script-kiddies who have never written one line of back-end code in their lives suddenly having to grapple with concurrency? Oh my god what a disaster.