4 ms·
How does smalltalk compare to objective-c? It's on my list of languages to learn because it started with message passing, but if it's user experience is as bad
by sportanova 10y ago
How does smalltalk compare to objective-c? It's on my list of languages to learn because it started with message passing, but if it's user experience is as bad as objective-c I might pass
- qwertyuiop924 10y agoIt depends on how you think objective-c's UX is bad. Smalltalk's syntax is much simpler than O-C's. It has three message passing formats: object message. object + arg. "There are very few valid names for these sorts of messages" object argNameOne: argOne argNameTwo: argTwo. Double quote is a comment, period is the statement delineator, and semicolon is the cascade operator, allowing you to send multiple messages to one object. It has a block (or lambda) syntax similar to Ruby's, although multiple blocks can be passed to a function. This is pretty much all of SmallTalk's synax. Yes, really. There's also syntax for local variables, and returning values from method calls, and maybe one or two other things. That's it. It should also be noted that Smalltalk is inseparable from its IDE and image. GNU Smalltalk tries, but it's not the same. To speak of one is to speak of the other, so I shall speak of both. Smalltalk code exists entirely within its image, along with all the tools that make up the IDE. It's sort of an OS in and of itself, although you can interact with the native system. The practical upshot is that when you edit smalltalk code, you have all the source code for the entire implementation along for the ride: You can not only query Smalltalk about your own code, you can query it about itself using the same mechanism. You can also edit and debug your app in real time, as it runs. Smalltalk's debugger allows to to inspect every single stack frame, and make changes to your source as necessary. You aren't editing text that will become objects: You are editing objects. And because the entire system state is saved to the image, none of the changes you make to the running code will be lost, unlike most Lisps, where changes you make at the REPL go away as soon as your app shuts down. It's truly unlike anything else you will see.
- sportanova 10y agoThanks! It sounds like the IDE is the real feature
- passthefist 10y agoI'm not really well versed in the language, but from what I've seen it takes the whole 'everything is an object' concept seriously, which I think is kinda fun. For example, booleans are an object that can have two values: True and False. There's also two methods on the boolean object, ifTrue: and ifFalse:, and they both take a code block/anonymous function as the only argument. Both True and False override these functions. True's version of ifTrue: calls the code it's passed, and False's version does nothing (and vice-versa for ifFalse:). For example: a < b ifTrue: [^'a is less than b'] ifFalse: [^'a is greater than or equal to b'] They're implemented more or less as a standard library package rather than a language construct. You could potentially extend the boolean class with different implementations of ifTrue and ifFalse, maybe reversing the logic or logging the branch taken or whatever. The functionality can be changed dynamically. I think it's neat when a language eats itself like that.
- qwertyuiop924 10y agoYeah. Smalltalk is pretty much that. Even moreso than Lisp. And now for the mandatory quote from "A Brief, Incomplete, and Mostly Wrong History of Programming Languages": 1980 - Alan Kay creates Smalltalk and invents the term "object oriented." When asked what that means he replies, "Smalltalk programs are just objects." When asked what objects are made of he replies, "objects." When asked again he says "look, it's all objects all the way down. Until you reach turtles."
- deleted 10y ago[deleted]