News for hackers. Stuff that matters.
Re:JavaScript for People Who Hate JavaScript by pbowyer on Wednesday August 09, 2017 @04:53AM (#14966714)
I've gone through the same experience this year, having picked up modern JavaScript, Angular2, TypeScript and RxJS for a project.

For me it was TypeScript that did it. I came to appreciate strong typing. And ES6, fixing the 'this' scope problems and with a conventional class syntax (I understand prototype inheritance is clever, but it's not the way I've been trained to think). I didn't get to use async/await for various reasons, but that looks to remove my third pain point (callback hell/promises/observables).

RxJS remains a mystery (I swear the API wasn't designed for humans) I use and hope it works, and combining code that use Observables with those that use Promises still wakes me up in a cold sweat.

But now going back to old territory (PHP, Symfony) I miss it. Yesterday's miss was union types. TypeScript has spoiled me.

Re:JavaScript for People Who Hate JavaScript by 5trokerac3 on Wednesday August 09, 2017 @09:17AM (#14968409)
I left React for Angular 4 this year, because I came to the realization that once I made the decision to leave the loosie-goosie world of default JS, there was no reason to have my framework be loose either.

I'm really loving the confines of a "one way to do it" framework like Angular 4. It makes teamwork much easier, speeds up development once you've gotten over the learning curve, and is damned impressive when it comes to app performance.

I'm really looking forward to the day when TypeScript platforms like Angular 4 compile down to WebAssembly and performance goes through the roof.

Re:JavaScript for People Who Hate JavaScript by pps on Wednesday August 09, 2017 @12:46PM (#14971051)
> I'm really looking forward to the day when TypeScript platforms like Angular 4 compile down to WebAssembly and performance goes through the roof.

You will be disappointed https://github.com/WebAssembly/design/issues/219

Re:JavaScript for People Who Hate JavaScript by 5trokerac3 on Wednesday August 09, 2017 @03:29PM (#14972722)
> We have spoken with the TypeScript team about this possibility and they have shown interest, but it seems like progress there is currently gated on adding typed objects into JS.

Once JS has typed objects, I think it can become as much of a valid compiled language as anything else. I'm still holding out hope.

Re:JavaScript for People Who Hate JavaScript by pps on Thursday August 10, 2017 @06:34PM (#14984989)
Sorry to be a party pooper again, but https://esdiscuss.org/topic/es8-proposal-optional-static-typ... and https://ecmascript-daily.github.io/pages/status-of-static-ty... ... I'd like to see that myself, but what can you do... I'm learning Rust instead to use this in wasm. With new webpack initiative https://medium.com/webpack/webpack-awarded-125-000-from-moss... it's looking good.
Re:JavaScript for People Who Hate JavaScript by pbowyer on Wednesday August 09, 2017 @02:44PM (#14972331)
> I'm really loving the confines of a "one way to do it" framework like Angular 4. It makes teamwork much easier, speeds up development once you've gotten over the learning curve, and is damned impressive when it comes to app performance.

I found thinking about apps easier in Angular too, being that bit more of a conventional system (for want of a better term) than React. Decomposing everything into a component (as I should in React) is a new skill, and will take some thought for me to get right. I started sketching it out for a personal project and went with VueJS so I could get it done quickly.

mobx fascinates me and I will be trying that - with Angular, with React, with anything it goes with.

Re:JavaScript for People Who Hate JavaScript by kneedeepclunge on Wednesday August 09, 2017 @10:06AM (#14968943)
how well does Angular perform on production?

as far as i know, React is used more widespread

Re:JavaScript for People Who Hate JavaScript by pbowyer on Wednesday August 09, 2017 @02:40PM (#14972298)
We used Angular inside Ionic for an iOS app. Performance is OK, but I can't tell you if a different JS framework would be faster, or if it's a device/Ionic limitation. The main problem has been with rendering large sets of data (say 100+ items) in a scrolling list.
Re:JavaScript for People Who Hate JavaScript by 5trokerac3 on Wednesday August 09, 2017 @12:30PM (#14970926)
It's blazing fast. IMO React is more widely adopted, because it's been production ready for longer and because of the whole Angular PR debacle.

Once the platform development settles down (v2 -> v4 anyone?), I think it'll be the clear option for enterprise level development.

Re:JavaScript for People Who Hate JavaScript by calafrax on Wednesday August 09, 2017 @02:10PM (#14971987)
horribly.
Re:JavaScript for People Who Hate JavaScript by disease on Wednesday August 09, 2017 @10:40AM (#14969427)
TypeScript also works wonders in React. Using a component that someone else made? TypeScript will make sure you are passing it the props it expects. Change the expected props for a component? TypeScript will immediately let you know what code you need to change for every component that uses that component.

Also NoImplicitAny and StrictNullChecks are two great tastes that taste great together. Everything in your code is now typed, AND TypeScript will now actually make you think about how you are handling (or not handling) null values. These two flags have basically allowed us to completely eliminate all the 'X is not a function of Y' and 'Z is undefined in this' errors - which is pretty amazing because for me at least these were probably the most common JS errors I get.

Re:JavaScript for People Who Hate JavaScript by TomMarius on Wednesday August 09, 2017 @05:22AM (#14966865)
There is no callback hell if you're using promises correctly. While await is the best option, plain promises are pleasant to work with as well. Could you paste an example of how do you use them? If you're actually using them wrong, I'll gladly show you how to do it right.
Re:JavaScript for People Who Hate JavaScript by bpicolo on Wednesday August 09, 2017 @08:58AM (#14968204)
Think he was trying to say that he likes neither callback hell nor promises
Re:JavaScript for People Who Hate JavaScript by TomMarius on Wednesday August 09, 2017 @09:06AM (#14968302)
Oh, I didn't get that. If that's the case, I'm sorry for misunderstanding.
Re:JavaScript for People Who Hate JavaScript by slackingoff2017 on Wednesday August 09, 2017 @06:03AM (#14967067)
Amen for typescript. With TsLint and all the options on JavaScript is almost pleasant to work with.
Re:JavaScript for People Who Hate JavaScript by WorldMaker on Wednesday August 09, 2017 @10:51AM (#14969569)
Most of my projects I wound up switching from RxJS to xstream [1], for several reasons related to size/performance and synergy with a framework I heavily use (Cycle.js). It's RxJS influenced, but written from scratch in Typescript with a much simpler API surface and somewhat easier to reason with semantics (default "hot" and "shared" Observables versus default "cold" and "unpublished" Observables).

Also, Typescript now supports (since 2.3) downleveling async/await all the way to ES5, which is very handy.

[1] http://staltz.com/xstream/

Re:JavaScript for People Who Hate JavaScript by flavio81 on Wednesday August 09, 2017 @12:34PM (#14970954)
Typescript will give you compile-time type checking, but the actual runtime (javascript) is weakly typed.

For me this is the main problem with the language, otherwise it is a good language even without compile time type checking.

Re:JavaScript for People Who Hate JavaScript by pbowyer on Wednesday August 09, 2017 @02:47PM (#14972355)
> Typescript will give you compile-time type checking, but the actual runtime (javascript) is weakly typed.

Yes and this sucks. There have been a few bugs I've had (can't remember details) where the types or visibility looked OK in the editor but I was bitten at runtime.

No doubt due to my loose configuration - tightening up the linter would help and getting rid of null/undefined overlaps is my next move.