Why I love Smalltalk
11–20 of 38 posts
Re: Why I love Smalltalk
#12equals: other ^ PTrue new The implementation of ifTrue isn't done. The branching was just deferred to the equals function, which has to somehow choose between PTrue and PFalse. Will it take advantage of the ifTrue function you're building? Will it resort to some nasty arithmetic? Will it call some baked-in feature of smalltalk? Without an answer here, the "implementation" of if is just an illusion.
I don't think that's fair. Being able to implement if doesn't mean that the entire remainder of the system is built without any conditional instructions anywhere in its implementation. (The point, after all, isn't some sort of mystical purity; it's that if you can implement if then you can probably also implement whatever other control structures you happen to fancy. Which you can.)
(define (my-if cond t f) (if cond (t) (f)))
(my-if #t (lambda () ....) (lambda () ....))
The trickyness about if lies in the order of argument evaluation. If you ignore that, then it is relatively easy to implement if in any reasonable language. Even C (I had to leave out the function pointer types, as I haven't worked with c in a few years, and forget the syntax):
void my_if(bool cond, t, f) { if(cond) { t(); } else { f(); } }
void if_true() { ... } void if_false() {
}
my_if(true, if_true, if_false);
Point being, I think redxaxder may have been coming from a scheme background, realizing that if needs to be a builtin. It would indeed be fancy to be able to implement an if that doesn't rely upon other logical branching, though!
Re: Why I love Smalltalk
#13A Smalltalk image contains every Smalltalk object. This includes classes (which are Smalltalk objects), instances of the classes, source code, the current running state, everything. You work within the image and interact with it.
Think of the image as a copy of your IDE, along with the compiler, your current project's source code, the compiled classes, methods, everything. You can save your image (state) at any time, not unlike the sleep feature of Windows and Mac. It's a live environment. During a programming session, you edit and save the code of class (it's automatically compiled) and every instance of that class is updated. This sounds like what you commonly have in many dynamic languages, but Smalltalk takes it to an extreme. You can re-configure your "IDE" as you go along since they are running in the same image, all the classes and objects are accessible. Or you can set breakpoints and step through code, changing code on the fly and resuming, all without stopping the "program" and starting again. Not unlike a graphical REPL.
Does anyone know if there's a similar tool utilizing the same concept other than Self?
Re: Why I love Smalltalk
#14Copy of the text, since it's hard to reach the site itself [any layout errors should be assumed to be mine]: This post was extracted from a small talk I gave at Simplificator, where I work, titled “Why I love Smalltalk and Lisp”. There should be another post, “Why I love Lisp” following this one. After I learned my basic coding skill in more or less traditional languages, like C, C++, Python, there were four language…
Re: Why I love Smalltalk
#15Copy of the text, since it's hard to reach the site itself [any layout errors should be assumed to be mine]: This post was extracted from a small talk I gave at Simplificator, where I work, titled “Why I love Smalltalk and Lisp”. There should be another post, “Why I love Lisp” following this one. After I learned my basic coding skill in more or less traditional languages, like C, C++, Python, there were four language…
Appreciated :) I'm unable to access the site at all right now. HN traffic might have brought it down.
Re: Why I love Smalltalk
#16The syntax is quite unique to Smalltalk. The message, otherwise known as “method call” in other languages, is called show: (including the colon) and it takes an argument. self also uses this method call syntax. However this syntax can get quite confusing, see this example from http://en.wikipedia.org/wiki/Self_(programming_language) valid: base bottom between: ligature bottom + height and: base top / scale factor. Sm…
Re: Why I love Smalltalk
#17It covers some of the minimal syntax of Smalltalk but didn't touch on Smalltalk images, which is a major signature of Smalltalk. A Smalltalk image contains every Smalltalk object. This includes classes (which are Smalltalk objects), instances of the classes, source code, the current running state, everything. You work within the image and interact with it. Think of the image as a copy of your IDE, along with the comp…
Re: Why I love Smalltalk
#18The syntax is quite unique to Smalltalk. The message, otherwise known as “method call” in other languages, is called show: (including the colon) and it takes an argument. self also uses this method call syntax. However this syntax can get quite confusing, see this example from http://en.wikipedia.org/wiki/Self_(programming_language) valid: base bottom between: ligature bottom + height and: base top / scale factor. Sm…
Re: Why I love Smalltalk
#19equals: other ^ PTrue new The implementation of ifTrue isn't done. The branching was just deferred to the equals function, which has to somehow choose between PTrue and PFalse. Will it take advantage of the ifTrue function you're building? Will it resort to some nasty arithmetic? Will it call some baked-in feature of smalltalk? Without an answer here, the "implementation" of if is just an illusion.
If you go deep enough, the comparison and/or branching is built in in the microchip and you use that.
Re: Why I love Smalltalk
#20Earlier quoted context omitted.
I don't think that's fair. Being able to implement if doesn't mean that the entire remainder of the system is built without any conditional instructions anywhere in its implementation. (The point, after all, isn't some sort of mystical purity; it's that if you can implement if then you can probably also implement whatever other control structures you happen to fancy. Which you can.)
Actually, that really is how Smalltalk does if.