News for hackers. Stuff that matters.
Re:Making bracket pair colorization faster by goldenkey on Wednesday September 29, 2021 @09:45AM (#28693559)
JS has Workers. VS Code uses them wisely. Other Electron apps? Not so much.

Block the event loop in other languages and you'll also see shitty results..

Re:Making bracket pair colorization faster by xg15 on Wednesday September 29, 2021 @01:51PM (#28697326)
Have fun implementing all the overhead just communicating with those workers. That's a serialisation pass, a serialisation pass and two event queues, all just so your application doesn't lock up.
Re:Making bracket pair colorization faster by goldenkey on Wednesday September 29, 2021 @03:26PM (#28698641)
https://developers.google.com/web/updates/2011/09/Workers-Ar...

For 10 years an ArrayBuffer has been able to be sent by reference but good effort on disinformation.

Re:Making bracket pair colorization faster by int_19h on Wednesday September 29, 2021 @11:09PM (#28702769)
You still need to serialize/deserialize to put your object graph into the array, no?
Re:Making bracket pair colorization faster by goldenkey on Thursday September 30, 2021 @12:18AM (#28703133)
Not if you use WebAssembly. You can simply pass an Array Buffer to be worked on, you postMessage it with transferable=true.

  transfer Optional
  An optional array of Transferable objects to transfer ownership of. If the ownership of an object is transferred, it becomes unusable in the context it was sent from and becomes available only to the worker it was sent to.

You can compile JS itself or pretty much any other language to WASM using Emscripten or the other LLVM toolkits. Looking at VSCode, it appears they use this technique for some of the heavy lifting.

JS is very performant if you know how to use this hybrid architecture. The C++ guys above are shitting all over JS when an Electron app can simply use C++ transpiled to WASM if they really wanted to. Electron isn't really for JS as a coding language. It is much more for the awesome cross-platform UI you get with HTML, CSS, and JS. A lot has been done to optimize rendering engines. The same techniques that render snappy web pages can be used within Electron. All the griping above is really just ignorance.

https://github.com/microsoft/vscode/search?q=wasm

https://github.com/microsoft/vscode/search?q=arraybuffer

https://developer.mozilla.org/en-US/docs/WebAssembly/Using_t...

https://developer.mozilla.org/en-US/docs/Web/API/Worker/post...

Re:Making bracket pair colorization faster by Jensson on Thursday September 30, 2021 @04:04AM (#28704138)
WASM isn't Javascript. WASM is a way to represent native code in Javascript that some Javascript runtimes then can use to run it as native code. If the Javascript runtime hasn't implemented a hack to run WASM as native code then WASM is ridiculously slow. If the VSCode team writes their code in C++, compiles it to WASM and then runs WASM and it is fast, then it was C++ that was fast and not Javascript.

If that is really how they got their performance then no wonder that few others actually managed to do it, because most teams wouldn't write their Electron app in C++ and then compile it to WASM. The difference is that Microsoft has a ton of C++ engineers so they could do it easily, but I doubt many Electron teams put out job postings to hire C++ people.

Re:Making bracket pair colorization faster by goldenkey on Thursday September 30, 2021 @10:06AM (#28706468)
That's like saying if you use the _asm directive in any language, your entire project is now assembly. Subtlety is not your strong suite. One can use WASM for manual memory critical paths while using raw JS for other parts. And you did not hear me. You can write WASM in JS. Transpiling. Amazing, huh?
Re:Making bracket pair colorization faster by int_19h on Thursday September 30, 2021 @03:07PM (#28710021)
And how fast is JS compiled to wasm? Are you claiming that it's also as fast as C++ compiled to wasm?
Re:Making bracket pair colorization faster by goldenkey on Friday October 01, 2021 @04:02AM (#28715841)
Yes, Typescript to WASM is just as fast as C++ to WASM.
Re:Making bracket pair colorization faster by npigrounet on Thursday September 30, 2021 @02:24AM (#28703727)
Why use C++ when JS is faster? VSCode proves that. It's orders of magnitude faster than old VS, has more features, uses less resources, etc.
Re:Making bracket pair colorization faster by int_19h on Thursday September 30, 2021 @03:05PM (#28710002)
VSCode does not prove that at all. The main reason why it feels faster is because it's written from scratch to be async. VS is a legacy codebase going all the way to 1997 (if not earlier, in places), with lots of code still running on UI thread, and all extensions running in-process.
Re:Making bracket pair colorization faster by hoseja on Thursday September 30, 2021 @03:57AM (#28704102)
Let's wait thirty years for the legacy to accrue and then compare weenies, shall we?
[dead]
Re:Making bracket pair colorization faster by hoseja on Thursday September 30, 2021 @09:28AM (#28706042)
Ah, I see. I appreciate the effort but maybe try being subtler, I was almost mad until you overdid it.