2 ms·
> For me, Python is a good (though not ideal) mix of simple syntax and power. The language is characterized by low redundancy, meaning it uses fewer unnecessary
by masklinn 2y ago
> For me, Python is a good (though not ideal) mix of simple syntax and power. The language is characterized by low redundancy, meaning it uses fewer unnecessary characters like semicolons or curly braces to mark the end of a line. If a human can recognize the end of a line without special characters, then the compiler should be able to as well. […]
Even a brief look at Rust’s syntax
That’s a shame because you’re missing that these sigils actually have meaning there, because the semantics of the language are completely different: Python is statements-based with very limited scoping (global and function), Rust is expression based with block scoping.
As a result, blocks (paired braces) are a way to pack multiple statements into an expression e.g.
let v = {
let a = thing1();
let b = thing2();
thing3(a, b)
};
And `;` is not an alias for end-of-line, it’s a separator for statements.
And not aliasing end-of-line to end-of-statement is relevant to rust being expression oriented, it’s very common for expressions to span multiple lines, in that case Python requires either wrapping the entire thing in parenthesis or escaping the EOL with `\`.
Could you find other ways to do this? Sure, but then you have to make other tradeoffs e.g. wrap everything in matching symbols à la lisp, or make statements into special cases à la Haskell.
- mavhc 2y agoWrapping 99% of things in {} seems worse than wrapping 1% of things in ()
- wqtrez 2y agoThat looks very clean, though the deviation from OCaml takes a minute to get used to.
- Ringz 2y ago> And `;` is not an alias for end-of-line, it’s a separator for statements. And in Python \n is not an alias for end-of-line, it’s a separator for statements.
- xigoi 2y ago> the semantics of the language are completely different: Python is statements-based with very limited scoping (global and function), Rust is expression based with block scoping. This is a red herring. Haskell, CoffeeScript, Nim, Lean, etc. are expression-oriented and use indentation like Python, while C(++), Java, JavaScript, etc. are statement-oriented and use braces.