Is TypeScript a fad or is my manager delusional?

SorteKanin@feddit.dk to Programming@programming.dev – 138 points –

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?

154

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 šŸ˜…

As long as JavaScript is being used, TypeScript will be used. It makes writing JavaScript tolerable.

Imo they'll add typing to vanilla js, which will kill ts.

And the ts devs support this

And I'm sure Microsoft would be happy to not have to do it anymore. And I personally would much prefer an actual typing system rather than a glorified linter.

Tho I wonder if it will end up being like jQuery, in the sense that, by the time core jQuery features got added to vanilla js, jQuery had developed new features that validated its continued existence. Maybe TS will go further than what gets absorbed into JS and keep it alive.

Honestly, I've never used jQuery despite writing JS for over 10 years. Just because I hate the reliance on massive nebulous packages so many have. Especially when I looked into it years ago, so much of what I saw jQuery being used for was stuff that was extremely easy to implement yourself. How has it changed?

jQuery is a lot smaller and less nebulous than its competitors (looking at you,React literally every JavaScript framework).

Jquery was what was popular when i learned js. I'm kinda glad it was, honestly: jQuery is a little unique in that it doesn't have magic to it the way js frameworks do. Everything you can do in jQuery, you can do in vanilla JavaScript pretty easily. With, say, React, how is a newcomer supposed to understand how a series of React components become HTML?

So jQuery kept it "real" for me. Fewer abstractions between me and the HTML meant it was easier for me to connect the dots as a self taught developer.

As for how it's changed, it's more any how vanilla JavaScript has changed. A lot of the things that made jQuery so much easier and cleaner than vanilla are now baked in, like document.querySelector(), element.classList, createElement(), addEventListener()... It had Ajax methods that, before jQuery, were a tremendous pain in the ass.

jQuery was great, but, you basically had to use it with something like PHP, because it had no back end. So when angular came out (and a few others that aren't around anymore and I've forgotten), it allowed you to replace both PHP and jQuery, and developers rejoiced.

Why did they rejoice? I'm not actually sure there was reason to, objectively speaking. As developers, we like new tech, especially if that new tech requires us to think about code differently, even if, in retrospect, it's a hard argument to make to say that, if we had just stuck with PHP and jQuery we would be somehow worse off than we are with React.

Of course, in tech, when a new system changes how we think, sometimes (not as often as we'd like) it helps us reconsider problems and find much more elegant solutions. So, would we have all the innovations we have today if all these js frameworks has never existed? Obviously we can't really answer that -- but it's a toke of copium for when we get nostalgic for the PHP/jQuery days.

(Also, for you newer people reading this, you should probably be aware that the PHP/jQuery mini-stack is still very quietly used. You'll definitely see it, especially in php-baaed COTS.)

Thanks for informing me, but I still kinda wonder why someone would use it today?

And also JS.

Well "kill" is perhaps a strong word but it definitely won't be JS anymore at that point. The changes required to bake in strong type support would be radical.

That would be a great solution, because while I love Typescript, I hate compiled web code. One of the coolest things about the internet is that as it's supposed to work, you can download the source code for any website you go to. It's open source by design. I hate closed source websites and I hate compiled website code that helps close the source it's quite a contradiction because typescript is awesome and I recognise that compilation is the only way to get it to run on our web infrastructure. So it would be great if we could just type JavaScript and solve the contradiction that way.

Doesn't typescript compile to js anyways? Is it obfuscated?

It's not intentionally obfuscated or minified. Generally it just strips out types and comments, but depending on how it's configured, it will rewrite certain things to work in ES5. At my work our build process uses a separate minification and bundling step, which also serves to a obfuscate our proprietary code.

It transpiles to js and there is some level of stripping for optimization yes.

the canā€™t add proper typing without adding a compiler. Whatever they add will be closer to puthonā€™s type hints. Iā€™ve had to write primary in python lately and type hints help very very slightly, and tools like pyright catch so many false errors due to lack of hints in libraries that weā€™re forced to add ignore statements on too many lines. I genuinely donā€™t understand how there can be so many languages and all of them be painful to use

I genuinely donā€™t understand how there can be so many languages and all of them be painful to use

What about kotlin?

yes I heard itā€™s great. Scala was one language where I didnā€™t constantly feel like getting hit in the head with a hammer and Iā€™ve heard Kotlin has a similar experience. Iā€™m not interested in Android development so I havenā€™t tried it

Kotlin isn't just for Android; IMO unless you're trying to do purely functional programming, it's preferable to Scala for JVM work.

Yeah anywhere were you would use Java. Scala has a too high adoption cost. Kotlin is better suited for enterprise, has a stronger ecosystem and better interop with Java. I did enjoy scala though when experimented with it. The only thing I missed was the lack of control flow, no labels, continue, break

I have very minimal pain in Go

Iā€™ve heard good things about it, looking forward to learning it (hopefully soon)

I was able to pick it up extremely quickly. Just basically looking at existing projects. Tbh, I don't even know how I learned it.

TypeScript might not be here to stay, but typed JavaScript definitely is. Iā€™ve switched to writing 100% TypeScript, and havenā€™t looked back. The fact that just adding types to one of my (admittedly more complex) libraries surfaced 3 unknown bugs was eye opening to me.

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.

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.

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

Exactly, it was pretty useful until ~2015 imho. Then JS got better, and coffeescript did not follow these evolutions.

CoffeeScript wasn't a fad, it just became obsolete because JS adopted the syntax sugar CoffeeScript was selling. In a way, it did its job.

Yup! All of the following features were in CoffeeScript first: Modules, classes, arrow functions, async functions, parameter defaults, ...spread, destructuring, template strings.

So I'd say it was extremely successful in making JavaScript better.

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.

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.)

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.

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.

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.

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.

Developers are still catching up, but it will be one-way traffic from here.

Honestly I disagree, maybe I exist in a bit of an echo chamber, but it seems like since around ES2020 or so (some) people have been transitioning from TS to write JS with JSDoc and modern JS style rules.

I've basically transitioned to Go for work(where I can), but don't really mind writing modern JS

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.

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.

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.

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

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

No. Dynamic typing, though, is absolutely a fad.

Dynamic typing is not a fad.

Python is older than Java, older than me. It is still going strong.

Python also has a statically typed option these days.

Edit: Previously said "strongly" instead of "statically"

Which one? There is static typing with the typing module, but that's not strong.

I should have said statically typed, fixed.

Ah, gotcha, thanks! I'd have loved a strongly-typed option.

The static typing system is slowly getting there, but many useful Python patterns can't be expressed yet. You can, for example, write a function that appends an item to a generic tuple - but you can't concatenate two tuples. I really hope they keep expanding on the system!

Isnā€™t Python already strongly typed?

No:

$ python 
Python 3.10.13 (main, Jan 28 2024, 03:02:00) [GCC 13.2.1 20230918 (Red Hat 13.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def handle_foo(value: list[int]) -> bool:
...     return 42
... 
>>> print(handle_foo(False))
42

I havenā€™t used Python since around the time when type hints first became a thing so I might be completely wrong here, but isnā€™t this because Python just generally ignores type hints? If you ran a static type checker like mypy over this it would complain right?

Also, if you actually did anything with the list that you couldnā€™t do with a bool (e.g. len(value)), it would throw an error too because Python is actually pretty strict about types, just only at runtime. Thatā€™s why itā€™s usually considered to be strongly typed, although people donā€™t seem to agree what exactly thatā€™s supposed to mean.

This just blew my mind. I had always assumed Java was older. I started writing hobby projects in Java in the 90s. I don't think I heard about Python until the early 2000s.

"Strong"... how many actual projects run on python?

Half of the internet ( backend) runs on java, banking, your government systems, etc.

It's not a fad, it's just unusable for anything other than research project and small time scripting, which to be fair, it's what it's designed for.

You have no idea. Python (and Ruby) are used widely in the industry. Large parts of YouTube are written in Python, and large parts of GitHub are written in Ruby. And every major tech company is using Python in their offline data pipelines.

I know of systems critical to the modern web that are written in Python.

With how shit youtube is I am not sure you made a great case for python mate.

AndĀ everyĀ major tech company is using Python in their offline data pipelines

Thats a meaningless statement, ETL tools can execute python as part of a multi step process and then yeah they use python in their data pipeline, but the ETL tool that orchestrates it is which is the actual value add software is not written in Python it's written in Java, I know this for a fact...

With how shit youtube is I am not sure you made a great case for python mate.

I'm not good with names about logical fallacies but that sure is one. You asked for "actual projects" and YouTube is one of the biggest and most popular platforms out there. That you personally dislike it is irrelevant.

ETL tools can execute python as part of a multi step process and then yeah they use python in their data pipeline, but the ETL tool that orchestrates it is which is the actual value add software is not written in Python it's written in Java

So what's your point, that interpreted languages don't count because they're interpreted? Why stop there? It's the actual C compiler that was used to compile the JRE that brings the value here, so your ETL tool doesn't count.

You're either a troll or a joke.

If you dont know the difference between software and script I am not sure I can explain it to you...

That distinction is not relevant at all in this discussion.

But hey, I think that's one I know: should count as a strawman.

How is it not relevant? This is my comment you are replying to

It's not a fad, it's just unusable for anything other than research project and small time scripting, which to be fair, it's what it's designed for.

I'm sorry, apparently I missed that because of your dismissal of YouTube.

To make up for it I have another small scripting example for you: the Instagram backend runs on Python, too.

So, to my example of critical, important infrastructure of government and banking running on Java, your reply is, youtube and instagram.

That's lit mate, no cap, frfr. (Sorry I am not that familiar with your gen's slang)

No, I'm not going to follow your logical retreat any longer. You said

it's [Python] just unusable for anything other than research project and small time scripting

You were presented with not small but big time scripting and two of the largest and most popular modern web platforms of the world (BTW I neither use nor like those myself but that's, as mentioned, irrelevant) and still cannot admit you're wrong, so I don't think you would even if I dug out some examples in "serious" fields (apparently building trillion dollar companies on such platforms isn't serious enough).

Also never assume generations. According to social media demographics, odds are I'm older than you.

And my example of knowing critical systems for the web written in Python is somehow different from your argument?

What a joke

I work in investment banking environments (calculations). Python is everywhere. Java and C++ as well.

Yeah calculations, not actual software... how is this hard to understand... you don't write long lived, stable software that multiple developers work on that needs to do real work in python

It might not be a fad, but it's definitely a local maximum and/or a limitation that many devs seem to be stuck with.

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.

So there is no productivity loss/learning curve unless you want there to be.

It's not significant but an extra build step can be annoying

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.

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.

I believe both are true... and I also develop a LOT in Angular (with TypeScript).

TypeScript is great but the thing is that if you look at the history of TypeScript and JS/ECMAScript you'll find out that TypeScript sometimes is the testing ground for the future features of ECMAScript - pretty much like what happens with Sass and CSS that how even has nesting and scopes.

The issue with TypeScript/Sass etc. is that it requires a compiler and that's totally obnoxious and completely defeats the point of having interpreted code on browsers. Depending on the project it might be better to go for TypeScript + Angular/React or other compiled solution or simply something vanilla with jQuery or the Vue runtime (no compilation) and other libraries.

If TypeScript ever goes away the underlaying features that make it great will be implemented in ECMAScript in the same way that we got modules, classes etc. and I really hope it happens. Less compilation usually equals code more maintainable in the long run because you won't require hundreds of dependencies (that will eventually break) to get it to compile.

TypeScript sometimes is the testing ground for the future features of ECMAScript

They have an explicit policy to only include features that are stage 3 already (i.e. that are pretty much certain to land in the language as-is). The only times they've diverged from this is long in the past (I think enum is the main remnant of that, for which I'd recommend using unions of literal string types instead), and experimentalDecorators under pressure from Angular - which has always been behind a flag explicitly named experimental.

So I really wouldn't worry too much about that.

The issue with TypeScript/Sass etc. is that it requires a compiler and thatā€™s totally obnoxious and completely defeats the point of having interpreted code on browsers.

Shouldn't WebAssembly be a solution to this? I.e. so you don't have to interpret code but rather run the wasm binary (which is kinda interpretation as well but you get what I mean).

I love seeing webassembly getting traction because it enable cool stuff never thought possible before running in web browsers. But webassembly is a blackbox that can't be tinkered with by end users. I dread the day webassembly become so widely used that average websites run under webassembly because that would be the end of blocking ads or tweaking websites behavior with greasemonkey scripts.

I don't think adblockers rely on interpreting JavaScript, I think they would still work even if a site used WebAssembly.

Source: I can assure you every single ad-funded website would be doing this if that was the case.

ublock origin won't help you blocking the ad elements if the entire website ui is rendered in a canvas (already starting to happen thanks to some frameworks like flutter) and can't block the ad logic if it bundled in the wasm along with the rest of the app. It might still able to block the requests, but they're starting to serve the ads from the same domain that serves the website so it can't be blocked without breaking the website itself, and might begin to serve those over websocket so adblockers can't block it by url path. With javascript, an ad blocker might still be able to monkey patch the ad logic on runtime to break it, but with black box like wasm I'm not sure if such thing is possible.

Once tooling and frameworks make it easier for average webdevs to use webasm, I'm sure ad companies will begin to offer it in their ads sdk. Thankfully most websites with ads are still care about SEO so at the very least we can be sure it won't happen anytime soon, unless something changes in how google works that could enable this.

the entire website ui is rendered in a canvas (already starting to happen thanks to some frameworks like flutter)

That sounds like an accessibility nightmare.

Have you tried not being disabled?

Flutter devs actually defended this approach, saying the web in general is moving to this direction. I think they've mellowed out somewhat and released html renderer support, though it's still default to canvas for desktop web browsers.

That's not a solution, it is the exact opposite - adding even more compilation and complexity to things. The ideia is to move away from compiled stuff as much as possible. WebAssembly makes sense for very complex and low level stuff that you can't run interpreted with reasonable performance.

Less compilation usually equals code more maintainable in the long run. Think about it: if you don't need a compiler and the hundreds of dependencies that will eventually break things will last way more time. Websites from the 90's still work fine on modern browsers and you can update them easily while compiled stuff is game over once you lose the ability to install run said compiler and related dependencies.

Think about it: if you donā€™t need a compiler and the hundreds of dependencies that will eventually break things will last way more time.

You can have hundreds of dependencies whether you use a compiled or interpreted language, that really has nothing to do with that.

Also compilation has lots of benefits, including being able to do lots of static analysis to find bugs. I definitely don't agree that we should move away from compilation in general or WebAssembly specifically. WebAssembly doesn't have to be only used for low level stuff, you can write your code in a high level language and compile to WebAssembly just fine.

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.

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.

Typescript is the only way I can agree to code in Javascript. And the only way you can have a sane project without writing double or triple the amount if unit tests for each function just to check things that a compiler would do. However it is absolutely a lipstick on a pig thing with confusing behavior sometimes, but thatā€™s because the underlying language it is trying to make bearable is bonkers

I don't think it's going away until ECMA supports native types. Until then it's the best game in town.

If a team decides to move away from it, it's only few hours work to entirely remove. So even if it's going away, it's risk free until then.

But I cannot imagine why any team would elect to remove Typescript without moving to something else similar. Unless it's just a personal preference by the developers who aren't willing to learn it. It removes so many issues and bugs. It makes refactoring possible again. I think teams that want to remove all types are nostalgic, like a woodworker who wants to use hand tools instead of power tools. It's perfectly fine, and for some jobs it's better. But it's not the most efficient use of a team to build a house.

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.

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.

Thank you for the suggestion. I'll check that out. I'm actually only writing TS temporarily for work. I'm going back to C# in a couple of weeks.

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.

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

Silverlight would like a word ;)

Javascript is a fad.

Reject web dev; return to native.

I strongly disagree with this, web dev is great because you can serve hundreds of different devices with the same code, I can't imagine developing native solutions to each one, yikes

What's the point of calling something a "fad"? If the technology works well and it provides value to you, why should you care what other people think?

(Example: Look at PHP)

The point of calling something is fad is a way to tell you that you shouldn't invest a lot of time into this because that knowledge will become obsolete soon.

I mean this is particularly relevant in the JS world because every week there's a new revolutionary framework that renders the previous framework obsolete. (Although, not sure if that's slowing down now...)

Unfortunately when it comes to my manager, I can't just ignore what he says as his opinions actually has an influence on what technology we use and such.

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.

after reading the title I thought he'd suggest something better than TS would take its place, but going back to JS? nah

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

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

By saying gut feeling I hope I am being clear I have zero tangible evidence? šŸ˜…

Maybe over the next decade its usage will grow? Or maybe it will end up relegated to performance critical applications, or JS/TS just end up with the same/better performance anyway.

I think you've got a point here, in that the sort of Devs who want to be able to refactor their code without breaking everything are also going to be the group who lean more into having code that actually runs quite fast; but given that reasonML is awesome and didn't get much mindshare my position here is that wasm will only start to eat into tyspecript's lunch well after a huge subset of TS can be compiled to wasm (or maybe python ((I blame the xkcd guy for python's unreasonable popularity, I feel it's hugely overrated))).

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.

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.

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

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

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.

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

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.

Id rather quit than go back to pure JavaScript.

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

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

To be honest Typescript and Javascript for me are both very bad Hacks driven languages. I explain myself: I've worked on a project for a client, with other devs who were experienced js/ts devs. Before to get on, I've read a book about them, went through the docs. But in the end, I would push PRs, and there was some hacky way to do stuff, now some stuff is just bad developers, choosing the hacky "obscure" undocumented way to do something, but other solutions were clear enough that deserved to be documented. Overall I am better off without using those

Unpopular opinion perhaps, but I rather have a language that allows me to implement hacky solutions than one that requires me to completely scrap and rearchitect everything.

I for example once had to overwrite a dozen or so of prototype methods in a JS class because the library a we were using just fell apart when doing certain things inside a Shadow DOM - it was a library that was released long before that feature. And completely rewriting huge chunks of code that interacted with that library would have wasted 100s of hours and the end result might have been really akward as well since many other systems are architected around how that one library worked. So instead it was a matter of patching in a few checks and workarounds for shadow dom elements.

And since its extremely well documented why we decided to to that, what these hacks do I don't see an issue with that. Obviously this shouldn't be the modus operandi everytime but its always good to have the option i.m.o. to dig yourself out of a hole.

Oh speaking of dependencies changes, you know one of the contributions to that team for me was to fight against them depending directly on third party libraries? I have to spend a lot of energy making people go through the pain of creating a middle layer between our code and frameworks code, because itā€™s not needed, because its repetition, because etc. until the dependencies change and everyone has to sweat blood, I donā€™t think thatā€™s a good argument for languages allowing hacky code, I think itā€™s an argument to improve developers awareness, and a team culture that doesnā€™t foster hacks over bad design decisions

I would argue that overriding methods on a prototype is not a hack. It's equivalent to overriding super methods in Java classes, but using javascript's prototype-based inheritance instead of class-based inheritance.

But I agree with your main point about choosing a language that lets the developer implement their solutions freely.

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

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.

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.

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.

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.

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.

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

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.

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.

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 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?

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

Have you tried slapping your manager?

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.

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

Wait until they realise its pointlessā€¦

For me, personally, yep; 100%. I've tried at least 3 times to convert, it just gets in my way. I'm way way faster with plain old JS. But I'm also a Rubyist so it is all ducks anyway.

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.

Is there some huge benefit that Iā€™m missing?

For example I recently fixed a bug where a function would return an integer 99.9999% of the time, but the other 0.0001% returned a float. The actual value came from a HTTP request, so it started out as a string and the code was relying on dynamic typing to convert that string to a type that could be operated on with math.

In testing, the code only ever encountered integer values. About two years later, I discovered customer credit cards were charged the wrong amount of money if it was a float value. There was no exception, there was nothing visible in the user interface, it just charged the card the wrong amount.

Thankfully I'm experienced enough to have seen errors like this before - and I had code in place comparing the actual amount charged to the amount on the customer invoice... and that code did throw an exception. But still, it took two years for the first exception to be thrown, and then about a week for me to prioritise the issue, track down the line of code that was broken, and deploy a fix.

In a strongly typed language, my IDE would have flagged the line of code in red as I was typing it, I would've been like "oh... right" and fixed it in two seconds.

Yes ā€”Ā there are times when typing is a bit of a headache and requires extra busywork casting values and such. But that is more than made up for by time saved fixing mistakes as you write code instead of fixing mistakes after they happen in production.


Having said that, I don't use TypeScript, because I think it's only recently become a mature enough to be a good choice... and WASM is so close to being in the same state which will allow me to use even better typed languages. Ones that were designed to be strongly typed from the ground up instead of added to an existing dynamically typed language.

I don't see much point in switching things now, I'll wait for WASM and use Rust or Swift.

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.

Let me reverse this question and ask what is the benefit of dynamic typing? What is gained from vaguely defined objects?

The purpose of typed languages is to ensure the bare minimum when it comes to safety. That when you're accessing a field of an object that field is real, and that field is always going to be an int or a string.

Try/catch only goes so far before it becomes way more cumbersome than necessary, as is checking every field of an object.

Typescript is an example of a language that does static typing poorly, because by design it has to. It's a quick bandaid fix over an inherently awful language.

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

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.