r/typescript • u/DanielRosenwasser • Oct 01 '22
Ten Years of TypeScript
https://devblogs.microsoft.com/typescript/ten-years-of-typescript/84
u/MrStLouis Oct 01 '22
I'm the only TS developer on my team and idk how the hell people code JS without it. Not even with JSDoc or VSCode. Makes me sick to think about
43
u/Cube00 Oct 01 '22 edited Oct 01 '22
Even worst are the ones that try to justify plain JS because it's "faster" to develop because thinking clearly about what you're passing around (or not passing in the case of undefined) is just too hard apparently.
11
u/MrStLouis Oct 01 '22
Ya that's the older people on my team. Especially because jQuery is a big library we work with (old enterprise) and basically all of the api for .val() types return string | string[] the type errors drive people crazy. Or "notepad++ is a perfectly adequate code editor" when they all use VS for dotnet code.
12
u/r0ck0 Oct 02 '22
Or "notepad++ is a perfectly adequate code editor"
Haha, yeah this one is so strange to me. I'm still surprised every time I hear it from actual programmers.
1
u/jackson_bourne Oct 02 '22
Notepad++ has a project viewer, plugins, dark mode, intellisense, etc. etc.
It's not my first choice, but it's not bad if you configure it properly
2
u/r0ck0 Oct 02 '22
I mean I guess it is "adequate" and "not bad", depending on what those things mean exactly.
...but this kinda assumes you're comparing it with like... notepad or something?
Thing is... I've never heard any of them say why they prefer it over anything that's actually commonly considered "good" these days. It's usually a case of them not having actually tried anything else since they moved from something super basic to notepad++ ...like 10 years ago.
When they haven't actually tried the alternatives that the other people are talking about... why defend your one-and-only thing against people who have experience with both?
If you're a full time programmer, a job which requires us to constantly be learning and trying new things... I just find it odd that these people don't spend time trying other stuff for their editor. And it makes me wonder if their actual programming skills have evolved much in the same period too.
11
u/r0ck0 Oct 02 '22
Especially funny is the argument "I don't want to spend time thinking about types".
funfunfunction actually literally said this once when talking about how he doesn't like TS.
I love the guy's videos otherwise, so I was kinda shocked that he said this. Especially given that he's even done a series of videos on Haskell and liked that.
The point of the typing system is not having to "think" about types. Because there's no doubt in the first place. Without a typing system, in some aspects, you're actually "thinking" about types even more, and especially when it comes to debugging.
Your code/data has types regardless of whether it has a static typing system or not. You've gotta "think" about them either way. But I'd rather than "thinking" time be preventative rather than painful debugging and everlasting doubt.
3
u/tyler_church Oct 02 '22
Yeah my least favorite kind of “thinking” about types is when I have to dig through legacy code to figure out what the heck the types even are so I can fix a bug or add a feature!
Much better to just write it down in the first place.
1
1
u/FormerGameDev Oct 02 '22
The only time I think about types with Typescript is when there's an error, and that's because the errors are absolutely unintelligible trash as soon as you get beyond the most simple of types.
6
Oct 01 '22
i just grabbed a new contract and this was exactly what the lead told me (it's faster not to use typescripts and we use proptypes anyway). i just uh-huh'd and took the job anyway because money.
2
u/retief1 Oct 01 '22
That being said, there are definitely times where you know what you have but ts doesn’t, and convincing ts that your correct code is actually correct can be annoying. I think ts is worth that price, but there is a tradeoff there.
10
u/SlaimeLannister Oct 01 '22
On a daily basis, it’s truly mind boggling how much I rely on Typescript to catch my bugs and autocomplete the libraries I’m working with.
9
u/geon Oct 01 '22
I wrote some ts 2020 that I opened up today to add a feature in.
It was a piece of cake. Just one more discriminated union, and ts told me exactly where to add the missing code.
2
u/jsideris Oct 02 '22 edited Oct 02 '22
Before I really got into TypeScript I spent years really in the weeds of JavaScript working on some really hard shit. One thing I'll say is that you get really good at predicting what might break and then diagnosing problems. And not only that, writing code in a safe way that is less fragile.
TS is a huge improvement though.
*grammar
6
u/r0ck0 Oct 02 '22
idk how the hell people code JS without it
The same way people lived without toilets in ye olde days...
You don't miss what you don't know.
The biggest sign of an inexperienced dev (or just stunted/stupid older person) is when they argue against things they have no experience with.
I was that guy in my younger days too. I've mostly grown out of it. But it's fucking weird seeing older people who never learnt this life lesson though.
2
Oct 02 '22
It took me a bit to understand how to think in TS properly, but holy heck was it worth it. I genuinely cannot understand how people are still religiously attached to plain js. The minor inconvenience you have to work around helps you fix issues you never would have caught otherwise
1
17
u/r0ck0 Oct 02 '22 edited Oct 02 '22
TypeScript really was the big thing that got me into static typing, including going on to learn other languages like C#, Rust, Haskell, #F.
But even though they all obviously have stronger runtime typing guarantees... they all fall short compared to TS when it comes to stuff like efficiently creating types from other types.
I use things like keyof typeof, and the util types so often, that I feel very stunted in other "more strongly" typed languages, where you don't have any of this stuff, and you just need to copy and paste or manually write more types to get the power of what TS can do with easy type-munging.
It completely affects the style of code you're going to use in the first place.
I also really really love string literal union types (is there are more succinct term for this?). I find enums annoying in comparison now, and don't even use them anymore.
And I keep finding more and more use cases for when I want special chars in the strings/tokens, which you can't do with an enum key. e.g. Domains and email addresses etc.
I've tried to find them in other languages, but nothing else seems to support them anywhere like TS can.
Personally for almost all of what I do, the compromise on runtime safety with TS vs other proper static languages is actually worth it for all this stuff I'm banging on about here. I miss it all too much in those other languages.
3
u/alliejanej Oct 02 '22
I love this take, and just moving over our production app from JS to TS. The more I use it the more I love it.
And didn’t know about all the Util types! I use Record quite a bit but going to have to learn the other ones. Thanks for the tip!
15
26
u/FullstackViking Oct 01 '22
Typescript single-handedly ushered in my passion for programming.
A perfect blend of approachable simplicity, and a long enough leash to get yourself deep in the weeds.
Combined with the complimentary development of VS Code, it’s a great time to be a programmer!
8
5
u/bussy-shaman Oct 02 '22
I'm trying really hard to get my team to move to TypeScript from vanilla JS. They have no idea what they're missing.
3
u/solidiquis1 Oct 02 '22
TypeScript made me realize how shit my JS was and I shudder now looking back at how much JS I've written in our codebase before we added TS. There's really no good reason to not use TS.
1
u/Ooyyggeenn Oct 02 '22
There is Typescript and theres also Typescript written by psycopaths which makes the codebase unreadable.
2
u/rcfox Oct 02 '22
I've been working with MikroORM lately, and it is really cool how it can type-check my queries, even within embedded JSON fields. But yeah, the package's source is really hard to read because of all the typing magic going on.
48
u/lifeeraser Oct 01 '22
People despise Microsoft for many reasons but TypeScript is not among them. Looking forward to the next 10 years <3