Elektrine lite

← Feed

@ela@infosec.exchange

Post #2639734

2025-05-16 05:51 UTC

@loke@functional.cafe The problem here is that the compiler can't tell if something is just an idiomatic expression or bad coding. In fact, such warnings might even distract programmers from getting things right. It's very important to keep in mind that source code has a dual purpose. Yes, it instructs the computer what to do, but computers are perfectly fine with machine instructions. Much more importantly, source code exists for humans to read, understand and reason about. Premature optimization is the root of all evil. The primary goals of writing code must be correctness and readability, with correctness often being influenced by readability. Sure, some code needs to be super fast. Your interrupt handler for that 10GB network card? This code doing the task switching in your OS? Absolutely. Every cycle counts. But in order to achieve this, you need to measure. I've seen a lot of theories about performance improvements collide hard with the realities of modern CPU and compiler architecture. Always profile, always measure, always benchmark. And for that precious lines of code, modern compilers are happy to infodump on you every step they take.

Replies (1)

  • @ela@infosec.exchange @loke@functional.cafe There's a lot of examples of this. Like mergesort vs quicksort (yes, no one uses vanilla quicksort but I would argue that it's closer to quick than merge). And then in network science you have these algorithms where runtime is around cubic and whether quadratic, cubic or tertiary is the right choice very much depends on the properties of your graph, like actual size, rather than what happens when n goes towards infinite. Edit: urgh, I'm being a reply guy. Sorry. Graphs are neat.

    Open ##2639735