Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I am puzzled by how an binary AST makes the code significantly smaller than a minified+gziped version.

A JavaScript expression such as:

var mystuff = blah + 45

Gets minified as var a=b+45

And then what is costly in there is the "var " and character overhead which you'd hope would be much reduced by compression.

The AST would replace the keywords by binary tokens, but then would still contain function names and so on.

I mean I appreciate the effort that shipping an AST will cut an awful lot of parsing, but I don't understand why it would make such a difference in size.

Can someone comment?



According to a comment by Yoric, they're seeing a 5% improvement in size over minified+gzip.

https://news.ycombinator.com/item?id=15046750


I would be more excited by the possible reduction in parse time since the grammar should be less ambiguous.


Indeed, this is the main objective. Reduction of file size is also an objective, albeit with a lower priority.


Afaik, improving parse time is the big goal here. Parsing is a significant stage of the compile pipeline, perf-wise. Some engines (Chakara at least), defer part of the parsing of the body of a function until the function itself is called, just to save precious milliseconds and not block the first render.


It's actually hard to get smaller than compressed minified JS. Source code is actually a very excellent high-level, compact representation of program text.

The space optimizations in BinaryJS are to get us back down to the point where we are as good or better than minified compressed JS.

The main goal is to allow for much faster parse times, but to do that without compromising other things like compressed source size.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: