4 ms·
While this doesn't seem to be very well expressed, I think the sentiment behind this is worth discussion. Computers do waste a huge amount of resources in the
by Lerc 11y ago
While this doesn't seem to be very well expressed, I think the sentiment behind this is worth discussion.
Computers do waste a huge amount of resources in the name of expediency, They are slow to do things, because it is simply cheaper to develop that way.
I think there is scope for the sort of crafted code that is described here though. Not only as an artform but as a practical measure.
For any small piece of code a compiler can produce a comparable result to hand written assembly. Entire programs that have been written in assembly tend to be much smaller, use less memory and run faster. That apparent contradiction is where the focus of crafted code should be. Most of the gains from hand crafted assembly do not come from finding the quickest way to do a simple calculation, but the additional attention that gets applied. It wouldn't surprise me if the majority of the gain comes from not instruction level optimisation, but calculation level optimisation.
For example, how do you find the last word in a string? Have a look on stackOverflow and you will see examples in many language that are the equivalent to.
var lastword = fullString.split(" ").pop();
The work done by this operation is easier and easier to overlook as things get higher level.
I have often wondered on the merits of writing a virtual assembly instruction set that is platform agnostic (so compiles/transliterates to native) to explore this idea. It wouldn't be like JVM bytecode which implements higher level magic, and it wouldn't be like LLVM which is not aimed at being human writable. Some existing RISC instruction sets might be close to what is needed. There would be potential to write things in multiple instruction sets, If the interfaces between code sections are well defined (stack/register/memory passing) you could write modular code in a preferred Instruction set.
This isn't practical for many applications, but I'm not convinced that doesn't have a possible niche.