Skip to content

Ask HN: effects of prefix notation on coding / thinking

2 pointsbOR_6 comments
On HN

Hi all. I was looking, and failed to find information on the net on what kind of effect coding in prefix notation has on the way you think, compared to infix notation.

I know that after a few months of toying with arc, the prefix notation seems to be clearer to my mind than similar code in infix (I still code in ruby at work), but finding anything concrete on the net about the effect of coding in prefix is tricky. I mainly run into blog-posts expressing a similar feeling.

  http://en.wikipedia.org/wiki/Sapir-Whorf_hypothesis
  http://www.frozenreality.co.uk/comic/bunny/index.php?id=919

Comments

Some languages allow an unambiguous mix of infix and prefix.

  OCaml & Haskell:   5 + 7    or   (+) 5 7
Most non-alphanumeric operators are infix unless in parens.
  Haskell: map (\ x -> x + 1) [1, 2, 3]   
           or (\ x -> x + 1) `map` [1, 2, 3]
Two-argument, alphanumerically named functions can be made infix with `backticks`.

Of course, infix is (always/usually?) only for some operators (e.g. arithmetic ones), with everything else prefix, just usually written foo(x, y) instead of (foo x y), but prefix nonetheless.

Have you tried coding in postfix aka Forth, yet?

bOR_OP

Learning one language at a time =). Haven't tried postfix / Forth yet.. so I don't know how that would feel.

Factor (http://factorcode.org/) is another postfix / stack-based language that may be worth a look.

bOR_OP

Heard of it. But I was looking not for different languages to learn, but some kind of analysis on what the effect is on the way programmers think because of using an infix / prefix or postfix language.

For example: I remember I heard somewhere that japanese kids are better in mental arithmetic based on the way the japanese counting system works (no clue if that's true, heard it ages ago). So it is the analysis of the effects I am after.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.