Reading for 11/2: SELF #411
Replies: 11 comments 29 replies
-
A common complaint with template instantiation in languages like C++ is the code bloat, and it sounds like SELF is essentially doing a similar thing with compiling special versions of methods for every receiver. I guess it's not as bad as C++ since message splitting would allow the compiler to reuse parts of the different methods, but at its core, SELF seems to be generating a lot of copies of methods. The paper does mention employing some limitations on inlining based on method or block size which does help prevent a combinatorial explosion for methods that might themselves call a bunch of other methods, but other than that, it doesn't seem like the authors address this too much. From a quick glance, it seems that more recent JITs employ a set of heuristics for determining when to inline things, reuse parts of traces, and compile code to avoid excessive code bloat. Overall, it seems (from a very cursory survey) that code bloat in language mechanics like C++ templates have much more "press coverage" than potentially duplicated bits of code in JITs. I'm not sure if that's due to the contexts in which C++ is generally used caring more about this type of thing, or if the primary concern is on executable size. Or maybe it's not too much of a concern with JITs because they might only compile function and argument-type pairs that are hot or only small, potentially reusable, bits of a function. A final unrelated thought is that I found their invention of a new metric (MiMs) kind of funny, especially being pretty unfamiliar with message-passing paradigms. They didn't really use it to compare to other compilers, so I suppose it wasn't really concerning. What was more concerning was the comparisons of wall clock and CPU time, despite their assertions that the comparison is valid. If the wall clock and CPU times were basically identical for the SELF benchmarks as they claim, then why not put them in the paper? |
Beta Was this translation helpful? Give feedback.
-
In the conclusions the authors write:
How much do we agree with this statement? |
Beta Was this translation helpful? Give feedback.
-
The authors seem to tackle the challenge of implementing a dynamically-typed language efficiently, which is no small feat. |
Beta Was this translation helpful? Give feedback.
-
Wow this paper was very disorienting for me to read, because I did not know what Smalltalk is.
At this point, I was already lost at this point. The wikipedia page for SELF definitely helped explain why prototype-based programming exists. Moreover, it helped elaborate how messages are a unified why to interact with both fields and methods:
Hope these two points of clarifications help. After this little background research, I was much better equipped to read the paper. This paper is definitely very interesting because the whole programming paradigm and model of execution is very unusual to me., |
Beta Was this translation helpful? Give feedback.
-
The message-passing style object oriented programming reminds me of objective-C, which is also heavily influenced by smalltalk. In my understanding, objective-C is developed upon C, and they want to add object oriented features to C. C is a static language, but objective C wants to add some dynamic features. In that case, message passing seems to be an interesting paradigm that allows us to have dynamic features in a static language. What are some other languages using message passing to implement their object oriented features? |
Beta Was this translation helpful? Give feedback.
-
I echo the sentiment of not being familiar with Smalltalk, and as such not being familiar with this particular programming paradigm. Regardless, I found the author's description of the prototype-based programming paradigm to be interesting to read through, despite not quite fully grasping it. I'm both curious as to what its common use cases are in the modern day (if they exist), and also in general what would be a good way to better understand this paradigm. |
Beta Was this translation helpful? Give feedback.
-
The combination of customized compilation, inlining, and splitting gives rise to a powerful set of static techniques for optimizing performance. It begs the question of how one could leverage these techniques - presumably partially - with run-time information. Specifically, I think adding some instrumentation at compile time in order to gather profiling information at run-time seems to me to be a good fit to the methods of this paper, especially since it seems to me that their compilation time can be a problem for big enough SELF programs. One can imagine partially carrying out some inlining, then gathering run-time info to, say, have more accurate predictions of the recipients of messages, and then returning to more inlining. It would be nice if the benchmarks covered compiling efficiency as well, but I guess they were not worried about that. |
Beta Was this translation helpful? Give feedback.
-
When reading this paper, I thought about what advantages a prototyping language like SELF had over a more classical object-oriented programming language like C++, as the language design itself seems very different from anything else that is taught in university. Some exploration led me to the "fragile base class problem," where in complicated inheritance structures, seemingly innocuous modifications to base classes, may cause the derived classes to malfunction. This is especially important in legacy codebases where refactoring is in order, but a break to the base classes could be costly and cause a much more intrusive refactor/rewrite. With dynamic linking, under prototyping languages, we can change superclasses without affecting pre-compiled binaries, and overall more flexible inheritance decisions that can be made at run-time. I've heard the quote that "all problems in computer science can be solved by another level of indirection" -- and I wonder how much that applies in such a case comparing SELF to a language like C++? Is this concept still relevant under these dynamically compiled languages? |
Beta Was this translation helpful? Give feedback.
-
As many of the other commenters, I found SELF to be really fascinating as a language. It has inspired many of the most widely used languages and language frameworks today, like JavaScript and some implementations of JVM. I think one really fascinating aspect of SELF is its emphasis on an "exploratory programming environment," where programmers are encouraged to think of the language and IDE as one entity. It allowed programmers to directly modify objects while the program was running to allow programmers to explore the program more and to help debugging. (The paper also has sections about directly supporting this with incremental recompilation, while still maintaining low speed and memory usage.) This features seems to be quite rare and unique—but extremely useful—in today's languages. Most debuggers allow for some minimal version of this: where you can stop and step through code, execute arbitrary expressions, and modify program state, but you usually aren't able to modify the code directly without rerunning (and potentially recompiling) the entire program. I think the JavaScript web console and interactive notebooks (like jupyter) also capture some of this feature, but it is also not complete. I was wondering why this feature is no longer part of modern languages? Is it because the existing debuggers and tools are enough? Or the feature is prohibitively expensive or infeasible to implement while still being efficient? Or it's simply not useful enough? |
Beta Was this translation helpful? Give feedback.
-
As someone who has primarily worked in more rigid and statically typed languages such as Java, I found SELF to be really interesting and a completely different way of thinking than I am used to. Being able to adapt when the structure of objects and class hierarchy are expected to change dynamically throughout runtime is a really cool idea, however I am having some trouble thinking about it in a more concrete setting. What is a specific example where the class hierarchy is not predefined, and the structure of objects can dynamically change during runtime? Initially I was thinking of some sort of UI framework where the structure of graphics elements can dynamically change based on certain actions that the user performs. |
Beta Was this translation helpful? Give feedback.
-
The authors' efficiency improvements reminded me a lot of recent Python 3.11 changes to reduce frame generation and customize operations for execution speedup. Incidentally, the changelog makes note of a new "Self" type annotation from PEP 673, reinforcing indications that the concerns of the reading are really quite persistent. |
Beta Was this translation helpful? Give feedback.
-
Hi all! Here is the discussion thread for An Efficient Implementation of SELF, a Dynamically-Typed Object-Oriented Language Based on Prototypes! Looking forward to all your thoughts and comments :)
Beta Was this translation helpful? Give feedback.
All reactions