Jun 1, 2009

KDE, revisited

The other day I posted about me trying out KDE, and my first impressions of it. I've been using it a bit since then to see how I like it.

Initially it blew me away, since the default look and feel is much nicer than GNOME. It's not grey and brown anymore, there are smooth animations and fading effects, etc. etc. It feels much more modern and appeals on a more aesthetic level.

However after I started using it more, there was just a few too many things that annoyed me for me to really want to keep using it. I will probably try and see how to fix some of the problems but for now it is easier just to stick with GNOME.

Here's a list of the annoyances I've had. Note that a lot of them I could probably fix by either searching through their settings panels, or scouring the Internet. However it is just easier for me to switch back to GNOME, which is already pretty much the way I like it.
  • Panel widget sizing - the widgets on your panels seem to have no maximum size, so they just expand to fill up the whole panel. This is really really annoying, because the little cashew thing on the right hand side overlaps the widget that is furthest to the right. Also if you like to use programs like Avant Window Navigator (AWN) like I do, there is no need for the "task manager" widget that shows the open windows. However if you remove it, the other widgets will expand to take up the entire space. Nothing like a clock widget that is 300 pixels across. I ended up having to split the one panel into two, with a huge gap in the middle. Kinda broke the aesthetic aspect there.
    This was something that I did try to look up online how to fix. Apparently there is a "Spacer Widget" that you can get that just takes up empty space, however it was not available through their auto-download thing and I didn't really feel like searching for it. On top of that it feels like a rather ugly way of handling this.
  • Cashews. The little cashew thing is for tweaking settings. It's nice to have it right there in front of you the first time you try KDE because that way you have easy access to make your tweaks. However after you make your tweaks, they are still there in the way of what you are trying to do. A good alternative would be that you right-click on the panel and go to "Settings". Oh wait, they do that. So why would they have the cashew thing?
  • Desktop - Where did all the files on my desktop go? I put lots of files on my desktop either for quick and easy access, or for reminders of a program that I'm supposed to check out - although it is surprisingly easy to forget the things that are right in front of you all the time.
  • The menu - I like the favourites part. And the search feature. However I have counters: with a dock there isn't really a need for the favourites list, because you just put your favourite programs on the dock. And the search feature seems to only be useful for me since the damn menus are a bit more of a pain to navigate! With old-school menus I just need to mouse over things and they open. If I open the wrong menu, it is trivially easy to go back to another one since I can still see it (and am likely still looking at it). Instead with KDE, it is a bit more work to actually have to navigate to the menu, so you just type it in the search field instead. I suppose some people may prefer this over the GNOME menus but I'm not sure if I do.

Anyway these are the little things here and there that I didn't like so far. I'll probably switch back and forth between KDE and GNOME until I get KDE working the way I want it, or when I finally get completely annoyed and stick it out with the less nice aesthetics of GNOME.

May 30, 2009

KDE

I'm giving KDE a shot with kubuntu-desktop. So far it seems pretty slick! The interface reminds me of SPORE.
Out of the box it is much more visually appealing than GNOME, and some of the feature seem kinda nifty. It seems they took some hints from Mac and Vista, where it seems like GNOME is still sticking it out with the minimalist idea.

Only problem so far: avant-window-navigator crapped out right away, but I just restarted it and it seems to work fine.

I'll post more on this later, maybe even give some tips on how to get things working under it if I run into problems.

May 14, 2009

SVN plugin for Vim

For those of us too lazy to use an IDE or fancy graphical front-ends to SVN, here's a nice little plugin for vim to help you with commit messages:

http://www.vim.org/scripts/script.php?script_id=978

When you use 'svn commit' and it opens vim, it will show two windows: one with the normal SVN commit message, and the other with the output of 'svn diff', which is handy when you want to remember what you had changed.

A shortcut that is very handy to know for this is Ctrl+W+W (that is, hold Ctrl and hit w twice), which is to switch between vim windows.

To install it, just drop the script in ~/.vim/ftplugin, and make sure that your ~/.vimrc file has the following:
filetype plugin on

May 10, 2009

Identity

Not too long ago someone I know wrote a post about identity and the question, "Who are you?" He says that our usual answer to this question is first our name, and then our occupation; he then goes to say that this answer is wrong.

After reading this, I found myself asking the same question - Who am I? No, who am I really? Rob? Well, yes, but a name is simply a label used to identify you. Kinda like a variable in your code if you named your variables Valerie or Steve or something - which would make for horrible programs, maybe we should all name our children when they're 20 or something after what they do, like Makes-Good-Hot-Chocolate or something. Those native peoples had something going there.

However after a fair bit of thought on the matter, I inevitably came to the thought, "Well, if I'm trying to figure out who I am, what is identity?" That is another slightly tricky one to put your finger on. Fortunately I went on vacation last week, so I had plenty of time to sit around and ponder.

I came to the following answer, feel free to debate: your identity is defined by what do you and/or what you believe. It is a collection of what I'll call "identity elements". I am a professional software programmer - why? Because I program software professionally. I am an amateur software programmer - I write code in my spare time for no real reason other than to see what happens. I make wine, play guitar; I believe in mostly free markets and science. I could go on like this for a long time. The accumulation of these identity elements is what makes up your identity.

It gets more complicated than that: some identity elements have more weight to them. Which of these elements has the higher weights is heavily influenced by your society and consequently (most of the time) the weight that you yourself apply to them. In Canada and most of the Western world it seems that your job has a higher weight than what you do Saturday nights - although if you do really weird things on your Saturday nights then perhaps that will more heavily influence the weight of that element, but then again "weird" is also defined by the society in which you live.

When you find that your identity is not really what you want it to be, then you're at a bit of an identity crisis. Maybe this crisis is better defined as lack of job satisfaction, boredom, feeling like you're not doing anything with your life, who knows. They're all pretty much rooted in the same thing.

So what to do? I suppose I'll play expert on this topic for a little while, although I am far from the ideal person to do so. I'd say look at these identity elements and see what you can do to affect the ones that you are not happy with. If you are not enjoying your job, why not try and figure out why? See what you can do to change it.
Sometimes you can't do anything to change these major aspects. Maybe you can't just quit your job, or change your significant other, or move to a new city (or maybe you can and you're just telling yourself you can't). In this case, it is important for your mental health to turn to the other elements of your identity and focus on improving those - and oftentimes it is much easier to change those than in the larger elements.

Rereading this, I noticed that part of this is about attaching yourself to some label(s). Many people believe that removing these labels is a good thing - reminds me of high school with the "anti-conformist" kids who shunned labels and sheeplike behaviour, meanwhile all of them seemed to be moving in the same direction and doing what each other was doing; all they did was trade one label in for another.
I don't think that these labels are completely bad, the important part is simply realizing what the labels are and arranging your labels in a way that satisfies you.

Keep in mind that change takes time. If you want to change your job, it is not a good idea to just drop it and quit (I've sorta done this, not a good idea!), instead just keep going, searching while you're working, or if you really hate it maybe save up some cash so that you can spend some time looking for a new job without worrying too much about finances.
Set goals for yourself and work to attain those goals. Don't expect them to be attainable immediately, and don't despair when it seems like your goals are so far away that they are out of reach. When I graduated from university I had lots of debt - maybe not as much as some people I know, but it certainly seemed like a lot to me. My goal was to pay that down as soon as possible, and not too long ago I did (yay!). Now I have new goals - finish studying! Learn French!

Perseverance is the key to attaining your goals. I know it is hard, but the rewards when you complete those goals are well worth the effort. Thanks for reading.

Apr 28, 2009

Type Checking in Dynamic Languages

I was having a discussion with a friend of mine not too long ago debating the merits of dynamic languages. My friend believes that type-safety is a top priority and that a language that does not do compile-time (or for an interpreted language, parse-time I suppose) type checking is a disaster waiting to happen.

This is completely correct. Unless you're doing something trivial like a script to resize/rotate the pictures from your digital camera, a dynamically-typed language will have problems when the app gets more complex. For example, suppose while refactoring you want to change the parameter list of a function for some reason. Maybe some parameter is no longer needed, who knows. In a statically typed language, this is not a huge issue because the compiler will pick up all the places that the function is called and tell you if there are problems. Not so in a dynamically typed language, instead you have to actually execute the code. If your program is highly interactive, this will lead to problems because you will manually have to execute each version and catch the error at run-time. And if you forget to check something? Well, your users will find it.

Here is where the standard response comes in from dynamic-typing enthusiasts: testing suites. All non-trivial programs should have testing suites, regardless of the language. No programming language, even Haskell with its crazy type system, will save you from the requirement of clarifying your ideas - at least you better hope so, or you're out of a job. A type-checker can tell you if the types you are throwing around make sense, but they don't check whether the code is working the way it is supposed to. For example, one time I wrote a 3D vector class in C++. I made a typo in the cross product function and put a - instead of a +. Passed the type check just fine, but when the shading on objects was looking horribly fucked up, I had absolutely no idea what was going on. This kind of bug can be easily avoided by a simple unit test.
A good unit testing suite will help a lot, and catch many of the errors that would normally be caught by a compiler (like type-errors or spelling mistakes) while at the same time verifying the behaviour of your code.

Unfortunately, the type-safety depends on the quality of your unit tests. It is prone to human error. It is this fact that I believe a program written in a dynamically-typed language can never be as type-safe as one in a statically-typed one.

You could work around this by checking the types of the arguments at the start of every function. However this is paranoid. If you're doing this, why don't you just switch to a statically-typed language which will do this automatically, more quickly, and with less work for you?

So we come to a trade-off. Many programmers discover quite quickly that a dynamically-typed language will let you get code out the door much more quickly than with a statically-typed one. I've been mucking around with a gaming library in Python (I'll post about this another time) and I'm finding it is much easier to get simple stuff done than I ever did with C++. In fact it is so simple that there is no need for adding scripting languages on top, or config files, or all that. I can just write the stuff in Python. I've had similar experiences with Ruby.
But to get these benefits, you must accept the fact that you will not be having 100% type-safety. There may have to write more tests than you would have.

Is it worth it? Sacrificing type-safety for faster development times? Well, it depends. In fact, you may not always have faster development times. I believe that there is a threshold at some point where a dynamically-typed language will have slower development times than a statically-typed one. This threshold is dependent on many factors - how good the design is, how good the programmers are, how many programmers there are, how big the project is, how quickly requirements change, etc.

Finally one last thing to note is that statically-typed languages are easier to optimize for speed than dynamically-typed languages. In a statically-typed language, the compiler knows without a doubt the type of a variable, and can sometimes drop the type information from the resulting machine/byte code. The compiler knows at compile-time whether an object has a certain method or not, so there is no need to check at run-time, or even keep track of what methods an object really has. A lot of this is why C and C++ are still faster than well, anything else (of course there are other factors, like how most dynamically-typed languages these days are interpreted).

Apr 26, 2009

Adventures in Python

Although over the last few years I've dabbled in Python a little, I've never really sat down and made an actual program with it. I made a little web app for Google's app engine some time ago, however I don't really consider it a lot of coding and hardly enough experience to say that I really know the language.

I have the same problem that most Ruby people seem to have: we really see no reason to learn Python. There is not really any objective benefit that it gives. Both Ruby and Python offer faster development times compared to languages like C++ or Java (although it would be interesting to see which of the two languages would be faster, I don't really know). They're both interpreted (and therefore, slow and memory-intensive). They both have good-sized followings and plenty of free software available for them. So I don't really know any good reason to switch between the two - I know many Python people say the same about Ruby.

For the record, the thing I'm making now is a little game. You can check it out here if you like, it is a little Diablo-style game where you go around stabbing monsters. Hopefully it will evolve into something cooler at some point, but for now it is pretty limited.

Anyway I'll give my first impressions of the language, from the perspective of someone who has lots of experience with other Perl-derived languages (namely Ruby and PHP). Keep in mind that this is all subjective and you are more than welcome to disagree - although I think most of the people who read this blog are Ruby people anyway so I doubt too many feelings will be hurt by this one.

Things I like so far:
  • Whitespace - I love it. At first I felt as though my code were naked without end keywords or closing brackets, however after a while it becomes enjoyable. I find it makes the code much more clean, and you don't have to worry about whether you have too many or too few ends, just make the indentation work (which I would have done anyway). I do tend to forget to put the colon at the end, but that's probably just because I'm still new to the game.
  • Modularity - At it was a little annoying to have to import the modules in every single file that use it or to have to specify "from ... import ...", but in the long run it is a better way to go in that it helps break down coupling between files. I'm thinking I should take this back to Ruby and design things in this way.
  • List Comprehensions - they're nice and precise and do things that in Ruby you'd have to use zips, maps and selects for (unless of course my Ruby-fu is not amazing and there are similar things in Ruby that I don't know about, which is likely).
Now for the things I don't like:
  • Object-Orientation - it feels a little...clunky. I have to put self everywhere. While it isn't a real complaint, it is a bit annoying and does clutter things up a fair bit. I find Ruby's sigil notation to be cleaner. Also one of the things from PHP that I really hated was having to declare something as global, it is here too. Don't like it.
    static vs. class methods? Not sure why. It also seems like I have to jump through hoops to create these things.
  • Naming conventions: __ clutters up the screen, I feel like I'm writing C again: typedef struct _name { ...
    I find def+() or operator+() to be much more readable. But then again, it's what I'm used to.
    Finally, certain things like lists not having a length() method and instead you call the global method len() seems to be a little inconsistent to me. Same goes for various things like map, filter, etc.
  • It's very imperative - This may not be a bad thing. Some people like this kind of programming, they say it's old school. Feels like real programming again instead of plugging libraries/gems into one another and suddenly having an application.
    For me, I've gotten used to using functional-esque programming with Ruby and to a lesser extent Javascript with jQuery, so coming to Python seems like I'm more limited in how I can express what I want to write. But whatever.
So yeah, my reasons for it aren't really substantial, nor are the reasons against it. What do other people think?

One thing I've really learned here is that I haven't really done much with Ruby besides web apps, which in terms of complexity really aren't that deep - I don't know if "deep" is the right word here, but it seems like that when you write a web app there are fewer levels of moving parts than in an app like a game. I wonder what it would be like if I rewrote this app in Ruby, if it would have taken as long to make and if it would be more maintainable or not - probably yes since I actually know Ruby a lot better, but maybe not.

Apr 25, 2009

pygame

In my latest project I've been messing around with pygame, which is a Python wrapper and extension for the SDL media library. It is great because it adds all sorts of object-oriented stuff on top of the original SDL functionality, without really sacrificing anything (at least as far as I've noticed).

You may wonder why I chose Python for writing a game over C or C++. Well to be honest, it was mainly just to learn Python, and Python just so happened to have this gaming library available. However the more I use it, I think it might actually be a viable strategy for simpler games. If something somewhere is going too slow or using too much memory, you can always just write a part in C++ using Boost.Python and import it in - I'll be honest, I haven't tried Boost.Python so I don't know if it is as seamless as they claim, there could be more on this later.
Python offers much faster development time over C++, I noticed this right away. I can add things very easily that weren't originally in the plan. If I have a bunch of classes with similar functionality, I can quickly refactor them to inherit from a base class which provides the shared functionality - while I can probably do this in C++ too, I'd have to go through the code everywhere and use references/pointers to base class objects instead of the original - bit of a pain.

You may also now wonder why I didn't write it in Ruby. Well, like I said, wanted to learn Python. At this point, I still want to learn Python - I haven't been turned off it yet like I was with Haskell or Scala either (not sure why I was turned off of these, maybe because I'm too dumb or entrenched in my ways to really grasp their more advanced concepts). Also, Ruby is nice and all, but it's what I use at work. I'm happy about that, I'd rather be doing Ruby than PHP or Java, but I'd like a little bit of change when I go home and do my own coding. Choosing another language helps satisfy that desire for change.