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.

Revan343 ,

I kinda like it, easy to see unbalanced braces

Fillicia ,
user224 , (edited )
@user224@lemmy.sdf.org avatar

Mmmm, perfectly level.

gofsckyourself ,

It’s just YAML…

Fillicia ,

YAML makes you appreciate Python’s 4 spaces indentation.

victorz ,

I thought python allowed whatever indentation you wanted as long as it’s consistent?

zalgotext ,

It does, but most style guides and autoformatters will use 4

HK65 ,

Python is one of the few languages with an official style guide, I think that guide says 4 spaces.

mariusafa ,

Literally me every time I want to program something slightly complex in Python.

victorz ,

;}}}

MTK ,

Honestly, looks neat, might adopt this

mox , (edited )

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.

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. I would have to do it anyway, regardless of whether the language demands braces, since confusingly indented code is unwelcome in my commits.

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.

Sanctus ,
@Sanctus@lemmy.world avatar
the_tab_key ,

I forgot Moses was in Tron

solidgrue , (edited )
@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.

zaphod ,

You can write Fortran Python in any language.

sunglocto ,

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

Vilian ,

God

i_love_FFT ,
@i_love_FFT@lemmy.ml avatar

Like like python if you give the right side column thingy

GissaMittJobb ,

Automatically enforced deterministic formatting is the best, there’s nothing that beats it. The productivity in just being able to format on save knowing that the code will be in the ideally formatted state, along with the anti-bikeshedding properties of this strategy, makes it unbeatable.

h0bbl3s ,
@h0bbl3s@lemmy.world avatar

gofumpt and gofmt are the best. One of the reasons if I have a choice I’ll code in go. I heard rumblings that rust was working towards having rustfmt be a standard crate.

GissaMittJobb ,

Go is in a good position, yeah. JavaScript has prettier, which is nice. Java has google-java-format. Python has ruff, which is quite good. Kotlin has ktfmt, which I believe made a mistake with their standards by not following the standard formatting guidelines for the language, but whatever. Uniform and deterministic for the win.

TunaCowboy , (edited )

What if I prefer this?


<span style="color:#323232;">#define CURLYOPENRIGHTCLOSEDLEFTBRACKET {
</span><span style="color:#323232;">#define CURLYOPENLEFTCLOSEDRIGHTBRACKET }
</span><span style="color:#323232;">#define CURVYOPENRIGHTCLOSEDLEFTBRACKET (
</span><span style="color:#323232;">#define CURVYOPENLEFTCLOSEDRIGHTBRACKET )
</span><span style="color:#323232;">#define PERIODWITHPERIODONTOP :
</span><span style="color:#323232;">#define COMMAWITHPERIODONTOP ;
</span><span style="color:#323232;">
</span><span style="color:#323232;">int main CURVYOPENRIGHTCLOSEDLEFTBRACKET CURVYOPENLEFTCLOSEDRIGHTBRACKET CURLYOPENRIGHTCLOSEDLEFTBRACKET
</span><span style="color:#323232;">  if CURVYOPENRIGHTCLOSEDLEFTBRACKET 1 CURVYOPENLEFTCLOSEDRIGHTBRACKET CURLYOPENRIGHTCLOSEDLEFTBRACKET
</span><span style="color:#323232;">    asm volatile CURVYOPENRIGHTCLOSEDLEFTBRACKET
</span><span style="color:#323232;">      "mov $1, %%raxn"
</span><span style="color:#323232;">      "mov $1, %%rdin"
</span><span style="color:#323232;">      "lea message(%%rip), %%rsin"
</span><span style="color:#323232;">      "mov $4, %%edxn"
</span><span style="color:#323232;">      "syscalln"
</span><span style="color:#323232;">      PERIODWITHPERIODONTOP
</span><span style="color:#323232;">      PERIODWITHPERIODONTOP
</span><span style="color:#323232;">      PERIODWITHPERIODONTOP "%rax", "%rdi", "%rsi", "%rdx"
</span><span style="color:#323232;">    CURVYOPENLEFTCLOSEDRIGHTBRACKET COMMAWITHPERIODONTOP
</span><span style="color:#323232;">  CURLYOPENLEFTCLOSEDRIGHTBRACKET
</span><span style="color:#323232;">  return 0 COMMAWITHPERIODONTOP
</span><span style="color:#323232;">CURLYOPENLEFTCLOSEDRIGHTBRACKET
</span><span style="color:#323232;">
</span><span style="color:#323232;">asm CURVYOPENRIGHTCLOSEDLEFTBRACKET ".section .datan"
</span><span style="color:#323232;">  "message: .ascii "wut\n"n"
</span><span style="color:#323232;">  ".section .textn" CURVYOPENLEFTCLOSEDRIGHTBRACKET COMMAWITHPERIODONTOP
</span>
humbletightband ,

You can’t be helped, sorry. We will put you to an asylum for people like you

magic_lobster_party , (edited )

I’m more concerned about that poor stack with all those recursions.

It’s also O(n^2) O(n!). I’m not sure what they’re trying to do, but I’m sure it can be done in O(n) (or at least polynomial).

Reject.

angelmountain ,

How happy I am with prettier. This is just a thing in an ancient past for me now.

Username ,

Recently tried biome for a web project. It’s a combined linter and formatter, and it’s so good. Compatible with prettier too.

key ,

Are you referring to autoformat like most linters and IDEs can do or does prettier have some special transpilation capability to hide braces?

some_guy ,

What the fuck!

nick ,

Jesus fucking Christ.

bdonvr ,

Actually that seems great?

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