Objective-Smalltalk has been carefully designed to remove barriers between scripts and programs, to the point of making the differences disappear. Scripts have direct access to the full power of the system frameworks, and methods written in Objective-Smalltalk have all the power of a scripting language.
Most of Objective-Smalltalk comes as a framework, and can therefore be added to an application by linking in the framework.
It is also easy to add methods to classes, and there is a MethodServer that enables loading classes into a running process via HTTP.
Objective-Smalltalk comes with a Unix REPL called
The method declaration in the second line acts as an architectural adapter,
Scripts have full access to Cocoa classes. The following script uniques the
arguments passed on the command line via an
As we just saw, Objective-Smalltalk makes it easy to interact with web resources. The following example looks up a zip-code using the zipTastic web service.
Web serving is supported using the Objective-HTTP micro framework. A trivial Hello World server looks as follows:
After we load the ObjectiveHTTPD framework, we create a scheme handler that operates
in memory and hook it up to the URI scheme
The major difference is that whereas most web frameworks expect you to plug your data
model into the framework's concept of web-serving,
Scheme handlers can manage access to objects, respond dynamically by computing values or combine other scheme handlers.
Through use of the scripting bridge, it also becomes easy to control other applications via Apple Events, for example setting the iChat status message to the current iTunes track name.
This can be used directly from Unix scripts or application code without having to deal with script strings and try to pass arguments to those scripts via string processing or other means. If I want to prefix the current track name, I just write the code to do it:
(Note that the ScriptinBridge framework and corresponding schema are not loaded
into the scripting environment by default, you need to add them by executing
|Copyright © 2012-2018 Marcel Weiher|