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

Programming

17364 readers
160 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 [email protected]



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 50 comments
sorted by: hot top controversial new old
[–] [email protected] 2 points 7 months ago

Wait until they realise its pointless…

[–] [email protected] 5 points 7 months ago* (last edited 7 months ago) (1 children)

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.

[–] [email protected] 8 points 7 months ago (1 children)

I honestly think this is fearmongering. Yes, Microsoft is a shitty company that has done shitty things, but:

  • the Typescript repo is licensed with Apache 2.0, which means the community can always fork it if they do bad/evil stuff
  • there are competing type checkers in the works, which would fully remove any Microsoft influence from a developer using Typescript
  • there already are competing compilers which are broadly used

The only real option they have to do what you're describing is to implement new features that could be used for monetizing it - there would be some inertia regarding community forks. But even then I can't come up with any monetization model that could make sense. Do you have a specific example in mind?

[–] [email protected] -2 points 7 months ago

I hope you're right. But my trust level for corporations is somewhere between 0 and 0.1

[–] [email protected] 9 points 7 months ago (1 children)

Id rather quit than go back to pure JavaScript.

[–] [email protected] 3 points 7 months ago

But it's so sexy. Strongly typed language? *Scoff

[–] [email protected] 12 points 7 months ago

In a small company with a non-complex product, there is a chance that TS creates more slowdowns than not.

In a large company with multiple cooks in the kitchen and a complex product, I'm personally of the mindset that there is substantial gain from typescript. I've had coworkers tell me it's bullshit, and then I do the smallest lift possible to convert and the amount of bugs it reveals are insane.

Is it necessary? No, probably not. But unless everyone's a 10/10 dev working on the world's simplest product, why not just do it and enjoy the benefits?

INB4 JavaScript blahblah, yeah I've added type hints to pure JS projects too and discovered bugs. At this point I don't get it. Typical resistance I get is that it's too prescriptive and lacks JS's dynamic nature - well, fuck off, I don't want to read through 200+ lines of code where you're changing types and shit on me willy-nilly.

[–] [email protected] 5 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.

[–] [email protected] 1 points 7 months ago (1 children)

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

[–] [email protected] 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.

[–] [email protected] 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.

[–] [email protected] 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?

[–] [email protected] 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

[–] [email protected] 9 points 7 months ago

Wow, he's living in 2012 or whatever. A true time traveler.

[–] [email protected] 25 points 7 months ago (2 children)

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

[–] [email protected] 1 points 7 months ago

Can't they just use JSDoc?

[–] [email protected] 8 points 7 months ago

[Object object] would like a word

[–] [email protected] 4 points 7 months ago

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.

[–] [email protected] 10 points 7 months ago (2 children)

I don't see it dying from my perspective. Its only been getting better and better. The only thing I could see displacing it in my org is maybe Rust due to WASM proving a transition path.

We use TS on the back end to leverage our teams existing skill set and libraries we've built up.

I know it's a meme to use "the next best thing" in the ecosystem, but we've been really happy with the newish Effect library + Bun runtime. Effect is like a merger of the older fp-ts/io-ts libraries (same author works on both) with Zio from the Scala ecosystem. It vastly simplifies the former and the new stuff with dependency injection and defect management is refreshing. With the Bun runtime, we see a 15x faster startup time (great for dev). Its halved the RAM requirements in prod. We don't even need to transpile... We still do for prod to tree-shake dev-only code to ensure its not available in prod, but deploying to dev is FAST.

[–] [email protected] 2 points 7 months ago

20 years into the future, once WASM has been widely adopted, a browser within a browser will have been created, with its own equivalent javascript, which will then lead developers to create a WASM equivalent for a web browser running in a WASM browser, running on a bloated OS.

[–] [email protected] 0 points 7 months ago (2 children)

We use TS on the back end to leverage our teams existing skill set and libraries we've built up.

I know you said this, but I'm still curious why not just something like Go, which I was able to basically learn in 3 days- just coming from a mostly JS and C++ background

[–] [email protected] 2 points 7 months ago

I'm coming from a Haskell/Scala background. This job just pays more. TS has been "good enough" for types. I don't think I could be as effective without them at this point.

[–] [email protected] 2 points 7 months ago (2 children)

As a Go dev, its simplicity is arguably taken too far. For example there are no union types or proper enums

[–] [email protected] 1 points 7 months ago

That's fair, I know they're actively rejecting inheritance, but I wish you could make like a prototype. Like say, a function can take a struct with these fields. Which yeah an interface can do but is much more clunky

[–] [email protected] 3 points 7 months ago

Yeah. I started as a C++ dev, fell in love with Go, then ended up on Rust.

Felt like a nice middle ground of "It's got the types I need, but it feels good to dev on"

I really did enjoy using go for smaller projects though, would do so again.

[–] [email protected] 25 points 7 months ago (2 children)

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.

[–] [email protected] 6 points 7 months ago (1 children)

Some of us are old enough to remember the browser wars and EEE, so I definitely understands not wanting to be sucked into some mega corps eco system with future lock-ins. Often you can't do anyhhing else, but that doesn't mean it doesn't suck.

[–] [email protected] 1 points 7 months ago

Same. Writing sites that relied on IE was always a stupid decision and kinda invalidated the point of writing a web app.

I think most people knew that and the managers fucked up big time pushing it. At least in my experience.

But that's very different to choosing a programming language.

[–] [email protected] 1 points 7 months ago

I mean it is fair to say sometimes it depends on the mega corp, if the whole thing relies on one corp if they're funding dries up then the whole project dies. But I also don't really think typescript would die without Microsoft now

load more comments
view more: next ›