Email or username:

Password:

Forgot your password?
Top-level
Matthew Lyon

I mean the real kicker here is, if you want to make infix notation with order of operations _readable_, you either have to:
- break up operations into multiple statements with only equivalent operators
- use parenthesis to group operations whether you need them or not

I vaguley remember one C-like language which forced these rules on you, but most don’t

16 comments
technomancy (turbonerd aspect)

@mattly I think Smalltalk just takes operations in left-to-right order when no parens are present, which might cause some people to complain but seems much better than the status quo

Jon (Snarf) Mason

@technomancy I'm not 100% sure it's what @mattly was thinking of, but I think so.

Anyway, a language called Pony makes it a syntax error to mix operators without parens: i.e. 1+2+3 is fine but 1+2*3 is a syntax error.

PEDMAS or BODMAS or whatever can go eat a bag of Dick's (meaning the burger place, of course).

technomancy (turbonerd aspect)

@snarfmason @mattly I will always have a place in my heart for Smalltalk's approach due to its sheer idgaf attitude but I do have to admit this is the better solution overall

Jon (Snarf) Mason

@technomancy @mattly well as a fellow Smalltalk lover, I can't fault you there. And frankly just evaluate left to right is still better then trying to remember binary operator precedence.

Matthew Lyon

@snarfmason @technomancy part of this as someone who gets real caremad about things like cognitive load and mistake-proofing,

while I can appreciate smalltalk’s approach in ignoring operator precedence, I can also see it biting people who aren’t throughly testing their stuff for unexpected errors

& I don’t view “you should have known better” or “you should have written better tests”  as acceptable rejoinders to language design that violates established conventions, even bad ones

Matthew Lyon

@snarfmason @technomancy that said, I think that if any language can pull off something like ignoring operator precedence and just doing LTR operations, it’s smalltalk, because the audience self-selects to the sort of people who can maintain that cognitive load

technomancy (turbonerd aspect)

@mattly @snarfmason that might be true nowadays but I dunno if it would have been in Smalltalk's historical context; these days being able to point to an identifier and immediately see its definition and all references is considered commonplace, but at the time it was leaps and bounds better than anything available

I would imagine going from Smalltalk to Pascal involved a pretty significant difficulty bump in terms of what you have to keep in your head at all times

more likely it's because Smalltalk self-selected for people who were willing to throw away everything they thought they knew about programming

@mattly @snarfmason that might be true nowadays but I dunno if it would have been in Smalltalk's historical context; these days being able to point to an identifier and immediately see its definition and all references is considered commonplace, but at the time it was leaps and bounds better than anything available

Jon (Snarf) Mason

@mattly @technomancy I agree with the principal. But I honestly don't know which way is better.

There are established conventions for the math operators yes. But those aren't the only binary operators in most programming languages.

What the fuck does order X + Y & Z apply in? (PS: fuck Ruby and whoever else though &&/and have different binding priorities was a good idea).

Once you move past the rules we learned for arithmetic, "go left to right for everything" actually is better, I think.

Jon (Snarf) Mason

@mattly @technomancy I agree with you about trying to design languages to make it harder to make mistakes though and that's why I like the Pony approach.

I'm honestly not sure any way of assigning precedence of binary operators is good.

Matthew Lyon

@snarfmason @technomancy which brings us back to lisp, where you just nest the expressions! :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D

Matthew Lyon

@snarfmason @technomancy no I know, I mean, there’s not *really* a right answer there, but if there’s anything I’ve learned in over a decade of figuring out how to mistake-proof semantics, is that it’s better to fail / throw errors / prevent obviously stupid things from happening (the way pony does) than to ship obvious footguns

Matthew Lyon

@snarfmason @technomancy I once had to build alternate number types into a schema to represent statistical averages to prevent people from adding them, because people were taking multiple averaging results and averaging *those* & making decision based off this

people do stupid things like this all the time, yet we still have yet to really evolve our concept of numbers in computers to do things like making dividing by zero impossible by having dividend / divisor types

technomancy (turbonerd aspect)

@snarfmason @mattly yeah, I think you have to consider differently what's "better" in isolation vs better in context

if everyone switched to L->R consistently one day by magic: great; wonderful

if you have the one language trying to do it right in a sea of wrongness: maybe it's better to trade a few extra characters for increased clarity

even with something like smalltalk you're bound to have programmers whose job involves 95% javascript and 5% smalltalk; they would definitely rather have a syntax error than an incorrect result when they forget for a minute which language they're using

@snarfmason @mattly yeah, I think you have to consider differently what's "better" in isolation vs better in context

if everyone switched to L->R consistently one day by magic: great; wonderful

if you have the one language trying to do it right in a sea of wrongness: maybe it's better to trade a few extra characters for increased clarity

Go Up