this post was submitted on 17 Dec 2025
515 points (96.4% liked)

Programmer Humor

28016 readers
1457 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] Lembot_0006@programming.dev 23 points 1 week ago (5 children)

FORTRAN isn't a beauty either.
And Python is strange as hell with its mandatory tabs.

[–] bleistift2@sopuli.xyz 22 points 1 week ago (2 children)

You can use spaces in Python.

[–] marduk 23 points 1 week ago (7 children)

Two, three or four spaces? If you answer wrong I'll never forgive you

[–] ChaosMonkey@lemmy.dbzer0.com 2 points 5 days ago

Depends on the mood.

No one will ever know. That is my editor's job. XD

[–] TeamAssimilation@infosec.pub 16 points 1 week ago

Whatever your place defines as a standard. I’ve seen ugly code in C, JavaScript, Java, etc., that uses them all over the place because they’re not mandatory.

If you don’t have consistent indenting, your code looks like copy/paste from several sources; but if you do have consistent indenting, then the indenting of Python is a non-issue.

[–] qjkxbmwvz@startrek.website 7 points 1 week ago (1 children)

Per the Linux kernel coding style:

Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even 2!) characters deep, and that is akin to trying to define the value of PI to be 3.

[–] hemko@lemmy.dbzer0.com 8 points 6 days ago

First off, I’d suggest printing out a copy of the GNU coding standards, and NOT read it. Burn them, it’s a great symbolic gesture.

[–] fartsparkles@lemmy.world 6 points 1 week ago

I’m rather partial to five myself but only when I’m feeling fancy.

[–] firelizzard@programming.dev 12 points 1 week ago (2 children)

Indentation-driven control flow is one of the most cursed things ever invented, excluding things explicitly designed to inflict pain or death.

[–] KSPAtlas@sopuli.xyz 5 points 6 days ago

Haskell has the choice of both indentation based and brackets for things like do blocks, but most people use indentation based cause it's the norm and looks cleaner

[–] CompactFlax@discuss.tchncs.de 8 points 1 week ago

White space sensitive languages are evil.

[–] tyler@programming.dev 11 points 1 week ago (1 children)

List comprehensions are much stranger than tabs vs spaces. There are very very very few languages that use them, and python’s is by far the worst out of the popular ones.

[–] SaharaMaleikuhm@feddit.org 6 points 6 days ago (2 children)

Skill issue. Once you learn them they are quite fun.

[–] unit327@lemmy.zip 10 points 6 days ago

The concept of a list comprehenshion is sinple but syntax is awful, as if Yoda was writing a for loop. "x for x in y it is, hmm yes".

[–] tyler@programming.dev 2 points 5 days ago

I'm not saying I don't understand them. I'm saying the syntax is terrible. Compare it to Ruby (or any other modern language) and it's abundantly clear.

python (uses syntax not available in any other top 25 language)

print([j**2 for j in [2, 3, 4, 5]]) # => [4, 9, 16, 25]

ruby (normal chain syntax with map)

puts [2, 3, 4, 5].map{|j| j**2}

even kotlin is more readable, even though you have to convert to a double and back kotlin

val list = listOf(1,2,3,4)
println(list.map{it.toDouble().pow(2.0).toInt()})

For nested cases it's even more apparent:

python

digits = [1, 2, 3]
chars = ['a', 'b', 'c']    
print([str(d)+ch for d in digits for ch in chars if d >= 2 if ch == 'a'])    
# => ['2a', '3a']

ruby

digits = [1, 2, 3]
chars = ['a', 'b', 'c']   
digits.product(chars).select{ |d, ch| d >= 2 && ch == 'a' }.map(&:join)

kotlin

val digits = listOf(1, 2, 3)
val chars = listOf('a', 'b', 'c')
println(digits.flatMap { d ->
    chars.filter { ch -> d >= 2 && ch == 'a' }.map { ch -> "${d}${ch}" }})

just from a base level, you have to read the middle of the comprehension first, then the end, then the beginning. It's a completely backwards way to write and read code. unlike other languages that use a 'functional' approach, where it's chained methods or pipes, etc. Even Elixir, which does have list comprehensions, reads and writes in the proper order:

elixir

for x <- 0..100, x * x > 3, do: x * 2
[–] OfCourseNot@fedia.io 5 points 1 week ago

Wasn't the python convention to use spaces (4 iirc)? Which is just plain wrong imho.

[–] eager_eagle@lemmy.world 2 points 1 week ago* (last edited 1 week ago)

most repos use 4 spaces

[–] aloofPenguin@lemmy.world 2 points 1 week ago (2 children)

This is the one thing I hate about python, because the spacing would differ between editors. I used vim to create the files on one system, and geany to edit them on another. Via uses 8 spaces in a tab (at least for me), while geany uses 4. This makes python mad, and drives me crazy. 

Also, the rules for whitespace separation between things like loops, methods, and the rest of the code is annoying/ wierd (at least to me).

[–] who@feddit.org 15 points 1 week ago (2 children)

Via uses 8 spaces in a tab (at least for me), while geany uses 4.

You know that editors let you change their defaults, right?

[–] eager_eagle@lemmy.world 4 points 1 week ago* (last edited 1 week ago)

and that indentation defaults in decent editors are usually language dependent. I'm not familiar with these editors, but... come on - if they use one default for all files, OP should use a better tool.

[–] aloofPenguin@lemmy.world 1 points 1 week ago

Yes, but I don't normally program in python, so I never did. When I had to, I never thought of changing it (it wasn't for long anyways and was less of a thought out decision to do programming in vim)

[–] jjjalljs@ttrpg.network 13 points 1 week ago

Get a code formatter. Ruff is popular. So is black. Never think about it again.