▲ | austin-cheney 4 days ago | ||||||||||||||||||||||||||||||||||||||||||||||||||||
I love that you are using colon for the assignment operator. This is absolutely correct. Most languages use the equal sign as the assignment operator in most contexts and then the colon in limited contexts. This comes from Fortan and its just wrong. The equal sign should be reserved for comparisons, because that is what it means in mathematics. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | jasperry 4 days ago | parent | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
To push back a little: Designing the syntax of a programming language always involves tradeoffs; nothing is "just wrong". For better or worse, equal sign as assignment has become widely used and understood. I think the author's use of colon is neat, but it is confusing if you're used to seeing that as the type indicator; again, a tradeoff. I like the look of := as the assignment operator but it adds another shifted key to type, which can push you that much closer to RSI for such a common operation. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | znkr 4 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
> The equal sign should be reserved for comparisons, because that is what it means in mathematics. This is touching on a pet peeve of mine: Mathematics and programming are similar in many aspects, but this is not one of them. In mathematics = is not a comparison, but a statement. More generally, mathematics is about tautologies, that is statements that are always true. In programming, a comparison is evaluated to either true or false. That doesn’t mean that there’s no room for conditionals in mathematics (one example is piecewise function definitions). But it’s not the same. Heck, even the definition of “function” is different between mathematics and programming. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | gucci-on-fleek 4 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
> The equal sign should be reserved for comparisons, because that is what it means in mathematics. "let x = 1" has the same meaning in mathematics as well as JavaScript and Rust. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | AdieuToLogic 4 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
> I love that you are using colon for the assignment operator. This is absolutely correct. Historically, distinguishing an equality operator from an assignment one has existed for many decades. Whether using colon for the latter is "absolutely correct" is the subject of valid debate. An equally compelling case could be made for any of the following assignment operators as well:
Etcetera | |||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | dist1ll 4 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
> because that is what it means in mathematics Personally, I think this argument only holds water for languages that are rooted in mathematics (e.g. Haskell, Lean, Rocq, F*, ...). If your computational model comes from a place of physical hardware, instructions, registers, memory etc. you're going to end up with something very different than an abstract machine based on lambda calculus. Both valid ways to design a PL. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | agalunar 4 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
I’d argue there’s a very big difference between “x: y” and “x : y”. I can only see the former as assignment and the latter as the has-type relation. (I find it baffling in the extreme that in many mainstream languages the convention is to write type annotations as “x: T”, both prima facie and because in those languages the notation then collides with field assignment!) | |||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | bluecalm 4 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
Mathematics, famous for consistent readable notation. Next idea should be to just stop declaring variables at all assuming they mean what they usually mean in similar programs. Starting array indexes from 1 instead of 0 is another one although that was already tried :) | |||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | zabzonk 4 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
what about:
not assignment, and it looks like maths to me | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | amelius 3 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
I'd like to see language designers make function calls happen in the order you read them. For example, in most languages you have a notation like f(g(h(x))) which calls the functions in the exact opposite order of reading which is unnecessarily confusing. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | bregma 3 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
Even this is wrong. Programming should be explicit and easy for anyone to read.
is bad since it's an assertion that c is equal to the sum of a and b, and before it's executed, it's completely untrue. Not only that, but it's math and like Barbie has taught us, math is hard.Nope, make it explicit. You're moving the value of an expression to a placeholder. The only sensible way to write that would be
Why, with such a simple and obvious English-like syntax even a common business-oriented person could use the language. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | 4 days ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
[deleted] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | rurban 4 days ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
Sure but mathematics is better. There you can switch LHS with RHS. Instead of := you should use => for assignment. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|