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

Programming

17518 readers
538 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?

(page 2) 50 comments
sorted by: hot top controversial new old
[–] porgamrer@programming.dev 1 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.

[–] Zannsolo@lemmy.world 1 points 7 months ago (1 children)

I'll riot if I ever need to write pure js again. 98% of web devs would be better served writing in TS. If you're actually knowledgeable enough to write more efficient js, more power to you but honestly I was probably being generous saying 2% of web devs fall into that category.

[–] shasta@lemm.ee 1 points 7 months ago

Even then, it just leaves behind an illegible mess that the next dev has to gut and replace with typescript later. If someone wants to use JS on their hobby project, go for it. The extra tools that types enable are super valuable for a team.

[–] shnizmuffin@lemmy.inbutts.lol 1 points 7 months ago (2 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.

[–] BrianTheeBiscuiteer@lemmy.world 1 points 7 months ago

Hoping this is true. The biggest annoyance with typescript is needing some kind of compiler. Haven't used Bun or Deno very much, both of which natively support TS, but there are still incompatibilities with the way Node does things and how certain modules were built (CommonJS vs ESM). I like writing JavaScript but the tooling is utter crap.

[–] Vincent@feddit.nl 1 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 1 points 7 months ago

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.

[–] locke@sopuli.xyz 1 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 1 points 7 months ago

Your manager is a fad.

If only...

[–] treechicken@lemmy.world 1 points 7 months ago* (last edited 7 months ago)

I hope not. I'm pretty sure me and my coworkers would be at each others' throats if it were not for some form of typed JS holding our Frankenstein codebase together.

[–] hawgietonight@lemmy.world 1 points 7 months ago (1 children)

Technicalities aside, TS is being pushed by MSFT in their SaaS custom components, and that right there will keep it relevant a while. MSFT is known for changing names a lot, but not for killing technologies.

After over 5 years of writing TS, I have had to do plain JS sometimes, and it is scary. It feels like walking blindfold. I'm spoiled.

[–] arendjr@programming.dev 0 points 7 months ago

MSFT is known for changing names a lot, but not for killing technologies.

Silverlight would like a word ;)

[–] breadsmasher@lemmy.world 0 points 7 months ago (1 children)

Based solely on gut feel, I think Typescript will become less popular as Wasm grows

[–] tias@discuss.tchncs.de 0 points 7 months ago* (last edited 7 months ago) (1 children)

When will Wasm grow, according to your gut? I feel like I've been waiting for a decade now.

[–] friend_of_satan@lemmy.world 0 points 7 months ago* (last edited 7 months ago) (1 children)

WASM made huge strides last year. You can run entire operating systems inside a WASM hypervisor now, and lots of packaging and transpiling projects came of age last year.

Example: https://copy.sh/v86/?profile=windows98

load more comments (1 replies)
[–] FizzyOrange@programming.dev 0 points 7 months ago (1 children)
[–] hydroptic@sopuli.xyz -1 points 7 months ago* (last edited 7 months ago)

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

[–] cyclohexane@lemmy.ml 0 points 7 months ago (1 children)

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.

[–] laughterlaughter@lemmy.world 0 points 7 months ago (1 children)

What's so special about Ocaml's type system?

[–] cyclohexane@lemmy.ml 0 points 7 months ago (3 children)

I won't remember everything, but one very important things comes to mind:

in Typescript, it is very difficult to assert on a type (let me know if you're not familiar with what I mean by this and I can explain further). In OCaml, this is trivial using pattern matching.

Why would you need that? The idea of a type system is it doesn't let you apply a function on a structure without the structure being of the right type. But the lack of type assertion in TS makes people follow hacky workarounds, which defeat the purpose of type system.

There are a couple of other things, like immutable types by default, automatic tail call optimization, functors enabling higher kinded types, etc.

Also in ocaml, you don't have to annotate any types on any variable or parameter, and you'll still get full type protection.

load more comments (3 replies)
[–] penquin@lemm.ee 0 points 7 months ago (1 children)

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.

[–] jamon@lemmy.world -1 points 7 months ago

You should check out Google Web toolkit, totally signs like your kind of thing.

Typescript is for people who hate JavaScript, for the most part. The bulk of the people who have been writing JavaScript for years and aren't Java converts are still using JavaScript and will continue to do so. The Java developers will continue writing Java, no matter what language they are programming in.

[–] ShaunaTheDead@fedia.io -1 points 7 months ago (2 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.

load more comments (2 replies)
[–] eratic@slrpnk.net -1 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 0 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 0 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.

load more comments (1 replies)
load more comments
view more: ‹ prev next ›