Tuesday, February 19, 2008

Free Speech and Civil Liberty

Free Speech and Radical Islam

I'm not sure if I totally agree with what she said. I am a full supporter of free speech. But two things come to mind.

First off, we, at least here in Canada and the US, teach our children to be careful of our words cause they might be very hurtful. I remember my mother always telling me that the tongue is a very powerful tool that can be used for good or evil. How does that translate to the geopolitical world? Do we have to start thinking of being careful what we say because it might offend people? My personal belief is that we should not restrict people from saying what they want to say. People should be aware of what they say and feel safe to say it, but should be conscious of the way it might affect other people. In NO WAY should the government start to regulate what people can and cannot say. This I surely agree with.

Secondly, at the end she says this:

We need a global movement to fight blasphemy and other insult laws, and the European Union should lead the way by removing them. Europe should make it clear that democracies will protect their citizens if they say something that triggers threats and intimidation.

I really don't agree with that. Countries should be sovereign. I don't like the UN and how it has the power to tell countries what to do. I think there is a fine line between helping a country in need and dictating the laws of a country.

Monday, February 18, 2008


GCC Non-Bugs

Some have been encouraging me to write my compiler to output C-- code. It's a cool idea and would probably like to do it at some point. But right now, since it's not in much use yet, I've decided to stick with Java Classes. Though, this talk has led to thinking about implementing it in GCC and/or helping them do it. So I started reading through the GCC website, looking at all kinds of stuff. Along the way I found this. It's a pretty good read, pretty short and might offers some good insights in good programming practices in a few of the languages GCC compiles. Let me know what you think. This could be a good discussion.


Here is a wonderful video about liberty.


So I've been playing around with developing a module to work with Java class files. Here is the specifications for the file format. If you check out my current files you can see that it's coming along. I'm mainly fighting with the problem of how much calculated data to store in my structure and how much to leave to the methods to generate when it's needed. This is sort of of a battle of lazy vs. immediate evaluation...but not quite.

For instance...A lot of the objects in the structure have length, and index fields into the other parts of the structure. Well, the structure is held together with pointers and lists in memory. The only time those indexes are useful, is when they are converted to binary for the file output. Holding these indexes in memory would add quite a bit of complexity, requiring an update to all affected pieces when another pieces is added, removed of modified. I guess a lot of these decisions will come out later when I start writing the method that writes the structure out to file. Does anyone have experience writing these types of files? I'd be interested in knowing what others have experienced.

Once I am far enough along with this thing, I'll have to start working on understanding the instruction set. This is where I expect the real fun to begin.

Friday, February 15, 2008

Finally Here

When I first got to Southern I had my heart set on taking Compiler Construction. So I set out on a mission to go full boar taking as many CS classes as possible to do all I can to make sure I've got the classes I need, and the knowledge I need to be prepared to take it when it gets offered again. So this semester, my opportunity showed up.

We had to do lots of work last semester to get it offered. We don't have a large department, so we had an option of having AI or Computer Construction offered this semester. At first, it seemed as though AI was going to be offered, but I was going to do everything I could do to swing the vote the other way. So a fellow classmate and I started campaigning for it. We spoke to as many students as possible to get the vote up. All we needed were 6 students for the class, and it would be enough to swing it. Well, we got our six. After a month of class, only 6 remain...well, there are still 6, but one guy only comes to class like every two weeks....I doubt he'll last much longer.

So far we've had got two pieces built. You can monitor my progress here. The goal of the class is to compile Decaf, a subset of Java to MIPS. But MIPS isn't very useful, so I thought of compiling to some type of intermediate language. The two options that come to mind are the .NET IL and Java bytecode. I decided I was interested in doing it in Java bytecode. So my prof told me to go get Inside the Java VM at the library. After reading it for a few hours, I realized that a Java class file isn't that complicated to understand. So last weekend I wrote a data structure to store the contents of a Java class file (class.[ch]). Next, I have to implement a few more methods to work with it. Then I need to figure out how the instruction set works. My prof tells me it's a stack based language, so I'll have to check that out some more. I've never worked with one of those before. Should be fun.

In any case, we've got a symbol table and a lexer build already for class. My symbol table, I cheated and just wrote a glib GHashTable wrapper. So that ran fast and reliably. Some are still working on theirs. My lexer on the other hand...that was a pain. Lex is annoying, and quite unpredictable from time to time. Take for instance the following lines from the Rules section of my lex file.



. {BEGIN ERROR1;unput(*yylext);}

If you want to completely understand what is going on, I suggest you find a lex tutorial, but the basic gist is simple. The first line is in the state. If it matchs a character that has been unmatched by all the other regexes from above, then one character is matched, we go into the state and put the character matched back in the buffer. THen the second line will match any single character followed by as many non-operator/whitespace characters to follow. the following is a sample matching

ie: bob?julie;

bob identifier
?julie error

THe use of states would seems to imply that the order of thsoe rules doesn't matter, hence why we use states, but if I switched those two rules, it wouldn't work properly. I think it's because the first line doesn't explicitly state the state, it assumes it...who knows. My lex and yacc book told me that if no state is specified, the INITIAL state is assumed. Who knows. I hate programming by coincidence, but for now, I think I have to deal with it. Cause I don't have time to figure this out.

Anyhow, I hope to be able to post here from time to time to give updates on my progress.