this post was submitted on 08 Sep 2023
526 points (94.0% liked)
Programmer Humor
19623 readers
25 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
My issue with typescript... and, correct me if I'm wrong... is it doesn't exist without Javascript. Typescript needs to be compiled down into Javascript to be run. It has no stand alone interpreter (that I'm aware of) and definitely not one baked into web browsers or NodeJS (or adjacent) tools. In essence, Typescript is jank sitting on top of and trying to fix Javascript's uber jank, simultaneously fracturing the webdev space while not offering itself as a true competitive and independent language for said space.
That's my amateur two cents for what it's worth.
The fact that TypeScript doesn't attempt to obfuscate JavaScript, and just fills in the gaps, is what makes it the best solution to the problem.
It's not a separate language, it's Javascript tooling
I've used JavaScript since its creation. I would describe typescript as JavaScript as it should have been. I've always actually liked JavaScript's simplicity, but I've never liked its lack of type safety. At its core, JavaScript has a tiny conceptual footprint, and that's actually pretty refreshing compared to other very complicated languages. But it was plagued with terrible implementations and the inherent messiness of dynamic typing. I've watched it evolve over the years and it's improved beyond my greatest hopes. Between the advent of transpilation, tooling, and typescript, I'm very proud of where the language has gotten to. Having made websites in the 90s and 00s, I feel like people don't realize how much work has gone into getting the ecosystem in a much better place.
I don't think it really fractures anything considering you can call a ts package from js without knowing. The other way also works with third party typings in DefinitelyTyped.
It really just adds a bit of extra type info into js, looks like js, and transpiles into js that looks almost exactly like the input, including comments and spacing and such if you like, so there isn't any lockin.
There isn't any competition, it's just an extra optional tool for the js ecosystem in my eyes.
The transpilation that typescript does doesn't really have anything to do with typescript, it's just there because typescript wants to support the latest ecmascript features, so transpilation is necessary for that, but technically you could simply strip out the type info and have another transpiler like babel handle the backwards compatibility. I think there are a few minor exceptions to that, like enums. There was even a proposal to add some typescript types to native JavaScript that would be ignored by the interpreter and just act as comments.
I mean, tsc without any of the backporting functionality is still a transpiler since it goes from a high level language(ts) to another high level language(js). Transpilation as a concept doesn't imply that it is for backporting language features or that the source and destination languages are the same, just that it is a transformation from source code to a similar or higher abstraction level language source code
Yes, it's still a transpiler, I'm not saying it isn't, but what I mean is that it doesn't add any functionally specific to the typescript language. There's a transpiler for TS that doesn't even do any type checking at all and just does the type stripping and back porting. But of course, that's not why people use typescript. All the features that are actually important to typescript could be done through a linter instead. If type annotations were added to JavaScript you could get most of typescript's features with linting rules and just handle back porting in a more standard way.
I think too many people ITT are conflating Typescript with Typescript frameworks like Angular.
As a professional with 25 years of experience I agree with you. The entire modern architecture was created by people who don't like simple things that work. I'm pretty sure there are a couple of high ranking master developers sitting at the head of W3C competing to create the most convoluted system possible.
You are correct.
That says I would never ever EVER start a project without TS.
It's like coding with hands vs coding with your elbow.
I also don't want to compile my C++ code myself. I'm pretty happy with letting a compiler do it's job...
I really don't get how people can feel more productive in JavaScript. With typescript the code practically writes itself. Sometimes when refactoring I'll change a functions input and output signature and just fix compiler errors until it stops complaining, and the code just works without me having to really even think about what the code is doing.
Any time I'm forced to go back to js I feel like I'm going crazy trying to keep track of what's in all the variables. With typescript I can use more powerful object structures without having to constantly double check where they came from.
Just fyi, while they don't help with running TS in the browser, the Bun and Deno runtimes both natively run TS without any compilation.
That's not true, deno compiles TypeScript to JavaScript, it just does it transparently. The code still runs on v8.
V8 also doesn't run js, it does some byte code compilation stuff amongst other things, then interprets that. But that's all a bit pedantic too, V8 runs js, deno runs ts.
fwiw https://deno.com even has as one of their first bullet points that they have "native support for TypeScript and JSX"
Sure, but part of the claim was "without any compilation". But bun/deno do compile TS into JS.
What we really need is a browser that runs something other than Javascript. Until then, stack of jank it is.
WASM?
Is that a standalone thing? This is obviously not my specialty but I thought it was part of Javascript.
I've never worked with it and don't know in detail, but it lets you compile several languages into web based client/server code (basically, converting other languages into website code). Works with C, C++, C#, Go, Rust, Swift, etc)
I agree.
I'm a hobbyist. I don't work on really large or complex projects. I just want to get the most productivity for my spare-time-dabbling and having tried a few times to get into typescript it seemed to create more "extra steps" for me than it saved.
Like 2023 CoffeeScript?
Typescript doesn't have strong typing but static typing still gets you really really far. It means you need to be more careful with your io and avoid dangerous type assertions, but I don't think that's a bad thing. Having used typescript an absolute ton, the only real jank I've encountered is from bad library typings that either use it lazily or incorrectly, but for code bases that use it through and through it has been smooth sailing, and having professionally used both traditional static typed languages and dynamically typed languages, I really enjoy typescript's type inference and structural typing. I think you should give it an honest try before judging it. But that's just my 2 cents as an industry professional who has used many languages and have been programming for decades for what it's worth.