this post was submitted on 02 Apr 2024
90 points (100.0% liked)

Programming

423 readers
4 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 

I was talking to my manager the other day, discussing the languages we are using at $dayjob. He kind of offhandedly said that he thinks TypeScript is a temporary fad and soon everything will go back to using JavaScript. He doesn't like that it's made by Microsoft either.

I'm not a frontend developer so I don't really know, but my general impression is that everything is moving more and more towards TypeScript, not away from it. But maybe I'm wrong?

Does anyone who actually works with TypeScript have any impression about this?

top 37 comments
sorted by: hot top controversial new old
[–] Vincent@feddit.nl 99 points 7 months ago

If TypeScript still is a fad at this point, his definition of fad is far lengthier than mine is.

I'm fairly sure TypeScript will remain in popular use longer than whatever project you're working on πŸ˜…

[–] redcalcium@lemmy.institute 32 points 7 months ago (1 children)

CoffeeScript was a fad, but TypeScript seems to gaining more and more popularity these days, with new runtimes like deno supporting them natively. TypeScript finally gave Microsoft relevancy again in webdev world, so I bet they'll go a great length to make sure it stays that way. If Microsoft were still making their own browser engine, I bet they'll make it natively supports TypeScript too.

[–] magic_lobster_party@kbin.run 27 points 7 months ago (1 children)

CoffeeScript was a fad because it didn’t solve anyone’s problems. It was basically β€œlook how cool code you can write”.

TypeScript is gaining popularity because static typing solves real problems. It’s also a superset of JavaScript instead of being a completely new language from scratch, which makes it easier for JavaScript devs to learn.

[–] brian@programming.dev 10 points 7 months ago

it felt to me like coffeescript solved problems that people had, then js got equivalent features. arguably that could happen to ts as well

[–] shnizmuffin@lemmy.inbutts.lol 26 points 7 months ago (1 children)

A fad? No, definitely not. TypeScript brings features (and structure) that will /should probably make their way into JS.

It's sort of like asking, "does SASS replace CSS" or "is liquid the next HTML?" They're just implementations of features FE developers want in the core spec of JS, CSS, and HTML.

[–] Vincent@feddit.nl 11 points 7 months ago (1 children)

that will /should probably make their way into JS.

Not really, IMHO. The main advantage of TS is that it will help you catch errors without having to run a particular piece of code - i.e. you won't have to move to the third page of some multi-page form to discover a particular bug. In other words, it helps you catch bugs before your code even reaches your browser, so it doesn't bring you much to have them in the browser.

(There is a proposal to allow running TS in the browser, which would be nice, but you'd still run a type checker separately to actually catch the bugs.)

[–] 56_@lemmy.ml 5 points 7 months ago (1 children)

I think the important part is that the syntax will become standardised, rather than being defined by microsoft/typescript, potentially allowing for alternative implementations. It could also make the build step optional in some cases, which is something people dislike about typescript currently.

[–] Vincent@feddit.nl 1 points 7 months ago

I think the syntax explicitly won't get standardised - but the places where syntax can be put will be (e.g. after a : following a variable, before the =). With, yes, the goal of eliminating the build step, but the type checker (which really is just a linter at this point) would still be able to define their own specific syntax. I don't think it could work any other way either, anyway.

Static typing, for the win, and I'll die on this hill.

Fight me.

[–] locke@sopuli.xyz 22 points 7 months ago* (last edited 7 months ago) (1 children)

Typescript makes writing Javascript a reasonable thing to do. Your manager is a fad.

[–] SorteKanin@feddit.dk 8 points 7 months ago

Your manager is a fad.

If only...

[–] porgamrer@programming.dev 18 points 7 months ago

5 years ago everything was moving to TypeScript. Now everything has moved. Developers are still catching up, but it will be one-way traffic from here.

I'm guessing your manager thinks TypeScript is like CoffeeScript. It is not like CoffeeScript.

Also, TypeScript is only the beginning. In the halls of the tech giants most devs view TypeScript as a sticking plaster until things can be moved to webassembly. It will be a long time until that makes any dent in JS, but it will also be one-way traffic when it does.

[–] expr@programming.dev 17 points 7 months ago (1 children)

No, because raw-dogging JavaScript isn't something grown-up software shops do.

[–] oscar@programming.dev 1 points 7 months ago

Can't they just use JSDoc?

[–] TehPers 17 points 7 months ago

Imagine changing your file extension from .js to .ts and calling it a fad. JS is TS. The difference is that TS does more (by actually doing stuff before runtime as a static analyzer, similar to eslint). If TS is a fad, then modern web dev is a fad.

Which, to be fair, it is.

[–] Lmaydev@programming.dev 17 points 7 months ago

When anyone in a professional setting says they don't like having a mega corp supporting something I lose a bit of respect for their opinion tbh.

Yes we all know mega corps suck.

But if you're using anything in a professional production environment that is meant to last in the long term this is 100% what you want.

[–] nick@campfyre.nickwebster.dev 16 points 7 months ago* (last edited 7 months ago)

Hi, I've been doing TypeScript in my day-job and hobbies for six and a bit years now. I would not write JS in any other way.

TS is also a superset of JS so all JS is valid (unless you turn on strict mode). So there is no productivity loss/learning curve unless you want there to be.

In fact, a lot of people who think they're not using typescript are using it because their editors use typescript definitions for autocomplete and JSDoc type signatures are powered by typescript.

[–] RonSijm@programming.dev 14 points 7 months ago* (last edited 7 months ago)

Javascript is a fad, we should all move to WASM. πŸ™ƒ

But no, TypeScript is not a fad. Unless a better "Typescript like" thing comes out - I know how in frontend land people like to make their own substitute framework that does something slightly different than an existing framework - But I don't really see why anyone would want to make a NewTypeScript, and not just expand existing TypeScript

[–] penquin@lemm.ee 12 points 7 months ago

A language that helps me write Javascript without writing Javascript? Nah, that ain't no fad, that's a grace from whatever god is up there.

[–] FizzyOrange@programming.dev 10 points 7 months ago (1 children)
[–] hydroptic@sopuli.xyz 15 points 7 months ago* (last edited 7 months ago)

They already said he is a manager, no need to repeat

[–] onlinepersona@programming.dev 9 points 7 months ago* (last edited 7 months ago)

The developer of Svelte moved from Typescript to JSDoc and explained in depth in an interview (you can find it on youtube). ECMA (the dudes making Javascript/ECMAscript) also started noticing that maybe static typing would be useful and there's a proposal to add typing to it. Whether that's moving forward or not, no idea, but if it were to come to vanillaJS, it's imaginable that typescript would be much less useful than it is now.

CC BY-NC-SA 4.0

[–] xilliah 6 points 7 months ago

Have you tried slapping your manager?

[–] cyclohexane@lemmy.ml 5 points 7 months ago

The only valid argument against typescript is that it is too similar to vanilla JavaScript. It does not go far enough. We need type systems like Ocaml's.

I suppose you can also complain about needing a build step, but I find this silly. There are so many tools that make this easy or automatic.

[–] eratic@slrpnk.net 5 points 7 months ago* (last edited 7 months ago) (1 children)

Personally I'd rather use JSDoc in my own projects for type annotations and call it a day. I find TS a bit annoying but that might be because I'm not that familiar with it.

[–] FizzyOrange@programming.dev 3 points 7 months ago* (last edited 7 months ago) (1 children)

That's just Typescript with extra steps.

Though I have also done this once or twice for single-file projects where I didn't want to deal with actually running tsc. It has some annoying downsides though, e.g. you don't get to have a tsconfig.json and the syntax sucks.

Microsoft had a proposal to allow TS annotations in JavaScript which would have been awesome and fixed the syntax issue.

Looks like it was discussed a year ago and hasn't really made much progress. Seems like lots of people wanting to shoehorn runtime type checking onto it.

[–] eratic@slrpnk.net 2 points 7 months ago* (last edited 7 months ago) (1 children)

Is it? I just have it auto-generate in my IDE with snippets. If I was using TS I would still document using TSDoc anyway. You can use jsconfig.json instead.

[–] FizzyOrange@programming.dev 1 points 7 months ago

If I was using TS I would still document using TSDoc anyway.

Yeah but you wouldn't put the types there. Putting types in JSDoc is awkward.

You can use jsconfig.json instead.

Unfortunately not. I even went as far as reading the source code for VSCode. There's no way to e.g. set noUncheckedIndexedAccess.

[–] tiredofsametab@kbin.run 5 points 7 months ago

I'm not a FE guy so don't write it much, but I'd always rather use typescript if I had to use anything like JS. Our FE guys use typescript at my current job and my previous one as well

[–] ShaunaTheDead@fedia.io 4 points 7 months ago (3 children)

I don't really get the appeal of strongly typed languages. Can't you just use try/catch blocks, and/or use functional programming and return early if the data structure of whatever you're working with isn't what you expected?

I guess it can help older code easier to maintain because the expected data structure is right there, but you could also just include it in a comment above the function.

I personally find TS slows down initial production of a project and raises so many unnecessary errors.

Is there some huge benefit that I'm missing? Because I don't really get the appeal. I mean, I do on some level, but I don't really understand why so many people are absolutely obsessed with TS.

[–] SorteKanin@feddit.dk 8 points 7 months ago* (last edited 7 months ago)

Can’t you just use try/catch blocks

No, because what if whatever you're calling is updated and suddenly it throws a new exception where before it didn't? Python or JavaScript or other interpreted languages will never warn you about that.

if the data structure of whatever you’re working with isn’t what you expected?

That sounds like a whole lot of boilerplate I have to write to verify every time that something is what I expect. Static typing does that for me much easier and more reliably.

Some languages like Rust have so good type systems that often when a program compiles, it just works. You don't have to run the code to know that it functions if you only make a small change.

What kind of systems have you worked in? In small systems, the static analysis doesn't matter as much, but the benefits become bigger and bigger the more code there is to analyze.

[–] towerful@programming.dev 5 points 7 months ago

I like typescript because my API can generate types for my FE project.
So, if i change my API, i pull in fresh types and fix the errors, and i get in-ide hints for the shape of payloads, responses and events. Not everything is simple CRUD.
Also, if you pull in a library, having types is a godsend

[–] haggyg@feddit.uk 2 points 7 months ago

Interesting argument. I have used both typescript and JavaScript, but I spend 99% of my time writing firmware in C, because of this I LOVE strongly typed languages, and I get kinda annoyed/paranoid when my variable COULD change type quietly so end up doing (perhaps too much) type checks etc.

I can say with surety I hate programming in both Typescript and JavaScript, but I definitely hate Typescript less because of the typing.

Having said that, I don't really like the compiled javascript that comes out of the typescript compiler, because it puts some distance between the user and the code and I am all for clarity, especially when people have to go out of their way to not run this code.

[–] Conyak@lemmy.tf 3 points 7 months ago

If JavaScript implements type safety then I believe it will go away. If not then it will continue to be used.

[–] Adderbox76@lemmy.ca 3 points 7 months ago* (last edited 7 months ago)

TypeScript is the new DOC format.

Create a language/format. Spend all of your effort making it ubiquitous until it becomes the default "standard" in the workplace. Then charge a metric fuck-tonne for the "official" software that makes use of it.

It's how Office became their cash cow. They create the proprietary doc format, get everyone using it, and once it's embedded in the workplace, charge exorbitantly for the software that uses it.

Once they get everyone using TS as a new industry standard, they'll find a way to make people have to pay for it. Mark my words.

I don’t think your manager is sane.

Why on earth would we move back to JavaScript at this point.

Disclosure: I am a TypeScript dev and my boss is fully invested in Microsoft at this point. We use C# .Net and we use Azure and Teams.

[–] starman@programming.dev 1 points 7 months ago* (last edited 7 months ago)

He might've watched this video: https://youtu.be/5ChkQKUzDCs

TL;DR: Big projects, like Svelte, Drizzle and Turbo ditched TypeScript