-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
[WIP] Make things a bit classier #1359
Conversation
Looking at the source... if you remove the |
In the interests of keeping byte size to a minimum, it's probably better to keep |
Codecov Report
@@ Coverage Diff @@
## master #1359 +/- ##
=========================================
Coverage ? 92.09%
=========================================
Files ? 127
Lines ? 4958
Branches ? 1592
=========================================
Hits ? 4566
Misses ? 158
Partials ? 234
Continue to review full report at Codecov.
|
I like the code this results in way more, though some discouraging initial news — the Hello World example is slightly larger:
Also, custom elements are slightly clunky. There might still be a couple of improvements we can make, and it needs to be tested with some larger components. |
Ok, so I just ran this on svelte.technology, and got slightly better results:
A modest saving but a saving nonetheless. So the question is whether (nicer code + smaller ES6 output) is a more important consideration than (larger transpiled ES5 output). |
Does perf change at all? |
Lemme get back to you on that. Running the js-framework-benchmarks, it takes a while... |
Here's the results: https://file-oprglutiur.now.sh/ There's basically nothing to choose between them. This PR ('linked') is the slowest of three on the keyed tests, fastest on the non-keyed, but they're so close that I'd call that statistical noise rather than anything. Perhaps not surprising, since it's only actually instantiating a single component. Incredibly though, this micro-benchmark I just threw together suggests that while classes are faster to instantiate than constructors in Chrome, and constructors are faster than classes in Firefox, |
Interesting, I wouldn't have expected that at all! Might be worth trying if you're down for the extra work. |
@Rich-Harris I'd take those micro-benchmarks with a grain of salt. It really depends on what we're optimizing for. We get different results when instantiating multiple components (eg. by moving the classes definitions to the setup); also when disabling the babel transpilation; and I bet it'd be even more varied if we tested long and short-lived components after creation (since all engines support hidden classes nowadays, and I'm not sure if any of them optimize ps. ESBench is failing on me so I can't save any of the modified benchmarks, sorry! |
Any update on this please @Rich-Harris? |
Closing; v3 uses classes |
Just an idea for now, it may turn out that this costs us more than it gains us. But now that we've dropped the ES5 constraint we can use classes to generate (in my opinion) much nicer code.
Custom elements are currently broken, and we'd need to handle the case where
options.name
isComponent
, since it doesn't currently deconflict.Also, I can't think of a good name for the base class shared by
Component
andStore
. Anyone?