How do you feel about TypeScript?

https://lemmygrad.ml/post/2269525

How do you feel about TypeScript? - Lemmygrad

Specifically, do you worry that Microsoft is going to eventually do the Microsoft thing and horribly fuck it up for everyone? I’ve really grown to appreciate the language itself, but I’m wary of it getting too ingrained at work only to have the rug pulled out from under us when it’s become hard to back out.

FYI, there’s a TypeScript community in Lemmy.

[email protected]

I’m sure that any non-trolling/flamebait discussion over TypeScript is welcomed in there.

Hi there! Looks like you linked to a Lemmy community using a URL instead of its name, which doesn’t work well for people on different instances. Try fixing it like this: [email protected]

Specifically, do you worry that Microsoft is going to eventually do the Microsoft thing and horribly fuck it up for everyone?

I’m not sure you are aware, but Microsoft created TypeScript.

…microsoft.com/…/announcing-typescript-1-0/

Without Microsoft, TypeScript would not exist.

Announcing TypeScript 1.0 - TypeScript

TypeScript 1.0 Today, we’re happy to announce TypeScript 1.0. First, we want to give a big “thank you!” to everyone who has helped us over the last year and a half to meet this goal. Together, we’ve grown a language, tools, and a community around creating large-scale JavaScript applications.

TypeScript
I think you’re missing the point. It’s exactly cause Microsoft created it that people get worried about it. The EEE is an actual phrase found to be used internally in Microsoft, albeit being some time ago. Though there’s no knowing whether it’s still circulating now, it’s hard to trust them to be good stewards forever.
Embrace, extend, and extinguish - Wikipedia

I think you’re missing the point. It’s exactly cause Microsoft created it that people get worried about it.

I don’t think there is any merit to that concern. Not only is TypeScript FLOSS, Microsoft also has an excellent track record developing high-quality programming languages and tech stacks. Take for example C#. It’s been around for over two decades and if anything it’s getting better by the release.

I understand the rationale behind the concern, but there is also a factor of mindlessly parroting cliches.

Without Microsoft, TypeScript would not exist.

I'm not sure you are aware, but TypeScript is not the first language to compile to JavaScript.

https://stackoverflow.com/questions/4414558/languages-that-interpret-down-to-javascript
https://github.com/jashkenas/coffeescript/wiki/List-of-languages-that-compile-to-JS

Without TypeScript, people would have adopted a different JS transpiler, one that isn't controlled by a monopolistic corporation with a history of extinguishing open source projects.

Languages that interpret down to Javascript?

Another post questioned how practical it is to compile languages into Javascript. Practicality aside, what interpreters translate from some language X to Javascript and were implemented in Javascr...

Stack Overflow

I’m not sure you are aware, but TypeScript is not the first language (…)

This discussion is about TypeScript.

Really? Name one open source project MS extinguished.
It’s open source. Anything is better than JS.
Chromium, Firefox, NodeJS, Deno, and Bun are all open source. I mean, sure the official name is ECMAScript not JavaScript, but unless you’re talking about a technicality I’m not sure what your point is.
I think the point is that since it’s open source, there’s not as much worry of Microsoft ruining a good thing.
Ah thank you, that makes more sense.
I’m not sure what that means. Open source telemetry is still telemetry.
The rug pull is google’s forte

Yes, MS’s standard operation is to evolve the thing until it’s completely hostile to your intentions, but not explicitly enough to justify a tool change for management.

They are currently in the “devs wanted” mode, it will be a few years before they change into “fuck you, pay me” mode again.

Ya “rug pull” isn’t exactly the best description but I figured people would know what I was getting at, ha
It’s nice, but it would be great if JS were replaced by WASM.

Well since this is a Typescript / Microsoft kinda thread - there are replacements… You can use C# with Blazor (from Microsoft)

And you can also compile Go and Rust to WASM (probably some other stuff as well that I’m not aware of)

But then reversing sites will be so much more annoying
GitHub - WebAssembly/wabt: The WebAssembly Binary Toolkit

The WebAssembly Binary Toolkit. Contribute to WebAssembly/wabt development by creating an account on GitHub.

GitHub
No, I’m glad that “now that wasm exists I can do web development in any language” isn’t thing yet. The web would get even more clumsy than it already is. I’m glad that when I visit 5 links I don’t have to download 10 different runtimes each time.
10 different runtimes? WASM what do you mean? It’s byte-code for the browser. It’s not like Flash or Java applets that required an external program to run.

Everything is temporary. If we were talking about a niche language, I might worry a little bit that it could just loose momentum and die. But TS is a juggernaut. The only way typescript “dies” is when JS integrates enough of its features to make it redundant.

Besides that, if Oracle managed to allow Java to continue to grow and flourish, I have confidence that MS can do at least that well.

Everything is temporary except for people’s opinion on Microsoft.

The company is spending a ton on supporting developers, tools, and open source projects but every time they get mentioned people just hark tired lines of past ill deeds.

I mean if they didn’t want a shit reputation, they shouldn’t have done those past ill deeds.

I think people should in general put as little trust as possible in corporations. Ensuring your tools, language and platform are as free as possible is a good idea.

Just look at the problematic situation for VS Code extensions by Microsoft, which are non-free.

I can agree with the goal but sadly the corporations have already got their claws deep in the tech stack.

Facebook control React. Google has its hands around Chromium, Android, Go, Angular and I’m sure dozens of others. Then of course Microsoft now own npm, GitHub etc. You’re making your life very difficult if you entirely avoid corporate entities.

If we don’t give corporations credit when they do run projects well then there’s no incentive for them to not go full on capitalist greed and destroy them.

Corporations aren’t people and don’t behave like people. Giving credit to corporations doesn’t work in the long term, because people who work for them are constantly changing. The ones who did a good job may leave or get replaced, and the ones who take over may not care about maintaining their legacy.
Surely the inverse is also true then? People change, leadership changes, goals change so why assume the Microsoft of today is as bad as its past self?
I actually drew that same Oracle comparison. They’ve made the occasionally bullshit effort, e.g. the API stuff with Google, but otherwise Java is just kinda Java. Fair point.

Maybe Im reading the vibe wrong but to me, it seems like when it comes to the programmer/sysadmin/poweruser side of Microsoft, they seem pretty good in terms of not being total shit. Their “normie” facing side though seems hella shady though. Things like ads in windows, the speculated subscription model for windows, office 365, one drive spam.

For example, things like vscode, WSL, winget, power tools, the new console app, powershell, typescript, opening up .net to native cross platform. All these things are pretty sweet and seem like something they wouldn’t be interested in doing.

It almost feels like there are two Microsofts right now and they are at odds with each other. So yeah, I guess enjoy it while it lasts, but always be ready to drop them like a sack of potatoes.

Like I said in my other comment, I think people tend to lump all of MSFT’s activities into the same bucket. DevDiv has always seemed pretty decent, and I am usually reminded of this comic when people talk about MSFT’s “shady” activities.
Organizational Charts

Historically speaking they’ve been shitty on all possible sides. Some people take that as “fool me twice, shame on me”.

Excuse me but I have it from a very reputable source that the saying goes “fool me once…

Shame on… Shame on you.

Fool me-- can’t get fooled again”

I remember that moment. It was like, halfway through the sentence he was like, “I don’t want the world to have a clip of me saying ‘shame on me,’ what do I do…” I wonder if he ever figured it out. Because what you don’t do, is what he did, just kinda stammer and stumble in a much more clippable way.

Bill Gates was and still is a shady piece of shit. Microsoft is a lot better without him - but that’s a low bar.

Personally what bothers me is that they’re starting to treat developers as users, the same as they treat Grandpa’s operating system, or Beth in accounting’s office suite: make everything “easy” and “intuitive” and “helpful”. I became a developer because I got tired of my computers getting in my way, so now I make them do what I want. I don’t want or need an intuitive, helpful interface. If you’re going to make a tool for me to use, just make the tool do that thing and that’s it.

I’ve mostly moved on from GitHub, only using it for little pushes because the green dots look good for prospective employers.

I’m curious, do you like cryptic errors from compilers, or do you like it when the compiler author provides some hints about a mistakes?

Or do you just not make mistakes?

do you worry that Microsoft is going to eventually do the Microsoft thing and horribly fuck it up for everyone?

I’m not really sure what you have against Microsoft, or what “Microsoft classic” you’d be referring to…

In the last 10 years or so they pretty much moved everything C# related to Core, cross platform and open source. Even the decision making for the language is “Open source” - Microsoft is not really behaving the same as the Microsoft from 2000…

Soo, I don’t really know how they could possibly fuck it up. They might add more and more features you might not like, but you could just choose to stick to an older version of the language

Issues · dotnet/csharplang

The official repo for the design of the C# programming language - Issues · dotnet/csharplang

GitHub
I’d like to point out that TypeScript is a superset of JavaScript, so if anything goes wrong with it, you can just remove the type information and you’ll have regular JavaScript.

If I take my json and add a .yaml extension it works If I take my c code and add a .cpp it works If I take my js code and add a .ts … it doesn’t work

TS is not a superset of JS

What are the additional requirements? Afaik valid JS is valid TS.
Type annotations. It can be as simple a adding any in front of parameters, but there are other edgecases too, and when you have a really big codebase that needs to be converted it’s a real pain.
var foo = {}; foo.bar = 42;

Perfectly valid, and extremely commonly used, coding pattern in JavaScript. Throws an exception in TypeScript.

Doesn’t change the fact that you can strip types and get js

I know a cool library you can use to convert .ts files in Js! It’s called tsc!

/s

In TypeScript, it fails. You can’t treat an object as an arbitrary key/value pair. That’s a good thing… but still, it means TypeScript is not a superset of JavaScript.

No, it doesn’t fail. It compiles to perfectly valid JS that runs exactly as you’d expect. The type checking itself errors, because you’ve made an error - but the compilation isn’t prevented by this error.

So yes, Typescript is a superset of JavaScript.

That’s an important difference. Still lots of people, myself included, classify “compiler printing an error (not a warning)” as failure, even if bizzarly the code still runs somehow.

That’s because you’re missing the distinction between compiler and type checker. The compiler doesn’t check types, it strips them. The type checker only checks types, it doesn’t compile. They are often used in conjunction, though increasingly the compilation is done by e.g. esbuild.

But there is nothing “bizarre” about the code running, since literally, TS is a superset of JS.

Wouldn’t it fail in strict mode?
The type checking does, but not the compilation.
Your own example fails because “class” is a valid variable name in c but not cpp.
I didn’t say C++ was a superset of C, I said “if I take my c code and add a cpp extension it works”. Believe me, I am painfully aware of the not-a-superset problem because I maintain the C and C++ syntax for VS Code. My point is Typescript doesn’t even meet the very loose “its practically a superset” relationship that C++ has with C.
Better C++ Syntax - Visual Studio Marketplace

Extension for Visual Studio Code - The bleeding edge of the C++ syntax

if I take my c code and add a cpp extension it works

and I pointed out that it doesn’t if your C code has a variable called “class”.

Don’t worry, none of my code uses that, designated initilizers, complex numbers, variable length arrays, typedef name overloading, unintilized constants, implicit void pointer casting, implicit function declarations, nested struct defintions, or any of the other exclusively-C features.
I’d still have to do some refactoring in and around my classes though. There’s some syntax that is TypeScript-only, including things like extended classes.

I’m not concerned about the Microsoft’s involvement. TypeScript shows an immature tooling ecosystem even on its own merits.

I posted some of my concerns earlier, along with a basic problem challenge (that I can easily do in many other languages) that nobody managed to solve: programming.dev/comment/2734178

Which side are you? Javascript or Typescript - programming.dev

This comment just seems weird no matter which angle I try to approach it from.

immature tooling ecosystem

It’s over a decade old now. I wouldn’t call that immature.

Looking at your linked comment…

following a basic tutorial somehow ended up spending multiple seconds just to transpile and run “Hello, World!”.

  • Install deno
  • Create hello.ts containing: console.log(“hello world”);
  • deno run hello.ts (time taken to run command: 0.037s)
  • […] 3 different ways of specifying the files and settings you want to use […] 3 incompatible ways to define and use a “module”

    Yes, that tends to happen as ecosystems evolve over time. Typescript allows developers to use modern standards-compliant modules, while maintaining backwards compatibility for older code.

    embracing duck typing means […]

    One of typescript’s strengths is that its type system isn’t all or nothing. Typescript will support duck typers, but it isn’t forced or limited to that. You can add as much or as little typing as you want. In theory, this means that the language supports simple beginners up to experts creating turing-complete theorem solvers at compile time. In practice, this means a much smoother onboarding and porting experience.

    Have a “generalized fibonacci” module taking 3 inputs […]

    I’m not sure if this is the basic problem challenge or the hello world example was. It seems a bit ambiguous as to what you really want, but it’s easy to create a module that takes inputs and produces outputs while running on backend servers, in browsers, and in CLIs.

    Obviously the actual programs are trivial. The question is, how are the tools supposed to be used?

    So you say to use deno? Out of all the tutorials I found telling me what tools to use, that wasn’t one of them (I really thought this “typescript” package would be the thing I was supposed to use; I just checked again on a hot cache and it was 1.7 seconds real time, 4.5 seconds cpu time, only 2.9 seconds if I pin everything to a single core). And I swear I just saw this week, people saying “seriously, don’t use deno”. It also doesn’t seem to address the browser use case at all though.

    In other languages I know, I know how to write 4 files (the fib library and 3 frontends), and compile and/or execute them separately. I know how to shove all of them into a single blob with multiple entry points selected dynamically. I know how to shove just one frontend with the library into a single executable. I know how to separately compile the library and each frontend, producing 4 separate artifacts, with the library being dynamically replaceable. I even know how to leave them as loose files and execute them directly (barring things like C). I can choose between these things all in a single codebase, since there are no hard-coded project filenames.

    I learned these things because I knew I wanted the ability from previous languages I’d learned, and very quickly found how the new language’s tools supported that.

    I don’t have that for TS (JS itself seems to be fine, since I have yet to actually need all the polyfill spam). And every time I try to find an answer, I get something that contradicts everything I read before.

    That is why I say that TS is a hopelessly immature ecosystem.

    It sounds like to me that you’ve taken your knowledge of your commonly used languages for granted, and assumed a new language would be just as easy. But if you watch a developer who is dipping their toe into that ecosystem for the first time you’ll find them making mistakes and running into footguns you didn’t know were possible.

    Regardless of the language, not having a proper guide leaves devs susceptible to the incorrect blogospam that’s out there, where engagement is rewarded over correctness.

    Ignore all of the blogospam.

    The two things you need to know:

  • C/C++/Java/Go/Python have all gone through changes, growth and churn just like JS.
  • Knowing the history of the ecosystem will go a long way towards helping you. If you understand why things have changed, then you’ll know how to ignore the bad advice out there.
  • Here’s my shortened version of number 2.

    The beginning:

    • JS starts as a scripting language embedded into a browser
    • Different browsers try to copy each other but put in their own “features” pulling the language in different directions.
    • The amorphous blob that is JS starts to congeal and language standards are solidified. This standard is known as ECMAScript (named for legal reasons). ES1 is the first version, followed by ES2 and ES3, each adding useful features.
    • ES3 (released in 1999):
      • This is what you could consider the first long term stable baseline widely supported version of the language, where you can make anything you want.
      • Almost everything you can make in future versions of the language can be backported to ES3.
      • If you want to go by analogy, you can think of ES3 as javascript’s C99.

    The false start:

    • Work starts on ES4 with a massive feature list (including static typing, classes, modules, algebraic data types, generators, embedded xml/xhtml known as JSX/TSX today, etc…). It fails due to political infighting, and for basically being too ambitious in a single version.
      • This sucks up years of progress between released versions.
      • This version is commonly seen as being poisoned by 90’s/00’s Micro$oft and the dark ages of Internet Explorer
      • But the spirit of ES4 was released spread out over future versions anyway.

    The resumption:

    • The v8 JS engine is released, making JS really fast and worth programming in. This is used in Chrome and Node.
    • ES5 (released in 2009):
      • Adds native json support, reflection, and a strict mode to avoid some footguns with ES3
      • Think of this as C11
      • Some developers being experimenting with a more consise syntax in CoffeeScript that compiles down to ES5.
    • 2012: Typescript is released adding an optional and gradual typing system to JS (inspired by C# and ES4) designed for both Humans and Computers.
      • In effect, this brings IDE-style support for JS
    • ES6 (released in 2015):
      • With the lessons learned from CoffeeScript, a whole bunch of syntactical sugar is added to make the language more pleasant to write in.
      • With the lessons learned from community made modules, an official module spec is released and added to the language.
        • Known as ESM (EcmaScript Modules)
        • The community starts moving away from unofficial modules (CJS, AMD, UMD)
      • Babel is created to allow any developer to create and share their their own language extensions.
        • The faster feedback cycle from Babel allows for smaller and more frequent language updates.
        • Javascript moves to a yearly release cycle and ES6 is renamed ES2015
    • ES2016
      • Adds block scoping as an alternative to hoisting
    • ES2017
      • Adds async/await/Promise() syntax sugaring, to make asynchronous programming easier
    • ES2018
      • Adds (rest/spread operator) syntax sugaring, to make destructuring and variadic functions easier
      • Ryan Dhal (creator of Node) releases his famous 10 Things I Regret About Node.js talk. Announces his intention to create a “modern reset” of Node known as Deno.
    • ES2019
      • Minor changes
      • Deno is released
    • ES2020
      • Adds ?? Nullish coalescing operator syntax sugaring
    • ES2021
      • Adds ??=/&&=/||= Logical assignment syntax sugaring
    • ES2022
      • Adds top level await, making asynchronous programming easier
      • Adds private field syntax sugaring
    • ES2023
      • Minor changes

    The current state of things

    • Language-wise

      • Javascript has added a whole bunch of syntactical sugar since 2009 making it really pleasant to code in.
      • Typescript adds some really nice IDE support to Javascript and the vast majority of all libraries and frameworks are written in it giving that IDE support to Javascript developers.
      • Babel allows developers to create their own language extensions, which are frequently put forwards at for other developers to give feedback on. Useful proposals are added to the language on a yearly basis.
    • Runtime-wise

      • Node is considered the older slow-moving most-stable release of running JS outside of the browser
        • Think Debian
      • Deno is considered the friendly Node, coming with all the tools a developer needs (linter, bundler, tester, ts support, etc…). In the last 5 years it has reached almost complete feature parity and compatibility with Node.
        • Think Ubuntu
      • Bun is a brand new kid on the block prioritising speed over compatibility.
        • Think nightly linux
    • Tooling wise

      • Everyone uses ESM modules now, almost no one uses the older modules.
      • Most projects use Vite / rollup / and other “zero-config” tools to build and bundle their applications. Some older projects still use Webpack (which does the same thing, but with a more complicated config file).

    For your simple fibonacci example:

  • Create your fibonacci module that exports your fibonacci function
  • Import module
  • Call function in module
  • Pick your endpoint:
    • Browser endpoint: Output result in console.log() and see result in browser’s console.
    • Server-side endpoint: Output result in Deno.serve() and see result in network requests/responses
    • CLI endpoint: Output result in console.log() and see result in terminal
    10 Things I Regret About Node.js - Ryan Dahl - JSConf EU

    YouTube