Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor client to ES6 #573

Open
3rd-Eden opened this issue Apr 10, 2017 · 5 comments
Open

Refactor client to ES6 #573

3rd-Eden opened this issue Apr 10, 2017 · 5 comments

Comments

@3rd-Eden
Copy link
Member

Wondering what people's opinions are on this. Currently, the primus.js file in the root of this repository is still written in ES5. Would it make sense for a maintenance point of view to transform this to ES6 as well and just have babelify it during the browserify process so we end up with ES5 again?

Obvious downside would be a slight increase in file size due to extra babel helpers and other sorts of polyfills that would be added but it might make more sense to have a unified code base here where everything is written in ES6 classes, const, fat arrows.

The only biggest hurdle we would need to tackle is Node.js support, because we re-use the same client code base from the browser for the Node.js client.

@lpinca
Copy link
Member

lpinca commented Apr 10, 2017

Happy to use ES6+ where possible but I think it's overkill for the client. Why rewriting and adding a transpilation phase when existing code is already transpiled? It is well written, easy to understand, modularized and works in very old browsers which don't even support ES5 features.

Slightly -1 on this.

@3rd-Eden
Copy link
Member Author

The main reason would be to have a consistent code base. As the rest of the code is already in ES6.

@lpinca
Copy link
Member

lpinca commented Apr 10, 2017

I get it but there are parts which can't be written in ES6 like the clients of the transformers unless we want to add even more complexity so I'm not sure.

@davedoesdev
Copy link
Contributor

Unless there's some feature which needs ES6 I don't see the point of rewriting code which works.
As long as it's readable I think it's fine.

@joepie91
Copy link

It's important to keep in mind that ES6 does not replace ES5. It merely adds a number of new features to the language that can help in the cases where they are appropriate (ie. where they fit the requirements well).

Rewriting code to "use ES6 features as much as possible, for the sake of using ES6" is therefore a bad idea. This particularly applies to remarks like:

a unified code base here where everything is written in ES6 classes, const, fat arrows

... which isn't really what you'd want. The value of ES6 classes is dubious in and of itself, const is not necessarily universally applicable (eg. when you need to reassign things you'll want to use let), and arrow functions are not functionally equivalent to regular functions; they have different semantics, so they can't wholesale replace regular functions.

I'm not at all saying it's a bad idea to start using ES6 features, provided that the transpilation concerns are addressed, but trying to maximize ES6 feature usage makes no sense and will just lead to a bigger maintenance burden.

(On a loosely related note, while 'consistency' can be a beneficial factor to readability and maintainability in some cases, it can also work against it; consistency in and of itself should really never be a design goal of any codebase.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants