News for hackers. Stuff that matters.
Re:The Monaco Code Editor by alexdima on Monday June 20, 2016 @05:20PM (#11941673)
Forgot to mention a funny fact I found. Minify everything [1]

[1] https://top.fse.guru/nodejs-a-quick-optimization-advice-7353...

Re:The Monaco Code Editor by vanderZwan on Tuesday June 21, 2016 @03:09AM (#11943993)
> v8 optimizer (crankshaft) inlines the functions whose body length, including the comments, is less than 600 characters.

In what kind of world is that a sensible metric to decide if a function can be inlined?

Re:The Monaco Code Editor by lorenzhs on Tuesday June 21, 2016 @05:52AM (#11944626)
In the world where you have to make these decisions quickly, and don't have time to parse the function.
Re:The Monaco Code Editor by vanderZwan on Tuesday June 21, 2016 @01:35PM (#11947595)
I don't buy it: that would only make sense if you could copy/paste the source or something, and even JS respects function scoping so you can't. You'd have to wait until later anyway, so why not count AST nodes or something instead?
Re:The Monaco Code Editor by lorenzhs on Tuesday June 21, 2016 @03:39PM (#11948798)
I can't make useful guesses about the V8 developers' reasoning, but I'd assume they considered several options and chose this one for a reason, concerning how much performance is at stake. I don't know about Crankshaft's inner workings, though, so I can't make qualified comments about it. Maybe something like http://jayconrod.com/posts/54/a-tour-of-v8-crankshaft-the-op... can answer some of your questions?
Re:The Monaco Code Editor by vanderZwan on Tuesday June 21, 2016 @07:22PM (#11950278)
Thanks. Quick CTRL+F for "inlining" produces:

> Graph generation: Crankshaft builds the Hydrogen control flow graph using the AST, scope info, and type feedback data extracted from the full-compiled code. Inlining also happens at this stage. Hydrogen is Crankshaft's high-level architecture-independent intermediate representation.

> Inlining: Performed during the graph generation phase. The inlining heuristic is very simple: basically, if the function being called is known, and it is safe to inline, the function will be inlined. Large functions (>600 source characters including whitespace or 196 AST nodes) will not be inlined. Cumulatively, a total of 196 AST nodes can be inlined in a single function.

So they do use AST nodes as a heuristic; I don't really understand why they would also use "source characters including whitespace" though.

Guess I better keep my comments outside the function body from now on when possible.

Re:The Monaco Code Editor by luckystarr on Tuesday June 21, 2016 @03:59AM (#11944178)
In the "I need to do this quickly to finish my sprint" world.
Re:The Monaco Code Editor by konschubert on Tuesday June 21, 2016 @04:06AM (#11944220)
Wasn't V8 written in a cottage in Denmark? http://www.ft.com/cms/s/0/03775904-177c-11de-8c9d-0000779fd2... I cannot imagine that they would take unreasonable shortcuts.
Re:The Monaco Code Editor by luckystarr on Tuesday June 21, 2016 @07:36AM (#11944959)
Well, unreasonable now was probably perfectly reasonable at the time of implementation. Perhaps they even have or had a plan to improve upon it, but given other tasks (ES6, etc.) it hasn't been given much priority.

I mean, why would they fix it with high priority if the engine already has reasonable performance and the benchmarks are happy as well?

Re:The Monaco Code Editor by egeozcan on Tuesday June 21, 2016 @04:17AM (#11944271)
Even then, why include comments? Is it to support stuff like multi-line strings as comments hack[1]?

[1]: https://github.com/sindresorhus/multiline