tamzinblake / js3-mode

A chimeric fork of js2-mode and js-mode
GNU General Public License v3.0
181 stars 13 forks source link

General question and js2 tools compatibility #87

Closed marcinant closed 10 years ago

marcinant commented 10 years ago

Hi!

I installed js3 as new and improved version of js2-mode. Then I realized that there are plenty of tools not compatible with js3.

For example: auto-complete - needs hack to make it work with js3, slime-js - depends on js2, js2-refactor, smart-tabs, skewer, ac-js2.... and probably few more I don't know about.

So, my general question is: What is the point of developing and maintaining two similar but not fully compatible javascript modes?

What exactly js3 can do, that js2 cannot?

Is there some precise comparison table?

Is this possible to just extend js2 with improvements taken from js3 and merge these features?

I will switch back to js2 for now as I want to try skewer/slime-js, but it could be nice to have best of these two forks in single one.

dgutov commented 10 years ago

js3 as new and improved version of js2-mode

js3 is a misnomer. It's a version optimized for comma-first coding style, using AST in its identation code. Which is an order of magnitude (or several) slower, but allows to support more complex indentation schemes.

Aside from that, I'm not aware of any major features. If I'm wrong, file a feature request.

As far as indentation goes, js3-mode could declare a dependency on js2-mode, derive from its major mode function and just change indent-line-function value.

tamzinblake commented 10 years ago

When I started working on js3-mode, a lot of those tools didn't exist. I haven't made any special effort to maintain compatibility with them as they pop up - I don't use them and js3-mode started as a tool for me to use, coincidentally put out for public consumption because GitHub is awesome.

js3-mode is hardly a 'misnomer', any more than js2-mode is. js2-mode was so named because it was intended to be compatible with the upcoming Javascript 2 from Mozilla, which is not really relevant to its actual use. js3-mode was so named because I sometimes used js2-mode and needed something to distinguish their names, and incrementing the integer seemed like the obvious way to go.

I'm continuing to develop it separately, in part because there is a lot of stuff behind the scenes that works differently or is intended to work differently eventually. For example, the AST printing routines are almost entirely different between js2-mode and js3-mode (though they will probably be scrapped / rewritten entirely in the next version). I intend to rewrite the JS parser with a more intuitive interface, using something that stores comments on the AST and doesn't require a reparse to indent multiple lines when the only change was whitespace. I'm a big fan of js3-pretty-print-no-indent, but it's annoying that there's currently no way to effectively indent-whole-buffer using js3-mode.

If you are aware of any hacks to get js3-mode to work with any of the js2-mode tools, feel free to let me know or file a feature request. I do try to keep it useful for anyone who's actually using it.

dgutov commented 10 years ago

was so named because it was intended to be compatible with the upcoming Javascript 2 from Mozilla

I sometimes used js2-mode and needed something to distinguish their names, and incrementing the integer seemed like the obvious way to go

Yeah, these two reasons are totally equivalent.

JavaScript 2 may not be a thing anymore, but support for syntax changes in Mozilla-vendored JS 1.7, 1.8, 1.8.5 and newer is still a priority for js2-mode, and some extension authors, as well as Mozilla contributors, do use it because of that.

tamzinblake commented 10 years ago

Incidentally, I've been considering a rename to v8-mode since I mostly care about syntax that's made it into the main branch of v8, and I think mostly Node people use js3-mode in the wild, and that would be nicely symmetric.

dgutov commented 10 years ago

I think that name sort of implies that you're supporting some special V8 features. Whereas "syntax that's made it into the main branch of v8" only contains features supported by other browsers, too. No?

marcinant commented 10 years ago

@thomblake If v8-mode is going to be major mode, then it's still a bad idea.

js2-mode gives access to useful extensions. v8-mode as minor-mode extending js2-mode and not trying to duplicate js2 functionality, would be something nice.