lunes, diciembre 13, 2004

Mono VM Docs

Miguel reported that now the docs for the Mono VM (Reflection, Internal calls, JIT, GC Handles, Interpreter, IO Layout,...) are avalaible to be seen in monodoc.

Note, however, that work for documenting them is needed. Currently, however, some of them are a little documented, and other can be just be seen (which is a good things, since I won't need to look the namesof the functions).

A screenshot below:

jueves, diciembre 09, 2004

Mono 1.1.3 released

Mono 1.1.3 was released yesterday. The mos important changes are:

  • New build system

  • SSAPRE (Common subexpression elimination)

  • Full support for Mono.C5 (Generics library) in gmcs

  • Bundles (mechanism to bundle in a single binary the Mono runtime)

  • Support for the /doc option in mcs

  • C# 2.0 new features (contravariance/covariance and properties accessors modifiers)



The last features added to mcs were made by me ;-)

martes, diciembre 07, 2004

Education Problems

Read at DW that Germany is currently having problems with its education system, because some students leave the school when the are still young (this also is a consequence of the education system). And it also points out that in Germany the success the students get is involved with their economical situation.

At least there they have good schools, and they are now trying to improve the educations system. In Mexico we have several problems, and the current government (that being said, the last government monopoly and the current one) is not improving the system, but just making it worse.

How? creating more techinical universities, technical high schools, which shows that the government is just interested in producing qualified workers for the big companies.

Second, the more money you have, the better work you get. If you go to a expensive (very expensive) private school/university, you get almost the same education you could gain in a public one, but with more expensive builds *and*, more important, you get the sympathy of the companies. If you studied in a public university, you have fewer probabilities to get a decent job than if you studied at a particular one. Worse, the education you get there is usually not as good (or not that bad) as the one you could get ina public universitie.

Third, I thinkg we have a matter of vision and the ideas we get. Students at public universities receive an excelent education, _but_ they are educated to serve and not to manage a company; they are going to be part of another problem that in Mexico happens: the chief is an dumb-ass and his workers are people with good level, but who don't want to improve their status.

It is well known that our current public system doesn't empaphize in teaching how to think, but how to repeat _and_ do the things your chief ordered to you.

One important person told me that our *president* Fox (the most bizarre political you could ever known) decreased the amount of money for public universities, and since he couldn't do that, he then gave that money to private ones. WHAAAAAAT?

viernes, diciembre 03, 2004

Covariance and Contravariance

Support for delegates Contravariance/Contravariance support is now in Mono SVN repository.

In C# world, delegates are constructions designed to save a function; in the C world, this is similar to function pointers. Delegates offer some advntages over C function pointers, as compile and run type checks, additional properties, and they also add clearness in code.

Currently, the delegates are defined just as the following example:

public delegate void MethodHandler (string msg);

In this case, MethodHandler will act as a pointer to methods with the signature defined by itself; this is, methods with void as return value, and string as a unique paratemer. A method such void SomeMethod (string msg) would be valid, but a one like void OtherMethod (string msg, string msg2) or int AnotherOne (string msg) wouldn't.

The problem here is that the methods passed to the delegates must have the exact signature defined by it. Here is where Contravariance and Covariance come to scene.

Covariance
Having something like:

class A {}
class B : A {}

delegate A MethodHandler () { // Do something }


It would be nice to have the chance to pass not only methods like A MyMethod (), but also B MyOtherMethod. This would be possible because Be is just only a specialization of class A, which is the return value defined by delegate MethodHandler. So, returning B instead of A could be done just because B is in fact, a A class, bust maybe with more methods, more properties, etc.

With the Mono 1.x series,a dn also with MS .Net 1.0, that wouldn't be possible. Mo more: .Net 2.0 (which is in state of beta) and current Mono development branch support it.

Contravariance
Again, having code like this:

class A {}
class B : A {}
delegate void MethodHandler (B b);

Methods in the form: void SomeMethod (A a) and also void OtherMethod (B b) could be passed. Why? it's because B instances could be casted to A, so, if a delegate is called, it will receive a B instance, which will cast to A for the void OtherMethod (B b).

Just as above, this is not possible with Mono 1.x/.Net 1.0, but it is avalaible with .Net 2.0 and Mono development branch.

domingo, noviembre 21, 2004

Invitation to avoid your daily lecture of a pseudo portal

Today I had the bad -when I say, I really mean bad- idea of reading some computer related news at a mexican portal -which name beging with "Co" and ends with "día"- just to see how the ideas are going in this country every day. All the things that, as mexicans dislike, are well represented there, and also they are well applied.

In this portal, is is easy to find persons with a bad aperture to new ideas, and the haughty ideas are there the bread of every day.

Nothing easier than go there (as mexican, it's probably you would have read sometime) and begin to read the news and find that almost everyone there don't believe in nothing, not even in the good things or bad ones; they don't think in the logical things or the other. I don't say anymore, because for a smart person, it should be enough.

I only hope that never the 'main' moderatore there contacts me or somehting like that.

And again, this is an invitation to not visit that pseudo portal anymore, and in general, all the portal where only people wanting see the bad things speak. As someone said, "there's no hope for those persons who only see the ugly things in the pretty ones".

Lets just try to make a better world.

miércoles, noviembre 03, 2004

Accessor Modifiers in CVS

The code for accessor modifiers support is -finally- in CVS. I wanted it to e included in the last release that will be taken place tomorrow (the development release, of course). However, as I said before, it is now in CVS in the mcs module.

The accessor modifiers are a new feature part of the C# 2.0 specification, and with it now is possible to add an access modifier -such PUBLIC, PRIVATE, etc- for the accessors -get/set- in the properties.

This is something important in classes where you want to keep some data hidden, and want to have your Property read-only, for example. A very common behavior for a class would be to have, then, your get accessor public, and keep your set accessor protected:


public int Count {
get {
// count is a private int field
return count;
}
protected set {
// Only protected members will be able to modify Count
count = value;
}
}


With accessor modifiers, there is improvement hiding get or set methods defined by a Property, thus avoiding the need no keep a lot of variables protected.

The rules for applying this are: your access modifier must be more restrictive than the parent, when overriding the accessor must keep the parent access modifier, and that if yor property has only a an accessor (only set or only get) you can't define an access modifier.

With the first, that implies every access modifier must be more restrictive than the parent, it is not possible to have:


public int Count {
get {
}
//
// Error: public is not more restrictive than public
//
public set {
}
}


The second is very obvious, but the third says you can't have a property just only one a accessor that has access modifier:


public int Count {
//
// Error: Property must have both set and get accessors
// for applying access modifiers
//
protected get {
}
}


And finally, a sample:

using System;

public class Test {
string message;

public Test (string message)
{
this.message = message;
}
public string Message {
get {
return message;
}
protected set {
message = value;
}
}

static void Main ()
{
Test t = new Test ("Mono");

// Good, it is possible to access get accessor
Console.WriteLine (t.Message);

// Bad, mcs will complain about the access
// t.Message = "Hey";
}
}

sábado, octubre 30, 2004

C# Generics

I wrote a paper about how the System.Object based collections (dynamic arrays with different properties) work and something about the performance. It is the beginning of a serie of small articles to show why Generics (Parameterized types) represent a major improvement in the applications.

The first paper is here: Understanding System.Object based Collections.