Friday, February 20, 2009

Mmm minty

I want to come on here and sing praises for something known as Linux Mint. I've been a user of the Ubuntu flavor for quite a while now ( a few years, to be sure. ) I've come to favor Kubuntu, but I was disenchanted with Intrepid Ibex because it basically undid everything I had found convenient about the previous versions. Well, KDE did anyway. I backtracked to Hardy Heron and was there for a little while, but then I got a new, powerhouse machine with an XP partition for my gaming. So I decided to start over and look for a new flavor to try.

There must be a different version of linux per user of the actual operating system, because hunting one down is not easy. I realized what I wanted was something that was ready for me, from the instant I installed it. I love the Debian approach to repositories, but their GPL-only ethos is a pain. For example, who ISNT going to install mp3 support? Seriously, now. I wanted that hot-and-ready feeling you get from Windows, except without the eventual meltdown. This brought me to look at linux mint.

Mint offered what I was looking for, but they did better than that. Their system is based off Ubuntu directly. That means that I am instantly comfortable in the new environment, because I know it. There are some new things to look at, but nothing is missing. And everything just works, even wireless detection - which usually sucks in linux. I seriously think I could give this OS to my mom and she'd get cozy in just a few minutes. It uses gnome, but the mint desktop is configured to have a sort of KDE feel to it in a lot of ways. As you might expect, everything's really green, including the many wallpapers you get by default. I think the offset of green and black/grey they use is calming. Reminds me of a 7-Up can.


I've gotten quite comfy and I just wanted to reccomend it, since I have a small voice here. You can find out more at: http://www.linuxmint.com/


Oh, and for those of you who don’t know already… it’s 100% free. In more ways than one.

Friday, February 6, 2009

Cool Programming Tricks Episode 2: Anonymous structs

This is a C++ trick that I learned at work. Similar concepts must exist in other languages, but I do not know of any. Additionally, this won't do much for EMACS or vi users who don't have auto-completion. How do you live by the way?

Anyway. You may be used to viewing structs as an inferior form of a class. Actually, they're technically the same in C++ with visibility differences, but in practice they are totally different! A struct is made for organization. Try thinking of them as tables inside a document, with several fields apiece that you can change separately. The uses of such might seem limited in programming, where you want to cut down on the amount of variables in each scope to simplify your efforts ( i.e., a new class with private variables. ) However, you will always wind up having a lot of things to choose from regardless of this simplification. Sometimes making a class to hold your many variables is not the answer. After all, what's the point of a class that's all accessors and mutators?

My sorting trick is an anonymous struct. I didn't even know these existed. They wear no type name, therefore you cannot instantiate it, ever. It exists once and only once: in the scope it's created in. Take a look:

class Game {
private:
struct {
BITMAP* player;
BITMAP* enemy;
BITMAP* background;
} graphics;

struct {
SOUND* music;
SOUND* hit;
} sfx;
}


These structs, graphics and sfx, ONLY exist inside this class. So they become like folders of data, and thanks to the power of IDEs, you can take advantage of this. For example, if you start designing a level for this game, you need to remember what the bad guy's BITMAP pointer was. Well you don't have to go to the header if you remembered 'graphics'. Simply type "graphics."(with the dot) and any IDE worth ten cents will pop up a box listing each of the images. If you don't want to have to memorize all these structs, put THEM in a struct called "media", and remember that. It's just like managing your desktop. You could take this really far and have every single one of your classes put all its private data in an anonymous struct called 'pdata', and never look through your headers again. A real time saver!

I do this frequently since learning at work. No problems so far. Do let me know what you think!