Re:Thought Experiment: An Introductory Compilers Class
by chubot on Tuesday February 18, 2020 @12:00AM
(#22353578)
About the last paragraph, R and Pandas both have that issue. (Although I'm not sure if it's a bottleneck in typical code, since there are other problems too.)
But Julia and the newer Weld compiler apparently have loop fusion:
Non-optimizing compilers for simple imperative languages are straightforward. There's a front end, which turns
into which can be represented as a tree. Then, for each operator, you generate code. So you generate something like Then you show how that can be generalized to cover functions, arrays, loops, etc. That's Compilers 101, Wirth's classic book on Pascal.This article takes a completely different approach. All functional, all the time. Not sure whether this is good or bad, but it's definitely different. Is what this guy is promoting mainstream in advanced compiler work today, or is he off in his own world?
One issue with functional everything is that naive functional compilation is very inefficient. If you write
where a is some kind of big collection, and g produces a similar collection as output, then you have an intermediate variable which is itself a big collection. Much of functional programming optimization is about trying not to generate big intermediate values, but converting the problem to a pipeline instead.