News for hackers. Stuff that matters.
Re:TypeScript is now officially 10 years old by moomin on Sunday October 09, 2022 @05:35AM (#33139403)
The post mentions one of the most important factors in TypeScript’s adoption: it launched, from the start, with good tooling.
Re:TypeScript is now officially 10 years old by throwaway0x7E6 on Sunday October 09, 2022 @05:42AM (#33139447)
that's maybe the second or the third most important factor. the first is aggressive marketing that microsoft does for its products.
Re:TypeScript is now officially 10 years old by scarface74 on Sunday October 09, 2022 @05:47AM (#33139468)
That unfortunately hasn’t helped C# become more popular outside of Microsoft legacy shops even when it did go cross platform and open source.
Re:TypeScript is now officially 10 years old by keewee7 on Sunday October 09, 2022 @06:21AM (#33139648)
C# and ASP.NET Core feels like the default stack in Western Europe, even among startups. You have to look harder to find companies using Node.js, Rails, Django etc.
Re:TypeScript is now officially 10 years old by scarface74 on Sunday October 09, 2022 @08:52AM (#33140521)
See my previous post about the bimodal nature of tech salaries in the US.

https://news.ycombinator.com/item?id=33140210

The “startups” in the US are even bimodal. You have the ones that set up shop outside of the west coast in big cities that hire “enterprise devs” and you have the well funded ones that try to compete with big tech salary compensation.

Re:TypeScript is now officially 10 years old by ido on Sunday October 09, 2022 @06:19AM (#33139630)
C# is extremely popular, maybe just not in your particular field.
Re:TypeScript is now officially 10 years old by scarface74 on Sunday October 09, 2022 @07:20AM (#33139977)
“My field” is a 20+ year MS ecosystem developer from C++/MFC, VB6, .Net Compact framework, .Net Framework, .Net Core, etc.

As I said, very few new companies that aren’t “legacy” shops are choosing .Net.

In my current job in cloud consulting at $BigTech, almost all of the .Net projects that come through are older companies compared to newer companies that are using non compiled languages.

These days I write in almost any language they prefer among the popular languages.

Re:TypeScript is now officially 10 years old by ido on Monday October 10, 2022 @01:54AM (#33148229)

    “My field” is a 20+ year MS ecosystem developer from 
    C++/MFC, VB6, .Net Compact framework, .Net Framework, 
    .Net Core, etc.
Right, and in that field you might be correct (I don't know but I'll take your word for it). It is however not the entire software industry.

    As I said, very few new companies that aren’t “legacy” shops are 
    choosing .Net.
I'm a game developer and the most popular game engine (Unity) uses c#. The newest up and comer (Godot) uses their own scripting language or c# as the most popular options. I've also worked in Enterprise before and c# and java were the popular choices there and as far as I know from friends still are (especially when servicing the government)
Re:TypeScript is now officially 10 years old by scarface74 on Monday October 10, 2022 @05:08AM (#33149324)
You realize you are echoing exactly what I’m saying? Governments are the definition of “legacy” Windows shops. The whole thing I’ve been saying is that new initiatives outside of historical Windows shop are not adopting .Net even though it’s been cross platform and open source since 2016. The new startups and newer companies that avoiding Windows like the plague are also avoiding .Net.

In the US, the companies that pay top dollar - the large tech companies and well funded VC back companies are not adopting tech companies.

Re:TypeScript is now officially 10 years old by ido on Monday October 10, 2022 @06:09AM (#33149636)
If that's what you meant ("c# is unpopular among the best paying tech companies") I can accept that. But what you originally wrote that I disagree with is:

    That unfortunately hasn’t helped C# become more popular outside of 
    Microsoft legacy shops even when it did go cross platform and open source.
Where I work is very much not a microsoft legacy shop (a game dev startup) & we use c#. This is hardly unusual.
Re:TypeScript is now officially 10 years old by scarface74 on Monday October 10, 2022 @06:41PM (#33157248)
And where you work is probably on the “enterprise” side of the bimodal enterprise dev/tech company compensation bimodal distribution.

https://news.ycombinator.com/item?id=33140210

When talking about compensation, it might as well be an “enterprise shop”

Just in case you don’t read the link above, that’s not meant to be derisive. It’s just a pure statement of fact.

There are plenty of “startups” that locate in major cities in the US outside of tech hubs, find a bunch of MS developers to write the next CRUD SaaS app and pay enterprise dev wages. I should know, I spent over two decades working for them

Re:TypeScript is now officially 10 years old by ido on Tuesday October 11, 2022 @06:43AM (#33161682)
I understand what you meant, i just disagree with your phrasing of it. You can simply call it the "best compensated/all the rest" divide. But other than that game development is not at all like Enterprise so I don't find yours a good name for this supposed dichotomy.

I think you would get a lot less pushback by simply using more precise terminology- even though for you it may all be the same, for people working outside of FAANG-esque companies it isn't.

Re:TypeScript is now officially 10 years old by christogreeff on Sunday October 09, 2022 @05:57AM (#33139515)
What is a "Microsoft legacy shop" ?
Re:TypeScript is now officially 10 years old by xboxnolifes on Sunday October 09, 2022 @06:07AM (#33139559)
Businesses that profit money without VC funding.
Re:TypeScript is now officially 10 years old by scarface74 on Sunday October 09, 2022 @06:09AM (#33139573)
Banks, insurance companies, government agencies, “enterprise development”.
Re:TypeScript is now officially 10 years old by LudwigNagasena on Sunday October 09, 2022 @07:12AM (#33139942)
So, 90% of the world GDP?
Re:TypeScript is now officially 10 years old by scarface74 on Sunday October 09, 2022 @07:59AM (#33140210)
Yes

In the US though, compensation for software developers is very bi-modal. You have the “enterprise shops” that start off around $80K and max out in the mid $100s and the “tech companies” that start out in the mid $100s and end up in the $350K+ range.

Most of the 2.7 million developers in the US are on the “enterprise dev” side. If you have a choice, you want to be on the “tech company” side if you care about your compensation.

For context: because of path dependencies and bad career choices, I spent most of my career from 1996 - 2020 on the “enterprise dev” side and only got into $BigTech by pivoting to cloud consulting (enterprise dev + cloud + a shit ton of yaml/HCL PowerPoint slides and diagrams)

Before anyone “well actually”’s me with numbers they are directionally correct on the enterprise dev side in most major cities.

Re:TypeScript is now officially 10 years old by tester756 on Sunday October 09, 2022 @02:55PM (#33144151)
How can I know if I work in $big_tech from eu?
Re:TypeScript is now officially 10 years old by iLoveOncall on Sunday October 09, 2022 @06:17AM (#33139618)
Well the fact that it was available solely on Windows for so long was its doom.

Actually I thought of using C# a few months ago, and I was like "Oh wait, does it even work on other platforms than Windows now?". Sure I'm not a C# developer, so I'm not up to date on C# news, but that's an issue if your goal is to drive adoption. Everyone that has heard of C# should know that it's now cross-platform.

Re:TypeScript is now officially 10 years old by cesarb on Sunday October 09, 2022 @08:54AM (#33140534)
Some things still seem to be Windows specific. If I want offline documentation (of the sort one can find at /usr/share/javadoc/java or /usr/share/doc/rust/html by installing the correct packages), every place I look tell me how to enable offline help in Visual Studio (for instance, https://learn.microsoft.com/en-us/teamblog/offline-book-refr...). Someone here told me last time that there's a way to download whole sections of the MSDN documentation as PDF, which helps, but it's not the same thing.
Re:TypeScript is now officially 10 years old by Kwpolska on Sunday October 09, 2022 @06:45PM (#33146048)
Off-line documentation being kind of a pain sounds like a very minor thing.

Other than that, and other than the obviously Windows-specific GUI and system management libraries, the rest of C#/.NET is pretty much fully multi-platform, maybe except a few obscure things.

Re:TypeScript is now officially 10 years old by trinovantes on Sunday October 09, 2022 @07:56AM (#33140192)
It's used in Unity game development

I think Godot also supports it

Re:TypeScript is now officially 10 years old by junon on Sunday October 09, 2022 @05:51AM (#33139490)
Which, frankly, has become an unwieldy mess over the years.
Re:TypeScript is now officially 10 years old by solids on Sunday October 09, 2022 @05:52AM (#33139492)
Incremental adoption and syntax close to JS
Re:TypeScript is now officially 10 years old by kuramitropolis on Sunday October 09, 2022 @08:51AM (#33140518)
>Incremental adoption

i.e. "it stays out of your way if you don't actually try to use it"

Re:TypeScript is now officially 10 years old by jbverschoor on Sunday October 09, 2022 @06:04AM (#33139547)
Microsoft always had great tooling
Re:TypeScript is now officially 10 years old by pjmlp on Sunday October 09, 2022 @06:12AM (#33139594)
Mostly, not when the domain is COM, and WinDev uses it all over the place.
Re:TypeScript is now officially 10 years old by kuramitropolis on Sunday October 09, 2022 @08:54AM (#33140530)
> great tooling

"go to definition" -> goes to type definition

Microsoft makes it intentionally impossible to get anything done in their ecosystem without having "great tooling".

Re:TypeScript is now officially 10 years old by tester756 on Sunday October 09, 2022 @02:49PM (#33144087)
Lol? what's the reasoning behind this?

Java does it too?

Re:TypeScript is now officially 10 years old by matt89 on Sunday October 09, 2022 @06:04AM (#33139552)
In my opinion the most important factor was that it is a superset of JS and any valid Javascript code is/was valid TS code. That allowed for gradual adoption and you didn't have to risk going all-in into new technology.
Re:TypeScript is now officially 10 years old by ly3xqhl8g9 on Sunday October 09, 2022 @07:24AM (#33139993)
Also the `any` type [1]. It makes porting an existing project ridiculously easy: just type everything as `any`, and it also gives freedom to the developer to think in code when developing, trusting that they (will) know what they are doing, instead of screaming at the smallest mis-type with annoying bright red squiggly lines.

It is so liberating to type a variable as `any` when sketching new code, figuring things out, that I would venture to say that any language not having the `any` type actually actively hates the developer.

[1] https://www.typescriptlang.org/docs/handbook/2/everyday-type...

Re:TypeScript is now officially 10 years old by kuramitropolis on Sunday October 09, 2022 @08:14AM (#33140311)
And then you have to contribute to a codebase with restrictive ESLint (bleurgh!) configuration, so you can't even try out whether your code works because the tooling disallows you from compiling it as long as it contains "any", and the other devs are like "but muh best practices". So not only you gotta work around TS, you gotta do it invisibly. How did people even live before VSCode's type hint popups covered up the previous line?
Re:TypeScript is now officially 10 years old by xodeus on Sunday October 09, 2022 @08:39AM (#33140451)
This comment has just triggered my PTSD from every Typescript project I've had to work on.
Re:TypeScript is now officially 10 years old by wiseowise on Sunday October 09, 2022 @08:25AM (#33140364)
> How did people even live before VSCode's type hint popups covered up the previous line?

Same. Like normal people do when they use Visual Studio/IntelliJ/QTCreator

Re:TypeScript is now officially 10 years old by kuramitropolis on Sunday October 09, 2022 @08:43AM (#33140475)
I.e. cringing all the time?
Re:TypeScript is now officially 10 years old by wiseowise on Sunday October 09, 2022 @09:34AM (#33140821)
Cringing at compile time safety or what?
Re:TypeScript is now officially 10 years old by kuramitropolis on Sunday October 09, 2022 @10:32AM (#33141501)
No, cringing at some "helpful" popup appearing right over the previous line of code. If anything, they could've made it appear under the current line; code's still written top to bottom so it's less likely for "suggested relevant info" to obscure the actual relevant info.
Re:TypeScript is now officially 10 years old by Tyriar on Sunday October 09, 2022 @11:26AM (#33142111)
You can press f8 to view the problem in a "peek view" under the problem line, or view on the problems panel.
Re:TypeScript is now officially 10 years old by kuramitropolis on Sunday October 09, 2022 @05:22PM (#33145465)
> 10542667 Aug 9 20:40 node_modules/typescript/lib/typescript.js

aint fitting ten megs in a peek view... :(

Re:TypeScript is now officially 10 years old by kuramitropolis on Sunday October 09, 2022 @08:13AM (#33140303)
TS is emphatically not a superset of JS. It rejects perfectly valid JS leaving you no recourse other than design your whole architecture around what TypeScript allows. Which is what Microsoft wants of course.
Re:TypeScript is now officially 10 years old by uup on Sunday October 09, 2022 @08:34AM (#33140419)
That’s not true. You can import JS directly into TS or use ts-ignore annotations.
Re:TypeScript is now officially 10 years old by kuramitropolis on Sunday October 09, 2022 @08:50AM (#33140514)
Hahahahaha no.

>You can import JS directly into TS

Using FFI, you can also import all compiled languages into each other, provided you provide the type annotations on the importing side. Does that make them supersets of each other?

>use ts-ignore annotations

Which do not get propagated into the compiled .d.ts. So if you're trying to publish a library with TypeScript, you know, like this thing called "open source", and naively expect it to work like a normal NPM package does, you're in for a bad time. You'll probably end up using a frontend bundler to smash the whole thing into a CJS monolith like an absolute genius, in the process preventing "muh tree shaking" downstream.

Re:TypeScript is now officially 10 years old by uup on Sunday October 09, 2022 @12:15PM (#33142592)
You can directly import any valid JS module using TypeScript if you have “allowJS”: true in the compiler option of your tsconfig.json file. The comparison to FFI doesn’t make any sense. FFI requires compiling a special library that explicitly exports the C types. This is different than TS. Using TS, you can import any valid JS module without any special preparation. Also, you can’t import all compiled languages into each other using FFI. You can also import and export C-based types. There is no way to export a Go struct for consumption via FFI, for instance. All valid JS modules will work with TypeScript.
Re:TypeScript is now officially 10 years old by kuramitropolis on Sunday October 09, 2022 @05:28PM (#33145502)
>There is no way to export a Go struct for consumption via FFI, for instance.

I hope not.

>Using TS, you can import any valid JS module without any special preparation

Why does the DTS ecosystem exist then (https://www.npmjs.com/package/@types/node etc)

Re:TypeScript is now officially 10 years old by uup on Sunday October 09, 2022 @06:29PM (#33145931)
That’s to add types to imported JS. You’re free to import raw JS as an any type and the compiler won’t complain.
Re:TypeScript is now officially 10 years old by kuramitropolis on Sunday October 09, 2022 @07:25PM (#33146275)
Okay...

    $ echo "export class Foo { a = 1 }" > test.mjs

    $ npx ts-node
    > import('./test.mjs').then(console.log)
      error TS7016: Could not find a declaration file for module './test.mjs'. '/home/user/Lab/test.mjs' implicitly has an 'any' type.

    $ npx ts-node -O '{"allowJs":true}'
    > import('./test.mjs').then(console.log)
      Promise { <pending > }
      Error [ERR_REQUIRE_ESM]: require() of ES Module /home/user/Lab/test.mjs not supported.

    $ echo "module.exports.Foo = class Foo { a = 1 }" > test.cjs

    $ npx ts-node -O '{"allowJs":true}'
    > const { Foo } = require('./test.cjs')
    > Foo
      [class Foo]
    > new Foo
      Foo { a = 1 }
    > function bar (foo: Foo) {}
      TS2749: 'Foo' refers to a value, but is being used as a type here. Did you mean 'typeof Foo'?
No I did not, TypeScript, and that's about as much as it seems to interoperate. I guess in some cases practical migration might be viable - but as for the general case, the out-of-the-box experience seems to speak otherwise.

It's not even viable to write in JS and manually write a DTS - no way to check em against each other. Except idk library in JS, test suite in TS anyway. So not a lot of lateral movement possible in practice.

Re:TypeScript is now officially 10 years old by uup on Sunday October 09, 2022 @07:44PM (#33146378)
ts-node isn't an official part of the TypeScript project. It has notoriously bad module support.

Try this:

    // tsconfig.json
    {
      "compilerOptions": {
        "outDir": "dist",
        "module": "es2020",
        "allowJs": true
      },
      "files": ["index.ts"]
    }

    // index.ts
    import('./test.mjs').then(console.log)

    > npx tsc && node ./dist/index.js
    [Module: null prototype] { Foo: [Function: Foo] }
Re:TypeScript is now officially 10 years old by kuramitropolis on Sunday October 09, 2022 @09:05PM (#33146802)
I'm not even talking about the module support. (It just seems to have the default support of TypeScript.)

Yes, it imports the module. No, it doesn't do even basic type inference (knowing that Foo is a class and consequently allowing it to be used as a type name) - which it would, if it was a superset of JS. Instead it seems to import everything as "any", which is... a start, I guess?

Re:TypeScript is now officially 10 years old by fabian2k on Sunday October 09, 2022 @06:30AM (#33139703)
I tried using Flow at some point when TypeScript was much newer and wasn't the obvious choice for typed Javascript yet. I couldn't get it to work properly. I probably could have with more effort, but I didn't feel like I would be able to keep it running well and debug issues if they would arise.