3 ms·
A minimalist lifestyle does not make you a better person But a minimalist coding style does make you a better programmer. I really don't mind a few extra Phil
by edw519 16y ago
A minimalist lifestyle does not make you a better person
But a minimalist coding style does make you a better programmer.
I really don't mind a few extra Philips screwdrivers, kitchen knives, or pairs of shoes in my house, but I every superfluous bit of code in my repository drives me nuts.
Others say I go overboard and they're probably right, but I can't help myself.
If a 6 character variable name can be shortened to 5 characters without losing meaning, then I do it. Same thing with labels and function names. If I find the same line of code twice, I write a function (but only after whipping myself). Complex If Statements are replaced by Case. Complex Case Statements are replaced by arrays and pointers. Two programs look alike? Replace them with one parameter-driven program. Two forms look alike? Replace them with a flexible form app. Reports? Same thing.
Old data? Archived! Old programs? Archived! Old notes? Archived! And not one trip to Goodwill, just to my e: drive. I'm so proud of myself when I can fit the software needed to run a $100 million company on a 256K thumb drive.
There must be a 12 step program for people like me. But then, by the time I was done with it, it would be a 7 step program.
- robryan 16y agoGoing a bit off topic but I really hate when you have a bit of code you can either have 2 functions with some repetition or one function that gets ugly because of the number of if statements required based on parameters. Both options feel suboptimal.
- HeyLaughingBoy 16y agoI've found that sometimes passing in a function/function pointer as a parameter makes this a lot cleaner.
- fragmede 16y ago> If a 6 character variable name can be shortened to 5 characters without losing meaning, then I do it. So.... what, you get rid of vowels, web 2.0 style?
- Raphael_Amiard 16y ago> If a 6 character variable name can be shortened to 5 characters without losing meaning, then I do it While i totally agree with the general sentiment of your post, i'm really not sure about this one. Or rather, im rly not sure abt dis one ;) It's all about balance really, and very often this balance is only subjective, even if we generally don't like this idea
- tome 16y agoSure, but to be charitable to edw519, it's possible to interpret the remark as "can be shortened ... without compromising meaning".
- Raphael_Amiard 16y agoDefinitely, that's why i said i agreed with the general sentiment. I generally reason in exactly the same way so i understand from where GP is coming from.
- T_S_ 16y agoInteresting example. In Mathematica, they opted for fully spelled out function names with caps to indicate new words for minimal ambiguity. For example LinearSolve is not linsolve or lnsolve or lsolve or even ls as it is in other languages or libraries. This makes the names of standard mathematical functions easier to remember or guess at. Your minima may not be my minima!
- threepointone 16y agoHere's an example regarding this that affects me in javascript - var t = this; and then every time I refer to 't', I save 3 bytes. It's something js compressors can't do, and every byte counts in the end :)
- sprout 16y agoIf a six character variable name is a real word and the 5 character variable name isn't, in my mind you've increased the number of objects in every statement that variable appears in from 1 to 5. Now, there are some really common ones that are more or less idiomatic. i is iterator, ct is count. That said, those save a lot more than 1 character.
- MichaelGG 16y agoIf statements? Case statements? Arrays and pointers? If you want minimalism, pickup a functional language and go pointfree.
- jules 16y agoThe thing is that sometimes when you've removed the redundancy you end up with a program that's more complex than the one you started with.
- peterbessman 16y agoToward the end the author says: "Simplicity" is a relative term, and perhaps inapt; try "convenience", which has more useful connotations. The lifestyle he describes and the programming style you describe are both, in the final analysis, maximally convenient (ceteris paribus). While not as catchy as "minimalism," I think convenience maximization (or time-debt minimization, as Patrick McKenzie might say) is a worthy objective. Perhaps call it "enlightened laziness" for that added sparkle.