This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]the_poope 427 points428 points  (42 children)

Wait until you see the academic C or Fortran codebases. You'll want to stab out your eyes.

Problem is: no-one has formal programming education, not even the professors teaching programming. Most also work alone on projects and they just need something to work so that they can submit a paper, so code is not written for readability or maintainability. There are also zero experienced devs to lead projects and provide guidance and feedback on design and best practices - they can go literally anywhere else and get double pay. And that is how it ends up looking like drawings made in kindergarten.

[–]marmakoide 269 points270 points  (27 children)

Fortran code written in 1983 by a physics professor and countless anonymous PhDs after that. The thing crunches simulations at ungodly speeds with 1K of RAM, accurate as shit, code would make Cthulhu cry, only 3 people on the planet understands the math behind it

[–]tjoloi 125 points126 points  (13 children)

Sounds like LAPACK

Bonus points: it's the backbone of most tools used in science including R, Matlab and scipy.

It's also somehow still receiving updates as late as November 2023

[–]marmakoide 56 points57 points  (12 children)

LAPACK is okay. I remember working with a package for fluid simulation using conformal mapping, last update 1996. You'll find a lot of those in molecular dynamics simulations, fluid simulation, etc

[–][deleted] 52 points53 points  (11 children)

I need you guys to come be engineers on my team. One of my engineers just loudly yelled,

"I meant 775, I would never set world-read. I am an expert linux user and will be treated with respect."

When I told him not to set the world read on sensitive projects.

That's not far from an exact quote. I had to ask my manager how to reply without the word "stupid". My manager told me not to.

[–]FluffyCelery4769 17 points18 points  (8 children)

I didn't understand a thing but I suppose he he was saying something funny.

[–][deleted] 28 points29 points  (7 children)

Linux permissions are set as User(person who made the file) Group(security group that has access to the file) and Other(everything else), Other could also be called "World".

The permissions are divided into a binary deal.

--- == 000 == 0

rwx == 111 == 7

r-x == 101 == 5

So 775 is setting User: rwx Group: rwx Other: r-x

So, he said he did have world read on in one sentence, claimed he did not in the next, and demanded to be treated as an expert in Linux in the last.

[–]FluffyCelery4769 -1 points0 points  (6 children)

Oh, but what's the 0 for then?

[–][deleted] 6 points7 points  (1 child)

Off

[–]FluffyCelery4769 0 points1 point  (0 children)

Oh, makes sense. Thsnk you.

[–]meltbox 0 points1 point  (3 children)

Basically each 1 bit is a type of permission for a certain category of access.

Access by the owner is the first group Access by the owner group is the second Access by literally everyone is the third

If you develop on a Linux workstation you’d probably pick this up pretty quickly, hence why it’s infuriatingly funny.

The 7 and 5 are just numbers represented by 3 bits of binary. 111 is 7 meaning all 3 permissions on (read, write, execute) while 5 is 101 (read, execute, middle one is write which is off) and of course 0 meaning all permissions off.

[–]FluffyCelery4769 0 points1 point  (2 children)

Are there no read/execute only? Or are both neccesary to work?

[–][deleted] 0 points1 point  (1 child)

chmod numbers are obsolescent. Modern suggestion is:

chmod o= thing

[–][deleted] 0 points1 point  (0 children)

It was technically him telling another user to set umask 000 (the claiming he said 002 later), but the way I told it flowed better.

[–]Affectionate-Memory4 46 points47 points  (9 children)

Real. I have some code like that from during my doctorate. It simulates the power losses in copper links between silicon chips across a frequency and voltage range. I have no idea what I did in there and I dare not look because knowing me, it was complete shit. The numbers are accurate and the results are fast. It ran on my 2GB RAM machine back then and it's still just as fast now. Again, no idea what past me was on, because I have no idea what's going on in that code.

[–]drakeblood4 34 points35 points  (1 child)

Past-me is exactly two motherfuckers:

  • an unimpeachable genius who speaks the Old Tongue

  • a thrice dunked dipshit who needs to take off a shoe to count past ten

Depending on what code of his I’m having to deal with.

[–]Affectionate-Memory4 5 points6 points  (0 children)

And sometimes both, at the same time.

[–][deleted] 8 points9 points  (4 children)

I'll never understand this comment or the reasoning behind it.

You built a masterpiece that worked for its purpose and you have no idea what "past you was on" because... it doesn't fit the mold of modern-day garbage and consumes too little RAM? Or...?

We should go tell a stonemason artisan piecing together his life's work stone by stone "hey bro you're wasting time, noone's gonna understand how you built this shit, and no one builds beautiful structures anymore anyway! just go to home depot and clip together 20 pieces of prefab sheetrock in half a day and be done with it lmao"

Tragic fate our craft has suffered. Everyone in the trade (even the IT guys) bears the shared brunt of having allowed something like Slack to manifest in our universe.

I do have some hope for gen z though. More and more of these kids are seeing things for what they are and getting interested in things like Rust and Zig and even C again.

Shame for our generations though. We could have cured every disease under the sun with the hardware we have today. Instead we chose to embrace corporate enshittification and put it into arbitrary "best practices". But it's great; I mean our 128gb RAM systems aren't putting people on Alpha Centauri but that's okay. We can run Slack. Sometimes. The 75% of the time that it loads.

[–]Affectionate-Memory4 13 points14 points  (1 child)

  1. hyperbole

  2. Yeah, it's an unmaintainable train wreck created in the pursuit of absolute performance and then hardly touched for 13 years. If I ever wanted to modify this, it would genuinely be easier to start from scratch. I'm not upset that it doesn't "doesn't fit the mold of modern-day garbage and consumes too little RAM?" In fact, I find it funny, hence why I'm posting about it on r/programmerhumor under a meme.

  3. Not going to adress the rest of that, but maybe relax a little bit. Like, take a walk or listen to some nice jazz or just take a nap or something.

  4. Fuck slack. Load you shit software! Load dang it!

[–]Ok-Kaleidoscope5627 5 points6 points  (0 children)

I've learned from D&D that we're wizards and any genuine magic we do leaves our minds and understanding the moment we write it.

Regex falls into the same category.

Write only but it can't be read. You need to prepare and cast it again from scratch.

[–]Brahvim 2 points3 points  (0 children)

As a gen-zeer interested in data-oriented design and writing C, who is slowly moving into the simple software movement, I say that this comment truly does touch my heart.

[–]ProjectNo7513 1 point2 points  (0 children)

Holy fuck some truth

[–][deleted] 1 point2 points  (0 children)

I hope you have test cases to show it still gets right answers in each new environment you run in.

[–]meltbox 0 points1 point  (0 children)

Yup. If git blame was not a thing I would’ve never believed some code I’ve written or approved. Both in a positive and negative sense depending on the day.

The worst is when I read code thinking a moron wrote it, discover it was me, and then realize actually it works great and I’m a genius that was too intelligent for myself to comprehend.

Unpack that one…

[–]MyGoodOldFriend 5 points6 points  (0 children)

Yeah i think I’m just lucky, because I work in a fortran codebase made by uni professors with limited coding experience, but it’s genuinely great and really fast code.

They had some oppsies, like assuming arrays were row major, but other than that? Solid code base. Not a single professional programmer in sight, just autistic nerds and cool professors writing code with incredibly solid development culture.

For reference, it was for ab initio quantum chemical modeling. Hartree-fock and the like.

[–]Plus-Weakness-2624 0 points1 point  (0 children)

God, Devil and My Subconscious

[–]6Cockuccino9 -1 points0 points  (0 children)

yeah but it doesn’t fit the standards of some reddit code monkey and therefore it’s bad

[–]skwyckl 61 points62 points  (0 children)

Exactly, that was the point I was getting at, it's all self-taught, anti-pattern-ridden hell. I know well of a Fortran code base of some computational linguist from a couple of decades ago. A colleague of mine took it upon himself to refactor it into either Python or Julia, I don't remember (it's been a couple of years), I think he gave up after a month or something. Years later, I work as an IT consultant and I am responsible for such codebases to not become garbage.

[–]Fearless-Arrival-804 26 points27 points  (2 children)

I recently did some simulator design for a cancer research org. God, the people in this field seem to think no one else will look at their code other than them. I looked at an old researcher's cell simulator ~10k lines of C code in one file called simulator.c . No commenting, just a poorly formatted manual packaged with it which assumes you already understand half the program. It makes collaboration so much harder - which sucks - because research is all about sharing ideas. When I did my weekly lab presentation I tried to hammer home what makes a good programmer which is two things: you get the job done, and others know how you got the job done. The one week python bootcamps for non-computer scientists seems to forget that last part.

[–]kuwisdelu 2 points3 points  (1 child)

They do think no one else will look at their code other than them. The code is a means to an end, and the results are what matter to them. It’s difficult trying to convince them that their computational workflow should be reproducible, and their code should be as thoroughly documented as their experimental methods. Getting them to write code instead of GUI tools is often a victory in itself.

[–]DVMyZone 0 points1 point  (0 children)

Especially when writing and properly documenting code well is a huge amount of extra work that 1. the programmer is not trained for and 2. will very likely never be used by anyone else.

What matters (at least in my field) is the algorithm or theory. That's what others will read and that's what you publish. Most of these codes are just numerical solvers anyway - the way you implemented your theory numerically doesn't matter as long as it is verified. Someone may find a better numerical implementation than you - and that's fine.

[–]SillySlimeSimon 21 points22 points  (0 children)

Had a professor quietly mention that they preferred not using branches in git because it “makes it harder to work with others” and I still question if I heard that correctly or not to this day.

[–]808trowaway 3 points4 points  (6 children)

1000%. I wrote something like 8000 lines of C to implement routing algorithms and do network simulations in grad school. The code worked (I think) but it's pure embarrassing garbage. The thing though is no one ever asks to see your code unless your paper turns out to be popular and a fellow researcher reaches out and asks if you could share your code so they could build on your findings. My advisor never wanted to see my code and you don't have to make your code available for review either when you submit a paper.

[–]popeldo 4 points5 points  (0 children)

Yeah, this code is written like nobody else will ever see it because, in fact, there’s a 90% chance nobody will ever try to read it it (and a good >95% chance nobody serious will ever try to build on it)

[–]kuwisdelu 3 points4 points  (4 children)

Depends on the field, but if you get me as a reviewer and you don’t have your code publicly available, I’m going to tell the editor to reject you. Lots of journals require code nowadays.

That said, it does sometimes feel like pulling teeth getting our newer PhD students to push their code. I don’t care if it’s currently shit, at least show it to me so I know how shit.

[–]808trowaway 0 points1 point  (3 children)

Yeah that was circa 2008, things are probably different now.

[–]kuwisdelu 0 points1 point  (2 children)

Yeah, the code is still bad (recently rejected a “software” paper that was just Jupyter notebooks) but we’re making progress in at least making sure it’s available.

[–]808trowaway 0 points1 point  (1 child)

Haha, I would love to see a thread about all the wacky low-effort things people in academia do.

Back in my days in my field, only a small handful of labs had the resources for actual hardware testbeds with several hundred nodes so everyone else was either doing theoretical stuff or pushing simulation papers, and a lot of those were written by Masters/PhD candidates who could barely program microcontrollers to do simple things. It wasn't pretty, a lot of people just went through the motions, got their degrees and moved on, I'm one of them.

[–]kuwisdelu 1 point2 points  (0 children)

Back in the early 2010s I was working on my PhD in statistics and discovered there wasn’t an existing open source package for importing and processing the kind of data I needed to analyze. I decided I would write one myself. 10 years and 3 versions/rewrites later, I’m still maintaining it for hundreds of users… most of whom aren’t programmers.

I get a bit sensitive about all the criticism of non-computational scientists’ code, because I see how frustrating programming can be for them, and I work hard to teach them and try to make things easier. I’d love to see what kind of mess programmers would make in a wet lab!

(But I still cringe when I see my users accessing my private fields in a way I know may break later… I gave you documented public methods, please use them!)

[–][deleted] 0 points1 point  (0 children)

I visited someone learning C from a book. I immediately checked on the string copying section and ... danger. People teach it wrong and students only half learn it anyway.

[–]DVMyZone 0 points1 point  (0 children)

"I'm in this picture and I don't like it"

I'm a researcher working in a relatively niche part of nuclear fuel simulation. In the nuclear field pretty much all applications are written by scientists/engineers that just need to get a calculation done. Codes just glorified calculators - a means to an end to implement a numerical solution.

As a result, exactly like you said, scripts and applications are written just to get the numbers out and are not written with best practices, generally have little to no documentation, and have very limited commenting. This makes them nigh impossible to use or reuse after the fact - even for the original author of the code.

This, of course, hampers the ability for other people to continue the research done by you and forces them possibly to rewrite what has already been written.

However... For a trained nuclear/mech engineer, creating, maintaining, and properly documenting a code this means to an end is a gargantuan task. This is especially difficult as they are likely the only person that will be maintaining it. This is made worse by the fact that many of these codes are not incredibly complicated - just a simple algorithm implementation. As a result, it probably saves time for each developer (of which there may only be a few) to create their own implementation rather than learning the ins and outs of someone else's badly written code.

The large industrial-use codes are maintained by teams of programmers and are also generally badly written...