Hacker News new | past | comments | ask | show | jobs | submit login

Not to get off on too much of a tangent, but you may be interested in concatenative programming languages. They’re a variety of stack-based programming languages with a functional flavour, in which the default style is a sort of data pipeline. For example, in Factor[1]:

    ! Just some imports.
    USING: accessors smtp ;

    ! Create a new email object.
    <email>

    ! That object is piped implicitly to these setter words.
    ! E.g., >>from: ( email new-address -- email )
    "alice@example.com" >>from
    { "bob@example.com" } >>to
    "Coffee?" >>subject
    "You pick the time and place." >>body

    ! Pipe that object on to the “send-email” word.
    send-email
Note how no local variables are necessary for simply plumbing data around—although of course you can use them if you want.

The weirdest thing is probably that arithmetic in most concatenative languages is written in postfix, which you may find off-putting. But it’s no worse than Lisp’s prefix notation, and has some other benefits.

Factor also has an excellent interactive environment; the whole thing feels like a Lispy Smalltalk.

[1]: http://factorcode.org/




>arithmetic in most concatenative languages is written in postfix

Postfix? I'm assuming a typo here but not sure what you meant.

Edit: Ah, I'm guessing it was supposed to be postscript. Makes more sense now.

Looks like an interesting language style though, I've been looking for a language that has the bash style piping baked into the language.


Prefix/postfix/infix refer to the order in which you write operations and their operands—equivalently you can think of preorder/postorder/inorder traversals of the syntax tree.

    AST          +
                / \
               *   5
              / \
             2   3

    Infix    2 * 3 + 5
             2 times 3 plus 5.

    Prefix   + * 2 3 5
    Lisp     (+ (* 2 3) 5)
             The sum of the product of 2 and 3, and 5.

    Postfix  2 3 * 5 +
             With 2 and 3, multiply. Then with 5, add.


Ahh, understood now. I figured postscript as it's also a concatinative programming language.

I read postfix as in the mail server not as a synonym of suffix, thanks for the clarification.


> synonym of suffix

Antonym, actually. Prefixes are literally on the other end of things than suffixes are ;)


He's talking about postfix, not prefix. It's closer to being a synonym of suffic.


Oh shit, true. My mistake. Sorry!




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: