# Which programming languages don't use operator precedence besides Lisp-like languages? [closed]

And what do you think about operator precedence? Would be harder programming in a language where the operations are executed in sequential order?

Ex.:

2 + 3 * 4 == 20

2 + (3 * 4) == 14

OK, the Lisp family doesn't have precedence by definition. Let's gonna talk about procedural and object-oriented languages using this "feature".

• It would be a strange language indeed that doesn't have operator precedence that isn't generally the same as found in classical mathematics. Sep 14, 2010 at 2:25
• This doesn't seem off topic to me. Is there a reason you decided to close your own question? Nov 25, 2010 at 5:24
• @Macneil: It's objective and can be ask on Stackoverflow. Nov 25, 2010 at 9:02
• This is a poll type question and I don't see the value in it. It's like asking "which languages don't support parameterized types" Feb 25, 2013 at 23:25
• Swift doesn’t have operator precedence in the language, but defined in the standard library or defined by the user. The language supports that operators have precedence, associativity but does not which one. Feb 22, 2018 at 9:05

## Smalltalk.

Everything's done with message sending, so `1 + 2 * 3` means "send * with parameter 3 to the object returned by sending the message + with parameter 2 to the object 1".

That throws people (it threw me) because of how we usually write maths, but since I can never remember C's operator precedence I cope in the same manner in both languages - I use ()s to group terms: `1 + (2 * 3)`.

### Forth

It's (almost) all RPN notation, so no precedence rules needed. I'd wager most languages using postfix or prefix notation (PostScript, Lisp...) would work the same.

LISP-type languages don't need precedence because expressions are fully parenthesized. There is no need for precedence to evaluate

``````(sqrt (expt (- x1 x2) 2)
(expt (- y1 y2) 2))
``````

I know J, and I believe it's close relative K (along with their parent language, APL, as noted by @Jerry Coffin), evaluate everything right to left with no precedence.

• Neither prefix notation (as in Lisp languages) nor postfix notation (HP calculators) need operator precedence. It's only infix that needs parentheses. Sep 15, 2010 at 6:15
• Prefix notation can do away with parentheses only if all operations have fixed arity. In the LISP family, the arithmetic operators can take more than two arguments (or less): (+) -> 0, (* 1 2 3 4) -> 24, etc. Sep 15, 2010 at 14:50
• Ah, you got me there! Quite right; I assumed "operator" meant "binary operator" Sep 15, 2010 at 15:30

APL has no precedence. If memory serves, everything is grouped right to left.

Oddly, at least in an official sense, neither C nor C++ has operator precedence. The standard isn't written that way, although (of course) it's mostly a different way of saying the same thing as having precedence. OTOH, it is only mostly the same thing -- ultimately, there's no way to write a precedence table for C or C++ and get everything quite right. There are a few things that just won't quite fit.

• C and C++ both have precedence. It's even a part of the formal grammar. I believe what you're talking about is the order of the evaluations of subexpressions. For example `f() + g() * h()` in C/C++ can call any of f, g, or h first, but it always computes (the equivalent of) the `*` happening before the `+`. Oct 29, 2010 at 1:02
• APL is parsed right-to-left, but evaluated left-to-right.
– Ven
Feb 21, 2018 at 13:45
• @Ven - yes APL for the win! Feb 18, 2021 at 17:09

## Prolog.

Well, kind of. There are standard operators, with standard precedence... but you can trivially define operators with arbitrary predence, because `1 + 2` is really the goal `+(1, 2)`.

You may define infix (`1 + 2`), prefix (`++X`) and postfix (`X++`) operators, with arbitrary associativity (so left, right or both).