Hacker News new | ask | show | jobs
by darthrupert 928 days ago
The things I'm looking for in language syntax these days are

1. That it's unambiguous enough that my editor can format it correctly every time (provided the code is correct, obviously). Indentation-based languages like Python fail this.

2. That its elements and keywords are distinct enough that my editor can apply colours on it. I sometimes feel that S-expression languages fail at this because of their small number of distinct keywords, but that might not be true.

Besides these two points, if the language is not a joke language, it's probably fine.

1 comments

What is ambiguous about Python’s syntax?

    if a:
        print("foo")
    if b:
        print("bar")
Or wait, maybe the copy paste didn't work exactly right and "if b" was supposed to be inside "if a"
That’s a problem with your editor, not with Python.
But it's what ambiguous about Python's syntax. And I can make it a bit worse:

    if a:
       print("foo")
     if b:
        print("bar")
This is not a huge problem, but problems with syntax never are (in non-joke relatively modern languages). But it's still something I prefer that languages fix in their syntax if I get to have a choice.
The example you just posted is a syntax error, as it should be. And I still don’t get what is ambiguous about the syntax, the specification clearly states how indentation corresponds to a syntax tree.
Your insistence on the technical definition of "ambiguous" aside, you see what I mean after thinking about it for a while, though, right?