Can you actually enumerate the things we are using that aren't standard (or soon to be standard) ES6? I can't think of many. My experience is that generally when a nice new ES6 feature comes along we rush excitedly to start using it, sometimes before the JS team think is is ready to ship unfortunately.
I know we have old-style generator functions that we can and should just switch to function*. For...each can probably be ditched in favour of for...of easily too.
Cu.import will be harder to remove but I don't understand what the cost of that is there, it's certainly a well-formed ES6 statement and until modules become a real thing there isn't really a replacement.
_______________________________________________
firefox-dev mailing list
firef...@mozilla.org
https://mail.mozilla.org/listinfo/firefox-dev
Ditching the preprocessor would also mean ungodly-long in-tree JS files because extra script references add overhead. It's no coincidence web devs unify their JS into only a few files, too. Obviously we could replace it with other magical "put the things together" solutions, but that's unlikely to solve the same tooling problem, ie, multiple files that apply to a single global. If anything, I wish we split up browser.js even more ways.
While preprocessed code could likely ultimately be tolerated, it is my preference to see it go away *unless* we adopt preprocessing conventions utilized by the larger JavaScript community and are well supported by 3rd party JavaScript tools. (Currently, the preprocessor is part of the build system and I'm pretty sure any overlap with existing JS preprocessors is coincidental.) Much like the larger Java world doesn't preprocess Java (like we do on Fennec, unfortunately), we shouldn't be doing it in Firefox JavaScript unless we have a very good reason. And if we must preprocess code, I think we should take steps to limit its impact (e.g. isolate all preprocessed code to standalone files so its effects don't creep into most code).
Use of the preprocessor would be pretty high on my list of things to get rid of.
Use of the preprocessor would be pretty high on my list of things to get rid of.
I suspect that a lot of the older non-ES6 JS features probably don't get used much in new code (old-style generators, for each, braceless functions), so a style guide won't help much. We just need to remove them from old code.
On 2/17/15 10:36 AM, Gijs Kruitbosch wrote:
However, you would be surprised how much JS tooling assumes that
references to |window| or |document| (or window's other properties!) are
always valid
This tooling is already broken for workers, node.js, etc, right? Can we not avoid such broken tooling and use tooling that doesn't make broken assumptions about the host environment?
or where (in order to get good/reasonable
results for inferences and so on) we would need to provide descriptions
of (web/xp)idl interfaces in some way that they can grok, as we can't
always point to a JS implementation instead...
That's fair.
Maybe we have very different expectations of what "tooling" means here -
That's possible. Gregory's post was very light on specifics...
On Tue, Feb 17, 2015 at 7:40 AM, Boris Zbarsky <bzba...@mit.edu> wrote:
On 2/17/15 10:36 AM, Gijs Kruitbosch wrote:
However, you would be surprised how much JS tooling assumes that
references to |window| or |document| (or window's other properties!) are
always valid
This tooling is already broken for workers, node.js, etc, right? Can we not avoid such broken tooling and use tooling that doesn't make broken assumptions about the host environment?
or where (in order to get good/reasonable
results for inferences and so on) we would need to provide descriptions
of (web/xp)idl interfaces in some way that they can grok, as we can't
always point to a JS implementation instead...
That's fair.
Maybe we have very different expectations of what "tooling" means here -
That's possible. Gregory's post was very light on specifics...
Here's a partial list:
* Machines should tell you when code doesn't conform to style guidelines
* Machines should be able to automatically reformat code to conform to style guidelines
* We should be able to mass-rewrite code by writing scripts that transform existing code (this is how Google and Facebook perform large refactors)
* Developers should be able to see code coverage for tests, etc (I view this as blocked on SpiderMonkey lacking a built-in high-performance tracing/profiling mechanism)
* Code editors and IDEs with JavaScript support should "just work"
* We should be able to write custom "linter" rules looking for common issues with Mozilla code (e.g. usage of nsIFile over OS.File)
Right. So as Boris said, most of this just needs parsing and "glue" to process the AST and hook up to our custom processing scripts/specifications (for refactors/reformatting/linting).* We should be able to write custom "linter" rules looking for common issues with Mozilla code (e.g. usage of nsIFile over OS.File)
Do you have evidence that a significant number of the above problems have ready-made "glue" that will work with ES6 once we get rid of the SM-specific stuff? Because we already have a working parser and AST generator - Reflect.parse. Its output format, last I checked, is largely compatible with the existing toolset. The main problem was ES6 stuff like "let", "const", "yield", generators, for...of, and destructuring expressions. Ditching SM-specific things wouldn't bridge that gap. Maybe I've been looking at the wrong tools, though?
Absolutely. If this particular argument is holding up patches landing
in practice, that's a problem. Flag it and I will help fix it.
Gavin
I’d be happy to jot this down as secondary Q2 goal for me!
Mike.
Gijs Kruitbosch wrote:
Because we already have a working parser and AST generator - Reflect.parse. Its output format, last I checked, is largely compatible with the existing toolset.
Reflect.parse's output is the standard that pretty much all other tools are based on. However, it's also inadequate for usage in pretty much all other tools. It's missing key things such as support for comments[1] - which many tools rely on. And of course there's the issue of nodejs compatibility. Other parsers are roughly the same, until you get down to certain details.
There's been some activity lately in being more intentional and organised around parsing and AST trees, and developing a more formal spec, with https://github.com/estree/estree
That reminds me of another area for improvement: automatic documentation generation. I think its wasteful of developers' time to update inline source/API docs *and* MDN. We should generate API docs from source code and markup MDN docs with additional comments, like how MSDN, php.net, etc do their docs. Extraction of documentation from source also enables IDEs and editors to have cool features like autocomplete and pop-ups containing usage docs. This does poke the hornets nest of how to format docs. But I'd like to think the end result outweighs the pain to transition to it.
What's the plan for #include, which is implicated here?
Aeons ago, I filed https://bugzilla.mozilla.org/show_bug.cgi?id=381210 about the ridonkulous size of browser.js (still pretty big, btw!) which much later got duped to https://bugzilla.mozilla.org/show_bug.cgi?id=758812 where dolske eventually did split up a lot using #include directives.
While I recognize I have no veto rights or whatever, I would be... seriously displeased if we went back to just using a single file.
AIUI, jsms are our next-best alternative, but using a lot of them has serious performance downsides (and will also require a bunch of refactoring for the included scripts).
Perhaps we can introduce a valid JS shorthand to include extra files by simply loading them into the global scope with the scriptloader, and then preprocess them for dist and/or pgo builds?
For CSS (which has this problem but worse because no scriptability) we can presumably do this with the pre-existing @import , and change %defines to use CSS variables?
On Fri, Apr 3, 2015 at 8:02 AM, Gijs Kruitbosch <gijskru...@gmail.com> wrote
AIUI, jsms are our next-best alternative, but using a lot of them has serious performance downsides (and will also require a bunch of refactoring for the included scripts).
We already import ~50 JSMs into browser.js. Converting 21 #include files to JSMs will be annoying, but I doubt it will have any significant effect on performance. We'll use a little more memory, but the code will be loaded more lazily in most cases. It's worth measuring though.
There are bugs on file to save even using 1 extra JSM ( https://bugzilla.mozilla.org/show_bug.cgi?id=986503 ) so 21 extra JSMs does not sound nice.
Perhaps we can introduce a valid JS shorthand to include extra files by simply loading them into the global scope with the scriptloader, and then preprocess them for dist and/or pgo builds?
Well, the point of removing the preprocessor is to use only standard JavaScript, so I don't think we should do that.
For CSS (which has this problem but worse because no scriptability) we can presumably do this with the pre-existing @import , and change %defines to use CSS variables?
That would be cool. I'm also worried about .xul files. It would be great to get rid of the preprocessor in those, but I don't know of any replacement for #ifdef in XUL.
> There are bugs on file to save even using 1 extra JSM (
> https://bugzilla.mozilla.org/show_bug.cgi?id=986503 ) so 21 extra JSMs does
> not sound nice.
That bug is a year old. Is the performance hit/memory consumption
still unchanged?
Mike.
~ Gijs