News for hackers. Stuff that matters.
Re:State of JavaScript 2019 by samspenc on Thursday December 19, 2019 @01:59AM (#21832651)
I'm surprised to see Angular drop in ratings and rank so poorly compared to React. I personally prefer Angular myself because it's (a) opiniated and (b) has everything included (HTTP REST calls, Material UI, etc). Just curious why so many people prefer React and mark it so positively.
Re:State of JavaScript 2019 by 734129837261 on Thursday December 19, 2019 @02:20AM (#21832726)
Angular ng-is ng-very ng-opinionated and requires a ton of boilerplate knowledge. It requires typescript knowledge, and I've noticed that (finally!) a lot of developers are realising that typescript actually doesn't make life easier at all.

React, on the other hand, is a very intuitive library instead of an all-encompassing framework. You can easily setup a React application in a few seconds and get started, adding whatever you want as you go.

The JSX syntax is infinitely more intuitive compared to the Angular way of doing things. Which also gets me to the point of Angular having a specific way of doing things, "the Angular way".

With React there's less thinking required to get things done. The learning curve is steep (as in: you pick up the knowledge quicker) because the amount of information to take in is relatively low.

Angular takes months to master. It's very opinionated. And it requires typescript.

I for one hate typescript with the passion of a thousand suns. I know it very well because I have to if I want to keep my job, but it's so freaking unnecessary...

Re:State of JavaScript 2019 by tannhaeuser on Thursday December 19, 2019 @03:46AM (#21833137)
Just the other day I had a look at a friend's customer Angular project. My eyes! I knew Angular from past experiences, but once again it stuck out to me that Angular devs tastelessly found it necessary to equip HTML with additional meta-syntax such as parens and asterisk as part of attribute names. Now I can get that some people dislike markup languages (SGML/XML), but going in there and invent a whole new syntax on top when SGML already has plenty (arguably even too much already, to the point that W3C found it necessary to invent the XML subset of SGML) just tells me Angular is made by people full of Java-ish MVC world-views but complete lack of awareness of prior art and established practices in the field. A similar thing is happening with HypeScript: bending a weakly-typed language to fit an outdated and obsolete OOP mindset when JavaScript has eg closures for modularizing event handling.
Re:State of JavaScript 2019 by tashoecraft on Thursday December 19, 2019 @09:55AM (#21835374)
I probably wouldn't go around discrediting a large group of extremely knowledgeable devs with extensive experience. My opinion is generally, if I see something a ton of people have spent countless hours building and I think it's stupid, I should atleast think about why.

Angular uses parens to bind to existing element classes, so if you use an html element, and it has a src field, you want to pass a string just do the normal src="string" you want to pass something from javascript [src]="variable". Boom, you just learned the biggest part of angular template syntax, congrats. This allows for using any existing element, or newly developed elements, web components, without worry about clashing, (jsx class...).

I do agree they went a little to heavy with OOP thinking, it's a weird balance between the functional reactive pushed by rxjs, and a more classic OOP line of thinking. I believe Angular will move more towards a functional way of developing as the team is coming off of the rendering refactor, ivy, and the community is working on the functional reactive component.

Re:State of JavaScript 2019 by hacker_9 on Thursday December 19, 2019 @02:49AM (#21832861)
Typescript doesn't make things easier, and react is intuitive? You know April fool's is still a few months away right?
Re:State of JavaScript 2019 by holler on Thursday December 19, 2019 @08:05PM (#21840918)
I have to say, although I agree that type-safety is nice, in practice having worked on many javascript apps large and small throughout the past decade, type errors have never been something that slowed me or my team down. Lately I've been questioning whether the hype around TS, and the extra layer of complexity, is really worth it. I guess it depends on the team etc, but I certainly question whether it's a good choice for new or smaller projects.
Re:State of JavaScript 2019 by joshsaintjacque on Tuesday December 24, 2019 @02:28PM (#21874312)
I think people underestimate how often they encounter type errors.

Anytime you try to call a property on an object that's undefined, or try to call a function that doesn't exist - those are type errors. And they're the most common JS errors we encounter.

Rollbar aggregated the 10 most common JS errors, and virtually all of them are type errors: https://medium.com/@Iren.Korkishko/10-most-common-javascript...

Re:State of JavaScript 2019 by 734129837261 on Thursday December 19, 2019 @03:02AM (#21832921)
TypeScript slows down a project. Nobody seems to ever point out what benefits it supposedly offers.

My claim: TypeScript offers no benefit. Ever. That's 2 years of fulltime TS experience talking and 18 years of fulltime JavaScript experience, on top of a whole bunch of full stack (Java and .Net with C#) experience.

I think the popularity of TS is going to decline. And I think it's only popular because of the influx of backend developers coming into the frontend. Additionally, because "everybody does it so it must be professional so I should like it".

As for React, well, great argument, I guess?

Re:State of JavaScript 2019 by hacker_9 on Thursday December 19, 2019 @04:27AM (#21833318)
Slows down what?

Compile times? By a small amount sure, but with the incremental compilation we're talking maybe a few tens of seconds max. Any longer and you need to look at improving your build dependencies for better parallelism, and upgrading your hardware.

Development time? Types reduce mental overhead and abstraction for the developer, speeding up development.

Run time? Variables with types that stay static execute faster in JS engines.

Types keep code maintainable, and protect against any accidentally implicit conversions (rife in JS). Types still exist whether you define them or not, so being explicit gives the maintainer of your code much less mental overhead when working with your code. Knowing the contract that a function follows allows them to skip over any assumptions and know exactly what the code is meant to do. Break the contract, get a compile time error.

Anyone can write code, writing maintainable code is the real challenge. In my own 20 years experience this is always what separates the wheat from the chaff.

Re:State of JavaScript 2019 by hajile on Thursday December 19, 2019 @11:16AM (#21836201)
> Development time? Types reduce mental overhead and abstraction for the developer, speeding up development.

React has proptypes that make contract guarantees -- ones that don't disappear at compile time. Most stuff is local to a single file. If your imports and shared objects are so poorly named and poorly understood that types become the major blocker, you have bigger issues.

> Run time? Variables with types that stay static execute faster in JS engines.

The biggest issue in JS engines is making functions monomorphic. Typescript is perfectly happy with every single function in your system being a slow, megamorphic call.

As to changing variables, judicious use of `const` is the real answer here.

There is definitely something to be said for enforcing object structure though. Adding and removing properties to an object is a significant issue. The non-type solution here is the addition of records and tuples to the system. Since they cannot be modified, the general performance will go up.

https://github.com/tc39/proposal-record-tuple

I like the idea of types, but dislike typescript. Most importantly, it is not a sound type system and the illusion of sound types is worse than dynamic types IMO. If I ever adopt a type system into my current project, it will undoubtedly be F# (fable) or ReasonML (ocaml) where I can gain sound types and better syntax without giving up the practical need for mutation (like with Elm where lots of garbage and poor interactions with JS libraries are the result).

Re:State of JavaScript 2019 by deckard1 on Thursday December 19, 2019 @04:59AM (#21833475)
> writing maintainable code is the real challenge

If you think these same developers can't do it without TS, then you really haven't seen the sort of mess lesser developers make when they try with TS.

Unless the JavaScript developer has a strong background in C/C++/Java, they are going to truly fuck up a code base with TypeScript. I'm not making a static/dynamic typing argument here. I'm making an observation that thousands of developers that haven't seen what the hell a type even is are now somehow expected to operate on the level of creating coherent abstractions throughout the code. Good luck with that, once your team starts allowing "any" and "ts-ignore" everywhere.

9 out of 10 JS developers I have worked with do not know how equality and object memory references work in JavaScript. They do not understand deep vs. shallow equality. They are barely aware of type coercion. When faced with a TypeScript error, their primary concern is shutting up the compiler. By any means necessary.

Getting typing correct is more nuanced than the pro-TypeScript group will ever admit, and TypeScript provides so many ways to dodge actual typing responsibility that it renders the whole exercise a colossal waste of time.

tl;dr: Good developers don't need TypeScript and bad developers pull good developers down with TypeScript.

Re:State of JavaScript 2019 by hacker_9 on Thursday December 19, 2019 @05:21AM (#21833559)
I think I'm going to have make this my last comment as this is going in circles. I mean what is even your argument? Types exist whether you like it or not, implicitly or explicitly. You cannot get around this, it is simply a fact. When you have input parameters, or a return type, they follow a structure. That structure is a type. This is not nuance, this is just how things work.

'Good' developers is a subjective term, what is a good developer to you? Someone who can work without types? Wtf?

Anyway, I'll keep being productive with typed languages. You do you I guess.

Re:State of JavaScript 2019 by Silhouette on Thursday December 19, 2019 @05:50AM (#21833737)
9 out of 10 JS developers I have worked with do not know how equality and object memory references work in JavaScript. They do not understand deep vs. shallow equality. They are barely aware of type coercion. When faced with a TypeScript error, their primary concern is shutting up the compiler. By any means necessary.

That sort of thing definitely happens, but the problem usually has very little to do with the choice of programming language. Front-end web development is the next generation's Visual Basic or PHP, the kind of software development that is easy to get into, but which as a result attracts a lot of people who have never really learned to program well. If you don't understand basic concepts like reference and value semantics, you're probably going to write bad code in any language, but you're also not particularly interesting from the point of view of what makes an effective language for a competent programmer.

Re:State of JavaScript 2019 by Aeolun on Thursday December 19, 2019 @08:20AM (#21834608)
> 9 out of 10 JS developers I have worked with do not know how equality and object memory references work in JavaScript. They do not understand deep vs. shallow equality. They are barely aware of type coercion. When faced with a TypeScript error, their primary concern is shutting up the compiler. By any means necessary.

I think the exact same problems exist with JS no? Except now there isn’t any compiler to shut up, and things just silently fail.

Re:State of JavaScript 2019 by Merad on Thursday December 19, 2019 @11:24AM (#21836293)
I'm totally in favor of using TS, but I agree that lazy devs can set up an absolute mess when they try to use TS without really learning it. I think probably the fundamental weakness of TS is that you really need a good understand of how it's limited to compile time type checking, and how easily you can set up situations where the actual run time types don't match what you have in TS.

For example, it feels like I'm in a constant battle with some of our front end devs about typing their models correctly... they don't seem to understand that they keep setting up the type system to lie to them. For example, if a property in our API is nullable, then the property will always be present in the json with an explicit null value, so the model should be typed `propName: string | null`... but they prefer being lazy when mocking out data on the front end, so they instead type the model as `propName?: string`. Likewise with properties that are date/times (ISO-8601 strings in the json) they love to use Date as the type for those properties, then everywhere they use that property they end up wrapping it with `new Date()` because "it doesn't work" otherwise. Yikes.

Re:State of JavaScript 2019 by verttii on Thursday December 19, 2019 @06:20AM (#21833896)
Typescript's inherent problem may well be that it's rules are too lax, it allows you to circumvent them conveniently. This keeps poisoning the code base piece by piece, leaving you with a false sense of trust.

Maybe it's because of the compatibility with Javascript but it does kill Typescript's type soundness.

Edit: rephrasing

Re:State of JavaScript 2019 by the_gipsy on Thursday December 19, 2019 @03:24AM (#21833026)
> TypeScript slows down a project. Nobody seems to ever point out what benefits it supposedly offers.

Types slow you down a bit at the start, but speed you up forever after that. Untyped projects are fast to whip out, but slow piles of undefined behavior forever on. Oh and add unit tests, without types, and all you have is a checksum.

> And I think it's only popular because of the influx of backend developers coming into the frontend.

That's not the only reason why it's popular.

Re:State of JavaScript 2019 by Aeolun on Thursday December 19, 2019 @07:56AM (#21834462)
Benefit? When my friendly junior developers add a variable where it isn’t supposed to go the system yells at them.

This is much preferable to me yelling at them, or production getting broken.

Typescript may be a little bit slower if you never make any mistakes ever, and can keep the full state of your program in your mind at a given time. Nobody makes no mistakes.

Re:State of JavaScript 2019 by 734129837261 on Sunday December 22, 2019 @09:23PM (#21861055)
If you don't require at least 2 approvals from medior/senior developers for your junior's PRs you're doing it wrong.

TypeScript is not a "little bit" slower, I've seen it take over 3 times more time (and frustrations, even for an experienced TS guru) to get simple things done.

TypeScript is a colossal waste of time that many sheep gladly embrace because they feel they're expected to. Nobody dares to ask "but why?" when someone else comes up with the idea of adding TS to a project. They should.

I wish I had the money to setup 2 teams of 5 developers each for 12 months. One team: JS only. The other team: TS only. Give them the exact same project instructions, same sprint length of 2 weeks, and the same expectations per sprint.

Here is my guarantee:

- The JavaScript team will get much more done consistently over the entire duration of the project; - The JavaScript team will have a higher quality of code that is more intuitive to read; - The TypeScript team will be the only ones that regularly fail to make deadlines; - The TypeScript team will have to be reminded time and again that they should focus on UI and UX details.

And at the end of the road the JS team will have a far superior project, simply because they didn't waste time typing all of their code.

I've seen it so many times already. Once you use TS the devs focus on the code and forego the idea of UX, a11y, i18n, progressive web, offline capabilities, etc.

They'll often pair-program and waste hours of time to figure out how the hell they're supposed to properly type that one complicated piece of code.

Meanwhile, the JS team using React will simply use JSDoc, code reviews, propTypes, and defaultProps and be done with it.

Re:State of JavaScript 2019 by Heyso on Thursday January 02, 2020 @05:21AM (#21934204)
I am reading your comments with interest. I do not find myself losing time using Typescript, quite the opposite, typing is in code documentation. And I find it much easier to read than untyped code. You say that TS dev focus more on code, maybe it is because they like to focus more on code that they use TS. I do agree you can waste time searching how to type a complicated piece of code. Meanwhile it is worth typing that piece of code if it is subject to change, or that the usage of it is not easy to understand.
Re:State of JavaScript 2019 by bcherny on Thursday January 02, 2020 @05:45AM (#21934336)
I hear the frustration in your comment, and I wonder if it’s because you might not be using TS correctly.

When used right: TS infers most of your types, TS does not add to the lines of code you need to write to get something done (especially if you’re already using propTypes), and TS multiplies your productivity by reducing time spent debugging and by making refactoring super easy.

If you’re interested, I wrote a book about how to use TS, targeted towards intermediate/experienced JS programmers: https://www.amazon.com/Programming-TypeScript-Making-JavaScr...

Re:State of JavaScript 2019 by electrotype on Thursday December 19, 2019 @06:42AM (#21834016)
Typescript is the only reason I am not shooting myself in the head, on projects at work based on Node.
Re:State of JavaScript 2019 by bryanrasmussen on Thursday December 19, 2019 @07:25AM (#21834262)
I personally dislike Typescript as it is most often a hindrance for me, but:

About 2 years ago I had a pull request from a junior Dev - I can't remember all of it but basically he had an event (passed from some slider component) if something in that event was undefined he set a variable to be null otherwise it was an array, then he did an if check against something else in the event, and inside the if he checked the length of the variable.

So of course I pointed out that getting the length of null would be a problem. I actually had to argue with him a bit because he thought it was necessary for reasons. I got him to go through his code again and stuff was refactored to be better.

Typescript would have solved that problem.

I am in a big react SPA right now, that also uses TypeScript, often TypeScript causes problems of the sort - I am in a place where X could possibly be one or the other type (null or an object) so you need to write a check for it, in reality it would never have gotten to that particular point if it was null but poor TypeScript cannot figure that out.

Often things are wrong because some library thinks something is an Element instead of an HtmlElement or similar type of problem etc. etc. you have to go fix types, which can take more time than it should.

Finally it can be that TypeScript gives you very cryptic messages about what is wrong and it can take a while to decode what is wrong with otherwise fine code.

I can also say that in the 8 months I have been on the project I think TypeScript has caught two bugs I would have been putting in.

This is based on 18 years JavaScript experience 1 year TS experience. So I don't think it offers no benefit, I think it offers some benefit and irritates me more than it benefits me - but that is not the same thing. I must say that if you've been using it for 2 years and never had that oh yeah, I didn't think of that experience - well that's pretty impressive as regards your attention to detail.

on edit: although I have 18 years JS experience I would say only 7 years major usage, full time doing major stuff with it.

Re:State of JavaScript 2019 by 734129837261 on Sunday December 22, 2019 @09:28PM (#21861074)
Well, TS does point things out to me in the IDE that make me correct it right there. But, I would have caught that in my browser in under 2 seconds anyway. With proper .map files to debug things it's infinitely more clear what's wrong than with TS's sometimes very cryptic messages.

As for your junior dev, maybe that makes the case for TS. But honestly, I've experienced junior TS developers who were simply overwhelmed by TS. They couldn't be trusted to write proper TS since they already struggled with JS. It just required us to review more code in their PRs.

I'll take a project with naming conventions, proper unit tests & code reviews over TS any day.

Re:State of JavaScript 2019 by lllr_finger on Thursday December 19, 2019 @09:04AM (#21834938)
Yes, it slows you down because you need to think about your domain and how that maps into types (whether you think those types exist or not, they do).

Having that opinion isn't backend bias - it's likely being exposed to a variety of programming languages and having first-hand experience with the pros/cons of static vs dynamic typing.

Re:State of JavaScript 2019 by acemarke on Thursday December 19, 2019 @01:57PM (#21837986)
I'll disagree with this completely.

I recently wrote an extensive post about my experience learning and using TS as both an app developer and a library maintainer for Redux, and why I am now completely sold on using TS across the board. As part of that, I listed several benefits of using TS that I've directly seen myself:

https://blog.isquaredsoftware.com/2019/11/blogged-answers-le...

Re:State of JavaScript 2019 by 734129837261 on Sunday December 22, 2019 @09:57PM (#21861193)
I love Redux, I love your dedication to the community (also on Reddit), and I love your work. But this is the first time I find myself completely disagreeing with you.

The bigger a project gets, the more unreadably TS snippets you run into. The cost/benefit ratio is awful; I've sometimes taken the actual author of the code and myself to analyse it, and it would take us over an hour just to get to the bottom of something that would be incredibly simple in regular JS.

From your article:

> Ah, the joy of reviewing a PR for a lib you maintain, when the PR contains code that you are not even remotely qualified to pass judgment on...

And then that code. Look at that. That's not nice. That's terrible code, horrendous. That should be rejected for the simple reason that it's unmaintainable.

> I begged for help on Twitter, and got a solution from the community that worked. I don't even pretend to understand the type declaration, but here it is:

The problem in larger teams is exactly this:

Some self-important TS lover in your team spends 4 hours tinkering together some arcane magic TS definition by copy/pasting a ton of shit from StackOverflow, is proud that it works, commits and pushed it, creates a PR... and everyone reviewing it is clueless what's going on. But it works.

Hell, if he understands it and it works, it must be good. Accept PR. Merge. Fast forward 3 months. Someone has to add a feature to this particular part of code. They look at the TS definition and 2 weeks later they have a new job.

I've seen people flee projects because of endless amounts of arcane TS...

If I'm imagining the perfect project it's based on a few qualities that I hold dear:

1. Sensible unit testing in place 2. Well defined code review standards 3. Strict naming conventions for code 4. Optional JSDoc where it makes sense 5. Minimalistic but readable amounts of code*

* Meaning that code should be short and concise, functional programming to the max, but not one big clump of inline nested functions.

JSDoc in itself allows you to type parameters and variables, it even adds human readable comments to the mix.

Then, when reading the project's code, you'll stumble upon a beautiful and sleek code base that just makes intuitive sense from the start.

---

I recently had a chat with someone about us developers always inventing the next pain in the ass to deal with. I think TS is a pain in the ass. When I started out with Classic ASP (Visual Basic 6.0) it was basically functional programming (functions and subprocedures) and we'd get everything done in record time, blazingly fast.

If VB6.0 was released by Microsoft today, millions of people would be fawning over it and it would become the next best thing. "What a cool Python alternative, thanks Microsoft!"

Same with Perl. Cool language. Hardly anybody uses it anymore. It's mostly Booking.com recruiting endless amounts of Perl developers because they're almost as rare as the fossils they often are (I worked there, I'd know.)

When we switched to XSLT and XML it was basically Handlebars, except not restricted, full of features, and just gorgeous to work with. But it lost its sexiness for some reason; mostly because JSON isn't compatible with XSLT. So nobody uses it anymore.

Now there's JSX, and that will also disappear over time. Probably for no good reason at all. Look at Angular and VueJS, they offer alternatives that are vastly inferior in many ways (no intuitiveness would be one, you need to learn the damn frameworks before you can get started), but they're the new kids on the block.

TypeScript is too often too easily accepted as the standard addition to a project. And I've experienced it NEVER to be the right call. And I've gotten other developers on said teams to–sometimes after some prodding–agree with my assessment.

Every project would be better off without TypeScript. I fail to see any of the benefits people mention because I've never seen them, I've only seen the exact opposite.

Re:State of JavaScript 2019 by acemarke on Monday December 23, 2019 @11:17PM (#21869829)
I agree that the particular TS snippet I pasted in that post is painful to look at, but it's also for library code, not app code.

Beyond that, yeah, we'll have to disagree, per all the reasons I listed in that blog post.

Re:State of JavaScript 2019 by kabes on Thursday December 19, 2019 @05:48AM (#21833724)
I do think it offers benefits. I'm not a big believer that it will prevent many bugs as is often claimed from typed languages, but IDE's can help you develop much faster (when everything is in TS already) and refactorings become way easier. If that outweighs the benefits is another question. (I still prefer regular JS myself)
Re:State of JavaScript 2019 by gherkinnn on Thursday December 19, 2019 @02:48AM (#21832858)
What’s with all the TS hate?
Re:State of JavaScript 2019 by bakuninsbart on Thursday December 19, 2019 @03:11AM (#21832971)
In my experience, people who have been experts on JS before TypeScript became a thing hate it. - It doesn't give them any advantages, while severely limiting their options and workflow. For newer developers with background in other languages it is quite nice though.
Re:State of JavaScript 2019 by Zarel on Thursday December 19, 2019 @04:33AM (#21833348)
I was an expert on JS way before TypeScript. I was kind of slow to adopt it because "the type hints are optimized away and can't even be used to boost runtime performance", but when I did start using it, I loved it and wish I had earlier.

The linked article says the vast majority love TypeScript, too.

I think the real dividing line is probably that people who haven't had to maintain a large project hate TypeScript.

(Which is still weird to me, because you can just turn off `no-implicit-any` and get all the benefits without drawbacks.)

Re:State of JavaScript 2019 by gherkinnn on Thursday December 19, 2019 @06:20AM (#21833899)
Good point. I too only saw the point after being burnt by a large JS application.
Re:State of JavaScript 2019 by jillesvangurp on Thursday December 19, 2019 @03:58AM (#21833192)
For developers coming from other languages, typescript and the tool support in VS Code is what makes frontend engineering tolerable these days. A big difference with just a few years ago. I insist on it in most projects I'm responsible for. I see no good technical reasons not to use it at this point.
Re:State of JavaScript 2019 by Aeolun on Thursday December 19, 2019 @08:24AM (#21834636)
I mean, if you really want to, you can configure it to be just JS with .ts file extensions :P
Re:State of JavaScript 2019 by jillesvangurp on Thursday December 19, 2019 @12:07PM (#21836789)
Well, strict mode is a thing of course. But yes definitely have seen a bit too much code with the any type.
Re:State of JavaScript 2019 by gherkinnn on Thursday December 19, 2019 @03:49AM (#21833160)
I understand “limiting options and workflow” as “limiting the stupid amounts of yolo that JS allows”.

TS shows you just how bad JS can be without very, very diligent processes to keep it in check.

Re:State of JavaScript 2019 by hackerbabz on Thursday December 19, 2019 @02:46AM (#21832851)
Why do you typescript so much?
Re:State of JavaScript 2019 by fuzzy2 on Thursday December 19, 2019 @05:07AM (#21833508)
Maybe because React is small (API surface) and does (or is felt to do) “one thing”. It is easy to wrap your head around it, even without fully understanding, say, the Virtual DOM diffing. Angular is very different in that regard.

I recently had to read up on how Angular applies changes to the DOM. It was extremely difficult to get this information at all.

For me, React with TypeScript is king. It trumps Angular in three IMHO very critical points:

* Typed “templates” (a tremendous help with IntelliSense, too)

* No change detection magic (I firmly believe Zone.js is insane)

* Build time

Re:State of JavaScript 2019 by buu700 on Thursday December 19, 2019 @09:36AM (#21835216)
* Angular templates are typed, but until version 9 (coming out in a couple weeks, but I've been using the RCs and they've been fine), any variable created in the template itself was defined as `any`, creating gaps in the compiler's coverage. A vscode plugin provides IntelliSense.

* Agreed, this is an awful default and I don't understand why the Angular team hasn't already deprecated it. I suppose a slightly simpler "Hello World" makes Angular look a bit more approachable, but it just encourages accumulating unnecessary tech debt. The proper way to use Angular is to disable the magic (`OnPush` change detection) and use observables.

* Prod builds take a while and use a lot of memory, but local development is fine. (I haven't observed that prod builds are necessarily "slow" relative to what they accomplish.)

I like both Angular and React, but generally prefer Angular. The structure and universal consistency imposed by the framework and CLI are convenient (particularly when moving between projects or adding devs to an existing project), and the limitations imposed by Angular-HTML vs JS(X) are great for readability.

Re:State of JavaScript 2019 by tashoecraft on Thursday December 19, 2019 @09:49AM (#21835316)
I think angular with zones will slowly start to fade away as the community moves more towards onPush components, with components hooks to trigger change detection. There is an ngrx proposal for a component that would handle this all nicely, but it's still only a proposal.
Re:State of JavaScript 2019 by fuzzy2 on Thursday December 19, 2019 @10:36AM (#21835752)
On templates:

Weeeell, no(-ish). Angular templates are text. They are checked during AOT compilation or otherwise at runtime (were most type information is gone already). And maybe at some other point I don’t know about.

The Angular Language Service (which came very late) is a lot of help, if doesn’t fail to pick up component members yet again. I’m not sure whether it knows about types either.

It also has problems with some complex use cases: for example, we have a derived `CdkTable` attribute, yet it doesn’t pick up its input properties.

tl;dr: I don’t like text templates! I really like React “templates”! :D

There’s also a minor annoyance: I’m not very fond of having the components as elements in the DOM. At least with modern browsers they behave predictably!

On change detection:

While `OnPush` is required for any sane application, you really need to fully disable Zone.js unless you want your application to re-render pointlessly. That could cause problems with third-party components I guess...? Either way, it’s really not as straightforward as it should be.

Re:State of JavaScript 2019 by buu700 on Thursday December 19, 2019 @11:33AM (#21836388)
In what sense do you mean that Angular templates (with the language service) more "text" than other programming languages?

Everything definitely has a type, and I'm not having any issues with syntax highlighting, mousing over things to see what they are, or peek / go to definition. There are a couple hiccups[1], but those are just tooling issues.

The template is ultimately compiled to TypeScript, which is type checked as one would expect. In my mind Angular-HTML is the same type of thing as TSX/JSX, except with the problem of being more unique / further removed from the target language, so not benefiting as much from preexisting tooling.

It's actually a minor annoyance for me right now that my existing code isn't yet compatible with the strictest compilation setting[2] because it was developed against the older, more lax compiler that littered its emitted TS with `any`s. If you're having trouble with the complex use cases (which I've definitely run into as well), Angular 9 / Ivy will be a welcome upgrade.

(And totally agreed re: Zone; it needs to die in a fire.)

---

1: 1) "Find All References" isn't working for me (I'll file a bug report if there isn't one already), and 2) I have to peek definition to see what something's type is; as-is it just says "(property)".

2: https://next.angular.io/guide/template-typecheck#strict-mode

Re:State of JavaScript 2019 by Bahamut on Thursday December 19, 2019 @02:20AM (#21832727)
It surprises me too personally - the testing experience is worlds better, better built in modules than what you get in the React ecosystem (especially routing, http request layer, forms, testing, etc.), and opinionation that helps improve the overall experience of working with it. I miss my time with Angular sometimes - my only gripes is TypeScript being limiting with regard to function composition, and creating a component in Angular requires quite a bit of boilerplate compared to React.

To some degree, I feel there are a varying set of reasons why people have settled on React - some were never fans of AngularJS/Angular and some disliked how Google handled the migration story from AngularJS to Angular are probably the strongest reasons. TypeScript also not being terribly FP friendly is also a huge negative to some, whereas React enables more functional patterns overall. Some also dislike separate HTML templates vs. HTML in JS templating, some prefer to cobble together a bunch of small modules together, even if the modules are weaker on average.

Ultimately, I think Google fell short on DX with the change over to Angular 2+ and the damage has lived on since, which is a shame because as a framework it was built really solid.

Re:State of JavaScript 2019 by ng12 on Thursday December 19, 2019 @12:23PM (#21836968)
I think it's the opposite. Angular1 was obviously dead on it's feet, and I respect Angular2 for admitting that. If anything I wish they had gone further and cleaned up some of the other smells around the Angular ecosystem.

My real problem with Angular is it's not great for either beginners or experts. There's so much boilerplate and Angular concepts a beginner needs to learn to use the framework well and for experienced developers that stuff tends to get in your way.

Re:State of JavaScript 2019 by jamil7 on Thursday December 19, 2019 @04:27AM (#21833319)
Basically this, I picked up angular 1 back in the day, for a while there was a lot of hype around it. The migration was very poorly handled and Angular 2 felt a bit alien when it was first released. React rose in popularity at exactly the right time and I think a lot of people felt a bit burnt by angular and didn't look back. Vue being released probably converted those still on the fence.
Re:State of JavaScript 2019 by nkingsy on Thursday December 19, 2019 @11:06AM (#21836105)
It’s just a bad framework for code reuse.

-No dynamic directives -Nothing dynamic works with @ContentChildren, making anything that uses it the “last stop” for abstraction. -DI system makes inheritance/mixins nearly impossible, and without dynamic directives there are situations where the only solution is a massive copy paste job.

I work in the framework every day and spend countless hours shaking my head at cryptic docs any time I try to do any type of abstraction.

Re:State of JavaScript 2019 by Bahamut on Thursday December 19, 2019 @03:24PM (#21838865)
I'd argue that inheritance and mixin patterns are both things you should stay away from, whether it's Angular, React, or whatever, they have proven to be poor patterns IMO and it is simple enough to create reusable abstractions without relying on those.

Code reuse is fine with Angular in my experience - it has been 2.5 years since I last used it though, as I have been working with React in that time and my frustrations about certain aspects of using React & the community has me in a the grass is greener on the other side sort of mindset from time to time, although I know things are not perfect with Angular either (I have some complaints there too).

I've basically learned to accept that using off the shelf libraries come with tradeoffs that you just have to accept as a dev.

Re:State of JavaScript 2019 by ggregoire on Thursday December 19, 2019 @02:17AM (#21832714)
It takes 1 afternoon to learn React and it never requires you to open the doc again.

Angular, on the other hand...

Re:State of JavaScript 2019 by Supermancho on Thursday December 19, 2019 @10:26AM (#21835656)
> It takes 1 afternoon to learn React and it never requires you to open the doc again.

You are confusing your imagination with reality (or the history of your own experience).

Re:State of JavaScript 2019 by jamil7 on Thursday December 19, 2019 @04:31AM (#21833338)
Until you need a router or state management ect, then you've got a few tabs of docs open and a case of anlysis paralisis and a bunch of glue code to write.
Re:State of JavaScript 2019 by tehbeard on Thursday December 19, 2019 @06:00AM (#21833777)
The same will happen when you fall off the happy path with ordained choice of any particular framework.
Re:State of JavaScript 2019 by jamil7 on Thursday December 19, 2019 @06:29AM (#21833948)
Absolutely, I'm not rooting for either framework to be honest just pointing out that the comparison is somewhat unfair.
Re:State of JavaScript 2019 by codingdave on Thursday December 19, 2019 @09:01AM (#21834921)
> Just curious why so many people prefer React and mark it so positively.

For the exact same reasons you stated -- Angular is opinionated and has everything. React is just a framework - you get to make your own opinions and are not handed the whole ball of wax, so you can make your own choices.

Re:State of JavaScript 2019 by tashoecraft on Thursday December 19, 2019 @09:41AM (#21835256)
When will this meme end. Angular is not crazy opinionated. The previous version more so, but it's really open to letting you do things in general ways. You want css scoped to your components? Sure. You want two way data binding? Sure, but wait you want one way binding? You go it. You can use rxjs, or you can avoid it.

There's some general ways to set things up, but it's nice to have a general approach to each project you encounter.

And the biggest thing is Angular wasn't designed to be used by a solo developer working on a side project. It's evolved to allow that, but it was designed with companies in mind. Multiple developers, multiple teams of developers, maybe with little communication to work together on single projects whilst allowing guide rails to keep things headed on the same track, but allowing many ways to move the track in a way that fits your style.

The idea that react is just a "library" (think you mixed up your words there) is absurd when you look at the majority of react in the wild. Using create-react-app, react router, forms library, animations, etc etc, and now look, you just pieced together a bunch of different libraries to form....Angular.

Re:State of JavaScript 2019 by codegladiator on Thursday December 19, 2019 @06:31AM (#21833964)
I stay away from angular (I don't do react either, prefer vue as long as I have a choice) mainly because of major time I invested in angular 1 and then they completely ditched it and kept the same name.
Re:State of JavaScript 2019 by CrazyDave on Thursday December 19, 2019 @03:41AM (#21833111)
I think the comments in this thread captures it pretty well. If someone doesn't see the benefits of typed languages, TypeScript will just be something that slows them down for no apparent reason.

Same goes with RxJs, dependency injection, unit testing, and modules.

Re:State of JavaScript 2019 by verttii on Thursday December 19, 2019 @06:22AM (#21833906)
But Typescript is not a "typed language", rather a "language with types". Because of having to maintain JS compatibility it lacks the inherent type safety that other similar languages like Dart provide.
Re:State of JavaScript 2019 by LocalPCGuy on Thursday December 19, 2019 @10:25AM (#21835644)
I also (as seen in at least one of your other responses) that people associate AngularJS and Angular when doing rankings in surveys like this one. There are many people who will never try Angular because of their experience with AngularJS.

Also, this isn't a scientific random sample survey, it's people who self-selected to take it. And I think that Angular specifically suffers due to that because it is more likely to be used at enterprise or large companies where devs often tend not to follow Twitter/surveys/etc at least, not in the same numbers as some other groups. Just my opinion.

Re:State of JavaScript 2019 by hateful on Thursday December 19, 2019 @10:02AM (#21835430)
Personally, I've switched from angular to vuejs after angular 2 (3, 4) came out. I found that vuejs was a better update from angular 1 than angular 2 was.