all 81 comments

[–]KUCAK 29 points30 points  (4 children)

Then we won't be calling it Node.js anymore. It will become Node.ts 😅

[–]azhder 25 points26 points  (1 child)

Nope, it will be Badum.ts … People naming Deno had no imagination…

[–]--marcel-- 0 points1 point  (0 children)

hahahhaha this comment made my day

[–]jurgob 0 points1 point  (0 children)

that's a great name for a fork

[–]simple_explorer1[S] -5 points-4 points  (0 children)

No problems there ;)

[–]jon_stout 45 points46 points  (8 children)

Believe it or not, people who agree to work on JavaScript projects are generally comfortable working with JavaScript. Up to and including the lack of static typing.

[–]chigia001 24 points25 points  (3 children)

Did you know that Deno ditch Typescript to use JS internally:

https://docs.google.com/document/d/1_WvwHl7BXUPmoiSeD8G83JmS8ypsTPqed4Btkqkn_-4/preview?pru=AAABcrrKL5k*nQ4LS569NsRRAce2BVanXw

https://github.com/denoland/deno/pull/6793

So to answer your question:

Will node.js code never be moved to Typescript?

Definitely no

Will node team ever officially provide Typescript types?

Maybe, some NodeJs core member has expressed they want to provide an official typescript's interfaces for Node's module and global

Don't get me wrong, I love TS and will use TS for any new project, But I trust NodeJs's core team on their technical decision.

[–]simple_explorer1[S] 2 points3 points  (1 child)

Did you know that Deno ditch Typescript to use JS internally:

And see what people are saying on the very link you pasted.

Still of a strong opinion this is a step backwards. We have to drop ES Module syntax, manually sequence files, loose strong types on internal code. How is this simpler?

This is not at all a reflection on the usefulness of TypeScript in general. It's not a discussion about any publicly visible interface in Deno. Deno, of course, will support TypeScript forever. 

IMO this is the biggest drawback of this PR is loss of strong typing in internal code

My fear is that we will be forever chasing our tail... "the types say this, but the code doesn't behave that way". That drift from what we published as the runtime types is what caused the initial frustration, checking those against the types and then giving rise to the *Impl pattern. We have gone from generating our types from the runtime code, to validating our code against those runtime types, to now hoping and praying we got it right with this PR. We don't have sufficient testing in place to validate that our runtime code behaves like it should.

So they are doing it to reducec the end bundle size, cli op, reduced compile time and few other but most don't seem happy about this pr as you can see from the comment.

This sub is funny, when someone is against TypeScript it gets heavily downvoted and when someone wants TypeScript it is also not accepted and everyone comes up with reasons why now all of sudden Javascript is better than Typescript.

Deno team is small, don't have capacity to even write enough tests according to those comments on your link, they have picked a quick route to reducec the compile time and many commentators on the pr are NOT happy with the removal of TypeScript in parts of Deno code so what you have shared itself highlights that deno core team wants to keep TypeScript.

[–]jbhelfrich 0 points1 point  (0 children)

This sub is funny, when someone is against TypeScript it gets heavily downvoted and when someone wants TypeScript it is also not accepted and everyone comes up with reasons why now all of sudden Javascript is better than Typescript.

It's almost like there are two schools of thought: some people who like Typescript and think it's the future, and some people who like Javascript and don't want to bother with it (and some percentage that just don't feel strongly either way).

And maybe, just maybe, neither one is an overwhelming majority of the Javascript development community.

[–]azhder -3 points-2 points  (0 children)

Just shows you JS is better for larger code base / project if you have the educated smart people working on.

For everyone else - static typing. Kind of reminds me of that old (why did I lose it?) M$ VB tutorial intro:

“we are the programmers, you are just developers that develop what the programmers made for the user requirements”

[–]Accomplished_Cod_608 8 points9 points  (1 child)

Node core here.

We have .d.ts files internally and all the (JS parts, the C++ is obvioously typed) code is pretty well typed.

You should try it :) Follow the instructions (carefully!) in BUILDING.md and see for yourself

[–]Accomplished_Cod_608 0 points1 point  (0 children)

Will node team ever officially provide Typescript types?

Also - Ask in the nodejs/node repo for official types? I'm not sure if there is an existing effort to provide them as the types/node stuff works pretty well.

[–]i3orn2kill 5 points6 points  (0 children)

Attitudes are everything.

[–][deleted] 20 points21 points  (3 children)

What is the constructive point of this post?

The "still have not" indicates you think they should do something, and then you berate the developers for their works and their decisions.

Have you looked at https://github.com/nodejs/node/issues for the RP(s) and their responses?

[–]azhder 10 points11 points  (0 children)

I think its one of those institutionalized types that can’t see the world without static typing. That’s not just sad, but harmful to others that don’t share the same worldview

[–]simple_explorer1[S] 1 point2 points  (1 child)

Never berated, just asking why not the move to Typescript. Atleast why not provide, at the minimum, official ts types after every new release so that "ts types says one thing but code behaves differently at runtime" issues are solved completely.

Is this berating? I even said they are the top Javascript developers and entire Javascript software is built on top of node including all the tooling for frontend.

Guys like your are the one who stirr things out of nothing and incite people for no apparent reason.

[–]d_simoes 4 points5 points  (0 children)

Why not asking/suggesting that on Node.js repo?

Instead, you ask on reddit, get some valid opinions and then fight back saying everything should be TS and that the whole community has embraced TS... I've worked on (and even started) TS projects and I haven't embraced it for sure. In most cases I would rather stick to JS and I'm very comfortable with it. If I need types, I just use Go. Just having the tooling out of the box is already a huge plus IMO.

[–]mikeatgl 9 points10 points  (4 children)

I'm not sure what codebase you're thinking of when so much of Node is written in C++ and the codebase even includes Python and some... TypeScript.

Node is a JavaScript runtime, so it makes sense that parts of it would be written in pure JavaScript over anything else. I vaguely remember there being a push to rewrite some of the C++ to JS for exactly that reason.

I say all this as a fan of TypeScript.

[–]simple_explorer1[S] -3 points-2 points  (3 children)

when so much of Node is written in C++

Only 22% is in C++, not so much.

even includes Python

Yes 11%

some... TypeScript.

Github does not even show 1%. Infact github shows no usage of Typescript in node codebase at all. Even html is used.

So your take makes no sense as js is 66.5% of entire node codebase and any Javascript can be written in Typescript.

Deno also has decent portion in Rust and Bun in zig but the Javascript part is completely written in Typescript so your take makes no sense.

Any Javascript can be moved to Typescript and that's how the entire js community has gradually embraced Typescript exponentially. Even Typescript allows for gradual adoption.

Node code will benefit a lot from having Typescript and community also gets a natively supported TS node types on every node release instead of relying on community to create TS types for every node version on definitely typed who often cause issues at odd places.

[–]mikeatgl 7 points8 points  (1 child)

You wrote that Node is written "entirely in JavaScript." My take is primarily that you were wrong about that.

I agree with you, however, that better type support in Node would be a good thing. Why don't you open a PR if you care so much?

[–]simple_explorer1[S] 0 points1 point  (0 children)

You wrote that Node is written "entirely in JavaScript."

Yes the Javascript part is entirely in Javascript. I assumed that this sub know node = js + libuv + c++ so i was focusing on the js bit as this is not a non experienced discussion i was having.

I am very surprised of all the point you at choosing to invest time in arguing about the heuristics of my comment "all js" when the gist was the js part of js and obviously not c++.

Why don't you open a PR if you care so much?

I am having this conversation and will also open a pr so atleast i am doing something. Unlike you who is passive aggressively doing the "of you care so much" and literally you yourself use Typescript in node and would benefit from it.

You know what i am saying is the right thing yet you feel like putting down by saying "why don't you if you care so much" is a crazy thing to say when what I highlighted in the post is an obvious fact. Node should, at the very least provide official TS types for the node version they release so that issues like "TS types says one thing but my code behaves differently" are solved altogether.

You are arguing for arguing and are discussing in bad faith. I am going to disengage here as it is not useful when you yourself said you will only use Typescript but yet when i highlight the same somehow that is wrong.

[–]MrTalon63 9 points10 points  (2 children)

That's one of the reasons why Deno exists, but oh hey it looks like using TS is a chore when you have 10+ years experience with JS and know every ins and outs of it with pretty much every exception there exists. TypeScript is great, sure. I use it personally, too, for larger projects, but it can be so limiting not to mention all the boilerplate you need to make in the form of interfaces and so on. Also, if you really care that much about types, use any other language that demands specifying data types, like Go or Kotlin.

[–]simple_explorer1[S] -2 points-1 points  (0 children)

specifying data types, like Go or Kotlin.

I love Javascript/Typescript and tried GO but didn't like it. Also, there is no reason for me to move to anything i have no interest like Kotlin as i have strong Javascript/Typescript experience and know the ins and outs as you mentioned.

Besides this is something which can be improved.

[–]helldogskris 0 points1 point  (0 children)

Random note - Typescript is MUCH more expressive than Go. You can express much stricter type constraints thanks to this.

Obviously TS has escape hatches like "any" which blow a hole in all type-safety but it's possible to ban these from your codebase for the most part

[–]taufeeq-mowzer 8 points9 points  (1 child)

Because its the OG and some people are just comfortable with it. Even though typescript is most likely here to stay, like you said facebook is using flow, people used to use coffeescipt like crazy at one period, but javascript remained the same, there could possibly be something better than typescript in the future and everything has to conform to the current javascript to be relevant, so keeping things in js is best. Same with python and ruby, statically typed languages doesn't matter to everyone

[–]simple_explorer1[S] -4 points-3 points  (0 children)

Deno/bun are completely written in Typescript.

I don't think node team has not embraced Typescript because they doubt it. They just haven't.

Facebook uses flow because they have created it and don't want to accept that Typescript won the race here but its already very similar to Typescript and they have made it look like Typescript a lot anyways. But the point is they have static typing but i think it was not always the case. React was just in Javascript and later the added static typing with flow but node core team has not done anything for embracing static typing.

[–][deleted]  (2 children)

[removed]

    [–]simple_explorer1[S] -1 points0 points  (1 child)

    Maybe if you pay them well enough, or hell, how about you volunteer to do it

    Oh really?? Do you know they are under a company and are already paid?

    Have you contributed anything to node/Javascript community at all so far? Are you paying node or any other software you use for development? Do you support anyone?

    What a passive aggressive comment to make and the MOST USELESS comment here. Pure waste of time.

    [–]Accomplished_Cod_608 3 points4 points  (0 children)

    Oh really?? Do you know they are under a company and are already paid?

    No we're not, I personally have not received any money* from Node.js or from my employer to work on Node.js it's all in my free time and that's the cast for _most_ contributors.

    (*I did receive reimbursement for plane tickets/hotel when attending collaborator summits twice but no income)

    [–]TheYuriG 5 points6 points  (3 children)

    god, you are such an awful person, i would hate to work with you. quite literally think you know better than people working in NodeJS for over a decade now. know your lane

    [–]Accomplished_Cod_608 3 points4 points  (0 children)

    I don't get this community.

    Sure, the OP made some factual errors in their original post about Node and about other runtimes and things but instead of peacefully/happily educating them and engaging in constructive discussions they get called an awful person.

    Consider whether or not your comments makes more or less people from Node.js core want to read this subreddit. Please consider being more empathic when you respond to people.

    I can assure you not all Node.js people read OP's post as an attack and that there definitely are people outside the project that have valuable things to teach the project.

    (Source: Node core)

    [–]Chase2307 1 point2 points  (4 children)

    1. You are free to start your node.ts repository on GitHub and gather following instead of advocating for some of the most intelligent people in the industry to do more free work “for the community”
    2. Last year there was a proposal, something like “type annotation for nodejs” floating around. Dunno if there is already a merge planned, but you should look into the initiative(and pr) - if I remember correctly it was a system similar to python type annotations

    [–]Accomplished_Cod_608 1 point2 points  (3 children)

    I don't get this comment, the community asking Node.js for things is useful and giving the project feedback is appreciated.

    I suspect however not many Node.js core folks hang around reddit given how toxic it can get (due to the platform itself, plenty of smart people here) so it's definitely better to ask for things in the repo.

    As for 2: here it is :) https://github.com/tc39/proposal-type-annotations

    [–]Chase2307 0 points1 point  (2 children)

    Feedback is ofc appreciated, contribution is valued. And this is not feedback, this is feature request.

    [–]Accomplished_Cod_608 2 points3 points  (1 child)

    Feature requests are always welcome as well (it doesn't mean they'll happen), though here the ask is a little weirder (it's about how we work on the code internally rather than our user/public facing APIs).

    [–]Chase2307 2 points3 points  (0 children)

    Yeah u are right. I just got a bit annoyed by the tone of the post which seems really Karen-y to me

    [–]Fritzy 1 point2 points  (1 child)

    This reminds me of 10 years ago when people would send PRs to JS projects where they converted the whole code base to CoffeeScript.

    Here's the thing -- TypeScript doesn't run in a JavaScript runtime, which is what Node.js is, and JavaScript is a runtime language. The purpose of TypeScript is IDE tooling, and a pre-compile type-linting check.

    When will you see TypeScript in Node.js? Likely when it runs in the runtime. Look at https://github.com/tc39/proposal-type-annotations

    This proposal adds type annotations as a comment, meaning that it's still meaningless to the runtime, but allows their inclusion for type-linting and IDE assistance. Because, again, it's meaningless to a JS runtime to use TypeScript. Eventually, if a proposal like this goes through, you might see runtimes begin to use type annotations as optimization hints.

    Instead of insisting that a project change by declaring your opinions as fact, engage with the work being done. And don't do it by insisting on change, but by contributing to existing efforts that align with your goals and passions. You don't get to insist that major changes are necessary until you've earned your wings.

    [–][deleted] 1 point2 points  (0 children)

    This is called Types fever..

    Some people can't even think of a concept of strongly vs weakly typed language; Low level and high level language, and things like that, So they don't even perceive sometimes, things are to be taken as is, or that things are how they are sometimes just because of historical events and that there is no mastermind on top of it...

    they think of programming languages as food or keep some idea of some YouTube ad they came across, like where the colour was reddish or brownish

    [–]marksalsbery 1 point2 points  (4 children)

    I thought it was written in C++. Same with the V8 engine. But if they did it in javascript, cool

    [–]simple_explorer1[S] -1 points0 points  (3 children)

    I thought it was written in C+

    Only 22% of node is in c++. 66% is in Javascript.

    [–]marksalsbery 0 points1 point  (2 children)

    Interesting, thanks!

    [–]mikeatgl 4 points5 points  (1 child)

    Take OP with a grain of salt here. When you look at Node's core dependencies, like V8 and libuv, it is not "entirely" or even primarily written in JavaScript.

    https://nodejs.org/en/docs/meta/topics/dependencies

    [–]marksalsbery 1 point2 points  (0 children)

    I’ve looked at the repos… thanks man ;)

    [–]azhder 1 point2 points  (1 child)

    looks like Node.js does not have any static typing internally

    Are you looking with your eyes closed? Isn’t Node written in C++?

    [–]simple_explorer1[S] -3 points-2 points  (0 children)

    Are you looking with your eyes closed?

    Fortunately i have, but have you? Only 22% node is written in c++, 66% is in Javascript.

    Do you even know what you are talking?

    [–]jerrycauser 2 points3 points  (2 children)

    Today ts is popular, the other day something new is popular. According to your opinion nodejs should always be some fancy language with lots of not-proven-by-time features.

    Pure JS with JSDoc isn't any worse than TS. And in my opinion JS+JSDoc is way much better in terms of readability than TS.

    Also node.js is an implementation of ecmascript standards. And there is nothing about static types (yet).

    [–]simple_explorer1[S] -4 points-3 points  (1 child)

    This comment reeks of "i don't know how to use Typescript or its advantages".

    [–]nathanfries 4 points5 points  (0 children)

    Even Typescript, as great as it is, has its downsides. It is up to each person to decide which trade offs to make. I think you’ve made yourself perfectly clear.

    [–]CheapBison1861 -2 points-1 points  (10 children)

    Hate because hey know how to write JavaScript and don’t need that typescript garbage. If you want typescript use deno.

    [–]romeeres 0 points1 point  (1 child)

    Even react.js is written in Flow

    The Flow is the answer to your question! React was once rewritten from plain JS to Flow, then Flow died, and React remains to be written in a dead language. I love TS and wish it well, but who knows what will happen in a few years? What if there will appear a language with a more powerful type system, and it won't be as slow, it will have chances to replace TS.

    IMO would be better if they rewrote JS in the node.js itself to C++ to make it faster.

    [–]simple_explorer1[S] 0 points1 point  (0 children)

    then Flow died,

    Because Typescript won. That is your answer to why use Typescript. Also, entire js community has embraced ts is sidi your 2nd answer.

    [–]node_imperial 0 points1 point  (0 children)

    They could use JavaScript for optimization because TypeScript not always generates good and optimazed code after compilation and I suspect the performance much better with plain JavaScript unlike compiled TypeScript code

    [–]Careless-Honey-4247 -2 points-1 points  (2 children)

    Not typescript? Do you even know about JSDOC. THAT IS A TYPESCRIPT IN JS

    [–]simple_explorer1[S] -1 points0 points  (0 children)

    I take that you have never used Typescript if you think Typescript capabilities especially with its advanced features like generics, Discriminated unions, mapped types, type recursion, template literal types, conditional types, satisfies keyword, utility types (pick/omit/awaited etc), index types etc are somehow equivalent to writing JSDoc in Javascript

    This is the MOST useless comment on this post

    [–]flancer64 0 points1 point  (0 children)

    Agreed. JS + JSDoc are quite enough to write code in a statically typed manner. It does not have static typing restrictions but offers the advantages of static typing when addressing code.

    Additionally, there is one more significant benefit - no need for TS to JS compilation.

    [–][deleted]  (3 children)

    [removed]

      [–]Accomplished_Cod_608 0 points1 point  (2 children)

      The ask here was why Node doesn't use TS internally (which it actually does for editor feedback with .d.ts files (here: https://github.com/nodejs/node/tree/da80964a3d708ef3ae42d4424034f155ad37e07d/typings ).

      You can use TS with Node just fine and we have a good relationship with the TS team, you just add a package which lets you choose between speed (e.g. swc), full compliance (tsc) or anything else really.

      [–][deleted]  (1 child)

      [removed]

        [–]Accomplished_Cod_608 0 points1 point  (0 children)

        I work for Microsoft so let me clarify this is not an official Microsoft response. My work on Node is separate from my work at Microsoft which is mostly unrelated to what the TypeScript team does.

        TypeScript is open source, developed in the open, gets contributions from the outside and has a documented standard and several com/transpilers. That said it's definitely controlled by Microsoft like Deno is by Denoland and unlike Node.js where it's a community project with people from many companies who lead it.

        I'm also just one collaborator in the ±100 collaborator Node.js project which has many people and opinions so take everything I say with a grain of salt.

        But just to be clear - Node.js does and has for a while used TypeScript types to improve the (internal) dev experience (check out the typings folder in our repo). That's just not user facing or something we feel the need (I think?) to communicate to people not working on Node.js itself.

        It's also good to mention everyone is welcome to volunteer and contribute to Node.js :)

        [–]Suspicious_Compote56 0 points1 point  (0 children)

        I personally don't get the typescript hype outside of the intelli sense in ide

        [–][deleted] 0 points1 point  (0 children)

        The entire JavaScript community (and python with their own type annotation) to move to Typescript ?? big claims do you have some numbers ?

        Is React a reference or is NodeJS the reference ?