Wrote a quick linter for #uxn, that raises warning for common optimizations. I will add more recipes as we find them.
Missing an optimization? Add it here: https://git.sr.ht/~rabbits/uxnlin/tree/main/item/src/uxnlin.tal#L178
Wrote a quick linter for #uxn, that raises warning for common optimizations. I will add more recipes as we find them.
Missing an optimization? Add it here: https://git.sr.ht/~rabbits/uxnlin/tree/main/item/src/uxnlin.tal#L178
@neauoire @alderwick There's an interesting discussion about tail call elimination in Forth at https://wiki.c2.com/?TailCallOptimization. Neither it nor Scheme provide for pragmas to disable optimizations, I believe ๐ค
@akkartik @alderwick this is the clearest definition of tail-call optimization that I have ever read ๐
@akkartik @alderwick It won't be nagging anyone unless they, like me, go about to assemble the linter and run their code through it. I made this for myself to see if I had some blindspots, and it turns out I do, I'm not saying I will obey all suggestions, but I will try to make the applications as fast as I possibly can for the user, even if that means making the code more convoluted.
@neauoire @alderwick That makes sense ๐ I just feel defensive with most linters ๐
@akkartik @alderwick I've given in ๐คฆโ๏ธ
https://git.sr.ht/~rabbits/uxn/commit/5a0e0c56aab08388833892129eae25be8e9dd208
@neauoire @akkartik I like it! I'm used to doing that optimisation manually, but now I can have
;do-something JSR2
JMP2r
not worry about writing that optimisation, and now when I add โ;do-something-more JSR2โ I can think less about changing the ending. ๐
However, we also have folx in IRC unhappy already about LIT merging, so to help them out we could incorporate a setting to turn all optimisations off somehow. Something both uxnasm and asma need to recognise per source file? ๐ค
@neauoire Turning "JSR2 JMP2r" into "JMP2" (tail call elimination) does feel like it makes the code a little harder to read. There's something reassuring about the way you have a function call per line at the moment.
@akkartik I know right, I haven't really found a good way to handle that yet, it might be that the assemblers should handle that, but I'm not sure if that's the best idea.
@alderwick and a few others have, from the very beginning, closed their routines in the same indent level as the body of the routine, and I'm starting to regret not catching on that habit earlier.
@neauoire @alderwick Can I ask what the motivation is for the optimizations?
Idea: distinguish between optimizations and _idioms_. If someone's writing something in an unncessarily convoluted way, a linter is a good way to remind them of features.
But programs are often fast enough. Nagging about optimizations might seem heavy handed. Show that sort of advice outside of build.sh, only when asked. "My app is slow, do you have any suggestions?" That way also lies a profiler.
@akkartik @alderwick this is not part of the assembler or anything, it's basically the tool you dig out when you're looking for optimizations.
"My text editor is as optimized as it can be.."
arg fuck me
@neauoire @akkartik @alderwick I wrote about it a while ago, if you want to take a look... https://ekaitz.elenq.tech/call-me-maybe.html
๐ค
tiflolinux.org - GNU Social is a social network, courtesy of tiflolinux.org. It runs on GNU social, version 2.0.1-beta0, available under the GNU Affero General Public License.
All tiflolinux.org - GNU Social content and data are available under the Creative Commons Attribution 3.0 license.