Archive for the ‘Smalltalk’ Category

For this week’s meeting, there will be two mini-presentations on F-Script and view-based animations in Core Animation. Source code and sample apps will be available afterwards. Read more…

Read Full Post »

A new episode of James Robertson’s Smalltalk for U series.

Read Full Post »

Ask F-Script

Vincent Gable on using F-Script for answering quick API questions instantly.

Read Full Post »

Thanks to the support of the good folks at the Mac Developer Network, the NSConference talk on F-Script 2.0 is now available for free. The session explores the need for interactive manipulation of objects and shows some of the cool graphical tools provided by F-Script to achieve it. Other new features in F-Script 2 are discussed, including dynamic Cocoa class creation, system wide scripting and the latest in exploring applications from the inside through run-time injection.

If you have never used F-Script and want to know what it is all about, this video should provide you with a good overview, packed with demos of interesting dynamic object-oriented technologies. If you are a regular F-Script user, you’ll feel at home but might still learn a few neat tricks.

You can watch the embedded video above or get to the video on its Vimeo page.

Read Full Post »

You can download F-Script 2.1 now (for Mac OS X 10.6 or later).

The main new feature in this version is support for adding methods to existing classes. This is similar to Objective-C categories, but works dynamically at run-time. This is quite useful for prototyping stuff and experimenting with new designs, as well as for making object-oriented frameworks developed independently work together. Besides, it is a natural extension of the ability to define Cocoa classes directly in F-Script and lets you write a bigger part of your application code in F-Script, should you want to.

You can teach new tricks to any class registered in the Objective-C runtime, regardless of its original implementation language (Objective-C, F-Script or other). The syntax is straightforward: class name followed by new methods inside a pair of curly braces. For example, here is how we can add a print method the NSObject class:

   - (void)print
       "Print the receiver's description on standard output."
       stdout print:self description

Of course, this also works for class methods. For example, the following code adds a pi method to the NSNumber class:

   + pi
       ^ 3.141592653589793

The following example, a little bit more sophisticated, adds some common Smalltalk collection methods (namely collect:, inject:into:, groupedBy: and select:) to the NSArray class:

   - collect:transformer
       "Answer a new NSArray constructed by gathering the results of
        evaluating transformer (a block with one parameter) with each 
        element of the receiver."

       ^ transformer value:@self

   - groupedBy:criteria
       "Answer an NSDictionary whose keys are the result of evaluating 
        criteria (a block with one parameter) for all elements in the
        collection, and the value for each key is the collection of 
        elements that evaluated to that key. For example
          {'Hello', 'guys', 'I', 'enjoy', 'programming', 'with', 'style'} 
        returns a dictionary with the following key/value associations:
           1 -> {'I'},
           4 -> {'guys', 'with'},
           5 -> {'hello', 'enjoy', 'style'},
          11 -> {'programming'}"

       | result |
       result := #{}.

       self do:[:each| 
           | key group |
           key := criteria value:each.
           group := result at:key.
           group == nil ifTrue:
               group := {}.
               result at:key put:group.
           group addObject:each.

       ^ result
   - inject:initialValue into:operation
       "Answer the final result of evaluating operation (a block with
        two parameters) using the previous evaluation result and each 
        element of the receiver as the parameters. The first evaluation
        of operation is performed with initialValue as the first 
        parameter, and the first element of the receiver as the second 
        parameter. For instance, to sum the numeric elements of an  
        array, use:
            anArray inject:0 into:#+"
       | nextValue |
       nextValue := initialValue.
       self do:[:each| 
           nextValue := operation value:nextValue value:each
       ^ nextValue

   - select:discriminator
       "Answer a new NSArray which contains the elements in the 
        receiver which cause discriminator (a block with one parameter)
        to evaluate to true. For each element of the receiver, 
        discriminator is evaluated with the element as the parameter. 
        Each element which causes discriminator to evaluate to true is 
        added to the new array."

       ^ self where:(discriminator value:@self)

Share and enjoy!

Read Full Post »

Michael Tyson’s Core Data Browser.app is a nifty tool which lets you easily open a Core Data database for graphical exploration with F-Script. You can read more about it in
Browsing Core Data databases using F-Script. I wonder where in Europe it has been developed…

Read Full Post »

In F-Script, blocks combined with message sending can be used to create new control structures fitting your needs (and mood!). Indeed, things like if/else, while or exception handling control structures are all provided at the library level, with no need for specialized syntax in the language itself. In F-Script Switching Options, Jeff explore creating new kinds of conditional control structures:

There are many ways to think through the flow of a program, and times when certain constructs like switch statements are a nice option, even in a language with no syntactical support for it, per se. Philippe Mougin was discussing just such options in F-Script back in the Oughts. I had a need for switching in F-Script, and came up with a few versions that I found useful. Read more…

Read Full Post »

F-Script injection brings amazing capabilities: it lets you explore applications from the inside, interactively navigating and manipulating the internal Objective-C objects they are made of. And it is all done live, while the applications are running. For example, if you haven't seen it yet, here is how the Finder looks like from the inside and here is a fun video clip showing how you can reprogram an application on the fly.

Since the dawn of times, F-Script injection was provided by F-Script Anywhere. But as you may know, Snow Leopard broke it without mercy. Fortunately, an alternative F-Script injection mechanism has been made available. Still, it requires launching gdb and typing a command, which is boring.

Today, I'm glad to announce that all of this is now entirely automated, thanks to the injection service developed by Silvio H. Ferreira. It adds an automated F-Script injection procedure in the Services menu, meaning that injecting a whole F-Script environment in an application is now just two mouse clicks away: one to go to the Services menu, and one to select the "Inject F-Script into application" item. This brings back the zero configuration and ease of use spirit of good old F-Script Anywhere.

Picture: injecting F-Script into the Finder using the new injection service
The revenge of F-Script anywhere

Once injected (which can take a few seconds), F-Script will make itself available by adding an F-Script menu in the menu bar of the target application.

You can download the F-Script injection service here (for Mac OS X 10.6).


Read Full Post »

Marketcircle, the maker of Daylite and Billings, is now an official sponsor of the F-Script project. Marketcircle is a big user of F-Script, which is integrated in Daylite and Billings and provides end-users with a lot of power and flexibility for advanced tasks such as creating sophisticated reports. Indeed, seeing how end-users directly make use of Smalltalk in the context of some of the most popular business applications on the Mac is quite nice.

By the way, if you are a Daylite or Billings user and are new to F-Script, there are a number of resources of should be aware of:

FSClass is a flexible and powerful block-based class creation and manipulation framework for F-Script 2.0. Jonathan Sterling is now implementing a similar framework for pure Objective-C:

I recently found an amazing bundle for F-Script called FSClass. FSClass allows you to mess with F-Script/Objective-C classes at runtime. […] Of course, this library can also be used from within Objective-C, but it isn't all that useful for most projects since the method blocks must be FSBlocks, coded in F-Script/Smalltalk. I wanted to write a similar system for pure Objective-C using normal blocks. And this is how I did it. Read more…

Read Full Post »

Nicholas Chen on making Objective-C land more habitable…

Read Full Post »

Jonathan Sterling discusses writing fully native Cocoa applications in Smalltalk with F-Script in "Writing Mac OS X applications in Smalltalk"

What I really wanted was a version of Smalltalk that used the same object model as Objective-C, like Pragmatic Smalltalk of Etoilé, or even MacRuby on Mac OS. Most of all, I wanted it to treat me like an adult: I don't need a class browser, thank you, I'm more comfortable working with plain-old files. The persistent image construct in Smalltalk really makes me uncomfortable. Eventually, I found F-Script, a scripting environment for Mac OS based on Smalltalk. It is not really meant for developing full applications, but with a little work, I was able to make this work. Read more…

Read Full Post »

Fabian Schuiki explains how F-Script can be used as a debugging tool when developing Cocoa applications in "F-Script: The Ultimate Debugging Console".

If it weren’t for F-Script, I would have spent 5 hours today writing debugging code and creating some testing UI for Artifica which would have been another source for bugs which increases complexity of the debugging process again. F-Script gives you the possibility to completely split up the development of your object model and your view model, which not only saves you a lot of time and is more productive, but is also less frustrating since you never have to go figure whether your app’s functionality is broken due to a bug in the UI, the object model or even worse, somewhere in between. Read more…

Read Full Post »

Joint Ruby and Smalltalk BlockCamp in Paris

The french Ruby and Smalltalk communities are organizing the first BlockCamp event in Paris on the 28th november 2009. I will be there and will talk about F-Script 2.0. Come join us! More information here…

Read Full Post »

In this fun video clip, it takes Jeff only a few seconds to bring support for Snow Leopard’s text substitutions to WriteRoom… Cool demo of F-Script injection, for those unfamiliar with it.

Read Full Post »

Older Posts »