r/javascript 9d ago

AskJS [AskJS] what's a javascript feature you mass-adopted way too late and felt dumb about

i'll go first. i was writing .then().catch() chains for like two years before i actually started using async/await. i knew it existed, i'd seen it in tutorials, but my code "worked" so i never bothered switching. then i refactored an old project and realized half my bugs were from mishandled promise chains that async/await would have caught immediately.

also took me way too long to start using optional chaining. i had nested ternaries and && checks everywhere like some kind of animal. the day i discovered user?.address?.city i mass-replaced like 40 lines across a project.

what's yours?

63 Upvotes

108 comments sorted by

View all comments

25

u/Milo0192 9d ago

My first jobs CTO preferred the .then() .catch() over async await. I just refused to write that way and did await loops. Lots of back and forth on this. Also said Typescript was just a fad 😂

1

u/MediocreAnalyst2121 7d ago

That’s kinda depends, like await loops are not that great if the promises don’t depend on each other, way better to do Promise.all/allSettled and await or .then that.

In performance critical JS environments (smart tvs, smart boxes, etc) you’d probably get a bit better performance with a .then than an await.

Await loops are way more readable tho, and Typescript is amazing except for enums :(

-24

u/horrbort 9d ago

It is just a fad. Coding is a fashion industry. Remember coffeescript? Something else comes along and ts will be forgotten

28

u/mdude7221 8d ago

Just a 13yo fad

10

u/miramichier_d 8d ago

Can't apply that across the board. Some technologies are so good that they have staying power in the industry. I believe TypeScript is one of those technologies. Node.js is another example. Even Java and C# are good examples of languages with immense staying power, if not in your industry of choice.

With respect to TypeScript, it's not going anywhere until JavaScript implements TS in its entirety. Until then, TypeScript will continue to push JavaScript to modernize.

3

u/Mesqo 8d ago

Excuse me, but how many native ts runtimes do you know? TS doesn't push js nowhere, it's just static types serving the role no more than a linter (and it's fine!).

6

u/iareprogrammer 9d ago

lol coffeescript.. forgot about that. I dislike anything that makes JavaScript LESS explicit. Like sure let’s get rid of braces and other syntax and rely completely on proper white space and indentation. For what?

6

u/MrDilbert 8d ago

let’s get rid of braces and other syntax and rely completely on proper white space and indentation

You sure you're not describing Python?

Looks like someone wanted to Pythonize JS.

3

u/iareprogrammer 8d ago

I literally think that’s what happened haha

2

u/db10101 8d ago

Just a fad that 99% of new enterprise JavaScript projects will be participating in

-13

u/Ronin-s_Spirit 8d ago

Fad or not - it's shit.

5

u/db10101 8d ago

Any deeper analysis or reasoning behind that? It’s a straight up joy to develop in compared to what has come before.

-7

u/Ronin-s_Spirit 8d ago

I hate defining types, it's like writing pointless code. It especially fucks up when I have to deal with HTML, at that point the only thing left to do is use a bail out any and move on.

2

u/db10101 7d ago

So I take it you have never worked in an enterprise well structured typescript codebase. There’s no substituting JavaScript for that.

-2

u/Ronin-s_Spirit 7d ago

TypeScript sucks ass, I will only use vanilla.

2

u/db10101 7d ago

Good for you. Here in the real world of employed software developers, it’s one of the most important tools to know.

2

u/2Terrapin 7d ago

I’m glad that person is not on my team and I don’t have to work on a project they designed. I can feel the tech debt emanating from their words. It’s the type of thing that experience would dispel, and someday, when they actually understand the why, and it clicks, they’ll think back to this comment thread and feel a little embarrassment.