Sunday, August 23, 2009

Safarà Development Status

Hi Squeakers, few news about the Safarà development status.


Safarà now runs on Pharo
With few changes, the main features of Safarà runs on Pharo, which, here on, will be the main platform of development. The only issue, I will tackle, in maintaining Safarà working both on Squeak and on Pharo is about the Parser class as I previously used the Parser2 class for editing Smalltalk code.


As we need to refactor some internal part of Safarà to improve the speed, I worked a lot on adding more unit tests. They are really useful to check that refactorings do not introduce new bugs and to find with the profiler the bottlenecks of the system.

We got the 92% of code coverage of the Safarà-Core category by running all the tests in Safarà-Core-Tests (98 tests). The remaining 8% is mainly about methods of abstract classes (question: is there a way to make Test Runner Coverage analysis ignore an abstract class?) and some basic accessors. This part can be improved further as some tests do not test some behaviors at boundaries, but, actually, they already give me a good warranty when refactoring.

Code Quality
A big effort has been also put in refactoring the code (both of the implementation and the tests) to make the code critics tool "happy". At the moment we have only two problems, related to the main object SAEditor which have too many variables (14) and too many methods (64).

I tried to group variables in new objects: a MarkManager (4 of them), an UIManager (3 of them), CommandManager (2 of them), but I was not satisfied with this solution, too much complicated.
Furthermore, objects that should use the SAEditor accessors with statements like
editor markManager cursorsAtPoint size = 1 fails the Demeter Law.

I do not know if I should mind about the problem of having too many methods, as the SAEditor object should be the only object exposed to the GUI. The GUI communicates with the model through the Command pattern, and a lot of other communications are implemented with Announcements, but queries about the editor internal state is mainly done with traditional methods sending.
Thus, the number of methods for cursor/range/marker querying is big. For the same reason stated above I do not find useful to use an other solution.
In facts, we can have a clear design just by partitioning methods into categories.

Next steps
Here on, we can work on improving performance of Safarà. The problems resides mainly in the Morphic part.
For the model part, the task is not so difficult as I individuated, thanks to the Profiler, the bottlenecks.
For the UI part, I started also to look at Sophie, who use a complete different drawing scheme. It should not be difficult to rewrite the SASafaraMorph in the same way. More in the next posts.

Happy Hacking

Wednesday, October 8, 2008

Safara project: results, personal experience and future directions

Hi Squeakers,

The Google Summer of Code period is over and I'd like to spend some words about the project I was involved in, Safara, a text editor for Squeak . The results obtained (from a project and a personal perspective) and what we still need to do is the gist of the post. If you are interested in knowing what Safara is look at squeak-source or in the blog archive.


First the bad news: Safara is not ready to use yet. It needs more
major features (like undo, completion, search/replace, templates) and
it should be a little bit faster (though some steps in that direction
has been already made). Safara is a big and ambitious project so I
expected this situation.

Then the good one: Safara is extensible and easily portable, so the
main goal of the Summer of Code project has been achieved. I am quite
satisfied about the design decision we took. Also the code quality
should be quite good as stated by SLint.

My first true Smalltalk Experience

Safara was the first (real) Smalltalk project I was involved in.
Actually I decided to join the Summer of Code with the Squeak Org.
because I needed an opportunity to improve my Smalltalk skills. You
can never learn a language without writing a big (roughly in terms of
number of lines of code) software. Playing with morphic toy examples,
developing little seaside apps or just copying some examples from a
book can be enough to learn the language and some good code styling
convention but not to really understand how the language can help you
in modeling the problem you want to solve. IMHO.

After three months of full time development with Squeak Smalltalk I
changed my mind about Smalltalk, and maybe Smalltalk changed a little
bit my mind about programming. Maybe now I am a better programmer also
when I develop with another object oriented language.
I was impressed by two aspects.

Smalltalk snippets of code, intended as the real lines of code you
write, are really simple and clear. The consequence is that when you
develop in Smalltalk you put your focus more on the whole design of
the software, and less on the single line of code.

Again, as the syntax rules are simple and the whole environment is
object oriented you have really powerful tools that helps you to code,
as the linter and the refactoring tools.

I also appreaciated the image-based style of development but I was
already used to it, so I got less surprises and I just enjoy my self
playing with inspectors and debuggers, modifying my application when
It is live and running.

Next steps

I have a short to-do list, whose outline follows. We need to run a code
coverage analysis, and write more tests to fix some bugs (mainly
related to command extensions and text presentation). We also need to
refactor the context menu (the one usually triggered by a right
click), in order to allow extensions like completion, spell checking
and so on.

I am still working on Safara but obviously putting less effort than in
the Summer of Code period, as I'd like to bring a new editor to the
Squeak community, or at least an alpha version before Christmas. I
don't want to release too early as I think it can be a bad advertising
for the whole project. After the first release It will be important to
create a community around Safara, with a website, a bug/issue tracker
and so on. At the moment the development mailing list is enough.

So if you are interested in the Safara project stay tuned and look at
the squeak-dev and the squeak-announcements mailing list.

Saturday, October 4, 2008

Smalltalk and FreeCAD/Croquet

I’m writing this article not only to fulfill the requirements of the Squeak Organization but also to remind myself how pleasant it is to be programming in Smalltalk. I have always liked computers and always did want to learn programming but never had the opportunity to do it right. There was always the complication factor and other obstacles such as the scarce availability of resources to me but the emergence of the internet age change that. I got serious with programming while doing my pre-u course in college. As with almost everyone else, I started with C and over the years, I did C++, VHDL and Java. Nothing really came out of it until I did my final year project with my mentor Dr. A.S. Koh. I was introduced to the world of Smalltalk and I had a goal which was to create a full fledge CAD system in Croquet and the journey begins.

In my short year of experience with Smalltalk, I find that it has really helped simplify a lot of things that were cumbersome or complicated in the other languages I have learned. The point that Smalltalk is purely object-oriented already makes it’s code more reusable and implementation a lot simpler. For my project, I use the Squeak implementation of Smalltalk and being open source, Squeak has a lot of good and usable classes already incorporated. I just had to work with them to get what I need.

Another thing I like about Smalltalk is the ability to just pass objects around without the need to stick to strict rules for types and all. This has made my working with Smalltalk very easy and reduces the time needed for debugging. I would not even want to think how to do the same things I have done in Squeak in the other languages I have learned. It would be a total mess and I might not have achieved this much in the same time frame.

Besides that, working with the Squeak tools such as the inspector, explorer, class browser, etc.. has been a great experience. It somehow gives me a feeling that the classes and objects actually have some sort of physical form that I can dig in to and understand properly. It saved me a lot of time considering the fact that I did not need to draw diagrams and charts to figure out the structure and flow of my project. It can be done there and then. Speaking of that, the late-binding characteristic of Smalltalk gave me the edge in debugging and testing.
Since this is a short write-up of what Smalltalk did for me, I just highlighted the most important points that came to my mind. Of course, the advantages of Smalltalk is not only limited to the few that I have mentioned. If you are reading this and new to Smalltalk, I would very much like to encourage you to try it out yourself and hopefully, you will feel the same way I do for this beautiful and versatile language.

Wednesday, October 1, 2008

Future of FreeCAD/Croquet

I have been working on porting freeCAD to Croquet for about 15 months now. A lot has been done and the base of the porting can be evidently seen and used in the current releases but this is just the tip of the iceberg of a somewhat adventurous career pursuit I have chosen. I have chosen to dedicate my first few months since graduating into developing FreeCAD/Croquet rather than joining the corporate world.
If all goes well and my mentor is able to secure funding for our project, a lot of features will be continually be developed and added into it.

Up till this point of writing, FreeCAD/Croquet is being developed in Cobalt and is able to draw basic solids and do simulation. Future plans will include doing Boolean operations for the solids. This means that we will be able to add and subtract solid shapes to and from one another. It will definitely be a great feature since we are aiming to develop FreeCAD/Croquet into a full fledged CAD system.

Other than that, I plan to complete the motion simulator in the near future so that it is useable like freeCAD with the added advantage of being in a collaborative virtual environment. Engineers and educators alike will be able to use it for work or educational purposes. All these will be free to the public too and anyone can download and use FreeCAD/Croquet.

We have generated quite a lot of interest among fellow enthusiast and our next project should be to create an importer for Google SketchUP models. This will allow users to import millions of models available in Google’s own 3D warehouse for use in FreeCAD/Croquet or even in Cobalt itself. If we manage to complete this, it will draw more attention from other communities into the work we are doing, into Croquet and into Smalltalk. It should be a boost for the Squeak and other Smalltalk communities alike.

Besides that, I hope to be able to put FreeCAD/Croquet online as a virtual world with accessible links to the public. Anyone can connect into it and each player would have their own avatar and virtual space allocated. This way, we will be able to achieve one of our goals which is to have FreeCAD/Croquet be used as a content creator to create objects in the virtual world.

Finally, I would like to express my gratitude to all those who have been directly or indirectly involve in making this project a success. It would be great if more people could help with the testing and debugging as it will definitely speed things up and help make FreeCAD/Croquet more user friendly. I will continue to put my heart into making all the plans work out nicely and hopefully, we will be able to see a full fledge CAD system in a virtual world very soon.

About FreeCAD/Croquet

For GSOC 2008, I worked on FreeCAD/Croquet building the graphical interface and 3D solids. FreeCAD/Croquet is meant to be a content creation tool in the collaborative virtual world Croquet. It is based on freeCAD by Dr. A.S. Koh and currently runs in the Cobalt version of the Croquet system. When completed, users will be able to create 3D models in a virtual world, simulate them and share it out to other users in real time.

One of the features that was added in the course of this program is the interactive tree view menu. The tree displays assemblies, parts, markers, etc. It can be used to select the objects in the world and also to bring up a menu by right clicking on the selected item. Some keyboard functions have also been added in for better avatar navigation control and view adjustability.

Besides that, I have added in a lot of windows that allow users to operate on the objects that are created. For example, there are windows that allow the user to change the properties and position of the drawing and 3D solid, window for animation, window to adjust rotation, etc. Click and drag functions were also added in for easy manipulation of the solids.

Other than that, the 3D models were broken down into separate faces and each face is contained in its own frame. This way, individual faces can be selected and manipulated. One example of this usage is the ability to add in markers to the face of a 3D solid. The markers will in the future be used to connect joints for simulation.

Currently, FreeCAD/Croquet has the simulation engine built into it and can do some simulation. There are a few demos of simulation done and the videos are posted on YouTube (It can also be viewed here)
The main goal is to port the whole freeCAD which is written in Visual Works to Croquet and my mentor, Dr. Koh and I are very close to achieving that. In the mean time, users can load freeCAD assembly files preloaded with simulation data into FreeCAD/Croquet and run the animation. This gives an idea of what solid modeling in Croquet will be like.

To conclude, I am very happy that I got accepted into GSOC 2008 because it has given me a great experience and also funds to continue working on FreeCAD/Croquet. With the funds that I have received, I will continue working full time on this project for as long as I can. We hope that more people will get interested and contribute to our work or even draw some attention to the Croquet/Cobalt community. Check out my website for future news and release of FreeCAD/Croquet.

Sunday, August 10, 2008

SqueakGtk Launcher

I've made good progress :

* there is a new main interface and we don't need no more morphs :D
* Exceptions during the events are handled with a new Exception UI
* A new website :
* A new image which autostart the Gtk user interface :p

Wednesday, August 6, 2008

Week 10 of GSOC - FreeCAD/Croquet

1) What did you do in the past week?
-Grid on sketch board is up
-Joints are ready now for simulation to be added
-Click and rotate around an object is ready(a bit more tweaking left)
-Fixed lost of keyboard focus on world when clicked on tree menu
-New buffered axis for smoother rendering and better looks

2) What do plan to do this week?
-Work with my mentor in adding simulation code

Tuesday, August 5, 2008


I've improved the support of the Omnibrowser tools, the Gtk port support
more events and is more stable :p I've also made a huge improvement
with the events handling it is no more an active waiting loop.
I use a thread in C and wake up the smalltalk process with a semaphore.
So the CPU is no more used at 99,99% by squeakGtk :D