5 ms·
The source code of my latest web app is over 1 MB of minified and obfuscated JavaScript. Technically you have the source but it's only marginally more useful to
by kjksf 11y ago
The source code of my latest web app is over 1 MB of minified and obfuscated JavaScript. Technically you have the source but it's only marginally more useful to you than looking at assembly generated by a C program.
And the benefits of having source are overstated.
I didn't learn web programming by looking at other people's html and javascript. There was a little bit of that but most of the learning is from tutorials and books and experimenting.
And in the old days of C programs delivered as executables, were people unable to learn how to program in C?
Finally, WebAssembly is not a replacement for JavaScript but fills a gap that JavaScript can't (really fast code).
WebAssembly is basically a compiler target for C-like languages, which means that it's dramatically more expensive to "write" WebAssembly code than it is to use JavaScript, so people will only reach for it in cases where there's compelling reason. It'll never be a default choice for writing web apps.
- Udik 11y ago> people will only reach for it in cases where there is a compelling reason. Why? Won't any javascript (or any other source code) be compiled to webassembly before going to production?
- azakai 11y agoWebAssembly is a low-level statically typed language. JavaScript is a high-level dynamically typed language. Compiling JavaScript to WebAssembly can't be done as a simple compilation step, at least not with fast results - you really need a JIT or multiple JITs. In other words, you'd need to compile a full JS engine to WebAssembly together with your code.
- vmorgulis 11y agoI had a lot of fun to see that the other day :-) > "Binaryen" is pronounced in the same manner as "Targaryen": bi-NAIR-ee-in. Or something like that? Anyhow, however Targaryen is correctly pronounced, they should rhyme. Aside from pronunciation, the Targaryen house words, "Fire and Blood", have also inspired Binaryen's: "Code and Bugs." https://github.com/WebAssembly/binaryen https://github.com/WebAssembly/binaryen Do you know XZ Embedded? http://tukaani.org/xz/embedded.html http://tukaani.org/xz/embedded.html I wonder if it could improve startup (with emterpreter?).
- azakai 11y agoI hadn't heard of XZ embedded. Might be worth measuring it, but it would be competing with native gzip in the browser, which is hard to beat on speed. But maybe better compression would be worth it?
- corysama 11y agoLZHAM is interesting in that area. Speed that competes with gzip and compression that competes with LZMA. https://github.com/richgel999/lzham_codec https://github.com/richgel999/lzham_codec
- vmorgulis 11y agoInteresting. It reminds me encode.ru :) Do you know the size of the compiled code?
- corysama 11y agoIn this discussion https://news.ycombinator.com/item?id=8911369 https://news.ycombinator.com/item?id=8911369 someone quoted this page http://mattmahoney.net/dc/text.html http://mattmahoney.net/dc/text.html as saying it compiles to about 150k. I can't find the current listing, but I'm on mobile :/ Btw: the author's blog talks about LZHAM quite a bit http://richg42.blogspot.com/ http://richg42.blogspot.com/ edit: Looks like it's up to 190k Compression Compressed size Decompresser Total size Time (ns/byte) Program Options enwik8 enwik9 size (zip) enwik9+prog Comp Decomp Mem Alg Note ------- ------- ---------- ----------- ----------- ----------- ----- ----- --- --- ---- lzham 1.0 -d29 -x 25,002,070 202,237,199 191,600 s 202,428,799 1096 6.6 7800 LZ77 70 xz 5.2.1--lzma2=preset=9e,dict=1GiB,lc=4,pb=0 24,703,772 197,331,816 36,752 xd 197,368,568 5876 20 6000 LZ77 73 gzip 1.3.5 -9 36,445,248 322,591,995 38,801 x 322,630,796 101 17 1.6 LZ77
- 11y ago
- AgentME 11y agoWebAssembly is a special encoding for a subset of javascript that's easier to optimize. If all arbitrary javascript could be compiled to WebAssembly and get any benefit, then browsers wouldn't bother with asmjs/WebAssembly and would just implement those optimizations in their general Javascript engines. WebAssembly is a good compilation target for languages with a flat memory space and no garbage collection.