News for hackers. Stuff that matters.
Re:KolibriOS – operating system written entirely in assembly... by londons_explore on Wednesday April 15, 2020 @04:18AM (#22875623)
I think one element of writing ASM by hand is the programmer subliminally changes the algorithm to be 'simpler' to write.

In Java, that might involve adding more classes and abstractions to make things conceptually simpler. In C, that might involve using structs to keep relevant data together. In C++, it might involve using a std::set to keep a list of 3 constants, Etc.

It turns out that when you have to write the asm by hand and you see that double pointer dereference is a pain, you avoid data structures with double dereferences (as C data structures often end up with). You avoid classes and abstractions (as are common in Java), because they involve a lot of boilerplate. You use compile time constants for that set of three things rather than any complex hashing that C++ would do, etc.

There are lots of small things like this, and it turns out the effect adds up significantly.

Re:KolibriOS – operating system written entirely in assembly... by wiz21c on Wednesday April 15, 2020 @08:01AM (#22876714)
>> I think one element of writing ASM by hand is the programmer subliminally changes the algorithm to be 'simpler' to write.

I strongly disagree :-)

My experience is that optimizing assembler leads to reorganize your code or even your algorithm into a form that you'll CPU will be most efficient at executing which almost always translate to unbelievably intricate, super hard to modify code. I've done stuff on 6502, 80x86, MMX and the assembly parts, optimized for speed and ended up with impossibly tricky code. Worst, sometimes I have to adapt my data structures to allow optimization, which becomes even tougher. So, I prefer to leave assembly code at the "onyl if necessary" level

But now, to be honest, optimizing assembly code is incredibly satisfying to me :-) I've got the feeling to use a CPU to its maximum capacity. Also, using assembly comes after thorough algorithmic study. So once I'm at the ASM level, I've maxed out my own capabilities ! How happy me !

So if you have the chance to do that, just give it a try !

Re:KolibriOS – operating system written entirely in assembly... by arghwhat on Wednesday April 15, 2020 @08:23AM (#22876866)
I suspect that this occurs for you exactly because you're aiming for optimization. This can happen in any language, really.

I'd assume that when you maintain larger codebases (i.e. full OS and application suite), that you start writing practical and maintainable code instead.

Re:KolibriOS – operating system written entirely in assembly... by wiz21c on Wednesday April 15, 2020 @12:40PM (#22879853)
ahhh I'm biased. Your analysis is right :-)

But even so, I'd say that ASM doesn't help. Clumsy code in ASM is worse than clumsy code in high-level language :-)

Re:KolibriOS – operating system written entirely in assembly... by fouc on Wednesday April 15, 2020 @10:14PM (#22885402)
If you write assembler in a maintainable way, do you still gain lots of benefits over a compiler?
Re:KolibriOS – operating system written entirely in assembly... by _never_k on Wednesday April 15, 2020 @11:25AM (#22878818)
>I think one element of writing ASM by hand is the programmer subliminally changes the algorithm to be 'simpler' to write.

It's not subliminal. It's packing a backpack that someone else has to carry, vs packing a backpack that _you're_ going to carry.