Bring Smalltalk into new technologies is always a hard but exciting job. In this talk we take another step from those already made, and we walk one of the possible approaches to build iPhone applications using Pharo.
2. Disclaimer
I’m very sorry, my english sucks... badly
But I’ll do my best
3. Esteban Lorenzano
On 1994 G. Rossi teach me that Smalltalk was the
future.
But future wasn’t here, so I worked in a lot of crap
Until 2007, where I, with two friends founded
Smallworks to work on the future promised
5. The iPhone
Why we want to use it?
Capabilities
Think on i386
RAM Memory growing (256M for 3GS)
Just one thread at a time
6. Why Smalltalk?
Because we like it :)
Code fast and flexible
Get rid of that ugly compile cycle and memory
management issues
We can take benefict from the green threads of Pharo/
Squeak
7. Where do we stand?
“Ad hoc” VM
Objective-C bridge
Some applications already in the AppleStore
Look for “WikiServer” and “Fractions Calculator”, for
instance
So, thanks John!
8. Our goal
To provide a framework for programming
the iPhone in a “Smalltalk way”
9. Deimos - Basics (1)
“Some kind” MVC Framework
Model: Anything you want
View: a NIB file
Controller: Deimos
10. Deimos - Basics (2)
Uses external files
You need to compile the “Ad hoc” VM each time
This is because of the NIB files, mainly.
Uses ObjectiveC bridge
11. Deimos - Creating a view (1)
On Objective-C side
Yes... you need to create the NIB files outside the
smalltalk image
Very important: use #tag property from UI widgets
#tag is there for using it, so... is not so bad
(althought I don’t like it)
12. Deimos - Creating a view (2)
On Pharo side
Extend DEView
override #createViewDefinition and maybe
#initializeContents
Register for execution
13. Deimos - Access widgets
This is why the #tag property must be assigned: we
look for them recursively, as childs of an UIView
We wrap (and cache) all this UI widgets as equivallent
Deimos widgets
You look for them just once
You can interact with them as Smalltalk objects
14. Deimos - Event callbacks
Once you mapped your widget, it is very simple
15. Deimos - Navigate views
[#show:|#showModal:|push:]/#answer: circuit
Yes, very similar to Seaside, I “borrowed” that
#push: makes a show inside a navigation controller
(that “flows” the views). Works only when views are
inside a navigation.
16. Deimos - Internals (1)
Using contexts to handle window navigations
So we can stack views and control behavior in a
fashion way
17. Deimos - Internals (2)
Announcements for handling events
For internal use (e.g. #onAnswer:)
Also provided for developers
(yes, right now that means: me)
18. Deimos - Internals (3)
Using one green thread for each:
Delegate object
Event callback
This can be a problem in the future, but right now is
working pretty cool
19. Deimos - Internals (4)
Using WeakRegistry for disposing the not-used views
A controversial solution (but working)
Maybe we can use a “cached views solution” to get
better performance, but it is still being studied.
21. Problems found (1)
The “dead lock problem”
Being worked on (by John... and my self testing)
Philosophical problem: how do I test this?
Debugging is also a problem inside callbacks
22. Problems found (2)
Performance
Not really an issue, but you have to take into account
that you are programming for the iPhone
Image size
Very tight to performace
23. Future
...a Sponsor, maybe?
Stabilization and optimization
call & return full cycle support
I don’t like the #onAnswer: stuff...
I don’t know how to do this, and even if possible, but I
will try
Use bundles to avoid VM recompilation.
Cool be nice, but I’m not sure about this point... I like
more the next point
24. ...far in the future
Getting rid of NIB files, using a declarative style
Lot of problems to solve (aquire images, for instance)
But this will drive us back to full-smalltalk
programming, so it worths the effort.
Why not an iMagritte?
25. Why is called “Deimos”
It is not about greek/roman mythology
Is about “being around Mars”
“...but that’s another story, and should be told
another time” (Michael Ende, The Neverending Story)