Live data from Hacker News

Just Say No to JavaScript

infoworld.com

1–10 of 86 posts

Re: Just Say No to JavaScript

#2
I never understood people discussing JS and TS as different entities. TS is JS, but with types. But to be fair I can't imagine now using untyped JS without an LSP of some sort.

Re: Just Say No to JavaScript

#3
This is a plea to use TypeScript instead of JS. Why not. Strong typing is certainly great. But the reason I don't use TypeScript isn't any of those listed: it's because it needs a compilation step, and I don't want that.

Re: Just Say No to JavaScript

#4
The author seems to ignore the fact that type hints are a thing even with plain JS. Serious question: does the author "just say no to Python" as well?

If lack of explicit typing is the issue, then his rant would apply to most scripting languages and to single out JS seems odd to me...

Re: Just Say No to JavaScript

#5
post #3

This is a plea to use TypeScript instead of JS. Why not. Strong typing is certainly great. But the reason I don't use TypeScript isn't any of those listed: it's because it needs a compilation step, and I don't want that.

> it's because it needs a compilation step, and I don't want that

Why? The seconds it takes to compile even a large project are paid back a million fold everytime it catches a mistake you'd have missed or your IDE out you used the wrong type.

It's probably not listed in the article because it's a nonsensical argument.

Re: Just Say No to JavaScript

#6
The author never actually says what is so wrong with JavaScript. I think it is quite a good dynamically typed language, and it certainly has some very high-performance implementations. If you don't like it, just use something else?

> Ultimately, JavaScript was the right thing at the right time. It ended up being folded, spindled, and mutilated to serve purposes that it isn’t well suited for

Counterpoint: many quirks in the language were addressed, e.g. introduction of === and with ESLint you get many of the practical advantages of a type checker. And when you need more safety, sprinkle TypeScript on top.

What I really want for Christmas is a TypeScript-to-native compiler.

Re: Just Say No to JavaScript

#7
post #4

The author seems to ignore the fact that type hints are a thing even with plain JS. Serious question: does the author "just say no to Python" as well? If lack of explicit typing is the issue, then his rant would apply to most scripting languages and to single out JS seems odd to me...

> type hints are a thing even with plain JS

Can you clarify how you do this? the type annotation TC39 is not approved; but I'm interested in hearing if you have a "userland" approach that works for you?

Re: Just Say No to JavaScript

#8
I'll happily use TypeScript for all my UI components, libraries and server code, most of the time with Bun thanks to its OOB support for TypeScript.

But for Web UIs I'll drop down to a #NoBuild "Simple, Modern JavaScript" [1] i.e. using JS Modules + JSDoc Type Annotations to avoid needing any npm modules/build steps/etc. I still benefit from a library's TypeScript definitions/VS Code intelli-sense/static analysis/etc but completely avoid any build/bundling complexity for the cost of a slightly more verbose syntax in JSDoc type hints.

I'd happily move to using ECMA Type Annotations proposal [2] if it ever got accepted, but alas TC39 moves slowly...

[1] https://servicestack.net/posts/javascript

[2] https://github.com/tc39/proposal-type-annotations

Re: Just Say No to JavaScript

#9
I don't see JavaScript as the webbrowsers assembly, and whilst it can be, don't agree that the web browser is the new operating system. These are the two predicates used to justify the author's argument to use typescript.

I don't have a problem using typescript, but prefer dart if you need a strongly typed (null safe) language.

Re: Just Say No to JavaScript

#10
post #3

This is a plea to use TypeScript instead of JS. Why not. Strong typing is certainly great. But the reason I don't use TypeScript isn't any of those listed: it's because it needs a compilation step, and I don't want that.

With runtimes like Bun and Deno (and lately Node itself), you can run Typescript directly with pretty much zero config. There is transpilation behind the scenes, but the time that takes is minimal.

I personally switched to Bun, and could not be happier. My build toolchain is quite simple now. I run the Typescript compiler to just type check my code, and use Bun to actually run it. For bundling, I use esbuild.

Post reply on HN