I have been learning Clojure and looking at Scheme and CL which introduced me to the world of prefix notation. At first I didn't like it but it is still starting to grow on me. To be honest though, there are still long calculations that are difficult for me to understand but I think that is an issue of me needing more exposure/practice and I'll get it.

But that leads me to the question: Which type of notation do you prefer and why?


8 Answers 8


I find infix notation easier to read, simply because I've been working with it ever since kindergarten.

  • 7
    +1 for not claiming that infix is more intuitive or natural. Commented Dec 15, 2010 at 19:34

I have no preference. I can work well in either.

Not many programmers realize that prefix notation is actually the norm and infix is the oddball. After all, just about every language uses prefix notation for function/method calls. It's only a relatively small number of arithmetic and logic operators that are infix.

The more you look at our system of mathematical symbols, the more screwy you see they are. Some are infix (+, -, *), some are postfix (x2), some prefix (tan x), some under-fix (ratios and fractions), and some overfix. It's not as simple as PEMDAS.

  • 5
    I suppose you wanted to say "Not realize many people that and actually is prefix notation the norm is infix the oddball". Parentheses omitted for clarity :P
    – back2dos
    Commented Dec 14, 2010 at 19:02
  • 1
    "After all, just about every language uses prefix notation for function/method calls" Actually method calls are infix in most mainstream languages, i.e. receiver.method(arguments), not method(receiver,arguments).
    – sepp2k
    Commented Dec 14, 2010 at 19:24
  • (with (edited the-answer) (of suggestion back2dos)) Commented Dec 15, 2010 at 8:55
  • 1
    @back2dos: And I suppose you wanted to say "Realize not many programmers and that actually is prefix notation the norm is infix the oddball." Not only is it unfair to bring natural language into a discussion about artificial langauge, but also, to quote Wikipedia, "The overwhelming majority of the world's languages are either SVO or SOV, with a much smaller but still significant portion using VSO word order." So actually prefix is more of an oddball than infix, and even less common than postfix.
    – Jon Purdy
    Commented Dec 15, 2010 at 21:38
  • SOV... I've always had an affinity for FORTH. And Japanese. Commented Dec 16, 2010 at 0:09

I like prefix for function-like things, infix for operator-like things, postfix for property-like things, and mixfix for control-flow like things:

// prefix:

// infix:
1 + 2
4 / 5

// postfix:
list size
employee name

// mixfix:
if a then b else c // (where if/then/else is the mixfix function)

What I don't like is languages that don't let me express things the way that reads most naturally to me. I don't like:

// lisp, have to do prefix for everything:
(+ 1 2)
(if a b c)
(size list)

// forth, have to do postfix for everything:
1 2 +
a b c if
1 + 2
4 / 5
  • 2
    Depending on which Lisp you use, you may not need to use prefix for everything. There are infix macro packages available for Common Lisp. Commented Dec 15, 2010 at 19:33
  • That's true in theory, but in practice Lispers seem to always go prefix.
    – munificent
    Commented Dec 20, 2010 at 23:55
  • Prefix: operator is on the left, args on the right. Postfix: operator is on the right, args are on the left. So I think your property-like things example is incorrect. Forth example is good though.
    – Adobe
    Commented Sep 9, 2016 at 8:35
  • In the postfix examples, "size" and "name" are the operations being performed and "list" and "employee" are the arguments.
    – munificent
    Commented Sep 9, 2016 at 14:32

Prefix, simply because operator precedence is explicit.

FYI, Longer calculations (really, any chain of operations) in Clojure can be broken out using the -> and ->> macros. e.g.:

(-> (get-some-value)
  (* 2)
  (max 50))

is the equivalent of:

(max (* (inc (get-some-value)) 2) 50)

While the -> macro prepends prior results to the arguments of the next expression, ->> appends them. This is typically very handy when used with functions that expect collections and seqs:

=> (->> "some string we want to capitalize"
     (partition-by #{\space})
     (mapcat #(cons (Character/toUpperCase (first %)) (rest %)))
     (apply str))
"Some String We Want To Capitalize"

Providing facilities for easily composing simpler operations into compound ones like this is one of Clojure's big advantages. For additional reading, check out fogus' post on the -> macro, and then his later post on the topic of "properly thrushy" thrush combinators in Clojure.

  • Function composition, you say...
    – Inaimathi
    Commented Dec 14, 2010 at 21:19

Of those two, prefix (postfix could be used the same way, but the only languages I know of that use that are PS and Forth).

  1. It removes the need for any kind of operator precedence and left/right associativity. Both in the sense that you don't have to think about it, and in the sense that the language implementation is slightly simpler since these forces are pre-resolved.
  2. If applied consistently, the resulting code is very close to a tree, which makes parsing easier or unnecessary (and this allows things like programmatic manipulation of that tree structure).
  • 2
    It hardly takes 100 lines to resolve the problems you are describing. Parsing really is not a challenge compared to whatever happens next. Programming language syntax is targeted at programmers, not at parsers.
    – back2dos
    Commented Dec 14, 2010 at 17:43
  • @back2dos - Agreed, the fact that it's resolved for the implementation is a minor benefit. Why should I (as the programmer) have to figure out what something like (3 + 6) - 8 × 3 / 24 + 5 actually means? Why not just write (+ (- (+ 3 6) (/ (* 8 3) 24)) 5) and remove all doubt, and need for mnemonics?
    – Inaimathi
    Commented Dec 14, 2010 at 18:06
  • 1
    For the same reason many people stick with QWERTY. It's the predominant way to do it. Speaking for myself, I can process the first expression much faster. I can see why prefix-notation is better, but I'd really have to get used to it.
    – back2dos
    Commented Dec 14, 2010 at 18:49
  • @back2dos - It's true; there was a non-trivial adjustment period the first time I saw the basic arithmetic operators in CL/Scheme. I think it's worth it for the added consistency and precision. YMMV, as always.
    – Inaimathi
    Commented Dec 14, 2010 at 21:15
  • 1
    @SHiNKiROU: However, if you have parens, you can vary the arity, and I think (+ a b c d e) is easier to read and write than, say, + + + + a b c d e. Commented Dec 15, 2010 at 20:46

I vastly prefer to have prefix when I'm reading code.

But infix when thinking about code.


Postfix. It is clearly the most commonly used in procedural languages and object oriented languages.

Sequential code is postfix notation:

  do x; do y; do z;

OO code is postfix too:


Most OO and procedural languages used both these conventions heavily mixed with a bit of infix and maybe some prefix to lighten the cognitive load an increase pattern recognition.

Even functional languages use postfix like format commonly:

   let x = g r in
   let y = f x in

as a way to make the less comprehensible prefix version:

  let y = f (g r) in

easier to read by factorisation (please imagine a longer more nasty chain of applications:)


It depends,

binary operators in which order is important (asymmetric) benefit from infix notation as it is easier to distinguish which way round the operator will be evaluated e.g.

x.Operation(y); //so x is doing "Operation" to y

compared to

Operation(x,y); //what was the order of arguments again?

symmetric operators this is less of an issue, and indeed can sometimes by expanded to be n-ary operators with pre or post fix notation when associative e.g.


for pre-fix vs post-fix I prefer prefix as like yoda, you talk, with post-fix

last of all here is what dijstra had to say on the subject in essence he favoured infix for associative operations

  • 1
    Love the djistra essay, in his original hand. A real gem, thank you. Personally love working with postfix as implemented in the R package magrittr. Commented May 19, 2018 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.