I recently coded a library in CoffeeScript and my friend pointed out that it would never get contributions. It's a valid point. Native JS makes your library much more accessible to contributors.
This got me thinking, I want to be able to write JS using a cleaner syntax like CoffeeScript, but output JS that is indistinguishable from hand-written code. Furthermore, I'd like to be able to convert Javascript to this more succinct language for editing, then back to Javascript when saved. This would allow seamless use of this tool while not diverging from the vanilla JS community. I envision this integrated into editors like Sublime Text. Alternatively it could be a grunt task.
Some of the features that could be transpiled to/from hand-written code:
- pythonic whitespace
- string interpolation
- function arrow syntax
- multiline strings
- bracketless objects
- @instancevar
- existential operator
- for... in over arrays
- for key, value in obj
- array slicing
- chained comparisons
A challenge will be editing a js file while preserving existing coding conventions and unedited portions as-is. I also have no experience with compilers, parsers, etc although I have an interest.
I want to get some initial feedback on the idea from other experienced JS developers.
Your honest feedback is appreciated! I'd have to learn a lot to pull this off and I'd like to see if it's worth pursuing before diving in.
Thank you!
-Raine