Some things to note:
- the default for the new compiler is -O 1 (not -O 0 !!!)
- I can hardly imagine any reason (unless we find some bug in the compiler that happens only in -O 2) why anyone would not use always -O 2
Yes, that statement is totally not true, even my app that did compile and run with -l 3 with the old compiler had to be modified. So that is an actual bug in the new compiler if you take that sentence…
Thank you for your detailed response, but I think any response will inexorably entrench us on opposite sides of the debate over the value of Object Oriented program design. And that won…
that's an interesting promo, but it looks like they intentionally didn't include it in the announcement, because I tested: -O2, -O2p -O2z, -O3, -O3p -O3z, and all of them produce the same code/data/..…
I don't use any dictionaries unless I have to, I use very limited classes, if/then/else is more efficient that switch, and direct dc calls are generally more efficient than users layouts.
Yeah, I know but my point is that Monkey C has a bunch of standard features (like classes and dictionaries) which are very expensive to use. Even enums are expensive to use. As per your example, layouts are expensive, but that's just another feature which is supposed to make our lives easier.
So if Garmin were to provide a tutorial on making super-efficient apps, the first thing they would have to say is "please disregard most of the friendly language features we provide", which would be a very confusing message coming from them. If I were a new dev, I would be thinking "why give us all of this stuff if we're not supposed to use it?"
1. I had to change the code that I used with 4.1.4 even to compile with 4.1.4 Compiler 2 Beta (no matter what -O setting). So no, this is 100% not compatible. Until now have you ever upgrade the SDK to the next one and needed to change your code? It's true, once it ran with -O 0 it also ran with -O 2.
2. Yeah, you kicked me out 3 times I think, the good thing is that refreshed the page and "started" to reply again and my previously typed text was there :)
Maybe I'm too optimistic, but this new compiler seems to be one huge step towards optimizing things, so maybe in the not so far future they can also add other optimizations. Like inlining code :) That's not hard to implement and helps readability and even decreases code size. And I'm sure there are lot of other things.
I am seeing a useful reduction using -O2 in Peak Memory from 108.7 down to 102.7 - that's a 6Kb saving on a 124 Kb device.
(I still have to compile with "-l 0" to ignore the literally hundreds of errors with "-l 1" which I'm still working through!)
other optimizations. Like inlining code
I suspect that while inlining may improve processing speed, it would be at the expense of memory usage - which is tight enough already!
I suspect that while inlining may improve processing speed, it would be at the expense of memory usage - which is tight enough already!
As discussed elsewhere, depending on the circumstances, manually inlining code can save a lot of memory.
For example, the following function would be a prime candidate for inlining:
function increment(x) {
return x + 1;
}
The programmer who wrote that needs to be sent to Siberia for re-educating!
As discussed elsewhere
That would make interesting reading, can you post a link please?
The programmer who wrote that needs to be sent to Siberia for re-educating!
Haha funny but obviously it's a toy example for the purposes of demonstration. I didn't feel like digging up a meaningful function in my own code which benefited from inlining.
Not to state the obvious, but even the most complex function is a candidate for inlining if it's only ever called once. In modern programming, we usually like to split up huge functions into parts, even if those parts aren't reused multiple times. In Monkey C, sometimes a huge monolithic function has advantages (not for maintainability or readability tho.)
That would make interesting reading, can you post a link please?
forums.garmin.com/.../big-update-to-prettier-extension-monkeyc