this post was submitted on 28 Jul 2024
1294 points (99.1% liked)

Programmer Humor

19503 readers
1248 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 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] solidgrue 81 points 3 months ago* (last edited 3 months ago) (3 children)

Looks like Python, but in an editor with a weird TUI scrollbar

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

High chance that it's a Python programmer who is really unhappy about having to work in Java, lol

[–] tan00k 16 points 3 months ago

Agreed. I saw this and thought it looked beautifully passive aggressive

[–] hemmes 4 points 3 months ago

Ha! Now I see it - that was very funny, sir!

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

Doesn't python need colons after if/else/for/etc. statements?

[–] _stranger_ 5 points 3 months ago (2 children)

Heh, so in Python it's possible to overload operators in the context of objects. I bet it would be possible to overload tabs to do the same thing as colons inside a context manager, but that's pure speculation.

[–] takeda 3 points 3 months ago (1 children)

Perhaps I don't understand you, but I don't think there's a way to override spaces in python in any way. The spaces are handled by the parser.

[–] _stranger_ 3 points 3 months ago* (last edited 3 months ago) (2 children)

You can define what happens for an object when an operator is applied (like +, /, or -) so that you can obj+obj. I wonder if there's a way to override "tab" such that it acts like a ":", but from inside the language (this is trivial if you edit the language itself like you suggest). Thinking about it more, I'm guessing not since ":" isn't an operator and this doesn't have a corresponding __operator__ function.

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

If Python has anything like Perl's source code filters, then anything's up for grabs, but Perl is kind of weird in a way that Python was specifically designed not to be. Or at least Python 1 was. Things may have changed in the intervening couple of decades.

If it's just plain overloading, then whitespace is probably off the table. Spaces, even required spaces, aren't so much syntax as they are structure. You could argue that the curly braces of some other languages are more syntactic than Python's whitespace, because it's actually Python's magic colon and the first unindented line (lack of whitespace!) that serve that specific syntactic purpose.

Examples of Perl's source code filters range from turning a program into binary representation of the syntax tree and still having it be executable, to new syntax, to writing programs entirely in Latin or something that looks almost but not entirely unlike it, anyway.

[–] takeda 1 points 3 months ago

I see. I would love to be proven wrong, but I don't see a way this would work with tabs/spaces in python.

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

IIRC, Python handles whitespace indentation by having the tokenizer convert them to INDENT/DEDENT tokens. The grammar can then handle them equivalently to a curly brace language.

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

You can write ~~Fortran~~ Python in any language.