Thursday, July 29, 2010

Ensnared by the magic box

The magical Pandora's box surely worked its magic on me. I am now on the waiting list for the Pandora Console having just pre-ordered (and pre-payed) it. Now I just have to bear with the incredibly looong waiting time. (Supposing I do receive the console, it will be a pleasant surprise if I receive it this calendar year. Surprise me.)

When I bought the Neo FreeRunner it was mostly for the sake of porting HelenOS to it as I am not really into smartphones. It is still a cool device, though, thanks to the integrated Wireless Ethernet, GPS and accelerometers (and the openness, of course).

With Pandora the situation is a little different. I really like old games and this is the retro gaming device. The real selling point for me is the keyboard (although it probably is not a great one). Pandora also has gamepad controls, but I don't really like gamepads, anyway. It also has integrated WiFi (just imagine the multiplayer possibilities!) So I definitely want to use it on gaming (you could call it love at first sight).

Porting HelenOS to Pandora should be relatively easy now, I should think, as I've already fixed the bugs that prevented HelenOS from running on a real ARM processor (despite working in emulators). Also, Pandora uses U-Boot just as FreeRunner does, so bootloader should not be a problem either.

Anyway it will be long before I have my Pandora, so I still have plenty of time to improve FreeRunner support :-)

Thursday, June 17, 2010

Watchen sie die blinkenlichten

Turn on CC (captions) in the player before starting the video.

Friday, June 4, 2010

GCC: plus plus or not plus plus?

It appears that GCC has green light to start using C++ in their code. The idea seem to have been under consideration for about two years. This time, however, it has been approved by the GCC steering commitee and the FSF.

The surrounding discussion is is pretty much the old battle between C++ proponents (who point out its many merits) and opponents (who point out its many flaws). Concerns about speed and the need to teach GCC devs to use C++. Concerns about 'misuse of C++ features.' I find the slowness argument especially amusing since Clang/LLVM is written in C++ and it does not appear to be suffer from severe performance problems.

And of course there are those who suggest only to use a subset of C++ that would not incur performance penalty nor contain features that are 'easily misused'. I hear many software projects claiming to use C++ are actually written in different, mutually incompatible subsets of C++ (using or not using exceptions, RTTI, templates, etc.) This seems to be encouraged by the historically bad conformance of C++ compilers to the language standard.

Looking away from the rather amusing bickering, does this change affect me, a mere mortal user? Well normally I couldn't care less. When I compile GCC on Linux this certainly does not present any problem. From HelenOS point of view, this is more interesting.

To make HelenOS self-hosting, we need to be able to have some compiler which can be compiled within the system. Question is, which compiler should it be? Today GCC is still a hot candidate -- it is probably the only compiler supporting all the CPU architectures and other features we need. Another selling point was it being written in C -- which it will now lose. In the future it would be necessary to implement or port the C++ standard library (and STL) to HelenOS in order to compile GCC in it.

This makes GCC drop closer to Clang/LLVM on our suitability ladder. (Clang/LLVM is also written in C++). Practically the only remaining deficiency of Clang/LLVM w.r.t GCC is that unlike LLVM itself, which should have good support for several architectures, Clang currently only has good support for i386/x86_64. It should not be hard to improve Clang support for other targets, but still there must be sufficient demand to drive the development (Apple does not need it).

Another player in the field is the Portable C Compiler. It is written in C, but it is a relatively small project and supports only a few CPU architectures. (Interestingly neither LLVM nor PCC support Intel Itanium architecture). I have some misgivings against depending on such project whose future is not very certain.

In any case, the choice of a (first) C compiler to run in HelenOS remains open for now.

Friday, March 5, 2010

Hash or dash?

I am pleased to say that SBI (Sysel Bootstrap Interpreter) is making good progress. You can already create object instances, play with the variadic built-in function Exec, raise and handle exceptions, etc.

Now I know you might think I am just being silly, but I still haven't decided on how to write comments. Basically I am oscillating between hash (as you saw in previous posts) and dash (--), i.e. double hyphen, for denoting comments.

Hash is easier for me to type, because I can type hash with my left hand and use arrow keys with my right hand at the same time. For double hyphen I either need to use the little finger of my right hand, or lift the hand and move it towards the minus key.

From aesthetic point of view... I just don't know. Most of the time I seem to prefer dash, although it clashes with the bullet point hyphens in the BSD license in the HelenOS format (but an alternative form could be used for that).

What I am quite confident with is that the commonly used comments should be single-line comments, where comments blocks would be created by typing in a series of single-line comments. Multi-line comments would only be used for disabling sections of code (typically for debugging purposes).

Doc-blocks will be started by a special single-line comment (such as ## or ---) and continued by regular single-line comments (such as # or --).

An interesting idea here pertains to the way of denoting the 'brief' part of the doc block. The common methods include: (1) up to the first period (.), (2) the first paragraph, (3) the first paragraph if marked with some special tag (such as @brief). Another way which came to my mind is that if the 'brief' part spanned more than one line, all these lines would use the same doc-comment mark. Example:


## First line of doc brief and
## this is the second line.
#
# This is no longer part of
# the brief.


or


--- First line of doc brief and
--- this is the second line.
-
- This is no longer part of
- the brief.



Do you like one of these comment styles better than the other? If so, why? Or would you recommend yet another one? Let's hear ye!

Tuesday, February 23, 2010

Watch out HelenOS, here comes Sysel!

It is alive! I had to put in some hacks to avoid name conflicts and I had to implement fgets() in the HelenOS C library, but SBI now works in HelenOS. It's not really a big deal, as SBI still doesn't do so much, but it's still nice.

If you're eager to try it, check out this Bazaar branch.

Build the system as usual and boot it. There are some really trivial demos in the sysel/ directory. Just run SBI with the source file pathname as argument. For example:


# sbi sysel/hello.sy


Well... back to work!

Monday, February 22, 2010

A Rodent is Born

I guess I cannot pretend it's a secret anymore. I am working on Sysel. What is sysel? Well, sysel is the Czech name for the European ground squirrel, or, in layman's terms, the European gopher.

Sysel with capital S is a programming language, however. From the previous posts you should already have some idea how Sysel should look like. Right now (in the 'first phase') I am developing Sysel Bootstrap Interpreter (or SBI for short). This is an interpreter of Sysel written in C.

The main purpose of SBI is to bootstrap the prospective self-hosting Sysel compiler, as well as serving as a testbed and refining the language design. Nevertheless, SBI will run under both POSIX-based systems and, of course, HelenOS. SBI as well as other Sysel tools that I will produce will be available under the same BSD-like license that is used by HelenOS.

Only real geeks develop alternative operating systems. Therefore, hopefully, by creating an alternative programming language to develop an alternative operating system in, I will be able to achieve whole new levels of geekiness.

I have created a project on Launchpad where you can now track my progress. I will also publish a HelenOS+SBI branch when that's ready.

Stay tuned!

Sunday, February 14, 2010

Inheritance Quiz

Now pay attention, class! Try to guess what does this fine C# program do?


using System;

public class A {
public static void hello()
{
Console.WriteLine("Hello World!");
}
public class B : A {
}
}

class Test {
public static void Main(string[] args)
{
A.hello();
A.B.hello();
A.B.B.hello();
A.B.B.B.hello();
A.B.B.B.B.hello();
}
}



I'll give you a few options. This C# program, when compiled with GMCS will:

(a) Compile without error and print "Hello World!" five times.
(b) Compile without error, but abort with a runtime error.
(c) Abort compilation because of the cyclic inheritance.
(d) Abort compilation because A.B is not defined.
(e) Abort compilation because A.B.B is not defined.
(f) Crash the compiler.


No cheating, please!