4 votes

Programming Languages which are Homoiconic

I've been looking for languages which are homoiconic. I've worked with Lisp, Prolog and Smalltalk, as well as some of their children. Are there any other designs which have this useful feature?

2 comments

  1. tesseractcat
    Link
    Befunge is an esoteric language that's built on a 2D grid of ascii values. I think this language could be considered homoiconic since you can read and change the 2D grid at runtime using the g and...

    Befunge is an esoteric language that's built on a 2D grid of ascii values. I think this language could be considered homoiconic since you can read and change the 2D grid at runtime using the g and p instructions.

    1 vote
  2. skybrian
    (edited )
    Link
    There are a bunch more languages listed under "Implemention methods" in the Wikipedia article. I'm not sure Julia should really count, though. I played around with this when inventing my own...

    There are a bunch more languages listed under "Implemention methods" in the Wikipedia article. I'm not sure Julia should really count, though.

    I played around with this when inventing my own language. I think the key point of a true homoiconic language is that every bit of syntax needs to have two interpretations, as a general-purpose data structure and as a language construct. I tried an approach with six kinds of lists: space-separated lists, comma-separated lists, square bracket lists, blocks (curly brackets), dotted lists, and "clusters" of words and symbols written without any separator.

    The result looked a lot like a normal programming language, but calling these general-purpose data structures is a bit of a stretch, because you don't normally need six kinds of lists when dealing with data. It was more of a general-purpose syntax tree with six kinds of nodes. There was another parsing stage where this intermediate representation got turned into bytecode.

    Since then I've been thinking that homoiconic languages are overrated. If you have built-in support for quasi-quoting uninterpreted code to build a syntax tree at runtime from a template, then that seems good enough? The punning aspect of it where data structures and code look the same and you use the same functions for manipulating both allows a minimalist language to do a lot, but not using puns means you know what you're looking at.