Style
What is a coding-style?
As programmers we write code in C.
If you don't write in C, I don't fuck with you, I don't care about you, I don't like you (but the rest of this text should also apply to you).
Anyway, C has a grammar.
The C grammar is a set of rules defining the language.
You have to respect those rules.
A coding-style is soft extra rules on top of C existing grammar.
Why soft? Because your code should compile even if you break coding-style rules.
Why you should have style?
Coding-style rules are not mandatory, but it is mindblowing-useful to have them.
Is like being sexy. You don't need to fit, you don't need to respect the (inexistent) standards of beauty.
Everybody can be sexy, everybody can have style.
If you are sexy, you attract people. There is no need to chase them.
If you write sexy code, skilled and sexy developers will help you.
They will like you even if your binary is crap. They will fix the issues, and make your binary sound.
Why? Because they like sexy code.
How to be sexy?
Never say 'I am sexy'. Arrogance is bad, don't jerk off on your own code.
Accept whenever someone tells you 'you are not sexy'. Criticism is good, it helps you grow.
Ignore compliments from un-sexy people.
To me, SEXY source code is:
- Systematic: a coherent body of ideas.
- Easy: simple, short, uncomplicated to understand.
- Xplorable: written for the active reader (check this https://worrydream.com/ExplorableExplanations/).
- Yours: shaped by your own logic and taste.
But how to get there?
Find a mentor, someone you find sexy, start from there.
Mesure the sexyiness of your mentor by reading its code, inspire yourself.
Evolve, realize your menotr was full of bullshit, become your own mentor.
After a while, realize you lack of something and go back to (1).
One of current problem of LLMs and so called 'AI' is their lack of sexyness.
Maybe I am a bad prompter, but whenever I try to generate code with AIs, it's simply ugly.
Lack of mentors?
Read what Rob Pike thinks: https://doc.cat-v.org/bell_labs/pikestyle.
Read what Grug thinks: https://grugbrain.dev
Read what Linux Kernel thinks: https://www.kernel.org/doc/Documentation/process/coding-style.rst
Read what OpenBSD Kernel thinks: https://man.openbsd.org/style
Note:
You do not need JS to read these articles. Don't get me wrong. I personally love JS. But why the fuck everybody asking me to run minified obfuscated JavaShit code on my machines? Disable JS and never go back. If your eBanking requires JS, do not use eBanking. Understand your freedom.
The problem with existing coding rules.
It is usually the boss/mantainer of group/project that picks the coding style rules to follow.
Unfortunately those people are most likely completley wrong about everything they do.
If they are not completely wrong, they simply suck, meaning: they are not sexy.
Everyone should be
If you are properly authistic, you should:
Write a grammar for your coding style.
Write a script/program that checks if you are respecting your own style.
When you feel the need of breaking your own rules, write new grammar first.
Whenever you write a new grammar, write a script/program that re-fromats existing source code.