Using FireBird.NET with Mono

Today I tried out the Firebird database as we just integrated Carlos' bindings for it into the Mono release. Firebird has two modes of operation, it can be used as a server that clients connect to or it can be used as an embedded database, just like SQLite.

The traditional server/client setup works as expected, but I was more interested in using it as an embedded database, This mode is not very well documented. This blog entry tries to document the steps necessary to embed the database and use it with the managed API.

I installed the "FireBird Classic" configuration as an RPM, which is available here. Other downloads are available here.

These instructions are based on the data I found here and here.

Then you must create a mini-firebird environment for your embedded database, the following commands must be done as root:


	# mkdir /home/miguel/minibird
	# mkdir /home/miguel/minibird/bin
	# cd /home/miguel/minibird
	# cp /opt/firebird/firebird.conf .
	# cp /opt/firebird/firebird.msg .
	# cp /opt/firebird/security.fdb .
	# cp /opt/firebird/bin/fb_lock_mgr bin
	# chmod +rx bin/fb_lock_mgr
	# FIREBIRD=`pwd` /opt/firebird/bin/gsec
	GSEC> add miguel -pw pwd
	GSEC> quit
	# chown -R miguel *
	

Edit the firebird.conf file and add (or edit the commented line) the following line:

	RootDirectory = /home/miguel/minibird

That will create the mini-root and create an account "miguel" with the password "pwd" and set the permissions for all the necessary files.

You can now create a database:


	$ /opt/firebird/bin/isql
	SQL> create database "hola.gdb";
	SQL> create table developers (name varchar (40), email varchar(40) not null);
	SQL> insert into developers (name, email) values ('miguel', 'miguel@novell.com');
	SQL> insert into developers (name, email) values ('duncan', 'duncan@ximian.com');
	SQL> commit;
	SQL> exit;
	

The C# program to access it is fairly simple:

    using System; 
    using System.Data; 
    using FirebirdSql.Data.Firebird;
     
    public class Test {
            public static void Main(string[] args) {
                    string connectionString = 
                    "Database=hola.gdb;servertype=1;user=miguel;password=pwd";
     
                    IDbConnection dbcon = new FbConnection(connectionString); 
                    dbcon.Open(); 
                    IDbCommand dbcmd = dbcon.CreateCommand(); 
                    string sql = "SELECT * FROM developers"; 
                    dbcmd.CommandText = sql; 
                    IDataReader reader = dbcmd.ExecuteReader(); 
                    while(reader.Read()) {
                            object dataValue = reader.GetValue(0); 
                            string sValue = dataValue.ToString(); 
                            Console.WriteLine("Value: " + sValue);
                    } 
                    
                    // clean up 
                    reader.Close(); 
                    reader = null; 
                    dbcmd.Dispose(); 
                    dbcmd = null; 
                    dbcon.Close(); 
                    dbcon = null;
            }
    }

Build your program:


	$ mcs sample.cs -r:FirebirdSql.Data.Firebird -r:System.Data

To run this program you must set the FIREBIRD environment variable to point to the mini-firebird directory:


	$ FIREBIRD=/home/miguel/minibird mono sample.exe
	Value: miguel
	Value: duncan

Posted on 30 Sep 2005 by Miguel de Icaza

World Wind Software on Linux

WW2D now runs on Linux using Mono:

World Wind on Linux.

[WW2D] [..] is cross-platform, free and open-source version of NASA World Wind software, see http://worldwind.arc.nasa.gov for details. WW2D allows you to explore Earth using satellite imagery, topographic maps and image from other data sources also providing large placenames and boundaries database and allowing you to install community-made add-ons for even more information about our planet.

In basic configuration WW2D uses images from Blue Marble (1 km/pixel), LandSat7 (15 m/pixel), USGS Topo Maps, USGS Digital Ortho imagery, USGS Urban Area imagery.

WW2D is designed to dynamically download needed data from internet, however you can download data you want for faster access and offline usage.

This is not the original NASA software, but a new implementation sharing some of the data. To render they use Tao.OpenGL and a little bit of native code.

The new version is available here to run make sure you have libgdiplus+ installed and then do this:


	$ cd demo-linux
	$ mono WW2D.Frontend.exe
	
Posted on 30 Sep 2005 by Miguel de Icaza

SharpMusique 1.0

Jon Lech Johansen has released version 1.0 of his SharpMusique client to iTunes Music Store, in 1.0 he supports:

  • Preview songs
  • Signup for an account
  • Buy songs and albums
  • Redownload songs that you bought with SharpMusique
  • Redeem Pepsi caps
  • Redeem gift certificates

SharpMusique uses Gtk# and runs on Microsoft.NET or Mono.

Posted on 30 Sep 2005 by Miguel de Icaza

Second Life

I just learned that the folks at Second Life are using Mono for their 3D Digital Online World:

Monoorientationisland Orientation Island with all 700+ LSL scripts compiled to CIL, assembled in to CLR assemblies and running in the Mono VM embedded in the Second Life simulator. The Mono scripted birds sing and the Mono scripted hands spin and go "bing" when you touch them. There's still lots of bug fixing, optimisation and integration to be done, but it's looking good.

By doing this their existing LSL code will be JITed and optimized by the Mono engine and run at native speeds while giving their developers the flexibility that they need in using the LSL language. This also opens the doors to the Second Life developers to use other CLI languages like C#, Boo, Python or JavaScript side-by-side.

A couple of weeks later they posted an update with more screenshots:

Monobiplane1Monobiplane2_1Monobiplane3Flying a mono biplane through a mono scripted Abbotts Aerodrome (in monochrome). All 2700+ LSL Abbotts scripts compile to CIL, assemble in to CLR assemblies and run in the Mono VM embedded in the Second Life simulator. Note that no source code was changed to make this work, the LSL source was just recompiled to run on the Mono VM.

This is pretty exciting. Am looking forward to help the SecondLife guys have a successful migration to Mono and assist them in exploiting the features of the Mono VM for their software.

Posted on 27 Sep 2005 by Miguel de Icaza

Kurt Vonnegut's New Book.

I enjoyed tremendously reading Kurt Vonnegut's latest book "A Man Without a Country" which recently came out.

The theme is very personal, Vonnegut's view on the current state of affairs on the world. Unlike his fiction books on "A Man Without a Country" Vonnegut explicitly states what he believes is wrong, what must be fixed and identifies the crookitude by name.

Posted on 27 Sep 2005 by Miguel de Icaza

Viggo Mortensen

Crooks and Liars has the video of Viggo Mortensen amazing interview on Charlie Rose's show.

I admire the man. He shows up with a gift for the host, a copy of Howard Zinn's Voices of A People's History of the United States. One of my favorite books and is followed by a brilliant presentation on the state of the country in a calm and articulate way.

And on his web site I find a quote from another favorite author of mine, Gore Vidal and plenty of articles from authors that I like.

Posted on 25 Sep 2005 by Miguel de Icaza

C# 3.0 Q&A

A C# 3.0 Q&A, a lot of folks have been asking about these and other questions. Find it here

People have been asking me when are we going to support C# 3.0.

Our current focus is on delivering a very stable platform, so we are trying to fix the bugs that people are reporting and give developers a great experience with their existing code base. This is just a basic Joel principle: fix bugs before you write new code.

Considering that C# 3.0 is still a year or two away from shipping and the specification will likely change it is best for us to polish our C# 2.0 compiler and our runtime classes than to start work on C# 3.0 right now.

The good news is that all of the new C# 3.0 features are relatively simple and it builds on existing C# 2.0 features. The specification so far is 26 pages long. It is probably one third of the effort that it took to implement generics on the compiler and the runtime.

We are as excited as everyone else about the language and can not wait to try to implement some of those features and provide feedback about it to the language architects, but this work will have to wait a few months. This is definitely not part of our Mono 1.2 release needs (that being said, if one of the contributors sends code for it, we will very likely integrate it).

XLinq

In the meantime, Atsushi has checked some early work on XLinq to our repository. It has only enough code to run Microsoft's XlinqIntro sample.

Posted on 25 Sep 2005 by Miguel de Icaza

Mono on ARM

Mono 1.1.9 shipped with a port of the JIT engine to the ARM processor and it currently supports the Linux operating system. A few days ago Paolo received his Nokia 770 which is a Linux/Gtk-based PDA. Mono and Gtk# work out of the box on it.

Paolo reports:

After the Mono JIT port was done using a desktop little-endian ARM computer, Geoff just recompiled it and run it on a Linksys NSLU2 (which runs a ARM processor in big-endian mode). That was pretty cool. I wonder if it is as cool as running mono on a Nokia 770 (no recompilation necessary, just copied the binary from my Debian box). Here it is running our hello world app. Many thanks to the fine folks at Nokia for sending me a prototype so quickly.

...

I made tarballs of binaries for use on Linux/ARM systems, including the Nokia 770. And, yes, Gtk# apps work fine on it:-). Happy hacking, you'll find them here.

I added a few links and updated some on the quoted text above.

In addition Paolo made a small video of Gtk# starting up on the Nokia, notice that it starts up very fast.

The NSLU2 has an ARM processor running at 130Mhz. At USD 78.84 it is probably the cheapest machine to run Mono. Geoff boostrapped Mono in about 10 hours on this little machine.

Update: Geoff reports that he un-underclocked his Linksys machine so instead of being a running at 133Mhz he is running it at 266Mhz.

With the machine at 266Mhz compiling Mono 1.1.9 (which includes building the C runtime with gcc and compiling the C# code for the 1.x and 2.x profiles) takes about 9 hours.

Posted on 20 Sep 2005 by Miguel de Icaza

Must-own book

The new book from Brad Abrams and Krzysztof Cwalina: Framework Design Guidelines : Conventions, Idioms, and Patterns for Reusable .NET Libraries is a must-have book for anyone writing .NET and Mono code.

I got my copy at the PDC this week and it is a wonderful book. The book includes many of the design guidelines that Brad's blog is famous for. The book is not just a collection of rules, but it also includes the rationale for some of the design decisions and what really makes the book interesting are the commentaries from other developers and architects involved in .NET.

This book is packed with gems. I hope we can start using these more in our own code

Oh, and I also got my copy autographed by Brad himself.

There are slides from his session posted here. Another set of must-read slides for any developer.

More PDC

Am working on a larger post with all-things PDC and the Mono meeting, but it is taking me some time to digest everything I learned this week.

Posted on 18 Sep 2005 by Miguel de Icaza

Mono Meeting at the PDC: Reminder

If you are attending the PDC or you live nearby, remember that today at 6pm we are having a Mono Users Meeting a the Sheraton Downtown Hotel in LA.

Details on the meeting are here.

We have a few fun stories to share about the PDC, I will try to blog them later this week.

Posted on 13 Sep 2005 by Miguel de Icaza

Mono Meeting at the Microsoft PDC

Update: We had a hugely successful meeting during the PDC. I will post details after I decompress from a great week at the event.

Mono users meeting at the Microsoft PDC.

Date: Tuesday September 13th.

Location: Sheraton Downtown LA hotel, a short walk (map) from the Staples Conventions Center.

Room: Santa Monica Room.

Time:The meeting will start at 6pm and will go until 9:30pm.

Open to the public

Pass the word to other fellow .NET developers.

At the meeting we will talk about the Mono Project's current state, milestones, new developments, platform support and upcoming releases. Various Mono developers will be there to answer your questions both members of the community and Novell employees working on Mono.

The evening surprise is the unveiling of the new Mono T-Shirts design by Finnish artist Tuomas Kuosmanen. We will be giving out t-shirts to the attendees.

We will showcase some of the Mono-based applications we have built for Linux:

We will also showcase the new vector-based rendering APIs available for developers (completely cross-platform) as well as the new OpenGL-based windowing system.

We will answer your questions on how to bring your .NET applications to Linux, MacOS X and Solaris and how to take advantage of the Mono and Linux-specific APIs.

Finally, we will demo some of the the new Mono software funded by Google's Summer of Code:

  • XBuild: the open source msbuild implementation for assisting you in rebuilding your new projects on Mono.
  • Ruby.NET and PHP.NET compilers.
  • The DIVA Movie editor.
  • The new ASP.NET editor.
  • The .NET bug finder.
  • The Cecil libraries for reading and writing CIL images.
  • Mono's XAML compiler.

Background for the Mono Meeting

Background: As some of you know, Microsoft for the second time in a row blocked the Mono Birds-of-a-feathers (BOF) meeting from being held at their Professional Developers Conference. It is their conference, and I understand that a cross-platform .NET implementation might make them nervous (we are creating lots of new applications with it, and we are helping people reuse their existing skills on Linux).

It is their conference, and they have every right to control what they will allow to be shown there, but they actively have misrepresented things. On the PDC web site they claim that the BOF selection is up to INETA ( apparently an independent non-profit organization). Here is what the BOF selection process was advertised (you must have an MS Passport to read this):

The Birds of a Feather sessions at the Microsoft PDC05 are chaired by INETA (International .NET Association), the premier .NET developer user group associations.

[..]

Final selection and scheduling of the sessions will be performed by INETA based on popularity: all decisions are final. Submitters will be notified by Friday September 2, 2005 whether their session was accepted or declined.

What they failed to mention is that the Mono BOF was never listed for voting, and hence it never received a single vote. My submission was confirmed as I exchanged two emails with Stuart Celarier at Corillian, but the BOF was never listed and further emails to Stuart went unanswered, he wrote on INETA'S web site:

INETA is chairing the Birds of a Feather track at PDC 2005. This community-driven activity brings together conference attendees for open, moderated discussions on topics of shared professional or community interest.
[..]

Birds of a Feather really do flock together!

Stuart probably did not get the memo.

My guess is that it is best not to list the BOF than have to answer obnoxious questions about why the top-voted BOF had not been accepted (this year they also removed vote count display from the BOF listing).

So much for the independent INETA chairing the BOF process. On Friday, I was notified that my BOF proposal was not accepted.

I believe this is at the core on what is wrong in the way that Microsoft treats its users and developers and why people consider alternatives in the first place.

BOF sessions in every conference I have attended in the past ten years is usually an event that happens after hours and is organized by the attendees in an organic way: a white board is left open for groups to allocate an hour or two for what they consider an interesting topic. Conference organizers never have any editorial control over them, they basically give out the rooms for the various communities to get together.

At Stephen Walli's urging we put together Mono meeting on a nearby hotel and Tuomas designed a beautiful new T-Shirt (Thanks!). It will be fun, and I will probably wear my large foam red cowboy hat.

Anyways, its important to separate the great and amazing developers, testers and architects working on .NET from the marketing and management people. I look forward to a great time at the PDC. See you there!

Stickers

We want to distribute some cute stickers, an idea courtesy of Mike Shaver's: something like this:

"[Logo] using Mono;"

Picture this with me: Black background, yellow letters, nice cute Mono logo outline. I think it will look lovely.

Small stickers to put on badges and medium size for laptops. If you know someone in LA or Boston that can get this done quickly and before the PDC, let me know

Posted on 06 Sep 2005 by Miguel de Icaza

Policies and Katrina

A collection of various articles that in my opinion are relevant about policy making and the Katrina effect on New Orleans.

First some background: The president finished his five week vacaction and went on a fundraising tour to Arizona and the west coast. He likes to keep a balanced life.

In the meantime, as the vice president continued to enjoy his holidays the Secretary of State was spotted in New York City attending a Broadway show and going on a shopping spree:

On Wednesday night, Secretary Rice was booed by some audience members at "Spamalot!," the Monty Python musical at the Shubert, when the lights went up after the performance.

Yesterday, Rice went shopping at Ferragamo on Fifth Ave. According to the Web site www.Gawker.com, the 50-year-old bought "several thousand dollars' worth of shoes" at the pricey leather-goods boutique.

A fellow shopper shouted, "How dare you shop for shoes while thousands are dying and homeless!" - presumably referring to Louisiana and Mississippi.

The woman expressing her First Amendment rights was promptly removed from the store.

Billmon:

Paul Krugman's column in yesterday's New York Times argues that the Cheney administration's lackadaisical response to Hurricane Katrina is a symptom of a much larger problem -- the GOP contempt for government:

At a fundamental level, I'd argue, our current leaders just aren't serious about some of the essential functions of government. They like waging war, but they don't like providing security, rescuing those in need or spending on preventive measures.

I was thinking about posting something along those same lines -- along with a modest proposal to chaingang all the conservative pundits and politicians who've spent the past twenty five years trashing the federal government, and put them to work stacking sandbags down in Louisiana. And while we're at it, we could take all the think-tank libertarians and corporate bunko artists who promised us their blessed free market could and would solve all human problems, and use them as filler for the sandbags.

Two Americas:

Local National Guard are serving in a President's war of choice. People in trouble need them here.

Molly Ivins states:

Just plain political bad luck that, in June, Bush took his little ax and chopped $71.2 million from the budget of the New Orleans Corps of Engineers, a 44 percent reduction. As was reported in New Orleans CityBusiness at the time, that meant "major hurricane and flood projects will not be awarded to local engineering firms. Also, a study to determine ways to protect the region from a Category 5 hurricane has been shelved for now."

Dave Winer:

Comment: The writer above is absolutely correct that, if we were prepared, the response to the aftermath of Katrina would be further along by now. Responsibility however is not with the administration, it lies with the electorate. We had a chance to make last year's election a referendum on the politics of terrorism, to seriously evaluate our preparedness, if we really cared.

If anything is learned from this, we have to think, we can't delegate. We need leadership that cares, not in a superficial way. That leadership must come from us. We have some very huge decisions to make right now, and many thousands of lives depend on how well we do. That said, I have few ideas of things we can do other than give money to relief agencies, which of course, we are doing.

Molly Ivins echoes the need to care about politics:

To use a fine Southern word, it's tacky to start playing the blame game before the dead are even counted. It is not too soon, however, to make a point that needs to be hammered home again and again, and that is that government policies have real consequences in people's lives.

This is not "just politics" or blaming for political advantage. This is about the real consequences of what governments do and do not do about their responsibilities. And about who winds up paying the price for those policies.

Maureen Dowd says:

Stuff happens.

And when you combine limited government with incompetent government, lethal stuff happens.

Others are a bit harsher, but still correct.

An open letter to the president:

Any idea where all our helicopters are? It's Day 5 of Hurricane Katrina and thousands remain stranded in New Orleans and need to be airlifted. Where on earth could you have misplaced all our military choppers? Do you need help finding them? I once lost my car in a Sears parking lot. Man, was that a drag.

Also, any idea where all our national guard soldiers are?

[...]

And don't listen to those who, in the coming days, will reveal how you specifically reduced the Army Corps of Engineers' budget for New Orleans this summer for the third year in a row. You just tell them that even if you hadn't cut the money to fix those levees, there weren't going to be any Army engineers to fix them anyway because you had a much more important construction job for them -- BUILDING DEMOCRACY IN IRAQ!

The president tried to use the "nobody expected this" excuse. Dave Winer has collected some evidence that the problems in New Orleans were well known.

CNN ripped each one of the excuses from the Homeland Security Secretary.

In the meantime, operation scapegoat is in full swing. Joshua explains this succinctly:

Now at least we have the storyline. The Bush administration wasn't caught sleeping on the job while New Orleans went under with a gutted FEMA run by a guy who got fired from his last job policing horse shows. In fact, according to the new White House storyline, the governor of Louisiana and the mayor of New Orleans didn't ask for help quickly enough. And the White House was powerless to act until they did. Apparently they couldn't even reschedule the president's vacation until the locals got the right forms signed.

The Independent hosts some questions and answers:

Why has it taken George Bush five days to get to New Orleans?

How could the world's only superpower be so slow in rescuing its own people?

Why did he cut funding for flood control and emergency management?

Why did it take so long to send adequate National Guard forces to keep law and order?

How can the US take Iraq, a country of £25m people, in three weeks but fail to rescue 25,000 of its own citizens from a sports arena in a big American city?

Click for the answers

Billmon points out that this disaster is similar to the 1927 flood of New Orleans and quotes some 1927 newspapers and photographs

Greg Palast on the 1927 floods and the rise of the government for the people:

There is nothing new under the sun. In 1927, a Republican President had his photo taken as the Mississippi rolled over New Orleans. Calvin Coolidge, "a little fat man with a notebook in his hand," promised to rebuild the state. He didn't. Instead, he left to play golf with Ken Lay or the Ken Lay railroad baron equivalent of his day.

In 1927, the Democratic Party had died and was awaiting burial. As depression approached, the coma-Dems, like Franklin Roosevelt, called for balancing the budget.

Then, as the waters rose, one politician finally said, roughly, "Screw this! They're lying! The President's lying! The rich fat cats that are drowning you will do it again and again and again. They lead you into imperialist wars for profit, they take away your schools and your hope and when you complain, they blame Blacks and Jews and immigrants. Then they push your kids under. I say, Kick'm in the ass and take your rightful share!"

Huey Long laid out a plan: a progressive income tax, real money for education, public works to rebuild Louisiana and America, an end to wars for empire, and an end to financial oligarchy. The waters receded, the anger did not, and Huey "Kingfish" Long was elected Governor of Louisiana in 1928.

At the time, Louisiana schools were free, but not the textbooks. Governor Long taxed Big Oil to pay for the books. Rockefeller's oil companies refused pay the textbook tax, so Long ordered the National Guard to seize Standard Oil's fields in the Delta.

Billmon points out that the US is capable of deliverig efficient relief efforts Where there's a Will. He presents various newspapers quotes from 2004 and Florida:

So you can see that when the chips are down, and the need is absolutely dire, this administration can still deliver the kind of coordinated emergency response that once made the U.S. government the envy of the world -- just as it cooly and capably protected the Iraqi Oil Ministry from the chaos and looting that trashed every other government office in post-invasion Baghdad. As is usually the case in public service, it's just a matter of having the right incentives.

The comparison between the TLC showered on Florida last year and Bush's initial "What, me worry?" response to this year's disaster no doubt will go unnoticed by the amnesia patients in the corporate media. And since I'm lucky enough to live in a swing state that is also coveted by GOP political strategists, I probably don't have to worry about it either -- that is, as long as any future disasters around my neck of the woods happen in one of those years divisible by two.

But for the citizens of staunch, deep red Mississippi and slightly less staunch but still red Louisiana, the lessons are painfully obvious. If you're going to insist on living in a hurricane alley, then you need to take personal responsibility for your own actions, stop whining about government incompetence, and embrace the free market solution to your problems -- by moving to Florida.

On Rebuliding New Orleans:

Long before Katrina, New Orleans was hit by a hurricane of poverty, racism, disinvestment, deindustrialization and corruption. Simply the damage from this pre-Katrina hurricane will take billions to repair.

Now that the money is flowing in, and the world's eyes are focused on Katrina, its vital that progressive-minded people take this opportunity to fight for a rebuilding with justice. New Orleans is a special place, and we need to fight for its rebirth.

[..]

No sane person should classify someone who takes food from indefinitely closed stores in a desperate, starving city as a "looter," but that's just what the media did over and over again. Sheriffs and politicians talked of having troops protect stores instead of perform rescue operations.

Images of New Orleans' hurricane-ravaged population were transformed into black, out-of-control, criminals. As if taking a stereo from a store that will clearly be insured against loss is a greater crime than the governmental neglect and incompetence that did billions of dollars of damage and destroyed a city.

The press has not noticed where the real looting is going on:

President Bush yesterday told ABC-TV, ''there ought to be zero tolerance of people breaking the law during an emergency such as this, whether it be looting or price-gouging at the gasoline pump or taking advantage of charitable giving or insurance fraud.''

[..]

In a thinly disguised attempt to act as if it cared about the people wading in the water, Chevron has pledged $5 million to relief efforts. ExxonMobil and Shell have pledged $2 million apiece. British Petroleum and Citgo have pledged $1 million each.

Those disciplined operating practices are hardly confined to the oil fields. Everyone knows that Bush does not really mean what he says about price-gouging at the pump, since he just gave energy companies the bulk of $14.5 billion in tax breaks in the new energy bill. Surprise, surprise. In Bush's two elections, oil and gas companies gave Republicans 79 percent of their $61.5 million in campaign contributions, according to the Center for Responsive Politics.

If Bush really meant what he said, he would call for a freeze or cap on gasoline prices, especially in the regions affected most dramatically by Katrina. He would challenge big oil to come up with a much more meaningful contribution to relief efforts.

Insurance companies are expecting up to $25 billion in claims from Katrina. For ExxonMobil, which is headed to $30 billion in profits, to jack up prices at the pump and then only throw $2 million at relief efforts is unconscionable.

Jamie has several other updates.

Posted on 04 Sep 2005 by Miguel de Icaza
This is a personal web page. Things said here do not represent the position of my employer.