this post was submitted on 12 Mar 2024
14 points (93.8% liked)

Programmer Humor

32039 readers
969 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 

Please dont take this seriously guys its just a dumb meme I haven't written a single line of code in half of these languages

top 43 comments
sorted by: hot top controversial new old
[–] [email protected] 3 points 6 months ago (2 children)

missing the stage of C where it's all incomprehensible bitfucking with comments like "this works, i do not know why it works, do not touch this"

[–] [email protected] 1 points 6 months ago (1 children)

Real fast inverse square root algorithm hours

[–] [email protected] 1 points 6 months ago (2 children)

That one is not that complicated if you don't think about the math. It's basically just if we interpret the float as int and add a magic number we have a good estimation.

From what I remember at least, it's been a little while since I implemented it.

[–] [email protected] 1 points 6 months ago (1 children)

IIRC also relying on how floating-point is basically scientific notation and the most-significant bits are the exponent.

And most importantly, relying on how a sloppy answer works just fine. The most important skill in game development is cheating.

[–] [email protected] 1 points 6 months ago

The most important skill in game development is cheating.

Makes me feel better about my own game dev attempts lmao.

[–] [email protected] 1 points 6 months ago

I was more thinking of the comments which are pretty much exactly what you said ("incomprehensible bit hacks" followed by "what the FUCK?")

[–] [email protected] 1 points 6 months ago

C should show some overflow corruption of the problem graphic.

[–] [email protected] 3 points 6 months ago* (last edited 6 months ago) (2 children)

Latex: Problem --> \def\please@#1#2#3#4{\e@kill#2#3{\me#1}#4@now} -->

[–] [email protected] 2 points 6 months ago (3 children)

Accurate. LaTeX is great, it makes you feel like you have superpowers compared to "office suite"-style software. But every once in a while you just run into some bullshit that feels like it's stuck in 1985 and it completely breaks your flow. I remember wanting to make a longtable where text in the "date" column would be rotated by 90 degrees to leave more horizontal room for the other columns. It took me two rotateboxes, a phantom, a vspace, a hspace and 40 minutes of my life to get the alignment right. Would probably have taken a duckduckgo search and three clicks in Libreoffice.

[–] [email protected] 1 points 6 months ago (2 children)

btw what do you think about typst?
i only used it for simple stuff so far but it seems pretty fun and easy to use

[–] [email protected] 2 points 6 months ago (1 children)

Never heard of it before, but might give it a try at some point. From the website, it seems like something halfway in between LaTeX and Markdown? Sounds exactly like what I need at times, tbh.

[–] [email protected] 1 points 6 months ago

yeah it's perfect for taking notes and stuff

[–] [email protected] 2 points 6 months ago

My two cents, after years of Markdown (and md to PDF solutions) and LaTeX and a full two years of trying to commit to bashing my head against Word for work purposes, I'm really enjoying Typst. It didn't take long to convert my themes, having docs I can import which are basically just variables to share across documents in a folder has been really helpful. Haven't gone too deep into it but I'm excited to give it a deeper test run over the next little bit.

[–] [email protected] 1 points 6 months ago (1 children)

I still have no idea how to exit the build process. It tells I need to type H or \end but it also just lies. I find the easiest way is to invoke Ctrl-Z and then kill the background process, and the ~~younglings~~ children

[–] [email protected] 1 points 5 months ago (1 children)

Yeah, what the hell is up with that? I always just echo | pdflatex to make it shut up and exit on error. Maybe one day I'll learn how to actually use that interactive compilation thing, but not today lol.

[–] [email protected] 0 points 5 months ago (1 children)

wait how does your hack work?

[–] [email protected] 0 points 5 months ago (1 children)

So there are many different commands that compile LaTeX, right? pdflatex, pdftex, latexmk, etc. But they all do that thing where they ask for your input as soon as they encounter an error, right? Well, if you just pipe an empty echo command to them, it notices that stdin has reached end-of-file, and gives up trying to ask the user for input, and just exits on first error. So instead of pdflatex mydocument.tex, you can do echo | pdflatex mydocument.tex and it won't ask you for input if it sees an error, it'll just exit. There's probably a "proper" way to achieve the same behaviour, but I can't be arsed to read the docs.

Speaking of stupid TeX hacks, at one point I had a script called latex_compile_and_install_packages_until_it_works.sh. It's essentially a loop that repeatedly tries to compile a document, searches the output of the compiler for anything that looks like a missing package error, and pipes it to sudo tlmgr install. The "fuck it" of package management, arbitrary code execution exploit included!

(Sorry for the screenshot, I lost the original script in text form, probably for the better)

[–] [email protected] 0 points 5 months ago (1 children)

Haha that's brilliant! I have a similar script for Conda, where it tries to install R packages by first looking in bioconductor and then trying the rejects through conda-forge, and then the rejects from that are compiled from source or just outright rejected.

I would have thought you would have needed a (while :; do echo; done) | pdflatex or a yes "\end" | pdflatex, i.e. something that repeatedly generates output. It's actually quite elegant that pdflatex checks if stdin is already EOF

[–] [email protected] 0 points 5 months ago (1 children)

tries to install R packages by first looking in bioconductor and then trying the rejects through conda-forge, and then the rejects from that are compiled from source

Just do all of these in parallel to maximise the change of installing the correct version

[–] [email protected] 1 points 5 months ago

lmao, though it's noticeably missing pacman, guix, and "pkg install "should be "pkg add" :P

[–] [email protected] 1 points 6 months ago

it makes you feel like you have superpowers compared to "office suite"-style software

Especially the installation process

[–] [email protected] 1 points 6 months ago (1 children)

I got way too excited Lemmy parsed LaTeX for a second

[–] [email protected] 1 points 5 months ago

Testing 123

$$ \sigma $$

aww.....

[–] [email protected] 3 points 6 months ago
[–] [email protected] 3 points 6 months ago (3 children)

Every programming language has it's place.

JavaScript's place is in hell.

[–] [email protected] 2 points 6 months ago (1 children)

What makes JavaScript so widely disliked? I know very little of it, and in skimming different stuff I think I've seen like a million different frameworks for it, so is that a part of it?

[–] [email protected] 3 points 6 months ago

It was mostly made for simple scripts to embed on a website for animations and handling updates without refreshing whole page. Not to make a full portable client (browser) side app.
Hating JavaScript is mostly a meme, it's just a programming language. But its very loose syntax, fact it's often someone's first programming language to learn and how most programs written in it nowadays are a hack build on top of a hack on top a hack makes this language easy to laugh at.

[–] [email protected] 2 points 6 months ago

JS is ironic punishment as a programming language. It's fun to screw around in! And then you have to use it for stuff, and pain ensues.

[–] [email protected] 2 points 6 months ago

I used to think Javascript was hell when I barely used it. Now I have to build with it regularly and... once in a while I'm just right about things.

[–] [email protected] 2 points 6 months ago (1 children)

C: "Segmentation fault."

Where?

C: 🤷🏻

[–] [email protected] 2 points 6 months ago

C: gestures vaguely everywhere

[–] [email protected] 1 points 6 months ago

PHP: Problem -> real_solution_for_real_this_time() (real_solution_i_swear() is unsafe and deprecated)

[–] [email protected] 1 points 6 months ago

The line between problem and solution for C should be 30 miles long.

[–] [email protected] 1 points 6 months ago (1 children)

python is like that. someone waay smarter than you have already done this 10 years ago.

[–] [email protected] 1 points 6 months ago (1 children)

Idk I still like writing my own stuff purely pythonic when I can. Pythons syntax is the most “fun” and “natural” for me so I find it fun. Like doin a sudoku puzzle

[–] [email protected] 0 points 6 months ago (1 children)

I can't get over the load-bearing whitespace.

[–] [email protected] 1 points 6 months ago (1 children)

This is the best way I’ve ever heard this described lol. You get used to it so fast, it’s really simple. Just indent your code like you’re supposed to 🤷🏻‍♂️

[–] [email protected] 0 points 6 months ago (1 children)

The problem is that Python programmers tend to think the job of readability is done just by indentation. This is wrong, and it shows in all sorts of readability issues. Many of which are in official docs.

[–] [email protected] 1 points 6 months ago* (last edited 6 months ago) (1 children)

Same could be said about people that ~~don't~~ think that indentation is not important for readability. Both are important, but if you really care about it defining an auto formatter and customising it for whatever consensus the team has is the only way to operate anyway.

[–] [email protected] 1 points 6 months ago (1 children)

Same could be said about people that don't think that indentation is not important for readability.

You should really avoid double negatives. What you actually said was "Same could be said about people that think that indentation is important for readability“, which makes no sense in the context of the rest of your post.

And I'm not saying this just to be a dick about grammar. I mean, obviously I am, but not just that. If your English isn't readable, then I don't trust your Python, either.

[–] [email protected] 1 points 6 months ago

My bad, I deleted part of the comment to rewrite it and forgot part of the original. And as you probably guessed I meant for it to be a single negative.

Good thing this is a casual forum and not a work environment where I would reread my code with care haha. There's a reason linters exist in code editors, it's for people like me.

[–] [email protected] 0 points 6 months ago (1 children)

Actual C: Problem → Segmentation fault

[–] [email protected] 1 points 6 months ago

Actual Problem: C → Segmentation Fault