5 ms·
x^2 means x squared, orphaning the XOR operator. Rune is for crypto, so math comes first. Isn't XOR used very heavily in crypto? (As is exponentiation of cours
by diarrhea 4y ago
x^2 means x squared, orphaning the XOR operator. Rune is for crypto, so math comes first.
Isn't XOR used very heavily in crypto? (As is exponentiation of course)
- troymc 4y agoIt looks like Rune still has a bitwise XOR operator: @ https://github.com/google/rune/blob/main/bootstrap/database/expr.rn https://github.com/google/rune/blob/main/bootstrap/database/... That innovation does seem like a potential footgun.
- kibwen 4y agoHere's my hot take: if you're designing a new programming language in the modern era, even a systems language, ignore the precedent of C and don't use &|^~ as bitwise operators. You can still have infix bitwise operators, but spell them out as bitand/bitor/bitxor/bitnot. Then you can just use &| for logical and/or, which are 1000x more common than bitwise and/or, and you can reclaim ^ for exponentiation as well. And don't forget to fix C's broken bitwise operator precedence while you're at it.
- lvass 4y agoHard disagree on single characters for logic and exponentiation. ASCII has too few special characters and you'd want to use those elsewhere, without creating ambiguity. Elixir got it right.
- PointyFluff 4y agoASCII has tones of unused chars we could grab for coding.
- junon 4y agoMm yes but BEL is not a character that can be typed on a keyboard with any amount of ease.
- deleted 4y ago[deleted]
- dragonwriter 4y ago> ASCII has too few special characters Unicode, OTOH, doesn’t have this problem.
- josephg 4y agoTrue, but we don’t have Unicode keyboards.
- mumblemumble 4y agoInteresting. I'd go the other way. Continue using single-character bitwise operators, but spell out "and" and "or" for the logical operators. Rationale: in normal usage, short-circuiting logical operators are, in effect, a special kind of control flow statement, and control flow statements are typically spelled out. Bitwise operators are more unequivocally meant for calculation, and therefore perhaps more deserving of similar syntax to the arithmetic operators, despite their less frequent usage. I think that this way of drawing the distinction might be particularly relevant in a language that disallows conditional branching - and, by extension, short-circuiting logical operations - on certain kinds of data the way Rune does.
- npn 4y agoSome language use three characters for bitwise operators, like `>>>`, `!!!`, `&&&`. I think it is a good compromise.
- sacnoradhq 4y agoSheer insanity. Sensible languages use ** for exponentiation and ^ for xor.
- namkt 4y agoI know, right? The strongest theoretical crypto is a one-time pad, often presented in its XOR form in the first chapter of every crypto book. But hey, if Google says math comes first...
- sacnoradhq 4y agoOTP is simply pt XOR giant-key. It would've been wiser to duplicate C's bit operators ( ~ ^ & | << >> ) than give the emperor some "new clothes." Welcome to another "Not Invented Here" language dying to be special and full of surprises. It's a fail.