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

ES5/ES6 wishlist #1302

Open
gfwilliams opened this Issue Jan 9, 2018 · 27 comments

Comments

Projects
None yet
8 participants
@gfwilliams
Copy link
Member

gfwilliams commented Jan 9, 2018

ES5/ES6 features that aren't in Espruino but that would be useful... I'll do one post per feature, and please use the add reaction button to vote on each one.

@gfwilliams gfwilliams added the question label Jan 9, 2018

@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented Jan 9, 2018

  • String.startsWith/endsWith/includes - would be trivial to add
@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented Jan 9, 2018

  • Proper let implementation - it's just treated as var at the moment, but nobody seems to actually care
@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented Jan 9, 2018

  • Proper const implementation - it's just treated as var at the moment
@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented Jan 9, 2018

  • Array.find/findIndex - find by executing a function for comparison
@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented Jan 9, 2018

  • JS classes - probably not too painful, and seems like it'd tidy up a lot of code
@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented Jan 9, 2018

  • Default argument values
@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented Jan 9, 2018

  • Array.includes - easy, just indexOf()>=0
@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented Jan 9, 2018

  • Object.entries and Object.values
@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented Jan 9, 2018

  • String.padStart/padEnd
@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented Jan 9, 2018

  • async/await - although this it likely too difficult to implement in Espruino as it is
@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented Jan 9, 2018

@FlowerOfLife

This comment has been minimized.

Copy link

FlowerOfLife commented Feb 20, 2018

@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented Feb 20, 2018

@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented Feb 20, 2018

gfwilliams added a commit that referenced this issue Feb 20, 2018

gfwilliams added a commit that referenced this issue Feb 20, 2018

@jjok

This comment has been minimized.

Copy link

jjok commented Feb 26, 2018

import and export?

@vshymanskyy

This comment has been minimized.

Copy link
Contributor

vshymanskyy commented Feb 28, 2018

Ok, I was actually able to get async/await working on Espruino (using Babel transpiler and some hacking).
Here is a full example: https://github.com/vshymanskyy/espruino-await
Looks pretty usable, but a native implementation would be so much better ;)
What do you think?

@louisvangeldrop

This comment has been minimized.

Copy link

louisvangeldrop commented Mar 24, 2018

Webassembly support?

@andrewwakeling

This comment has been minimized.

Copy link
Contributor

andrewwakeling commented Apr 3, 2018

I did a similar exercise to @vshymanskyy and got various modern JS features working using Webpack/Babel. See: https://github.com/andrewwakeling/espruino-webpack-babel-sample

Although supporting modern JS features (spread, destructuring) out-of-the-box would be convenient, these things are somewhat trivial to support if you compile the code.

I would love to see fixes/improvement to ensure that more modern JS features work correctly and more reliably (after compilation). It would also be great to see improvements that would reduce the size of the compiled code. e.g. Transpiling async/await increases the bundle size a fair amount. I understand that supporting async/await isn't trivial, so I'm not pushing for this.

@opichals

This comment has been minimized.

Copy link
Contributor

opichals commented May 16, 2018

This would allow for shorter syntax which is quite important for Espruino.

@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented May 18, 2018

@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented May 18, 2018

@opichals

This comment has been minimized.

Copy link
Contributor

opichals commented Jun 6, 2018

This would be nice way to deal with stuff like case-insensitive Object key lookup in a standard way.

gfwilliams added a commit that referenced this issue Jun 21, 2018

@loganpowell

This comment has been minimized.

Copy link

loganpowell commented Jan 3, 2019

Hi, sorry to chime in as a complete stranger, but given the whole Babel ecosystem, wouldn't it be more prudent to get complete ES5 feature coverage and then let users compile their ES6+ code down to ES5 before running through Espruino? I'm sorry if this is a naive question that has a straight answer somewhere obvious.

@gfwilliams

This comment has been minimized.

Copy link
Member Author

gfwilliams commented Jan 7, 2019

Hey, no problem. It's actually pretty trivial to set up your own Babel + Espruino CLI toolchain right now if you want to - just not inside the IDE.

The problem with Babel on Espruino is really:

  • if you write code on the left-hand side of the IDE it goes straight to Espruino, so you don't get to use babel - in fact babelified code will probably be harder to interact with.
  • Without a lot of work it'd also mess up the debugging functionality
  • In fact in quite a few cases babel will significantly increase the amount of code used on the micro itself

It's not a reason not to do it, but I think there's still a place for implementing this stuff natively, especially where doing so reduces the amount of code storage needed.

@loganpowell

This comment has been minimized.

Copy link

loganpowell commented Jan 7, 2019

@jjok

This comment has been minimized.

Copy link

jjok commented Jan 7, 2019

@loganpowell Is there anything in particular from ES5 that you've noticed is missing? Maybe open a separate feature request, if there is something.

EDIT: Oh. This is also the ES5 Wishlist. Just add it here, I guess.

@loganpowell

This comment has been minimized.

Copy link

loganpowell commented Jan 7, 2019

After reading @gfwilliams reply, I believe my point was made moot. I was thinking that developers could more easily use NPM libraries with Espruino if it had an ES5 complete API, but I would imagine the bloat that Babel compilation would add to the program, which could be a big performance issue.

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