Modern compilers seem to work with trees more often than graphs. Trees would certainly be easier to work with in any language.
That said, functional languages can and do work with graphs when needed, but yes it is much more awkward than trees.
Re:A Simple Compiler in JavaScript
by seanmcdirmid on Sunday January 21, 2018 @11:19AM
(#16198579)
Not down in the lower levels of IR and IL, the trees have mostly disappeared by then. If you are just interpreting or doing unoptimized compiling, you can get by with just trees.
GHC Haskell does nearly all its optimisation using trees and a high-level functional IR, so I think you are understating trees.
Re:A Simple Compiler in JavaScript
by seanmcdirmid on Sunday January 21, 2018 @02:45PM
(#16199592)
Yes, but I don't think they require a low-level IR in that case (purity, no re-assignment, no loops). LLVM does not use trees at that level, for example, because they really need to use stuff like SSA, basic blocks, and so on.
Re:A Simple Compiler in JavaScript
by thangngoc89 on Sunday January 21, 2018 @11:09AM
(#16198543)
Tree is also a form of graph
Compilers often use graphs as intermediate representation, and functional languages often are not a good fit for dealing with them.