338
you are viewing a single comment's thread
view the rest of the comments
[-] Swiggles 31 points 1 year ago

Python is stupid. Using non printable characters as anything other than token separation is just asking for trouble.

[-] Sigmatics@lemmy.ca 14 points 1 year ago

Just use a modern editor and you'll never have this problem

[-] Swiggles 18 points 1 year ago

You can work around most issues in any language with the right tools. That's not the point.

If a design decision introduced a whole new class of errors it is probably just bad design.

[-] dudinax@programming.dev 7 points 1 year ago

It also greatly improved readability of the language. Since switching to the standard of using 4-space tabs, I've not had any problems except when dredging up someone's old Python 2 code.

[-] nous@programming.dev 7 points 1 year ago

You can create some really ugly code in spite of the forced indentation in python. Indentation does not really help here at all. In all languages you can correctly or incorrectly format things. A code formatter strictly applying a coding standard helps far more here than indents vs bracers. Take a look at black it takes the pep8 standards and adds more strict things on top making code look a lot more consistent and thus makes it easier to read.

And all formatters will indent code consistently, so having it as part of the language parser does not really help improve readability at all. And even without a formatter everyone I know will still correctly indent their code no matter the language used. But sometimes forcing new lines to have a meaning does make things worst - just look at pythons lambdas which have to be a single line.

[-] Reptorian@programming.dev 1 points 1 year ago

Indentations does not really help readability that much in case of really, really, long code, and in some cases, a code can execute without with unexpected result because of one single indentation being off. Both of these why I like things like curly braces/brackets and terminators like endif/fi/done/end/etc. But, at the end of the day, if there's a readability problem, then that's a sign that the code needs to be reworked on.

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

Oh I think indentation helps a ton with readability. Even for bad, long or otherwise hard to read code - it would be way, way worst with no or wrong indentation. Correct indentation helps a lot. It is not the only thing that can be done to improve readability but it is the first and simplest fix you can apply to a code base. So a language enforcing it with syntax does not matter when even basic text editors can correctly and automatically indent your code.

Though one thing I do like about bracers is I can be lazy with formatting and let my formatter sort it out for me on save. With a white space sensitive language you need to get it correct from the start or else the program just does the wrong thing.

[-] Reptorian@programming.dev 1 points 1 year ago

I didn't say it doesn't help. But, it alone does not really help for bad and long code, but you are correct in that it would be worse with the wrong indentation. Like you pointed out, the program could do the wrong thing if there is a wrong indentation where indentation matters which is one of my issue with something like Python. And languages with explicit exit scope tend to not have that issue while adding to the benefit of making longer code readable. Where white-space sensitive languages really shine on in my opinion are small codes, and that's where I think of using Python.

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

Indentation can be wrong, but braces can't?

[-] Reptorian@programming.dev 1 points 1 year ago

Braces too can be wrong. But, one is less likely to get it wrong. Modern editors often allows one to highlight matching braces immediately after selection, and rainbow braces(if available) makes it clear on the nest level.

[-] Sigmatics@lemmy.ca 3 points 1 year ago

It's a choice, do you want to deal with brackets or indents? Pick one

[-] Swiggles 1 points 1 year ago

With printable characters. Which disqualifies indents, but doesn't leave brackets as the only choice.

[-] xigoi@lemmy.sdf.org 11 points 1 year ago

The space is a printable character.

What trouble have you gotten into due to this?

[-] Swiggles 6 points 1 year ago

Just copy some code over into a not properly configured vim.

People seem to forget that not everything is a fully configured development environment working locally on your laptop which attempts to fix the issues introduced by that design decision.

[-] xigoi@lemmy.sdf.org 3 points 1 year ago

I use (Neo)Vim and never had a problem with indentation. When pasting code, I can easily indent it to any level I want with the > operator.

[-] Swiggles 4 points 1 year ago

Which actually breaks the code if you don't have sw configured to the same width as used by the code.

If anything that proves my point.

[-] Crisps@lemmy.world 4 points 1 year ago

Add YAML to that for the same reason.

[-] Swiggles 1 points 1 year ago

Actually I did below! You are absolutely correct.

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

Is Haskell, YAML, or Sass also stupid? 🤔

[-] Swiggles 7 points 1 year ago

Absolutely yes. JSON and SCSS > YML and SASS

[-] OsrsNeedsF2P@lemmy.ml 4 points 1 year ago

YAML can die in a fire, thanks

this post was submitted on 01 Sep 2023
338 points (100.0% liked)

Programming

17476 readers
178 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS