Summer of Code: Lunar Eclipse Final Report
Thu Sep 4 21:45:02 2008
I had a lot of fun participating in the Google Summer of Code. As I said before, I worked improving Lunar Eclipse, an open source visual designer for Silverlight/Moonlight. This is what I achieved during the summer:
Tools & Handle Support:
I worked on editing support for the following Silverlight Elements:
- Circle, Ellipse, Rectangle and Square
- These are the basic boxed shapes. Previous version of Lunar Eclipse already had support for this elements. Anyway I almost refactored the entire Handle & Tool subsystem. This helped me to adapt it to more complex shapes like bezier paths.
- Line and PolyLine
- Simple two point line and multiple point line.
- Bezier Path and Pen Tool
- I worked on two tools for creating Path figures. One let you create a path using Bezier Segments. This is working fine but there are a couple of bugs regarding translations of points. I also implemented a Pen tool for creating paths based on manual movement, it's working, but it needs to be optimized to produce less nodes.
- TextBox
- I have partial TextBox support. I couldn't implement graphical text editing because the Entry control is not yet implemented in Moonlight.
I also tried to add Image support. But it was impossible to use the Downloader and set media to objects using the GtkSilver widget (used for creating Desktop Moonlight applications).
Other features
- Selection Rect - Select All - Clear Selection - Delete Selection
- I improved the selection rectangle and all the selection subsystem. This was important in order to implement other operations such as ordering and alignment. The use of keys for selection (like control to add to selection) is not working because the Keyboard class was not implemented in Moonlight at the time.
- Property Panel
- The properties panel was fixed. I believe that in the future, Lunar Eclipse will use the toolbox system of MonoDevelop, but some of the internal parts of this work, such as property introspection, can be reused in the future.
- Infinite Undo Redo
- Undo and Redo was implemented in previous versions of Lunar Eclipse, anyway, I fixed a lot of bugs related with this and implemented Undo - Redo support for all tools and operations.
- File Open / Save
- As simple as that. Files can now be saved and loaded :)
- Zooming and Scrolling
- Zooming is now possible. There are some ugly effects caused by the GtkSilver implementation. I guess this will be fixed in the future. Scrolling is working good but it needs improvements to be more usable.
- Ordering and Alignment
- Send to Front, Send Backwards, Align Right, etc.
- Serialization and Back
- Serialization has been fixed. Loading from XAML is working too so you can move back and forth between Xaml and Design. Serialization still need a lot of love. Output is too verbose and the text indentation structure is not 'remembered' by the serlializator. I want something similar to the MS Expression Blend's system, which is awesome.
- Copy - Paste - Clone
- Clipboard operations. Copy was a bit difficult because Silverlight elements don't have a clone method. I Implemented my own Clone method based on the serialization work.
- New interface
- This wasn't a critical feature, but I rewrote the GTK# based user interface. This was an easy task thanks to the awesome MonoDevelop.
Video Demo:
Here is a demo video showing some of the features of Lunar Eclipse:
Future
It was really difficult to work on Lunar Eclipse the last weeks of the Summer of Code. Moonlight hackers started to work heavily on the 2.0 version. Moonlight became very unstable and its API changed a lot, (besides Silverlight 2 Beta 2 API changed too). All these changes broke Lunar Eclipse. The last objective, animation support, was not completed. Anyway, I definitely want to keep working on this project. I decided to freeze Lunar Eclipse while Moonlight gets more stable, but I started to work on adding support for Silverlight projects to MonoDevelop. After that, I want to fix bugs in LE and start isolating the design surface to be easily plugged in applications such as MonoDevelop or a Web Based Lunar Eclipse.
Python vs C#: Queries
Wed Aug 13 05:20:57 2008
One of the most beloved C# 3.0 features is Linq. Linq brings great power to C#, it allows you to easily write structured queries over collections or remote data sources. Now with C# is possible to make queries as easy as with other languages like Python. I decided to compare the way you make queries with C# and with Python. I found a great page showing 101 Linq examples, I decided to write Python versions of this examples. Which version do you like more?
C# version:
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
var lowNums = from n in numbers where n < 5 select n;
Python version: numbers = [5, 4, 1, 3, 9, 8, 6, 7, 2, 0] low_nums = (n for n in numbers if n < 5)
C# version:
string[] digits = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
var shortDigits = digits.Where((digit, index) => digit.Length < index);
Python version: digits = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'] short_digits = (digit for index, digit in enumerate(digits) if len(digit) < index)
C# version:
var numsPlusOne = from n in numbers select n + 1;Python version:
nums_plus_one = (n + 1 for n in numbers)
C# version:
string[] words = { "aPPLE", "BlUeBeRrY", "cHeRry" };
var upperLowerWords =
from w in words
select new {Upper = w.ToUpper(), Lower = w.ToLower()};
Python version:
The exact Python version would be something like:
words = ['aPPLE', 'BlUeBeRrY', 'cHeRry']
upper_lower_words = ( type('', (), {'upper': w.upper(), 'lower': w.upper() })
for w in words)
But I feel more Pythonic this:
upper_lower_words = ( (w.lower(), w.upper()) for w in words)
Or even this:
upper_lower_words = ( {'upper': w.upper(), 'lower': w.upper() }
for w in words)
C# version:
int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 };
int[] numbersB = { 1, 3, 5, 7, 8 };
var pairs =
from a in numbersA,
b in numbersB
where a < b
select new {a, b};
Python version:
numbersA = [0, 2, 4, 5, 6, 8, 9]
numbersB = [1, 3, 5, 7, 8 ]
pairs = ( (a, b) for a in numbersA
for b in numbersB
if a < b)
C# version:
var orders = from c in customers,
o in c.Orders,
total = o.Total
where total >= 2000.0M
select new {c.CustomerID, o.OrderID, total};
Python version:
I couldn't find how to make the assignment in Python, so the version is:
orders = ( {'customer_id': c.customer_id,
'order_id': o.order_id,
'total': o.total }
for c in customers
for o in c.orders
if o.total > 2000)
C# version:
var orders = from c in customers
where c.Region == "WA"
from o in c.Orders
where o.OrderDate >= cutoffDate
select new {c.CustomerID, o.OrderID};
Python version:
orders = ( (c.customer_id, o.order_id)
for c in customers if c.region == 'WA'
for o in c.orders if o.date >= cutoff_date)
C# version:
var first3Numbers = numbers.Take(3);
Python version:
if we are working with something like a list, we could do:
first_3_numbers = numbers[:3]
but, if we are working with iterators, we must do:
first_3_numbers = itertools.islice(numbers, None, 3)
C# version:
var allButFirst4Numbers = numbers.Skip(4);
Python version:
all_but_fist_4_numbers = numbers[4:] # list version all_but_fist_4_numbers = itertools.islice(numbers, 4, None) # iterator version
C# version:
var firstNumbersLessThan6 = numbers.TakeWhile(n => n < 6);
Python version:
fist_numbers_less_that_6 = itertools.takewhile(lambda x: x < 6, numbers)
C# version:
var allButFirst3Numbers = numbers.SkipWhile(n => n % 3 != 0);
Python version:
all_but_first_3_numbers = itertools.dropwhile(lambda x: x % 3 != 0, numbers)
C# version:
numbers.First() numbers.Last()
Python version:
numbers[0] # first for a list numbers[-1] # last for a list numbers.next() # first for iterator list(numbers)[0] # first for iterator list(numbers)[-1] # last for iterator
C# version:
int evenNum = numbers.First((num, index) => (num % 2 == 0) && (index % 2 == 0));
Python version:
even_num = [n for i, n in enumerate(numbers) if n%2 == 0 and i%2 == 0][0]
or:
even_num = (n for i, n in enumerate(numbers) if n%2 == 0 and i%2 == 0).next()
to be continued...
Segunda GUADEC
Mon Jun 9 21:53:29 2008
A menos que algo extraordinario ocurra, este año asistiré por segunda vez a GUADEC. La primera vez, en Birmingham, la pasé muy bien. Esta vez será en Estambul, lugar que, según he escuchado, es uno de los más bellos en el mundo. Estoy muy emocionado por este viaje. Muchas gracias a la Fundación GNOME por patrocinar gran parte de mis gastos.
-soc
Wed Apr 23 17:00:26 2008
[unable to open file: weblogs/ceronman/-soc]
I am a SOCker !
Tue Apr 22 05:59:14 2008
I'm participating in the Google's Summer of Code of this year! I was selected for the Mono Project. I'm going to work on a Visual XAML Editor for Moonlight called Lunar Eclipse. LE was started months ago by Alan McGovern (from MonoTorrent). My work is to improve it and make it shine!. My mentor is the famous Miguel de Icaza
This is going to be the funniest summer ever!!
Distributed Version Control
Mon Apr 14 00:17:22 2008
Actualmente se está dando una avalancha de migraciones desde sistemas de control de versiones centralizados (Subversion) hacia sistemas distribuidos. Prácticamente todos los grandes proyectos de software libre o ya migraron o están en discusiones sobre la migración o están usando sistemas paralelos.
A diferencia de lo que sucedió con Subversion, donde también hubo una avalancha de migraciones desde CVS, en esta ocasión hay varias buenas alternativas, lo que hace la cosa mucho más interesante. La guerra entre Git, Mercurial y Bazaar, está generando un montón de innovaciones en el campo del control de versiones. Nos está beneficiando mucho a nosotros los usuarios.
La carrera por popularidad la va ganando Git con proyectos como Linux, X.org, freedesktop.org, Wine, OLPC, entre otros. Mercurial va muy cerca con proyectos como Mozilla, OpenSolaris, OpenJDK, Xen, entre otros. Bazaar va en último lugar siendo usado por Ubuntu y otros más.
Git está escrito en C y muchos de sus comandos son scripts de Shell y Perl. En consecuencia, el soporte de Git en Windows es muy pobre. Mercurial está escrito principalmente en Python. Algunas rutinas cuello de botella están escritas en C. Mercurial funciona muy bien en Windows. Bazaar es 100% Python. Funciona muy bien en Windows. Mercurial y Bazaar son extensibles via Python.
Git va en primer lugar en cuanto a velocidad, Mercurial de segundo, Bazaar de tercero.
Git tiene una interfaz de usuario difícil de comprender. Mercurial y Bazaar son muy fáciles de usar.
En cuestión de documentación, Mercurial se lleva el primer puesto, Bazaar el segundo y Git, de lejos, el tercero.
Elegir uno de los tres es una tarea complicada. Hay un millón de páginas y entradas de blog que hablan a favor de uno u otro. Como van las cosas es muy posible que haya que aprender a usar los tres, al menos a un nivel básico. Mi elección personal ha sido Mercurial, por su documentación, facilidad de uso y velocidad.
Mi experiencia en las últimas semanas con Mercurial ha sido muy placentera. Los sistemas distribuidos no solo dan una gran ventaja para proyectos grandes y con muchos contribuyentes, sino también hace las cosas mucho más fáciles en proyectos pequeños de uno o pocos desarrolladores. Empezar a versionar un proyecto nunca fue más fácil.
Tengo muchos pequeños proyectos que no están versionados, por ejemplo los de PyWeek. No lo hago porque me da pereza arrancar un nuevo repositorio de Subversion, importar, hacer checkout... Con Mercurial es tan fácil comenzar un nuevo repositorio que nunca más tendré un proyecto no versionado.
La velocidad es un factor muy importante a la hora de que a uno no le de pereza usar un sistema de control de versiones. Con Mercurial todas las operaciones se sienten instantáneas. En cambio Subversion se siente taaan lento, incluso usado localmente.
El poder clonar repositorios fácilmente me da más seguridad. Sé que es menos probable que se pierdan datos. Sitios como freehg.org y github.com son lo máximo.
Trabajar al estilo Branchy Development se siente muy bien. Ahora tengo la costumbre de crear un branch por cada nueva característica, por pequeña que sea. Trabajar paralelamente cada cosa en un branch aparte es muy cómodo, ya que una cosa no rompe la otra. Además todo el historial termina mucho más organizado. Luego cuando todo está listo, un merge sin traumas.
A la hora de colaborar a un proyecto de software libre, me parece fundamental el hecho de que uno siempre tiene acceso al sistema de control de versiones. A diferencia de Subversión donde sólo el que tiene acceso de commit puede usarlo. El sistema de red de confianza del que hablaba Linus Torvals en el famoso vídeo de Git, también me parece una forma más natural de hacer las cosas.
Hay dos cosas que no me gustan de Mercurial. Una es que el soporte para Subversion es bastante pobre. No hay algo tan bueno como Git-svn. La otra es que la forma de hacer branches haciendo clones todavía se siente muy Subversion, me gusta más el estilo Git (Ivan habla de ello más detalladamente). No uso Git porque en el trabajo eventualmente me toca hacer ciertas operaciones en Windows. Sin embargo, como dije antes parece que dominar Git va ser esencial pronto. De todos modos aprender Mercurial me ha servido para entender muchos conceptos que no entendí bien cuando comencé a leer sobre Git.
PyBotLearn
Sun Apr 6 19:32:36 2008
PyWeek is finished. Unfortunately, I didn't have enough time for it this year, so I'm almost a DNF. The theme for this year was Robot. My idea ended up being more like an application than a game. I wanted to create an educational environment for teaching programing to children. Something similar to Logo. The idea was to build a game where your could program a small robot. It should be interactive so children could experiment on the fly.
In other words, It should be something like this: A window with a robot and a world, bellow a Python console. The users should be able to write commands in the console and the robot should execute them. The robot should be able to interact with it's environment and with the user too. Error, warnings, etc, should be given to the programmer in a friendly way. Additionally, there should be various challenges that the programmers should solve. This should be the fun factor for the game.
But, unfortunately, as I said before, I didn't have more that a couple of hours every day since Thursday, so I've failed on most of my objectives, and the only thing I have is a barely working demo. No challenges, no fun, no objects, no cool environment. Any way, I still like the idea, and I will try to continue with this project. I would love to hear more opinions about it.
My final submission was called "PyBotLearn". You can download it from my PyWeek 6 Entry Page.
Here is a small video of the demo:
A higher resolution video can be downloaded from here.
Effective Text Editing
Sun Mar 30 01:18:41 2008
I saw the video 7 Habits For Effective Text Editing 2.0 that arhuaco recommended months ago. I was tempted to start learning Vim, but after thinking for a while, I came to the conclusion that there is no good reason for learning Vim. I still don't get why people likes Vim that much. Most of the features that Bram Mooleenar showed in the video have been present in other tools for years and, in my humble opinion, they work much better than in Vim. Other things Bram talked about are just too crazy for me (He suggested that word processing would be more productive if we edit every paragraph in Vim and then copy-paste it on Microsoft Word... WTF!!)
Here are my habits for effective text editing:
Golden Rule: Use the best tool for the Job. I have learned that using a generic text editor for everything leads to be very unproductive. I like to use JEdit as my generic Text Editor. I love it for things like XML, C/C++, this weblog, etc. It has all the advanced features I need in a text editor. I used to use it for C# and Python but I discovered that using an specialized IDE for these languages is thousands of times more productive. Now I use MonoDevelop for C# and PyDev for Python.
The most important features I need when editing source code that can be hardly founded in a generic text editor are:
- Good Code Completion. Note the "Good" word is remarked. Some generic text editors have support for code completion but most of the time is very, very poor. For C#, MonoDevelop is the open source tool with the best code completion out there (ok, maybe #develop has good code completion too). For Python it's a bit more difficult due the dynamic nature of the language. I have tested many editors and IDEs and I think PyDev has the best code completion (I've heard that Wing IDE has good support too). Code completion is specially useful when you're working with large libraries like GTK+.
- Refactoring Operations. Rename, go to definition, go to parent definition, encapsulate, look for references, etc. They are essential features, it's impossible to be effective without them.
- Integrated Debugger. This one is missing from MonoDevelop. Hopefully will be there for the next release. It's lovely how with a simple click you can create a break point in your code, run it, and it will stop right there, then you can easily watch every object state and even add some code (on dynamic languages).
- Version Control Integration. Automatic add, remove, rename subversion files. Easily track the changes on the files. I love the ChangeLog integration of MonoDevelop. Eclipse has a good support for Subversion too.
- Integrated UI Editors. It saves a lot of time if you're writing GUI applications.
- Task list. If you put notes on your source code comments such as: TODO, FIXME, NOTE, HACK, etc. It will generate a list with all notes present on all files, so you can look for pending things easily. This feature is present in MonoDevelop, PyDev and JEdit. I love it.
- Integrated Help. Put the cursor on a word, hit F1 and automatically open the help browser with the page for the class or method description for the object or definition you selected.
There are other cool features that I like and most of the time are present in a good generic text editor:
- Code folding.
- Easy comment, uncomment of lines.
- Advanced search and replace.
- Diff viewers. JEdit has a Diff plug in, but I prefer Meld.
- Splits. Actually I have not seen a tool with a split support as good as JEdit.
Involucrate
Wed Mar 19 05:32:59 2008
Last week I went to Lima (Perú) to attend Involucrate+GNOME. I really had a good time. Special Thanks to Diego, who invited me. Of course, I've got everything what I've seen in peruvian tv for years and never had the opportunity to taste. Inca-Cola, Chicha Morada, Cremolada, etc. I also verified that no one can eat a Margarita cookie as a normal cookie, leafs must be eaten first :P
Photo Stolen directly from Tatiana's Flickr. More Photos on Flickr
Comming soon...
- PyWeek: March 30th. Of course, I'm not going to miss it.
- Summer of Code 2008. Receiving applications on March 24th. I'm Trying again. Last year I couldn't apply because I was in London and I suspended my studies. I hope the third one is going to be the winning one.
- GUADEC 2008 Istanbul. Registration and sponsorship requests open!
Trolling
Tue Feb 26 16:02:00 2008
The wisest/funniest answer for flamebait.
Last update: 2007-06-28 (Rev 11825)





