Moonlight, trivial Video and Canvas

by Miguel de Icaza

As part of my Silverlight for Linux research I have prototyped a native code library that uses Cairo and ffmpeg to prototype some of the ideas from the Silverlight canvas.

The above picture shows 2 videos playing, one of them rotated and a triangle object rendered in the middle as well. This was just a test to get an idea of what is involved.

The code does no attempt to keep up with the clock or do anything reasonable with time: it just renders stuff as fast as it can and does have no audio support. The next step is tune this a little bit (I do too many copies right now, too much stuff is done on the critical path) and then contrast this with an Agg-based implementation.

The canvas implementation that am using right now is inspired by the Gnome Canvas in many regards.

Compiler Lab: First Day

Today was the first day of the Compiler Lab and got to see again many good friends and some folks I had not seen for ages. This will feel like a name-dropping blog post, but here it goes anyways.

Scott Gunthrie introduced the day with a general overview of where they are and where they are going with .NET, Silverlight and WPF.

JB Evain and Rodrigo Oliveira were both late for the opening session, but they looked like they had been hacking all Sunday.

Jim Hugunin introduced the Dynamic Language Runtime in the second half of the morning and went through the design decisions behind the DLR. Although he has covered some of this information in blog this presentation was colored with the history of how decisions were made and the engineering choices that they had made that took them from IronPython to work on a general purpose framework for hosting dynamic languages.

The historical bits are always the most interesting to me. Jim talked about how they decided to go for a general purpose framework as people started asking for support for more dynamic languages. They were not really interested in writing all the compiler themselves, so instead they decided to turn their experience in building IronPython in some reusable work that could be used by others.

To accomplish this, they chose to implement four different dynamic languages extracting the common infrastructure into a reusable framework. Jim did not say how much they had learned from each language (which I guess is a good question for tomorrow), but he mentioned that the DLRConsole sample for Silverlight originally was pure Python. That it took him about three hours to add Javascript, three days to get Ruby in shape to work on the DLR and their new VisualBasic required almost no work.

I have extensive notes, but they are too extensive and am not sure I want to edit those, but you can get a good idea of what the presentations were all about from his blog posts:

The DLR is pretty serious, there were at least six people in the audience from the DLR team. I finally got to meet Dino Viehland, Bill Chiles was handing out copies of ToyScript (a reference small interpreter), Martin Maly was there, John Lam sat on the back (we all presume he was working furiously on his presentation for tomorrow) and Mahesh Prakriya was there as well.

Jim Miller of Scheme fame was there and made things all the more amusing by pointing out the similarities of certain features to Scheme. He also brought up a few issues that would need to be included in the DLR to support languages like Scheme as the day went by.

Jim Hugunin has always found interesting ways of demoing IronPython. He used to build a calculator with Avalon and rotate the buttons. Today he showed us some XNA space ship controlled with an Xbox control and later used IronPython to control a Lego Robot that his nine year old son had built.

John Gough was also here and he has retired from teaching at QUT. Nigel Perry has left the University too and is now working at Microsoft.

John Lam is organizing the lightning talks, and he has divided things neatly into three categories: Monday was the day for 5 minute talks. Tuesday was the day for 10 minute talks and Wednesday is the day for 15 minute talks.

When I left the building there were zero talks scheduled for 5 or 15 minutes. Everyone is listed on the 10-minute column for tomorrow.

I had a fantastic dinner with Scott Gunthrie and Jason Zander. I got a chance to pepper them with questions about the early history of the .NET framework for my pet project on the archaeology of .NET to be published in May 2nd, 2076. They were also kind enough to explain to me some of the technicalities about the Silverlight implementation. I should be updating the wiki page with the details later.

Help Rodrigo

Apparently "Console.ReadLine" on Cygwin in some way gets line editing even from C# applications. Am not sure how this works, but Rodrigo can not live without this feature in Booish.

I remember that a few years ago there was a Unix program that will provide readline capabilities to any program that lacked them by running a process under a pseudo terminal and providing line editing functionality to tools like ftp, nslookup or any other Unix tool that did not provide its own command-line editing functionality.

Posted on 22 May 2007


Rob Connery Interviewed

by Miguel de Icaza

In this interview Rob Connery explains how he came up with SubSonic. A tool that helps developers build applications:

That someday came when I was refactoring the Commerce Starter Kit, trying to leverage as much Data access code into the base classes as I could. I was using generics in a way that they probably weren’t designed to be used, but in the process I stumbled on a really cool pattern for generating very little code for a full data access layer. When I first got it to work I literally jumped out of my chair, swearing to myself.

I gave it about 2 weeks and tested and tested and when it didn’t break or slow down, I remember thinking "I’ve got something here!". I had been doing some Ruby/Rails stuff at the time, and I had the idea that much of that ΄love‘ could be brought over to the ASP world. Although the real joy of Rails is the language Ruby - but maybe someday RubyCLR will be finished (or some other dynamic language package for .NET) and that’s when I think SubSonic will come into it’s own.

Through Phil Haack

Once Subsonic runs on Mono, we should integrate it into MonoDevelop. Rob did a great demo of it at Mix.

Posted on 22 May 2007


Compiler Lab Meeting at Microsoft

by Miguel de Icaza

I will be arriving at noon to Redmond on Sunday and spend Monday and Tuesday (skipping Wednesday) at the Compiler Lab meeting at Microsoft.

Drop me a note if you want to get together on Sunday afternoon or swing by and say hi during the meeting.

Rodrigo de Oliveira from Boo fame and JB Evain will be both there as well.

Mono and the Dynamic Language Runtime (DLR)

Thanks to Zoltan Varga, Marek Safar and Sanghyeon Seo it is now possible to run the Dynamic Language Runtime in Mono and run the new DLR-based IronPython 2.0 in Mono.

Update: Mono already supports the pre-Alpha releases of IronPython and has for a long time. What is different is that this is the DLR-based IronPython.

The changes did not make it into Mono 1.2.4 (Mono 1.2.4 was branched before MIX 07 even started, or the DLR was announced). So you will need to build Mono from the source on SVN or wait for Mono 1.2.5 to include the fixes.

Posted on 17 May 2007


Mono.DataConvert

by Miguel de Icaza

Our just released Mono 1.2.4 contains a class that replaces System.BitConverter: Mono.DataConvert.

We created this interface a few months ago when we ran into problems with the limitations in System.BitConverter in Mono and when we noticed that it was not possible to fix this API. Mono is switching internally to use this instead of BitConverter as it leads to subtle errors when making your code work in big-endian systems.

Mono.DataConvert offers conversions from and to .NET types to raw byte sequences:

  • Host types to native byte arrays, little endian byte arrays and big endian byte arrays.
  • native, little endian, big endian to Host types.
  • Helper routines for Stream I/O.
  • Perl-like convenience routines for packing and unpacking data structures.

I like the Perl-like interface, for example:

	// The following means:
	// Little endian encoding of a Int16, followed by an aligned
	// int32 value.
	byte [] r = DataConverter.Pack ("_s!i", 0x7b, 0x12345678);

	DataConverter.Pack ("^ii", 0x1234abcd, 0x7fadb007)
	// Result: 12 34 ab cd 7f ad b0 07
	

We also have a more traditional APIs, for example:

	// The instance-based API
	byte [] x;
	x = DataConverter.LittleEndian.GetBytes (my_double_value);
	x = DataConverter.Host.GetBytes (my_double_value);
	x = DataConverter.BigEndian.GetBytes (my_double_value);

	// Or a static version of it:
	x = DataConverter.GetBytesLE (my_double_val);
	x = DataConverter.GetBytesNative (my_double_val);
	x = DataConverter.GetBytesBE (my_double_val);
	

The code is licensed under the MIT X11 license, and we encourage developers on both Mono and .NET to use this library as opposed to the fundamentally limited and broken BitConverter.

This class is bundled as part of corlib, and is by default "internal". Since this is a small class, developers are encouraged to copy the source code into their own applications. See this for details

Posted on 15 May 2007


Paint.NET 3.0 for Mono: Now Public

by Miguel de Icaza

We have used Paint.NET for a long time as a test for our Windows.Forms implementation. In the past I have blogged about it (here and here).

Until now, releasing the port was either painful (because I had botched the 1.x port) or not very useful (because newer versions of Paint.NET depended on 2.x features that we were missing). In Mono 1.2.4 we finally have an implementation of the *Strip classes that are heavily used in Paint.NET for the menus, toolbars and floating editing gadgets so now Paint.NET looks great.

The port is not complete, but it works. Am releasing it to the public since so many people asked about it and volunteered to contribute to complete the port.

Links:

Feel free to join the effort.

Posted on 15 May 2007


JB Evain joins Novell

by Miguel de Icaza

Jean-Baptiste Evain, the author of Cecil the CIL manipulation library that is now used by various Mono components as well as the Mono Linker has joined the Mono team at Novell.

Posted on 15 May 2007


أهلاً حَبِيبين,أهلاً (Ahlan habibin, ahlan)

by Miguel de Icaza

J'ai essayé de faire une interview en Français l'autre jour, mais mon français est pire chaque année, vous pouvez la voir ici.

J'y parle de nos plans d'écrire une version libre de Silverlight pour Mono.

Autres nouvelles: j'adore Arvo Pärt et pour quelque raison mon Emacs ne fonctionne pas avec l'arab. of أهلاً

Posted on 13 May 2007


TimeZoneInfo in Mono

by Miguel de Icaza

A few months ago, Stephane Delcroix was working on F-Spot and he needed to track time zone information for pictures.

The .NET framework did not offer anything to make this easy. Only one timezone could be constructed: the system one.

His original plan was to implement Mono.ExtendedTimeZone that would be a derived class from the TimeZone class in the framework but that would be populated from some other database.

He considered a few choices and discussed:

  • Use libc in some form, to pull the data out of it (external program) and create the instances of the timezone as needed. This could be slow due to using an external program with a temporary TZ setting.
  • Parse the libc datafiles, very OS/distribution-specific.
  • Ship our own databases.

We did not want to go into the business of maintaining the timezone files and redistribute Mono updates every time new countries were created or rules changed, so we opted for dumping the data out of libc in some form.

Stephane ended up parsing the GNU libc datafiles: they did not depend on external programs, works on Linux easily and is fast. This will require the code to be ported to other platforms though.

Around that time we discovered that Orcas (.NET 3.5) included a class to cope with this problem in the form of System.TimeZoneInfo in the System.Core.dll assembly. So his API effort changed from implementing a Mono.ExtendedTimeZone to implement System.TimeZoneInfo. Yesterday he emailed me the above screenshot and we got the code commited to SVN.

Check Stephane's PicasaWeb album it contains various screenshots of his F-Spot work.

Posted on 12 May 2007


C# 3.0 updates

by Miguel de Icaza

Scott Peterson blogs about his recent contributions to the C# 3.0 compiler:

  • Variable type inference (the "var" keyword)
  • Anonymous types.
  • Implicitly typed arrays.
  • Object initialization.
  • Collection initialization.
  • Scott is participating in the Google Summer of Code. His summer project is to port the Banshee Media Player to Windows. But I guess he had to have those 3.0 features before he could start. It makes perfect sense. This patch was reviewed and mentored by Marek Safar who has been implementing various other parts of the C# 3 support (extension methods, the new LINQ parser and the updated delegate semantics).

    The new object initialization allows properties to be set at construction time, for example:

    	// C# 2 style
    	Gtk.Window w = new Gtk.Window ();
    	w.Title = "My App";
    	w.Visible = true;
    
    	// C# 3 style
    	Gtk.Window w = new Gtk.Window () { Title = "My App", Visible = true };
    	

    This also works for events:

    	Gtk.Button b = new Gtk.Button ("Ok") { Clicked = ok_clicked };
    	

    Or using the new lambda expressions:

    	Gtk.Button b = new Gtk.Button ("Ok") {
    		Visible = true,
    		Clicked = (sender,args) => { Console.WriteLine ("Clicked"); }
    	};
    	

    The last case (delegate) is currently not supported by mcs.

    Posted on 09 May 2007


    Digger on Silverlight

    by Miguel de Icaza

    So we have all seen the spinning text, the video puzzles and the rotating spiderman trailer.

    But real programs are more complicated than those simple demos. Lutz Roeder has a page with Silverlight applications that he has written.

    My favorite: his Windows.Forms digger port. You can see it here or you can download the sources and learn for yourself here.

    Posted on 03 May 2007


    « Newer entries | Older entries »