this post was submitted on 03 Apr 2024
1331 points (98.8% liked)

Science Memes

11130 readers
3096 users here now

Welcome to c/science_memes @ Mander.xyz!

A place for majestic STEMLORD peacocking, as well as memes about the realities of working in a lab.



Rules

  1. Don't throw mud. Behave like an intellectual and remember the human.
  2. Keep it rooted (on topic).
  3. No spam.
  4. Infographics welcome, get schooled.

This is a science community. We use the Dawkins definition of meme.



Research Committee

Other Mander Communities

Science and Research

Biology and Life Sciences

Physical Sciences

Humanities and Social Sciences

Practical and Applied Sciences

Memes

Miscellaneous

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] rockerface@lemm.ee 227 points 7 months ago* (last edited 7 months ago) (7 children)

As a software developer, the less ambiguous your notation is, the better it is for everyone involved. Not only will I use brackets, I'll split my expression into multiple rows and use tabs to make it as readable as humanly possible. And maybe throw a comment or 2 if there's still some black magic involved

[–] dustyData@lemmy.world 65 points 7 months ago (6 children)

As a professor said, most programming languages don't care about readability and whitespace. But we care because humans need it to parse meaning. Thus, write code for people, not for the machine. Always assume that someone with no knowledge of the context will have to debug it, and be kind to them. Because that someone might be you in six months when you have completely forgotten how the code works.

[–] zalgotext@sh.itjust.works 18 points 7 months ago

Exactly. You read code way more times than you write it, so it makes all the sense in the world to prioritize readability.

[–] Swedneck@discuss.tchncs.de 13 points 7 months ago

Source code is for humans, then the compiler turns it into code for machines.

[–] oce@jlai.lu 7 points 7 months ago (1 children)

Python forcing end of line and tabs kinda does. Add Black auto-formatter and it's pretty good.

[–] frezik@midwest.social 1 points 7 months ago (1 children)

I've seen too many Python devs write out complex statements all on one crammed up line. Including some that are in the main docs.

Enforced whitespace is just one aspect of readable code. There are many others, and Python is no better at enforcing those than any other language.

[–] oce@jlai.lu 2 points 7 months ago

That would probably make very long lines and black would automatically add returns to line with proper indentations. But it has a a limit for sure. If you chain many list comprehensions it's going to be a mess.

[–] rockerface@lemm.ee 6 points 7 months ago* (last edited 7 months ago) (1 children)

Yep, if you're writing code for a machine, just do it in binary to save compilation time (/s just in case). Also, you in six months will indeed be someone with no knowledge of the context. And every piece of code you think you write for one-time use is guaranteed to be reused every day for the next 5 years

[–] Mic_Check_One_Two@reddthat.com 20 points 7 months ago

And every piece of code you think you write for one-time use is guaranteed to be reused every day for the next 5 years

[–] feinstruktur@lemmy.ml 5 points 7 months ago

This. Always be kind to your future self.

[–] snowsuit2654@lemmy.blahaj.zone 2 points 7 months ago

Yeah I totally agree. You can minimize and optimize as part of your build procedure/compilation but the source code should be as readable as possible for humans.

[–] Quetzalcutlass@lemmy.world 59 points 7 months ago (1 children)

I had someone submit a pull request recently that, in addition to their actual changes, also removed every single parenthesis that wasn't strictly necessary in a file full of 3D math functions. I know it was probably the fault of an autoformatter they used, but I was still the most offended I've ever been at a pull request.

[–] rockerface@lemm.ee 29 points 7 months ago

Autoformatter? More like obfuscator

[–] MotoAsh@lemmy.world 9 points 7 months ago

I genuinely hate being human for this stuff. So many things have such crazy computational shortcuts, it's sometimes difficult to remember which part represents reality. Outside of the realm of math, where "imaginary" numbers are still a touch of enigma to me, so many algorithms are based on general assumptions about reality or the specific task, that the programmatic approach NEVER encapsulates the full scope of the problem.

As in, sometimes if you know EXACTLY how a tool works, you might still have no idea about the significance of that tool. Even in a universe where no one is lazy, and everyone wants to know "why?", the answers are NOT forthcoming.

[–] penquin@lemm.ee 3 points 7 months ago

You're a good human being.

[–] neidu2@feddit.nl 1 points 7 months ago

As someone who used to code in Lisp, I'm all for excessive paranthesis use.

[–] stebo02@lemmy.dbzer0.com 0 points 7 months ago

Ok but that's unrelated to putting some numbers and operations in a calculator. No one is going to proofread that. If anything, you simply calculate it again.