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

ES5/ES6 wishlist #1302

Open
gfwilliams opened this issue Jan 9, 2018 · 30 comments
Open

ES5/ES6 wishlist #1302

gfwilliams opened this issue Jan 9, 2018 · 30 comments
Labels

Comments

@gfwilliams
Copy link
Member

@gfwilliams 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
Copy link
Member Author

@gfwilliams gfwilliams commented Jan 9, 2018

  • String.startsWith/endsWith/includes - would be trivial to add
@gfwilliams
Copy link
Member Author

@gfwilliams gfwilliams commented Jan 9, 2018

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

@gfwilliams gfwilliams commented Jan 9, 2018

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

@gfwilliams gfwilliams commented Jan 9, 2018

  • Array.find/findIndex - find by executing a function for comparison
@gfwilliams
Copy link
Member Author

@gfwilliams gfwilliams commented Jan 9, 2018

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

@gfwilliams gfwilliams commented Jan 9, 2018

  • Default argument values
@gfwilliams
Copy link
Member Author

@gfwilliams gfwilliams commented Jan 9, 2018

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

@gfwilliams gfwilliams commented Jan 9, 2018

  • Object.entries and Object.values
@gfwilliams
Copy link
Member Author

@gfwilliams gfwilliams commented Jan 9, 2018

@gfwilliams
Copy link
Member Author

@gfwilliams gfwilliams commented Jan 9, 2018

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

@gfwilliams gfwilliams commented Jan 9, 2018

@FlowerOfLife
Copy link

@FlowerOfLife FlowerOfLife commented Feb 20, 2018

@gfwilliams
Copy link
Member Author

@gfwilliams gfwilliams commented Feb 20, 2018

@gfwilliams
Copy link
Member Author

@gfwilliams 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
Copy link

@jjok jjok commented Feb 26, 2018

import and export?

@vshymanskyy
Copy link
Contributor

@vshymanskyy 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
Copy link

@louisvangeldrop louisvangeldrop commented Mar 24, 2018

Webassembly support?

@andrewwakeling
Copy link
Contributor

@andrewwakeling 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
Copy link
Contributor

@opichals opichals commented May 16, 2018

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

@gfwilliams
Copy link
Member Author

@gfwilliams gfwilliams commented May 18, 2018

@gfwilliams
Copy link
Member Author

@gfwilliams gfwilliams commented May 18, 2018

@opichals
Copy link
Contributor

@opichals 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
Copy link

@loganpowell 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
Copy link
Member Author

@gfwilliams 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
Copy link

@loganpowell loganpowell commented Jan 7, 2019

@jjok
Copy link

@jjok 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
Copy link

@loganpowell 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.

@MaBecker
Copy link
Contributor

@MaBecker MaBecker commented Nov 7, 2019

What about

> var text = 'uololooo';
undefined
> 
> // With ES6
undefined
> [...text].forEach(c => console.log(c))
u
o
l
o
l
o
o
o
undefined
> 

workaround for now

text.split('').forEach((c) => {
    console.log(c);
});
@nebbishhacker
Copy link

@nebbishhacker nebbishhacker commented Jul 8, 2020

Nullish coalescing operator (??)

It would be nice to be able to write options.foo ?? 42 rather than (options.foo != null) ? options.foo : 42

@nebbishhacker
Copy link

@nebbishhacker nebbishhacker commented Jul 8, 2020

Similar to the above: Optional chaining (?.)

Allows foo?.bar?.baz?.() instead of if (foo && foo.bar && foo.bar.baz) foo.bar.baz()

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

Successfully merging a pull request may close this issue.

None yet
10 participants
You can’t perform that action at this time.