I was trying to understand the Wikipedia article on homoiconity, but it's too verbose and does not explain the main theory behind the word concisely. I should add that I'm not a native English speaker so I prefer simple English over academic white paper quotes.
So, what exactly does it mean if a language is homoiconic? What makes C#, Java or JavaScript non-homoiconic?
It means "code as data" which is a general characteristic of Lisp family.
Just like above string, which is both a list and also a function call. The "Homo" prefix stands for this characteristic.
Scheme is homo-iconic because its programs have an interpretation as data structures.
is a list, the first element of which is
define
, the second(foo x)
(a list), and so on. The quote mark'
means: don't interpret this, leave it as a list. If we remove the'
we getwhich is a Scheme function definition. Because Scheme program definitions are nested list expressions (and thereby a sort of "syntax tree literals"), and Scheme is a dynamic language, you can play tricks with this to build very powerful macro/code generating systems.
Now Java isn't homo-iconic simply because it doesn't provide these kind of "program literals" that evaluate to parse tree fragments. Of course, you can define a string
which you could parse and feed to a compiler, but that's awkward, because it's a string rather than a structured term.