Mono Weekly News (Jan 10th, 2003)

Overview

Welcome to the third MWN letter. We have a lot of news for you!.

Table of contents

1.1 Switch support has landed in Mono CVS.

At the beginning of the week Jonathan Pryor sent this amazing email. Mono supports now the 'switches' as described in MSDN docs: "a way to get flags/control information into your program so they can be used". They're primarily used with code instrumentation. More info in the email!.

1.2 Glade# use attributes and implicit names.

Rachel has made Glade# use attributes so binding C# widgets to the designed widgets is now easier than ever. Alp has improved this to use implicit names as well. This means, before you had to do:

     Gtk.Window main_window = (Gtk.Window) gxml["main_window"];
     
but now you can just use the attribute:
     [GladeWidget("main_window")]
	Gtk.Window main_window;
     

1.3 Mono debugger now has support for multi-thread debugging.

Martin's Mono debugger now has support for multi-thread debugging that makes possible to have the new special feature of having breakpoints that can be defined in a per-thread basis now.

1.4 Mono and Mono ASP.NET as an Apache module.

Daniel Lopez has checked in his Apache module to integrate Mono and Mono's ASP.NET support as an Apache module. Gonzalo has folded his new Mono hosting classes into this module (they are now shared between XSP and mod_mono). You can get the mod_apache from CVS (module name: mod_mono).

1.5 Zoltan has published his Code Coverage analysis tool for Mono.

Zoltan's Code Coverage Analyzer snapshots are now on his web. You can get them here

1.6 Paolo added a memory profiler to Mono.

This memory profiler gives a report of where memory was allocated in a program the number of allocation, the types of the objects and the total memory allocated it's used to identify what codepaths are the most involved in wasting GC memory.

1.7 Steve Newman contributed his Javascript interpreter to Mono.

Steve is the author of Janet: an ECMA compliant JScript engine, and a new group of developers is stepping up to continue his work on the interpreter and turn it into a full compiler for Mono and .NET. If you are interested in joining, join the mono-list.

1.8 Jonathan Pryor has published his type-reflector.

Type-reflector is a program similar in spirit to the .NET ``TypeFinder'' SDK Sample. It allows a regular expression (as understood by System.Text.RegularExpressions) to be used for finding types and a lot of more interesting options for making your life easier. You can find the code at mcs/tools/type-reflector

2. Meet the team. This week Daniel Morgan.

The Mono team is integrated by contributors all over the world that are working really hard to get this project going further. In this section we will be meeting this people so we can know more about them and what they are doing.

This week we have been talking to Daniel Morgan in the IRC. Daniel is the developer who has worked out most of the SQL providers in Mono. He is from South Carolina, USA and before joining the Mono Team he was an active hacker in the GNOME Database Project (http://www.gnome-db.org) and prior to that he was a database driven insurance applications developer. He enjoys programming on Mono, riding his motorcycle and reading and watching science-fiction. Let's see what he told us.

Interview with Daniel Morgan

MWN: So you are the Mono expert on DataBase Providers, don't you?, can you tell us what can be done using the code you contributed?
Daniel Morgan: I'm no expert, just a willing contributor to System.Data in Mono. Currently you can create database driven applications with GTK# or ASP.NET depending on your requirements, you have to various DBMS backends, including MySQL, PostgreSQL, Microsoft SQL Server, Sybase, and SQL Lite. If you need access to a database not listed, you can get access via the ODBC or OLE DB providers. Both ASP.NET and GTK# have become useful for creating real world applications... along with System.Data, you could start creating programs like SQL#, financial, accouting, or other business applications. I know the Microsoft SQL Server is probably the most stable provider there is... simply because its pure C#... it does not use any client libraries because there are no client libraries, it has no dependencies other than Mono and access to a SQL Server database...
MWN: As you are involved in the GNOME-DB Project how do you see the ADO.NET model for the new application development?. Do you feel like having Mono's ADO.NET implementation will make Linux DB Access applications much easier to develop?
Daniel Morgan: Yes, I am involved in the GNOME-DB project. GNOME-DB was designed to provide an ADO or OLE-DB like data access model for Linux and UNIX. So, ADO.NET seems the natural way to go. Mono's ADO.NET will definitely make application development much easier; however, this isn't the main reason for using it. It allows the programmer to concentrate more on implementing the business requirements instead of spending more time on the details of the language.
MWN: did you find any mistakes in the design, do you think there are some classes or assemblies that might be changed in the SPEC?
Daniel Morgan: There are a few mistakes in the design... as with the first version of any complex design... such as, all data providers should have inherited from the same database exception class. Creating generic connections and adapters are difficult, but this has been helped by Brian Ritchie's ProviderFactory. Every database vendor has their own API for accessing their database. ADO.NET provides an abstract way to access these databases via interfaces which must be implemented by a data provider: IDbConnection for connecting to a database; IDbCommand for executing SQL commands; IDataReader for reading data from a result set, IDbDataAdapter for filling a DataSet or DataTable, IDataParameter for parameters
MWN: Could you give some advice for the Mono users about the Providers and their use?. If you were to write a new application that uses databases through Mono, which classes would you use?, what would be your general method to achive that?.
Daniel Morgan: System.Data isn't all about databases; it can be used for non-database data too... you could create a data provider which does not even connect to database for instance, a DataSet and XmlDataDocument can read and write XML. Ville Palo has been working on the DataSet and XmlDataDocument and understands it better. Most database application programmers are used to developing in a relational manner... tables having rows and columns...while XML application programmers are used to developing in a hierarchical tree manner...XmlDataDocument and DataSet bridge that gap.
MWN: For the people interested in contributing, which classes and tasks do you think need more help?
Daniel Morgan: All the classes need loving :) especially any that throw NotImplementedExceptions or has MonoTODO's DataSet needs work; Reggie Burnet, the developer of a 100% C# provider for MySQL is interested in including his provider in Mono... last I've heard, it works with the lastest cvs Mono basically, just like all the other areas of Mono, System.Data needs lots of testing it actually works better on Linux.
MWN: Is there anything left you would like to say to the world and the Mono Community in special?
Daniel Morgan: Yes, even though Mono has a PostgreSQL and MySQL provider; they both use a native client library which has its drawbacks. These drawbacks includes, depenedency problems, slower performance compared to a 100% pure .NET provider, sometimes failure, such as, PostgreSQL does not work in SQL# For GTK# on Windows. Npgsql is a 100% C# provider for PostgreSQL and works on Mono. The Npgsql developers have already approved it to be included in Mono and under X11.
MWN: Thanks Daniel for your time and your work. Best wishes for the new year.

Daniel also provided us with a nice example of how to add database access to your programs using Mono. Here is the code:

Mono MySQL Hello World Example

Log on to the MySQL client tool mysql:

DanielMorgan@DANPC ~
$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7 to server version: 3.23.51-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

Change to a database:

mysql> use test
Database changed

Create a database table named hello_world_test with the columns hello_id and
hello_desc.
hello_id is the id to this table and hello_desc is an attribute that is a
description.

mysql> create table hello_world_test (
    -> hello_id varchar(2),
    -> hello_desc text);
Query OK, 0 rows affected (0.01 sec)

Insert a row into the new table named hello_world_test
with hello_id set to 'HW'
and hello_desc set to 'Hello World'.

mysql> insert into hello_world_test (hello_id, hello_desc) values
('HW','Hello W
orld');
Query OK, 1 row affected (0.00 sec)

Verify the data in the table.

mysql> select * from hello_world_test;
+----------+-------------+
| hello_id | hello_desc  |
+----------+-------------+
| HW       | Hello World |
+----------+-------------+
1 row in set (0.02 sec)

Now, create the SQL statement you will use in your C# program.

mysql> select hello_desc from hello_world_test where hello_id = 'HW';
+-------------+
| hello_desc  |
+-------------+
| Hello World |
+-------------+
1 row in set (0.02 sec)

// MySqlHelloWorld.cs
//
// On Windows, compile like:
//     mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe
MySqlHelloWorld.cs \
//          -lib:C:/cygwin/home/MyHome/mono/install/lib \
//          -r System.Data.dll -r Mono.Data.MySql.dll
// On Linux, compile like:
//    mcs MySqlHelloWorld.cs -r System.Data -r Mono.Data.MySql
//
//DanielMorgan@DANPC ~/mono/20021223/mcs/class/Mono.Data.MySql/Test
//$ mono f:/cygwin/home/DanielMorgan/mono/install/bin/mcs.exe
MySqlHelloWorld.cs
//    -r System.Data.dll -r Mono.Data.MySql.dll
// Compilation succeeded
//
//DanielMorgan@DANPC ~/mono/20021223/mcs/class/Mono.Data.MySql/Test
//$ mono MySqlHelloWorld.exe
//Result: Hello World
//
using System;
using System.Data;
using Mono.Data.MySql;

class MySqlHelloWorld {
        static void Main(string[] args) {
                string connectionString = "Database=test";
                string sql =
                        "SELECT hello_desc " +
                        "FROM hello_world_test " +
                        "WHERE hello_id = 'HW'";

                // connect
                IDbConnection dbcon = new MySqlConnection();
                // set the connection string
                dbcon.ConnectionString = connectionString;
                // open a connection to the database
                dbcon.Open();
                // create command
                IDbCommand dbcmd = dbcon.CreateCommand();
                // set the command's SQL
                dbcmd.CommandText = sql;
                // execute the SQL
                IDataReader reader = dbcmd.ExecuteReader();
                // read the first row in the result
                if(reader.Read()) {
                        // display the result
                        Console.WriteLine("Result: " + reader["hello_desc"]);
                }
                else {
                        // display message row not found
                        Console.WriteLine("Row not found.");
                }

                // clean up
                reader.Close();
                reader = null;
                dbcmd.Dispose();
                dbcmd = null;
                dbcon.Close();
                dbcon = null;
        }
}

3. The Mono Spell.

dietmar ignores papers comparing java with .net Dietmar Maurer.

If God meant us to use unicode, He would have put 16 bits in a byte. Marcus Urban.

4. Mono Socials: Duncan does Tokyo.

The always_minded_to_help and Ximian Mono hacker Duncan spent some of his hollydays visiting the monkeys at Tokyo, as Atsushi Enomoto who is the maintainer of System.XML and Nick Drochak known mostly for his tests although he contributes in lots of places. You can see the gallery here

5. CVS Activity.

This has been a bussy week. Here are the results. (*) Actually I am using the number of commits as measure, I will try to get more accurate aproximations in the future. (Starting Jan 01th, till Jan 08th)

Authors: Total 23

AuthorCommits
Alp Toker4
Atsushi Enomoto6
Daniel Lopez9
Dennis Hayes1
Dick Porter2
Dietmar Maurer6
Duncan Mak17
Gaurav Vaish10
Gonzalo Paniagua47
Jackson Harper2
Jaime Anguiano5
Jeroen Janssen4
Johannes Roith51
Jonathan Pryor1
Marco Ridoni5
Martin Baulig210
Martin Willemoes Hansen9
Miguel de Icaza20
Paolo Molaro14
Piers Haken2
Rachel Hestilow4
Sebastien Pouliot7
Ville Palo7

ModulesCommits
mono32
mono/jit14
mcs/mcs7
mcs/class84
mcs/class/corlib23
mcs/class/System.Web35
debugger199
Windows.Forms1
gtk-sharp27
mbas5
monodoc12
mod_mono9

6. Mailing List Activity.

A bad ass week for the mono-list but as a matter of fact most of the mails have gone around buggy setups and about what is Mono going to do with JScript.

The Mono and Javascript thread has been really interesting. The main points:

Please visit us at the homepage of the Mono Project: http://www.go-mono.org