Tuesday, November 30, 2004


It looks like the Earth forgot to keep rotating. Combine the shorter days with overcast skies and the slight tint in the windows in my office and I feel like I'm working at the bottom of a very very large cave. I am affected by a lack of sunlight in a not very good way (ask my wife or anyone else who has known me for a while), and it's making me a little grumpy lately.

Thursday, November 18, 2004

Language Design

So I've been doing some reading about different kinds of programming languages and found some really good references, and it feels like my head is going to explode some of the time. I think that there's going to be a bit of a tradeoff on how powerful a language is versus how readable and maintainable it is. It's nice to be able to get a lot done in a few lines of code, but if those lines of code make no sense to anyone but the writer, it just doesn't do much good. It's obvious to me that comprehension of code drops dramatically when a single function won't fit on the page at one time.

I think strong typing is a good thing. The ability to detect type mismatch at compile time (or in the IDE) as opposed to at runtime is a really good thing. I think that errors at runtime should be minimized where possible. However, I also think that implicit casting is also a good thing. I don't want to have to tell the damn machine that yes, I know this is an integer and yes, I want to use it as a float. It should just work, and if the cast is legit, it should do it with no warnings at all. Some type casting makes no sense, however, and that's when it should throw errors, or at least warnings for cases where it could be a problem but night not be.

Do I want to allow operator overloading? Really, that's just another form of function overloading, just allowing extending the definition of tokens with a normally fixed meaning at parse time. I don't want to have a language that allows redefinition of reserved words. That's just too painful for me. Sure, it's powerful, but that goes back to power versus readability. (Note that's not the same as allowing variable names to be the same as reserved words - that might be allowable due to a difference in scope, but it could make the parser too complicated.)

Wednesday, November 10, 2004


It's a really long week. It's only Wednesday and it already feels like it should be Friday. In fact, yesterday felt like it should be Thursday. It's as if Monday was three days long. I've been tired all week. I realize I haven't gotten enough sleep, and that's part of it, but holy crap, this is annoying.

The stupid part of this is that I don't have anything really exciting coming up that would make it reasonable that I'm just being impatient. I could see how that would make time seem to flow really slowly. That's not the case here, though.


Tuesday, November 09, 2004

Quiet musings

Sometimes I feel obligated to write something, anything. Not that I expect anyone in particular to read it, and not that I really have anything to say, but mostly to be in the habit of writing. This is one of those times. Like a really good bowel movement, sometimes you just need to evacuate your mind.

I'm running a D&D game lately with a group with a wide range of experience. I've played since 1979, and a couple of the players have played about that long. There are also a couple that have played, but not in years and years, and at least one that has never played before. The novelty of it all is something to see. There is such a plethora of material these days that it's really easy to get lost. I'm just using the core 3 books to start out, but in the design I am (will be) using several other texts. As people get used to the rules, whether new players or old, I'll be introducing some variant rules and additions to make it even more interesting. In hopes of not startling them too badly I want to collect the rules and give them something to read on their own. We've had a few sessions, and they've solved a couple simple problems. I'm also including hints for long term complexity, which is always fun - factions, alliances, recurring villains, and so on.

Unfortunately what I haven't spent enough time on is background. I need to spend quite a bit of time spread out over a much longer time to give it the substantial depth that makes a long term game worthwhile. I need maps, deities, organizations, and so on. Names and NPC's and rumors and legends. It's easy to ad lib a low level game for a while, but if you want a game to last 10 years or more you really need to do a lot of work up front. (I know - I've done it before.)

So anyway, I guess that's what was floating around in my head. As always, it feels good to get it out.

Friday, November 05, 2004

Bleary eyed and grumpy

A little more on languages. The language I create will have a well defined grammar, and I'll be writing forms of it for tools like ANTLR, JavaCC, Bison, and so on. It's very important to have this as opposed to a haphazard language with features thrown in at random. These tools are well established and very stable, and they can generate code reliably. It's much more difficult to write refactoring tools for a language when the parse tree is ill defined.

There should be a way to use a grammar to not only create a parser for a given language, but also a code generator for it as well. If a parser creates a parse tree, you should be able to feed that tree into a code generator and generate equivalent code. (Not necessarily identical code, because formatting will undoubtably be lost, but you could certainly regenerate most comments, especially comments used as documentation or similar special features.) You also can parse code, manipulate the tree, and generate resultant source code, and that ability is needed for refactoring tools. Many optimizers operate on the tree automagically, too. So, anyway, I've seen plenty of tools that create a parser given a grammar, but none so far that create a generator given that same grammar. I'd like to write one. It would wind up being very similar to CodeDOM, but specific to a given language, and you could generate the entire program-space the grammar defines.

Thursday, November 04, 2004

Mumbling to myself under my breath

So I've been toying with the idea of writing a complier for a really long time now. I actually really like Microsoft's CodeDOM that's part of .Net, but I got really frustrated by a couple deficiencies I found in it. For starters, there is no way to declare a function that exists as exernal - not "extern" in the C sense, but "native" in the Java sense. I don't have a problem with being unable to use language features that are not supported in a given language ("native" has no meaning in Javascript, for example), but if I want to programmatically generate code that the language supports, well, I want to be able to actually do it. I am toying with the idea of trying to make a CodeDOM of my own that fully supports msil, and throw exceptions if a given provider indicates that a language doesn't support a desired feature. Not sure on the best way to go on that.

I also want to target multiple platforms. GPCP is a flavor of Pascal that targets both .Net and the JVM, so they are a lovely example, but I also want to target Win32/x86. Clearly the way to go is to take some other language and write a compiler that targets only one of those 3, and use that as the basis to write one that can bootstrap itself. Then add other targets, refactoring as I go.

I've decided I don't like aspect oriented programming. The ability to inject behavior into a class without modifying the original class makes it impossible to determine what a given class will do without knowing the full context. I think this is a bad thing. Attributes, like Microsoft has created with .Net, are similar, but require you to inject them into the code of the class they apply to. In this situation you can tell what it's supposed to do in a given situation when you read the code in isolation. A good language exists for the code writer, not the computer or the compiler.

Generics? I probably should, right from the start. There was screaming for them right away in Java, and they only just now got them. C# didn't have them, but it will in version 2.0. Done right, they are ridiculously powerful. My only concern is that I'm not sure how to implement them in a compiler. I can see classes, interfaces, inheritance, etc., but generics sort of hurt my brain. That's just me whining, though, so feel free to ignore it. Like I said, a good language exists for the code writer. If a feature makes it easier to write good code, it should be there.

That's a good point, though. If a feature is really easy for a code writer to use improperly, it either shouldn't be in the language, or it has been implemented wrong. Pointers are really really powerful that are also easy for many people to get wrong, so you see many newer languages lacking direct access to them.

So anyway, I'll stop here for now. More later.

Wednesday, November 03, 2004

O, Discordia!

The Crimson King is another step closer to breaking the beams that hold the Tower in place, so it feels.

Yes, this post is directly related to my previous one, and those of you who have read Stephen King's Dark Tower books should understand.

Tuesday, November 02, 2004


So I went and voted. I usually go and vote in the morning, and today was no exception to that rule, but there was a real difference today. Most of the time I can just walk right in, sign my name, and vote. Today there was a line. I stood in line about 40 minutes before going through the signing and voting ritual. It actually felt good to stand in line for once. I really hope it's because there are a lot of really pissed off people who want a change. When asked how I voted (elsewhere - at the poll itself people were carefully avoiding asking that), I responded with "Against Bush." Technically I voted Democrat, but it's much more against Bush. I'd really like to have a candidate I wanted to vote for, as opposed to one I am voting against.

Many people insist that we should vote for third party candidates, and overall they are right. I don't think that any of them have a chance of winning this time around, and I think it's much more important to try to get Bush out of office. As soon as Bush is not up for office, I'm going straight Libertarian ticket, which I saw for the first time as an option the last time I voted. I mean, literally, I had never before seen it as a physical option until then, but then, and today, you could vote straight Libertarian, which I thought was very cool.

Understand that I think politics sucks. I generally don't care for it, I think most politicians are corrupt simply because the job itself is inherently far too tempting for most mere mortals to avoid corruption, and that it attracts the worst sorts of people. (There are people worse than politicians, but they are high on the list.) Politics is about compromise, but this time of year it's about mudslinging. I actually respect those who can do the job honorably and keep their hands clean, but they are few and far between. I'm tired of people bringing religion into politics. Worship whatever entity you like, live they way you want, and accept the fact that the freedom you have to do so is a freedom you share with other people, and that they will also worship and live as they like. So long as they are not interfering in your life, you should not interfere in theirs. Maybe that last bit needs to be in a separate paragraph, but it's one of the more anoying things I've seen recently in political campaigning - bringing religion into it. It's pretty much one of the best ways to guarantee that I'll vote against you.