[ALOY-1263] Compiler should force "strict mode" to increase (Android) performance
GitHub Issue | n/a |
---|---|
Type | Story |
Priority | None |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2017-05-03T07:38:09.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Tooling |
Labels | n/a |
Reporter | Fokke Zandbergen |
Assignee | Feon Sua Xin Miao |
Created | 2015-04-29T06:40:54.000+0000 |
Updated | 2018-03-07T22:28:25.000+0000 |
Description
Looking for optimisations of https://github.com/appcelerator-developer-relations/Mobile-App-Performance I saw that enable strict mode meant a 20x performance increase on Android and a significant increase on iOS as well.
Unfortunately, because
"use strict";
needs to be the first line of the file or function scope and Alloy wraps the original controller code, a developer cannot (simply) enable strict mode. The workaround is to wrap inline controller code in a self-executing function and add "use strict";
as the first line for this and every other function.
https://community.appcelerator.com/topic/391/how-to-enable-strict-mode-in-alloy
Phase 1: Always add strict
We should probably promote strict mode in our docs, but with Alloy we could even force it. Simply adding"use strict";
to all compiled files will only mean a slight decrease of performance if the code is not really strict but a huge increase if it is, as this [StackOverflow user found](http://stackoverflow.com/questions/23997267/using-node-why-is-code-so-much-faster-with-use-strict).
Any progress on this?
I second the motion to get some movement on this, as it sounds so simple a gap to bridge in theory and no-one has claimed anything to the contrary. Given the widely accepted benefits of running strict mode code, surely we could bump this up the list of things to do? If you're working in an editor that supports JS linting (such as Atom, which I believe more and more people are doing), you're bombarded with warnings about unnecessary 'use strict' directives, which I for one would not mind seeing the back of... If a well-placed rant doesn't get the job done, maybe I should pull my finger, fix it myself and submit a pull request, eh? Although a soap-box is so much easier to come by...
If Francois hasn't pulled his finger ;) I would also like to see this happen! If the performance gain is that massive it's an easy win with many Titanium developers.
bump Someone raise this priority please.
Would be nice if this was implemented.... I have started looking into doing this manually - but would be so much nicer to have it done automatically. If backwards compatibility is an issue then perhaps make it possible use by setting some configuration somewhere on the project... (tiapp.xml perhaps?)
Hey [~fmiao], can you take a look and scope this out?
PR: https://github.com/appcelerator/alloy/pull/823
We decided to not implement this change at all, because most recent benchmarking tests related to the above PR did not result in an improved Alloy performance. If there are other thoughts on this, please test the PR and let us now, but for now we will go with the current Alloy implementation and expect huge speed improvements in Alloy v2 which will begin planning this week. Thanks!
Closing as invalid. If this is incorrect, please reopen.