I have been really pleased with how much code I can load/run within 48K ram. My current project is getting quite large yet when using minification I still have room for 700 variables.
I would still like to ensure I use as little memory as possible (just in case I hit the limit).
Minification works really well but for those variables that the minifier cannot rename i.e. those that interface with the object (at root level) what length should I try to keep variable names to?
i.e. what are "Short" variable names - I saw this mentioned somewhere but can't find it again?
If I have a module defining an object/class of which there will only ever be one instance, is there any benefit (or overhead!) in having all functions against the objects prototype?
I also tried placing all my main code within onInit(). i.e. instead of:
var aaa, bbb, ccc;
function one(){
}
function two(){
}
function three(){
}
onInit(){
one();
}
I used:
onInit(){
var aaa, bbb, ccc;
function one(){
}
function two(){
}
function three(){
}
one();
}
This allowed the minifier to rename most of my variables/functions but resulted in more memory being used - why did this happen?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I have been really pleased with how much code I can load/run within 48K ram. My current project is getting quite large yet when using minification I still have room for 700 variables.
I would still like to ensure I use as little memory as possible (just in case I hit the limit).
Minification works really well but for those variables that the minifier cannot rename i.e. those that interface with the object (at root level) what length should I try to keep variable names to?
i.e. what are "Short" variable names - I saw this mentioned somewhere but can't find it again?
If I have a module defining an object/class of which there will only ever be one instance, is there any benefit (or overhead!) in having all functions against the objects prototype?
I also tried placing all my main code within onInit(). i.e. instead of:
I used:
This allowed the minifier to rename most of my variables/functions but resulted in more memory being used - why did this happen?
I have read http://www.espruino.com/Internals but not 100% sure about the best approach.
Any other ideas on how to minimise memory usage yet keep my code readable/maintainable would be appreciated.