Hacker News new | ask | show | jobs
by ajross 30 days ago
This is the ActiveX/nacl/wasm/etc... argument recapitulated. For decades, people dithered about how to get fast code into browser environments such that it could be deployed safely.

Then the V8 team at Google just asked "well, what if we just made Javascript crazy fast instead?", and here we are. There's still room for native code in environments that don't map nicely to scalar scripting languages, but not a lot of room. Basically everyone is best served by ignoring that the problem ever existed.

It took the rendering side a little longer, but we're here nonetheless. There's still room for specialty apps with real need to exploit the hardware in ways not abstracted by the DOM (not 100% of it is games, but it's close to that). But for general "I need a GUI" problems? Yeah, just use Electron.

1 comments

Except JavaScript isn't "crazy fast".

Not by a long shot.

How did Microsoft just make Typescript 10x faster? Oh right, by reimplementing it in Go.

https://devblogs.microsoft.com/typescript/typescript-native-...

See also:

https://blog.metaobject.com/2015/10/jitterdammerung.html

Please don't use Electron.

The problem with Electron is not that people choose it over native tech like WPF or SwiftUI, they choose it over nothing. Without Electron tons of cross platform apps simply wouldn’t exist.

I think macOS suffers the most since it is not that hard to port an iOS app to Mac, and Linux benefits the most.

The author said the mean reason for the speedup was parallelization, not Go being particularly faster. The JS JIT is very good. In most benchmarks I've seen its not much slower than Go.
I am going to miss being able to host TypeScript in a web view however.
You still can. If you port the compiler to something that runs in a web view. WASM sounds easiest.
Meh. Flaming about this is so exhausting given that the war was already fought and we know who the winner is.

First, that's the typescript compiler, not typescript apps. And it was a ground-up rewrite effort (a very large one) with a specific eye toward improving the performance of the original, which was widely held to be sub-optimal for reasons entirely unrelated to implementation language. Suffice it to say that, hell no, you can't just transpile your code to Go and expect it to run faster. We all know it doesn't work like that.

But more broadly, landing with "Please don't use Electron" in the context of a comment about a MS product seems weird given the implementation framework of Microsoft's single most impactful new UI project of the last decade...

Just stop, basically. You lost. Use Electron. It works great and everyone else already does and proved you wrong.

> that's the typescript compiler, not typescript apps.

Of course it's the typescript compiler. What else is an implementation of "Typescript" that you could actually make faster? And how would Microsoft go to all Typescript users and re-implement their code in Go? How would that work?

But that doesn't change the simple fact that the Typescript compiler written in Typescript was too slow:

"As your codebase grows, so does the value of TypeScript itself, but in many cases TypeScript has not been able to scale up to the very largest codebases."

And to fix that performance problem, they had to reimplement Typescript (aka "the Typescript compiler") in Go. And that made it 10x faster.

And I am not sure you got "just transpire your code to Go" from, because I sure as hell didn't write it. And if you know it doesn't work like that, and I sure as hell didn't claim it works like that, why did you introduce this straw man?

This is all plain facts.

So yes: please stop the flaming. And please stop using Electron. Dennard scaling hasn't been with us for some time now.

Again, meh. I'm just happy you've admitted that the idea that Go is 10x faster than V8 is bunk. Use what you like. But like I said everyone else is using Electron and winning. I don't make the rules, I'm just trying to explain them.
> you've admitted that the idea that Go is 10x faster than V8 is bunk.

I admitted nothing of the sort. Where did you get that from?

On a comparable project, Microsoft determined that

(a) the performance of the existing JS solution was practically insufficient

(b) doing a rewrite while keeping JS would not be sufficient

(c) rewriting the TS/JS compiler in Go yielded an empirical speed boost of 10x.

And once again, I never claimed that "Go is 10x faster than V8". Please do refrain from these straw-men arguments, it is not conducive to a good discussion.

In general, however, it is true that JIT compilers perform far less well on real-world production code than they do on small synthetic benchmarks, and so the 10x performance penalty that Microsoft found empirically is well within the range of what is observed elsewhere.

Overview and links to research here:

https://blog.metaobject.com/2015/10/jitterdammerung.html

And remember: this was a response to this comment:

"well, what if we just made Javascript crazy fast instead?", and here we are."

JavaScript is not "crazy fast".

Whether it won or is otherwise just the bees knees is irrelevant. It ain't "crazy fast".

Electron does not, in fact, work great. Apps which use Electron are an absolute drag for the user because they are slow, use a ton of memory, or both. Any developer who cares one iota about the quality of his software will try to avoid Electron.
> Electron does not, in fact, work great.

People get so outrageously bent out of shape over the details here. But it's 100% just geek nattering. People who need to develop and ship general use UI code that isn't a game or an iOS app write to the web stack, every time, for very good reasons. And these solutions win every market they're in.

Basically: show me someone displacing VSCode (or any other large established Electron app) or GTFO. Won't happen. The reverse happens all the time, though. How's Eclipse doing these days?

I abandoned VSCode for zed, because I was tired of the slow performance of VSCode and how much memory it consumes.
The typescript compiler is a typescript app. Or was, I guess
>Meh. Flaming about this is so exhausting given that the war was already fought and we know who the winner is.

I mean yeah its obvious that typescript had insufficient performance for the typescript compiler. They made a big public announcement about the rewrite to golang. It's pretty clear who the winner is.

>First, that's the typescript compiler, not typescript apps. And it was a ground-up rewrite effort (a very large one) with a specific eye toward improving the performance of the original, which was widely held to be sub-optimal for reasons entirely unrelated to implementation language.

The typescript compiler uses v8 as a runtime to run itself and it used to be written in typescript. It was probably one of the biggest typescript apps there is.

Here are some reasons why they chose golang over v8:

* the memory allocation patterns of a compiler were a poor fit for the v8 JIT * the runtime is restricted to a single thread * JITs have to make a tradeoff between startup time and how much time they spend optimizing generated code, AOT compilation can spend more time optimizing while having a faster startup time which is critical for a CLI application, where the JIT cost is paid every time the program is started

You can even look at this blog post and see it for yourself: https://grokkingtechcareer.substack.com/p/the-real-reason-mi...

>Suffice it to say that, hell no, you can't just transpile your code to Go and expect it to run faster. We all know it doesn't work like that.

This is a straw man that nobody is proposing, but even a naive attempt would probably have some benefits, primarily relating to startup time and memory consumption.

>But more broadly, landing with "Please don't use Electron" in the context of a comment about a MS product seems weird given the implementation framework of Microsoft's single most impactful new UI project of the last decade...

>Just stop, basically. You lost. Use Electron. It works great and everyone else already does and proved you wrong.

Use Electron for the typescript compiler? Are you crazy? (note that ajross responded with this comment https://news.ycombinator.com/item?id=48170285)