this post was submitted on 02 Apr 2024
142 points (98.6% liked)

Programming

17540 readers
65 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 2 years 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?

you are viewing a single comment's thread
view the rest of the comments
[–] cyclohexane@lemmy.ml 5 points 8 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 1 points 8 months ago (1 children)

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

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

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

Oh, so what you're describing is strong typing. I thought it was a unique feature of Ocaml. But in reality, any strong-typed language will have this as well.

And yeah, Typescript merely "suggests" typing, and it will allow you to build the project even if you ignore the type errors. A build system refusing to, well, build, if there are typing errors usually takes care of this, but again, the dev team may as well not implement this.

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

Any examples other than ocaml? From my understanding, ocaml's type strength may only be found in a couple other languages. Haskell, scala, and maybe Rust. Any others?

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

I thought of Pascal, Java and C#, but pretty much any language listed here as "explicit / nominal / static" makes the cut:

https://en.wikipedia.org/wiki/Comparison_of_programming_languages_by_type_system