I feel that Yaml sucks. I understand the need for such markup language but I think it sucks. Somehow it’s clunky to use. Can you explain why?

You are viewing a single thread.
View all comments
82 points

Any language in which whitespace has syntactic value is intrinsically flawed.

Can’t speak to your specific issues, but that’s why yaml will always suck.

permalink
report
reply
25 points

As a serialization format, agree 100%, but would Python really be better if it switched to braces?

permalink
report
parent
reply
61 points

Yes, I think so. The downside with Python comes when refactoring the code. There’s always this double checking if the code is correctly indented after the refactor. Sometimes small mistakes creep in.

It’s really hard to tell when Python code is incorrectly indented. It’s often still valid Python code, but you can’t tell if it’s wrong unless you know the intention of the code.

In order languages it’s always obvious when code is incorrectly indented. There’s no ambiguity.

permalink
report
parent
reply
13 points

I think this is just familiarity. I never have issues with indentation, but when refactoring js I’m always like hey who’s fucking brace is this

permalink
report
parent
reply
6 points

It’s only hard to tell indentation in Python when the code block gets longer than about a screen, which is usually a sign the code should be refactored into smaller methods.

permalink
report
parent
reply
1 point
*

Can address it by writing code that doesn’t depend much on indentation, which also makes code more linear and easier to follow.

permalink
report
parent
reply
28 points

Yes it would - look at optional braces for short if expressions in C family languages and why it’s so discouraged in large projects. Terminating characters are absolutely worth the cost of an extra LoC

permalink
report
parent
reply
15 points

I started in C before moving on to C++, Java, Ruby and Python.

I’ve had more bugs from missing braces than from misaligned whitespace because the latter is far more obvious when looking at a block of code.

permalink
report
parent
reply
7 points
*

False dichotomy. Optional braces are bad practice because they mislead the programmer that is adding an additional clause to the block.

This misleading behavior wouldn’t happen in Python, as it would either be invalid syntax, or it would be part of the block.

Indentation problems are pretty obvious to the reader. Even more than missing or unbalanced braces.

permalink
report
parent
reply
4 points

I’m fine with python, because it’s consistent. In C I get nervous every time I see it.

obligatory goto fail;

permalink
report
parent
reply
16 points
*

would Python really be better if it switched to braces?

Yes. A thousand times, yes.

permalink
report
parent
reply
5 points

To be pendantic, it’s level of indentation in Python that has semantic meaning, not whitespace.

permalink
report
parent
reply
13 points

The end of line also has semantic meaning. Both indentation and eol are whitespace.

permalink
report
parent
reply
2 points

If nothing else it enforces readable code which I think is a good thing.

permalink
report
parent
reply
7 points
*

Haskell supports both semantic whitespace and explicit delimiters, and somehow almost everybody that uses the language disagrees with you.

But anyway, for all the problems of YAML, this one isn’t even relevant enough to point out. Even if you agree it’s a problem. (And I agree that the YAML semantic whitespace is horrible.) If YAML was a much better language, it would be worth arguing whether semantic whitespace breaks it or not.

permalink
report
parent
reply
0 points

Yeah but Haskell is mostly used by mathematicians…

permalink
report
parent
reply
6 points
*

YAML sucks because, among other things, indenting it is not obvious.

In contrast, the only mistake of Python when it comes to whitespaces was allowing hard tabs, which makes it too easy to mix them if your editor is not configured.

Improper indentation stands out more than missing or unbalanced braces and it’s really not an issue to delimit code blocks.

permalink
report
parent
reply
8 points
Deleted by creator
permalink
report
parent
reply
1 point

In any modern editor it is configurable with spaces too

permalink
report
parent
reply
2 points

Not any language. I code professionally in F# which has semantic whitespace and it has literally never been an issue for me or my team. In contrast to Python, it’s a compiled language and the compiler is quite strict, so that probably helps.

permalink
report
parent
reply
1 point

It’s the only time that tabs Vs spaces really riles me up. So annoying when everyone has different tab lengths

permalink
report
parent
reply
-1 points

I now use Scala 3, and very happy with syntactic whitespace (combined with an intelligent compiler)

permalink
report
parent
reply

Programming

!programming@programming.dev

Create post

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



Community stats

  • 2.2K

    Monthly active users

  • 1.8K

    Posts

  • 29K

    Comments