7 ms·
Seeing an article about Smalltalk with Hernan presenting so up in HN is nice. I worked with Hernan a while ago. We worked in a financial system with very cool
by diegof79 3y ago
Seeing an article about Smalltalk with Hernan presenting so up in HN is nice.
I worked with Hernan a while ago. We worked in a financial system with very cool things: an OO database, a workflow system that can work locally or remotely transparently, a good model for units and dates, tons of custom tools in the IDE (something that is only possible with Smalltalk IDEs) that allowed us to automate unit test generation, versioning, and database migrations. The last time I saw that level of productivity in any IDE was then.
However, Smalltalk is not perfect, and when I see these presentations, I cannot stop thinking that a more balanced discussion is needed.
The presentation shows how Smalltalk blocks are uniform with the if/then/while syntax. But that's only part of the history. To support blocks that way, the compiler optimizes those cases and inlines the block unless you do something else. So, while assigning the block to a variable looks the same, it's not executed similarly. That's the beauty of hiding the implementation details. But, sometimes, those details bite you. Most St programmers avoid creating custom "ifThen:else" messages because, in most VMs, that will break.
In other words, like any design decision, the simplicity of the "object message" syntax has trade-offs, too. The performance trade-off is fixed by having exceptional cases hidden from most programmers. The other trade-off is the need to always dispatch to a receiver. Compared to Lisp or other functional languages, the need for a receiver dramatically impacts how you design and structure your program. Many things that you can resolve with a polymorphic function need to spread across classes in St. And that introduces the problem of sharing the implementation: class hierarchies, traits, or composition. Resolving those problems with a simple function is refreshing and falls under the statement at the beginning of the talk: the programming language affects how you think about the problem. When I look at the code I wrote back then in Smalltalk or Java, I cannot stop thinking about how the restriction of using classes and methods adds unnecessary complexity.
- JonChesterfield 3y agoI'm a little confused by the receiver thing. Is the idea that each object has a dictionary mapping function names to code and sending a message to an object means execute whatever was found in that dictionary? So the example of { a < 3 } while involves evaluating a block, getting a boolean, then calling the while method on that boolean? That would seem to have a bad time with things like compare. Neither argument is special, you end up implementing a lot of compare-with methods. I.e. the expression problem. Is that understanding broadly correct?
- smackeyacky 3y agoPretty much although it doesn't end up being quite as bad as it sounds. For example, your code wants to compare a string with some other object, if the other object understands 'string' then the built in method for comparing two strings can work. Otherwise you get a #doesNotUnderstand exception. Making arbitrary comparisons is a bit silly though, so in practice it doesn't happen very often.
- zozbot234 3y ago> Is the idea that each object has a dictionary mapping function names to code and sending a message to an object means execute whatever was found in that dictionary? Isn't that how Python, Ruby, JS etc. work under the hood anyway? And yes it's quite predictably a drag on performance.
- lovelyviking 3y agoIf one needs to run Squeak in a very minimum VM . Is it possible? Any help with that? I tried to make vm in Squeak turning off graphics/sound and compiled vm but it just didn’t work when I was trying to run it. Is there a relatively simple way to remove all fancy objects and keep only bare minimum that would at least run it so I can learn it further? It has to be VM that gives repl through terminal and ability to modify image further, vm need to run without breaking if graphics/sound not available when even linux drivers aren’t available, on pi zero w let’s say. With my current limitations I cannot dive into learning the language deeply in any other different setup. Is it possible? I am sure someone have already done that somewhere. I am really trying to avoid dealing with c++ but the way vm is done it seems that instead of learning Squeak I have to dive into all the ‘beauty’ of compiling c with cmake instead.