Entries in Programming (20)

Wednesday
Mar032010

Processing

So I just came across this language called Processing... How did I not already know about this!?

What Is It?

Processing is a free, open-source, multi-platform, programming language and IDE used for easily creating digital artwork and visualizing data.

While looking through some code samples, you'll quickly realize how quickly easy it is to achieve impressive results. The rotating cube above, with a fire-effect, was done in less than 100 lines of code (including comments and white space.)

Click to read more ...

Wednesday
Feb032010

I Really Want to Be Able to Put if Statements on the RHS of an Assignment Operator

That's pretty much my whole rant right there in the title. But I suppose I should elaborate a little.

At work, I write a lot of code in Progress (I know, nobody's ever heard of it.) In Progress, you can put if statements in the RHS of an assignment operator, like so...

Click to read more ...

Saturday
Sep192009

Are Small Coding Tricks Worth It?

The following code snippet is part of the PAUSE BUTTON implementation in a video game. The game is paused by setting Time.timeScale to 0 and it is unpaused by setting it back to 1.0.

if (GUI.Button(Rect(25,100,100,30),"PAUSE"))
{
    if (Time.timeScale == 1.0)
    {
        Time.timeScale = 0;
    }
    else
    {
        Time.timeScale = 1.0;
    }
}

The code is simple and straightforward. The solution is logically consistent with the way most people would naturally think through the problem. But is this the most efficient solution? With just a little more thought, one might come up with something similar to the following solution.

if (GUI.Button(Rect(25,100,100,30),"PAUSE"))
{
    Time.timeScale = 1.0 - Time.timeScale;
}

Click to read more ...

Saturday
Aug082009

Pass-By-Reference Error Handling?

I'm going to try something new here. Normally when I write a post, I think through everything that I want to say before I start writing. But I think I'm going to just shoot from the hip on this one and see what happens. Since I'm just writing this as I'm thinking about it, the end result may be brilliant or it may be senseless drivel that will make you dumber by reading it - Proceed with caution.

I was just reading Joel Spolsky's argument against programming with exceptions, and I'm inclined to agree with him.

A better alternative is to have your functions return error values when things go wrong, and to deal with these explicitly, no matter how verbose it might be. It is true that what should be a simple 3 line program often blossoms to 48 lines when you put in good error checking, but that's life, and papering it over with exceptions does not make your program more robust. I think the reason programmers in C/C++/Java style languages have been attracted to exceptions is simply because the syntax does not have a concise way to call a function that returns multiple values, so it's hard to write a function that either produces a return value or returns an error.

While I completely agree with this, I think one could argue that we do have a way of returning multiple values: Pass-By-Reference.

Click to read more ...

Tuesday
Jul282009

Code Complete

by Steve McConnellFirst of all, I will say this. I should NOT have to tell anyone to buy this book. If you are a programmer, then you should already have a copy of it sitting on your desk or bookshelf. If you don't, then shame on you.

Code Complete is THE quintessential guide to building software. Not only does this book teach you techniques for creating a solid structured design, but it will also help you turn that design into a reality with clean well-written code.

Over the course of this book, Steve McConnell covers nearly every aspect of constructing software. Such topics include choosing a programming language, high-level design, coding conventions, class interface design, defensive programming, comparison of control structures, formal inspections, testing/debugging, and much more.

Click to read more ...

Monday
Apr202009

The Default Case Dilemma

I have to confess something. In my last post, I talked a lot about good coding practices. Well, it seems I have a tendency to break one of my own rules. I was looking through some of my Memories of Hyrule code and I realized that I have a tendency to leave the default cases, in my switch statements, blank.

Click to read more ...

Saturday
Apr112009

A Passion for Programming

I Love CodeThere exists programmers who do not love what they do... I know, I can't believe it either.

To many, software development is just an everyday 9-5 job. But to others (such as myself), programming is practically a way of life! But I suppose not everyone can have the same love for code that I do. Not everyone can really admire the elegance of a well-formed recursive function. Not everyone can read a piece of code and appreciate it in the same way that others might appreciate a song, film, or book. But the problem is not that there are people who don't love software. The problem is that there are people who don't love software despite the fact that they CHOSE a career in which they write it every day.

But how do I know? How do I know that the people writing software don't love it the same way that I do? How do I know that people chose to go all the way through school in order to start a career in a field that they don't love?

I know because I read their code.

Click to read more ...

Saturday
Mar142009

What Makes a Good Programmer?

 

I just came across this awesome video, and thought I'd share it.

Richard Buckland, a UNSW professor, discusses problem solving, craftsmanship, and what it means to be a good programmer. If you enjoy this video, you can watch his entire COMP-1971 course here.

Click to read more ...