There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

nick , in Brace Style

Jesus fucking Christ.

bdonvr , in Brace Style

Actually that seems great?

mox , (edited ) in Brace Style

Growing up with C made me assume semicolons and braces were needed to avoid subtle bugs, but experience with more recent languages showed me that it’s possible to reliably parse the same semantic cues that humans use: indentation, parentheses, and other such context. (Perhaps this was less viable when C was invented, due to more constrained hardware.)

I was skeptical at first, but in practice, I have never encountered a bug caused by this approach in Python, Nim, or any other language implementing it consistently, over the course of a decade or two using them. Meanwhile, I have seen more than a few bugs caused by brace and semicolon mistakes.

So nowadays (outside of niche & domain-specific languages) I see braces and semicolons as little more than annoying noise and fuel for religious arguments.

GBU_28 ,

Plus any decent editor catches when lines are unreachable or in violation due to misformatting.

If not that, which seems unlikely, your unit tests would

Ephera ,

Well, Python kind of does the reverse of a semicolon: If you want to continue a statement over multiple lines, then you have to \
escape it.
Python also then tries to avoid multi-line statements for that reason, but yeah, in most other languages this would be equally as annoying as semicolons are.

There are some languages which use neither, for example Scala, but I can at least say that while I consider the people behind Scala and Rust equally competent and the languages more or less equally modern, Rust just completely blew it out of the water in terms of error messages despite being much younger. (Not because Scala is bad, Rust is just incredibly good there.)

And yeah, I’m suspecting that Rust using semicolons makes the difference there.
While Scala will pretty much have to guess where a statement with compile error ends, Rust just knows it ends at most at the next semicolon.

I will also say my experience is opposite of yours. I have managed multiple times to try to access a variable in Python, which wasn’t in scope anymore, because the indentation wasn’t enough of a visual cue to me.
And in any modern language, missing/missplaced semicolons or braces are a compile error, with clear error message where it’s missing. I genuinely don’t even know how you’d get a bug out of that.

mox ,

Well, Python kind of does the reverse of a semicolon: If you want to continue a statement over multiple lines, then you have to \ escape it.

That’s not true. Being within parentheses, brackets, quotes, etc. is enough for the parser to know you’re continuing. In practice, I find that context is already present in most cases.

For the other cases, occasionally surrounding an expression in parentheses is easy enough. Long conditionals probably deserve parentheses anyway, for clarity.

Ephera ,

Well, it mostly being already correct is what I meant with Python avoiding multi-line statements.

In JVM languages, Rust etc., it’s for example popular to use Fluent Interfaces. These also reduce visual clutter and the number of variables in scope (and/or the need for mutability).

I did not know about enclosing them with parenthesis, but apparently that works, too, as this library shows: pypi.org/project/fluentpy/

sparkle ,

I am a Scala and Rust fan. I can corroborate what you said

The part about no semicolons/curly braces I like in Scala is that I can write a function and it’ll look virtually indistinguishable from a regular ol variable. Functions become much less of a ritual and integrate more nicely with the rest of the code. Other than that though, Rust definitely wins out because of the curly braces & semicolons. I use curly braces in most situations in Scala where I’d normally use them in Rust, and I would use semicolons everywhere in Scala if it weren’t considered unidiomatic. Whitespace-significant syntax is just really annoying to deal with. Using Python or even maybe F# makes me want to die because I keep accidentally missing an indent somewhere or indenting too much somewhere else or using the wrong kind of whitespace and the entire program implodes. At least Scala and Kotlin keep it sane

Also it’s just way harder to visually organize in whitespace based languages. You basically have to do a bunch of magic tricks to make the code look slightly different in a specific scenario than what the language wants you to. Rust allows you to actually visually organize your code easily while also having a strong style rules which you shouldn’t stray too far from (or else the compiler will yell at you).

Monstera ,

Fortran is ancient and does fine without ;

mkwt ,

When Fortran was created, each line was a separate punched card. The syntax made sense for that medium.

C was setup from the start for use on teletypes with fancy line editors like ed.

magic_lobster_party ,

In Java it’s quite difficult to forget semicolon and still have a syntactically correct program.

I think braces are incredibly important. With Python it can be confusing which indentation is correct when copying code between files. Different indentations can easily be still syntactically correct, but the outcome is vastly different. It’s often I have to double and triple check to verify I copied the code with correct indentation.

mox , (edited )

It’s often I have to double and triple check to verify I copied the code with correct indentation.

I vaguely remember facing that issue once or twice in the past, but certainly not often. It was because the pasted code was too long for its starting point to be easily found in my editor, even if I scrolled up a bit.

If this happens to you often, I wonder: perhaps the code you maintain should be broken into smaller functions?

If I was in that situation again, I think I would simply place a bookmark before pasting and then jump back to the bookmark to indent/dedent the pasted block appropriately.

Edit: Come to think of it, I would have to check and correct it regardless of the language and braces, since confusingly indented code is unwelcome in my commits.

spikespaz ,

Don’t you use a formatter that fixes whitespace in sloppy writing?

mox ,

I’ve never needed one.

humbletightband ,

It’s kinda organic in python, but God forbid how often I made mistakes in yaml learning k8s

mox ,

Haha… Yes, I’ve found yaml to be problematic in this area, too. Probably because it lacks the context cues and modularity of a programming language.

humbletightband ,

Context cues could be provided by jsonschema, but still it’s unbearable in comparison even with json.

leftzero ,

As someone used to working in c# (and before that Java, C++, Visual Basic, and Pascal) I haven’t seen any brace or semicolon related errors since the days of Borland IDEs (any remotely self respecting IDE will highlight them and refuse to compile, these days), but working with Kotlin has shown me that I, at least, read code with semicolons slightly faster than code without.

There’s a reason we use punctuation when writing, and the same applies to code.

ChickenLadyLovesLife ,

Borland IDEs

Ugh, you just gave me Turbo Basic flashbacks. My favorite thing was that variable names could be as long as you liked and mixed case, but the compiler only used the first two letters and case insensitive at that. So “BatShitCrazy” and “BALLPARKESTIMATE” actually referenced the same variable.

uis ,

GCC has separate warning when braces don’t match identation

sunglocto , in Brace Style

Idk why but i fell in love with this and might just use it now

Vilian ,

God

morrowind ,
@morrowind@lemmy.ml avatar

It would be nice and easy if we had elastic tabstops

Vilian ,

That’s true, I wanted to port that to Kate for me to test, but I’m too dumb to port the Scala implementation to QT/KDE framework

NigelFrobisher ,

I just realised why we do live coding interviews.

Gsus4 , in When your shower uses GitHub more than you

Damn, that cuts deep 😞

PumaStoleMyBluff , in When your shower uses GitHub more than you

A four day work week with no overtime!

wesker , in Brace Style
@wesker@lemmy.sdf.org avatar

bro what the fuck

savvywolf , in Brace Style
@savvywolf@pawb.social avatar

Whitespace isn’t semantically important. Ticket closed.

DrWeevilJammer ,
@DrWeevilJammer@lemmy.ml avatar

That would be a very satisfying ticket closure

superkret , in Brace Style

The braces need indentation, of course.

zqwzzle ,

Fibonacci indentation of course.

solidgrue , (edited ) in Brace Style
@solidgrue@lemmy.world avatar

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

subignition ,
@subignition@fedia.io avatar

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

tan00k ,

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

hemmes ,
@hemmes@lemmy.world avatar

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

arudesalad ,

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

_stranger_ ,

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 ,

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_ ,

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.

palordrolap ,

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 ,

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

frezik ,

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.

zaphod ,

You can write Fortran Python in any language.

CanadaPlus , (edited ) in When your shower uses GitHub more than you

I like to think the tiler knew exactly what he was doing, and sometimes chuckles about the epic troll to this day.

DieguiTux8623 , in When your shower uses GitHub more than you

Seeing that image has always made me enter a “brain short-circuit” mode where half of my personality wants to cry and the other half wants to laugh. Does anyone experience anything similar?

abbadon420 , in When your shower uses GitHub more than you

I hate these unrealistic beauty standards

AFC1886VCC , in True?
TootSweet , in When your shower uses GitHub more than you

If I ever saw a Github commit history like that, I’d be concerned.

Quality over quantity, hackers.

Zikeji ,
@Zikeji@programming.dev avatar

When it comes to commits, single feature / scoped commits are quality. So this git history is actually underwhelming if the author is full time. This is a good read.

TootSweet ,

I’m familiar with and practice atomic committing habits. Still seems excessive.

nik9000 ,

Mine looks a little like that. It’s my job though. Everything’s on GitHub.

https://programming.dev/pictrs/image/16b72a6e-8a24-43de-8337-9eb3af8587b8.png

Zangoose ,

That article also mentions squashing merges though, which would lower the contribution count by a lot unless there’s a GitHub setting to have separate branch commits tracked that I’m missing out on.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines