Archive for Programming

C assertions

The assert method is a very useful debugging macro for C/C++. It’s great when developing code that other people will be using and extending, to ensure that someone doesn’t do something unintentional. In cases like this, a useful assert(0) will spew an error and abort the instance of the application. It tells the developer “oops: you did something wrong”. Yes, it can be confusing to some developers, and it’s even worse when a user sees it (insert boring rant about the necessity of good breadth testing). But when used well, I quite like it.

At work I’m using the LSB C++ compiler to build our latest product for all Linux Standards Base platforms. I’ve written about how the compiler is buggy before (at least I meant to..), but this time it’s an issue in the assert.h header that ships with the LSB SDK: it’s completely broken.

The macro doesn’t work properly whatsoever.

It’s rather frustrating when something like that is so utterly broken. The only good news is that the LSB folks are taking the bug rather seriously.

Comments off

WebCID

I’ve renamed and reversioned my old Web Caller ID project as WebCID v1.1, and released the full source to the modem daemon and web application under the GPL. The SourceForge project page is here and more details are here.

Who knows. Maybe someone will find it useful. If not, at least it has big geek factor.

Comments

Computer Graphics Project

My computer graphics project is done. Well, it was done last week. But I’ve only now gotten around to making a few screenshots and combining it into an animated gif.

The first project was to draw and animate a dinosaur using only ellipsoids (stretched spheres). In this last project, I worked with 2 people. We each included our dinosaur in the making of this project. Everything you see has been hand drawn using basic geometric shapes. Grass, water, sky/cloud and dirt textures were borrowed from the Internet. Each dinosaur may be moved independently. Each has a shadow that is geometrically correct, but does not match the light source (and it’s also slightly skewed…). Shadows are tough! The water is transparent and specular (reflective). And there are multiple light sources in the world. When a dinosaur is selected to be moved, a spotlight appears over it. As the t-rex moves closer to either of the other two, it shades to red; the other two dinosaurs also turn automatically such that they are always facing the t-rex. They animate at all times, either performing some arbitrary idle motion (tail wagging, neck bending, etc.), and their legs move when they walk. Very simple animation, but it works.

Here are some screenshots scaled down:

Comments

Is the Future in .Net?

Some days when you read the tech news, all you hear about is .Net. It makes you wonder whether the future of everything is in .Net. And it’s not just from Microsoft; it comes from all directions, including Novell’s recently purchased Ximian Inc., project owners of Mono, the open-source GNU .Net release.

It makes me uncomfortable knowing Microsoft has full control over this technology. They control the licenses under which open-source projects like Mono can exist. If they pull-back, would that kill Mono and .Net on every other platform apart from those which Microsoft supports (i.e., Windows)? Novell/Ximian doesn’t seem to worried.

Personally, I have a Java bias. I like Java most because it’s multi-platform. This is huge. I’m a big multi-platform user. My primary workstation is Linux, but I still have some Windows boxes kicking around. And let’s face it, anyone that hasn’t locked them selves in a GNU/GPL cage has to use Windows sometimes. And Java applications can be run on any of these systems with ease. I love the language, it’s strictness and syntax. It’s really quite beautiful. But the virtual machine is somewhat slow. And Swing is not the nicest of GUI’s out there. When I’m working on Linux, I want something native, preferably something that uses the KDE/Qt framework to integrate nicely with my KDE desktop. And on Windows, I want a native Win32 UI.

Java just doesn’t cut it for large GUI applications. How many large-scale Java applications can you think of that are widely adopted? Apart from development tools like Eclipse, the biggest I can think of for the end-user is OpenOffice.org. And this is an excellent example of a large, slow Java app. It crawls compared to native Office suites like Microsoft Office or KOffice. Don’t get me wrong, though — I use OO.org all the time and I’m very thankful for having such a full-featured open-source multi-platform office suite. But it’s still slow. And it doesn’t “fit in” with the rest of my native, platform-specific software.

In comes .Net and C# — Microsoft’s answer to the Java threat. This language is very similar to Java. A little less strict, maybe not quite as reflective, but it’s close enough that a Java programmer wouldn’t have to spend much time learning new syntax to successfully write C#.

Say goodbye to annoying old-school Windows development using MFC and the like. Say hello to object-oriented development for all your Windows needs, including GUI with Windows.Forms. It’s about time.

Not only is there C#, but Visual C++ .Net, Visual Basic .Net, J#, and third-party things like Delphi for .Net, and even FORTRAN for .Net. I guess it only makes sense that there would be a surge of development environments and languages that compile into CLI. Today I’m evaluating #Develop, an open-source IDE for C#/VB.Net for Windows. It’s very light-weight but not quite as nicely refined (not surprisingly) as Visual Studio .Net 2003.

Despite my Java preference, I have to say that for once I’m almost impressed by Microsoft’s work. At least, what they’ve done with the framework. Mono is starting to look more promising, and I’m even considering tinkering with it at home on Linux (despite having to deal with GTK rather than Qt). Apparently Windows.Forms for Mono is in the works. This is good news. Essentially the same piece of code will run natively on both Windows and any other Mono-supported platform. This is excellent. It’s like native Java, if that were possible.

So is the future of development in .Net? It sure is starting to look like it. .Net is invading everything and every platform. The only places that Java still seems to hold firm ground (and perhaps any serious ground at all) is in J2ME (mobile clients, such as PDAs and cell phones) and J2EE (server-side web services and the like). But even J2EE is threatened by .Net’s Web Services.

I guess I had better get my feet wet with .Net. Luckily I’m working on a (Windows) C# project at work. I’m using both #Develop and Visual Studio .Net 2003 on my workstation. We shall see how this goes.

Comments

The Thing About Object-Oriented Design

The thing about object-oriented design is that it’s not always necessarily the best design choice. Sometimes, in a small piece of code (I’m thinking a script, for the most part) you’re better off writing it functionally. In fact, often times in this situation you will have less code if you do not do OO design.

With Java and .Net and the rest of them, OO design is being pushed from all directions. And while it is true that is probably the better abstract design methodology that we have today, it doesn’t mean that it’s the bees knees in the grand scheme of things.

Sometimes, it’s just not necessary; period. Not everything needs to be OO. So, get off your OO band wagon and start making some intuitive design choices. Just because something is OO doesn’t mean it’s inherently better than that which is not.

Comments

« Previous entries ·