‹ BackHN Continuity

Thread

Needed 1+1, built a functional programming language

151 points · 80 comments · birdculture

  1. herodotus · · focus · HN ↗
    I once invented a programming language where EVERYTHING was an object. No message keywords. 1 is an object. + is an object. You can send an object to another object - you get back an object. Example 1+ is an object. Its is the result of sending + to 1. If you send 1+ the object 1, you get 2. If you send 1+ the object + you get a run-time type error. You can also go left to right. +1 is an object. If you send +1 to 2, you get 3. It gets nice when you add list objects. (1,2,3,4,5)+1 => (1+,2+,3+,4+,5+) 1 => (2,3,4,5,6). And so on.
    1. skrebbel · · focus · HN ↗
      Does that imply no support for operator precedence?
      1. herodotus · · focus · HN ↗
        It does. Parenthesis are allowed - they are syntax for lists so that a * (b + c) will compute the contents of the list before sending the resulting object to a*. The inspiration is the idea of Currying in Lambda Calculus, although it requires postfix notation. Now you have me thinking about whether I could alaso make parenthesis and commas into objects. So (1+2) for example for do this: ( is sent the object 1. That yields the object (1 That is, an object that is not ready to be sent on. The "(" bounded object would only be released when it received a ")". Thanks for the thought!
        1. Zone3513 · · focus · HN ↗
          So not everything then
    2. TazeTSchnitzel · · focus · HN ↗
      This sounds a bit like Smalltalk! But with partial application…

      It also reminds me of the Emily programming language: <a href="https:&#x2F;&#x2F;github.com&#x2F;mcclure&#x2F;emily&#x2F;blob&#x2F;stable&#x2F;doc&#x2F;tutorial.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mcclure&#x2F;emily&#x2F;blob&#x2F;stable&#x2F;doc&#x2F;tutorial.md

      1. WorldMaker · · focus · HN ↗
        Yeah, the Smalltalk and Self family take this &quot;everything is an object&quot; approach, sometimes to extremes.

        Another relatively well known language in this space for its use as an alternative to especially Lua in embedding situations is Io: <a href="https:&#x2F;&#x2F;iolanguage.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;iolanguage.org&#x2F;

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.