368
all 32 comments
sorted by: hot top controversial new old
[-] PhobosAnomaly@feddit.uk 41 points 1 year ago

I was brought up on C, did a module of Java at uni, and am doing an algorithms course which is python heavy.

My other half - who's quite handy with Python - looks in sheer horror at my code which is littered with semicolons.

I was stumped for half an hour figuring out why the Python interpreter was bouncing an error before it had even reached the main program logic... turns out a { before the block of code royally ruins the interpreter's day.

Still, I live and learn.

[-] sirico@feddit.uk 39 points 1 year ago
[-] Dirk@lemmy.ml 8 points 1 year ago

I;don't;think;that;helps

[-] Carighan@lemmy.world 24 points 1 year ago

For bonus points take their code and completely go wild with utterly random indentation and line breaks, just to drive the point home. 😈

[-] trolololol@lemmy.world 10 points 1 year ago

Pfff just randomly replace tabs with 4 spaces and see the world burn

[-] muntedcrocodile@lemm.ee 3 points 1 year ago

4 spaces is the preferred pythons is happy with either but the standard is 4 spaces. Vscodium ensures that.

[-] trolololol@lemmy.world 1 points 1 year ago

Your editor is happy with either, but is it happy with both?

[-] muntedcrocodile@lemm.ee 1 points 1 year ago

My editor will take either and convert it to 4 spaces. Python can use spaces or tabs but not both in the same file.

[-] trolololol@lemmy.world 1 points 1 year ago

Buahahahah I know what to do next commit

[-] muntedcrocodile@lemm.ee 1 points 1 year ago

Its the python equivalent of a Greek question mark

[-] Gabu@lemmy.ml 23 points 1 year ago

That's actually me removing semicolons from Python.

[-] cybervseas@lemmy.world 14 points 1 year ago

How does one manually add a semicolon? vs. automatically?

[-] atyaz@reddthat.com 7 points 1 year ago

JS formatters add them if the project requires it

[-] CanadaPlus@lemmy.sdf.org 4 points 1 year ago

Manually would be if it prompted you every time you every time the program inserts one. No, wait...

[-] lowleveldata@programming.dev 10 points 1 year ago* (last edited 1 year ago)

~~Python~~Amateur programmers

[-] shasta@lemm.ee 8 points 1 year ago

This is why linting and auto-format on save exists in IDEs. Don't make things harder on yourself.

[-] LazaroFilm@lemmy.world 3 points 1 year ago

I have a plugin in VSCode to remind me not to forget the semicolons

[-] arudesalad@sh.itjust.works 2 points 1 year ago

I was taught python by my school but I would rather write in other languages but the difference in formatting still gets me after years

[-] Daxtron2@startrek.website 1 points 1 year ago

can I interest you in some delicious linters

[-] toastal@lemmy.ml 0 points 1 year ago

Folks acting like Python is the only language without semicolons. 😏

I got tripped up so many time in the last 3 weeks using PHP after years in ML family languages. I am already newlining & it’d be poor style to put more than one statement on a line so what is the point of these semicolons?

[-] palordrolap@kbin.social 19 points 1 year ago

In some languages
a newline does not
necessarily indicate
the end of a statement.

In others, sometimes it could, but would leave things ambiguous
as to whether the statement was ended or not.

And so, punctuation is necessary.

[-] toastal@lemmy.ml 3 points 1 year ago

But newlines + indentation are supported by a lot of languages & when it is, it’s easier to read since the prevailing convention is already to newline, then in indent. When you follow the usual coding styles or autoformatted & removed the semicolons, you’ve gained nothing for readability & added noise. I much prefer the languages that take this convention & bake it in so you don’t have to have that that visual noise—and in these languages, I never felt the parsing rules were ambiguous.

[-] pixelscript@lemmy.ml 7 points 1 year ago

it’d be poor style to put more than one statement on a line

Unlike Python, most languages do not endorse a specific concept of style. You're free to dabble in all the bad style choices you like, on the off chance that once in a blue moon they prove to be situationally useful.

[-] CanadaPlus@lemmy.sdf.org 2 points 1 year ago* (last edited 1 year ago)

Why haven't custom parsers become more of a thing? All the compiler or interpreter really needs is a valid parse tree. You could even have some kind of special command or directive to switch styles, if a section would be really ugly otherwise.

[-] toastal@lemmy.ml 1 points 1 year ago

With indentation-based languages the bad coding style we are talking about is putting multiple statements on a line or unindenting a block …& never has that been something I wanted to do. I would rather this aspect be enforced at the language for readability where there is still room in all other aspects to try out other styles.

this post was submitted on 04 Apr 2024
368 points (95.8% liked)

Programmer Humor

37027 readers
78 users here now

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

Rules:

founded 5 years ago
MODERATORS