I was reading blog entries today and stumbled across this article. Basically it talks about universities and Java and how programmers nowadays are sucking. It's been a fairly repeated argument over the last little while it seems.
The difference is this: I've been reading that stuff and wondering, "Hmm, are Canadian schools the same?" Up until I read this article, I've been thinking that it is true, Canadian schools pretty much are the same.
Now I'm not so sure. Yes, I did learn Java in my first year (I had done C++ in high school, so it was a breeze learning Java) instead of C or Pascal or Scheme or what else. It also seemed like the math requirements were a little skimpy.
However this article says that many of the students had never seen assembly language or things like that. We were required to take a class on assembly (more specifically, MIPS assembly with some Intel x86 stuff at the end). We also used some C, which the students were required to figure out a bit on their own having not being taught it in any class, although the extent of C that we did wasn't very much. There was one project where we had to take the assembly output of gcc and make some tweaks.
We were required to take a course on programming languages (I think all universities do, don't they?), where the coursework was heavy in Scheme. There was some stuff in Prolog and SmallTalk, although I don't recall there being any major assignment using them.
Finally, many of the upper level classes required coursework to be done in C or C++, two that come to mind immediately were called "Computer Graphics" (that's a no-brainer what it's about) and "Microcomputer Interfacing", which involved programming a mini-computer embedded on a robot with wheels and sensors and what-not.
There was math requirements, of course. Basic calculus, like derivatives and integrals. The honours program that I was1 in required two advanced calculus courses, which looked at calculus using higher dimensions and vectors to name a few things. Other required courses included a course on linear algebra, and one on logical proofs and things like that.
Are these not things that are taught at all universities? I looked at some others and the curriculum seemed somewhat similar. Some of them had maybe one or two required classes that I didn't have to take, or I had to take one or two courses that they didn't have to take, but for the most part it was the same.
I've never looked at the American universities though. Is it similar to what I wrote above?
1That's a big "was", I dropped the honours program later in my degree in favour of taking more economics courses.
Jul 29, 2008
The Power of Destruction
I've been working a bit with C++ recently on some personal projects, and it reminded me a bit of the C++ nuances. Mainly, memory management and destructors. The memory management isn't nearly as hard as everybody seems to think, most of the time you can just use boost::shared_ptr which does reference counting and you're set. In cases where you may have cyclical references you'll probably need to keep other things in mind, also you'll need to keep track of exception safety when executing complex statements. You can use a garbage collection library if you are really worried.
However, I'm remembering how much easier it is to manage non-memory resources with C++. In Java/Ruby/PHP/etc. you can have destructors or things that emulate destructors, but they have an element of non-determinism added: the garbage collector. You don't know when your object will be destroyed (in the case of PHP since the lifetime of your program is usually very short, this doesn't matter all that much).
Why might this be a problem? It means that you either have to manually release any resources that an object may use, or accept that the resources will stop being used at an undefined point in your program.
Here's an example. Suppose you have a mutex. Here is how you would normally use it:
Second, and more important: what if the code between the lock and unlock is not exception safe? What if something in there throws? Will your mutex be unlocked? You now have to handle any exceptions that may be thrown in that area before the unlock() statement. You could put the unlock() in a catch block, but what if lock() throws and the mutex doesn't get set? Also, what if you don't want to catch the exception here, you want it to be handled higher up in the code?
These are all things that are completely avoided in C++:
There are all sorts of other resources that are available to objects, like database connections, network connections, and file resources to name a few. Being able to have an automatic, deterministic mechanism for releasing these resources makes your life as a programmer much easier.
However, I'm remembering how much easier it is to manage non-memory resources with C++. In Java/Ruby/PHP/etc. you can have destructors or things that emulate destructors, but they have an element of non-determinism added: the garbage collector. You don't know when your object will be destroyed (in the case of PHP since the lifetime of your program is usually very short, this doesn't matter all that much).
Why might this be a problem? It means that you either have to manually release any resources that an object may use, or accept that the resources will stop being used at an undefined point in your program.
Here's an example. Suppose you have a mutex. Here is how you would normally use it:
lock(mutex)What is wrong with this model? First, it requires you to remember to unlock. Not a huge deal, but it lets in a certain degree of human error.
code that needs to be locked
unlock(mutex)
Second, and more important: what if the code between the lock and unlock is not exception safe? What if something in there throws? Will your mutex be unlocked? You now have to handle any exceptions that may be thrown in that area before the unlock() statement. You could put the unlock() in a catch block, but what if lock() throws and the mutex doesn't get set? Also, what if you don't want to catch the exception here, you want it to be handled higher up in the code?
These are all things that are completely avoided in C++:
{In this case, Lock is an object. The constructor locks the mutex, the destructor unlocks it. Since lock is a stack object, it gets deallocated automatically (and its destructor called) when the exception is thrown, or the end of the block is hit. You no longer have to worry about exception safety in your block.
Lock lock(mutex);
... code to be locked
}
There are all sorts of other resources that are available to objects, like database connections, network connections, and file resources to name a few. Being able to have an automatic, deterministic mechanism for releasing these resources makes your life as a programmer much easier.
Jul 26, 2008
OpenPolitik
I've been a little quieter recently compared to normal, and I'll tell you why now. I've been riding my bike to work, so there is less time in the morning for me to think about what to write in my blog entries while I dodge traffic and retarded pedestrians. And it takes less time to bike to work than to take the bus/metro, so there is less time to think even without distractions. I've also been on vacation for the last week (hooray!) so I've been out and about.
Second, I've been working on a programming project. It is a little app for playing a diplomatic board game that I used to play a lot while in university. Since there are no longer hordes of geeks around for me to play with, I've created an online version for us to play it. You can see it here. I released it under the GPL too, so if you want to see the code it is here. It is written for Google's App Engine, which I wrote about in a previous post.
I have found a few restrictions though. The biggest problem I had was manipulating images. Google doesn't allow you to use the Python imaging library (PIL), you have to use a set of functions that they define. It does things like cropping, resizing, rotating, etc. The basics. However I wanted to be able to update a board, which involves pasting one image onto another one and the engine didn't allow me to do it. I had to do something a bit more involved, where I created pieces and placed them as <img> tags on top of a div that had the background image set to the board, absolutely positioned to where they were supposed to be. In retrospect, this might make it easier later on for an admin to modify the board, using some fancy drag and drop Javascript. Cool.
Anyway, that is my advertisement. If you are interested in playing, just head over to the game and either start a game, or join an existing one. I'm sure you will be more than welcome.
Second, I've been working on a programming project. It is a little app for playing a diplomatic board game that I used to play a lot while in university. Since there are no longer hordes of geeks around for me to play with, I've created an online version for us to play it. You can see it here. I released it under the GPL too, so if you want to see the code it is here. It is written for Google's App Engine, which I wrote about in a previous post.
I have found a few restrictions though. The biggest problem I had was manipulating images. Google doesn't allow you to use the Python imaging library (PIL), you have to use a set of functions that they define. It does things like cropping, resizing, rotating, etc. The basics. However I wanted to be able to update a board, which involves pasting one image onto another one and the engine didn't allow me to do it. I had to do something a bit more involved, where I created pieces and placed them as <img> tags on top of a div that had the background image set to the board, absolutely positioned to where they were supposed to be. In retrospect, this might make it easier later on for an admin to modify the board, using some fancy drag and drop Javascript. Cool.
Anyway, that is my advertisement. If you are interested in playing, just head over to the game and either start a game, or join an existing one. I'm sure you will be more than welcome.
Jul 22, 2008
Closed-Source and Incentives
One part about being a programmer is wanting to do cool things on the side. Maybe you get a fun idea for something and you want to whip up something to put that idea into practice.
Now think of yourself at your job as a programmer. One thing that's really nice on the job is having stuff to improve your productivity. So you think of something cool or some good idea to do that, you program it and then start using it. Maybe it's not the best right away, but you work with it a bit and iron out some of the flaws and it gets to be good.
Here comes the problem. Now you've got this software you've been using, and you want to use it on your own projects. But sometimes you'll be stopped by the deadly non-disclosure agreement (NDA). This is an agreement with your employer that any code you write while at work can only be used at work and you can't do anything you want with it.
I'm sure some of you have figured out that I am speaking from personal experience.
Anyway, here is my current dilemma: I don't want to come up with creative things at work, because I won't be able to use them the way I want to use them. If I do anything above-and-beyond the norm, what do I get from it? Maybe a raise, but the marginal utility of income is ever decreasing, so these raises really get to a point where I don't care anymore about raises, I just want to do cool shit. And be able to do what I want with the cool shit.
So then I end up doing the cool shit at home, where I can slap a big MIT or GPL on it and say, "this software is free!" But there's only a limited about of time at home. Each day there's probably two hours that I have free (after work, sleep, travel, eat, clean) to do what I want, and that needs to be split among other things besides coding: girlfriend, other friends, video games, guitar, reading, etc. So I don't really end up spending that much time doing what I want, rather what I have to do in order to pay bills and all that. Which I don't find to be a very satisfying career.
What do others think of this?
Now think of yourself at your job as a programmer. One thing that's really nice on the job is having stuff to improve your productivity. So you think of something cool or some good idea to do that, you program it and then start using it. Maybe it's not the best right away, but you work with it a bit and iron out some of the flaws and it gets to be good.
Here comes the problem. Now you've got this software you've been using, and you want to use it on your own projects. But sometimes you'll be stopped by the deadly non-disclosure agreement (NDA). This is an agreement with your employer that any code you write while at work can only be used at work and you can't do anything you want with it.
I'm sure some of you have figured out that I am speaking from personal experience.
Anyway, here is my current dilemma: I don't want to come up with creative things at work, because I won't be able to use them the way I want to use them. If I do anything above-and-beyond the norm, what do I get from it? Maybe a raise, but the marginal utility of income is ever decreasing, so these raises really get to a point where I don't care anymore about raises, I just want to do cool shit. And be able to do what I want with the cool shit.
So then I end up doing the cool shit at home, where I can slap a big MIT or GPL on it and say, "this software is free!" But there's only a limited about of time at home. Each day there's probably two hours that I have free (after work, sleep, travel, eat, clean) to do what I want, and that needs to be split among other things besides coding: girlfriend, other friends, video games, guitar, reading, etc. So I don't really end up spending that much time doing what I want, rather what I have to do in order to pay bills and all that. Which I don't find to be a very satisfying career.
What do others think of this?
Jul 14, 2008
Back to Linux at Work
Not too long ago, I wrote a post about my experiences of using Linux at work. I had to stop using it, since the new software I was using ran out of memory in the virtual machine, so I had to run it off of our dev server. I then couldn't figure out how to mount the samba shares in my virtual machine, so I was out of luck for development (although now it is occurring to me I could have used FTP).
Now though, I've discovered two more awesome things about VirtualBox. First, I can use shared folders to mount the samba share through Windows, then mount it in the virtual box. So now I can go back to the way I was developing before!
Second: This is very awesome. VirtualBox has this mode called seamless mode. Before, I was using fullscreen mode, where the virtual machine takes up your entire monitor, with the virtual desktop, etc. In seamless mode, you can still see the Windows taskbar, and on top of that any Windows programs that you have open. Basically the windows that you have open with X in the virtual machine are inter-mingled with the windows you have open with Windows. You can also see your Windows desktop with the little icons on your host OS desktop, but at the same time you can see the GNOME menu bar at the top. Very convenient!
So if you haven't tried VirtualBox yet, I definitely recommend it. It's been a pleasure working with it so far.
Now though, I've discovered two more awesome things about VirtualBox. First, I can use shared folders to mount the samba share through Windows, then mount it in the virtual box. So now I can go back to the way I was developing before!
Second: This is very awesome. VirtualBox has this mode called seamless mode. Before, I was using fullscreen mode, where the virtual machine takes up your entire monitor, with the virtual desktop, etc. In seamless mode, you can still see the Windows taskbar, and on top of that any Windows programs that you have open. Basically the windows that you have open with X in the virtual machine are inter-mingled with the windows you have open with Windows. You can also see your Windows desktop with the little icons on your host OS desktop, but at the same time you can see the GNOME menu bar at the top. Very convenient!
So if you haven't tried VirtualBox yet, I definitely recommend it. It's been a pleasure working with it so far.
Jul 13, 2008
Contrasting Programmers
Peering through my RSS feed today, I read an article by Jeff Atwood titled "Monkeypatching for Humans", where Jeff talks about monkeypatching in languages. While I agree with some of his points (namely that people will come up with nasty stuff), he does seem to think that monkeypatching is some demon from hell sent to destroy all of our coding projects. His quotations talk about Ruby monkeypatching, but his descriptions talk about PHP (a language I don't consider capable of monkeypatching, especially when you compare it to Ruby), so there is a bit of inconsistency that indicates Jeff doesn't really know much about either language.
Then I get down to the R's, and read Reg Braithwaite's predicted1 response to Jeff's post: My analyst warned me, but metaprogramming was so beautiful I got another analyst. Here, Reg states that things like monkey-patching and programmers being allowed to tweak their tools results in many failures, but in some successes. Basically the successes brought to us from the freedom are well worth the failures.
I've written on this dichotomy before. In Reg's post, he draws a parallel between this and the Renaissance-age church vs. science debate. Another example from more recent history is the comparison between Soviet authoritarianism and Western capitalism. Jeff takes a more conservative, communist style approach that allowing people to do what they want is bad, and that we should be given orders (or guidance, depending on how you look at it) from up high (aka language designers, super smart computer scientists). Reg takes the other side and says that given the freedom, people will write horrible things - but people will also write beautiful and useful things.
The idea that change is bad, leaders should be the one's taking charge, etc. is an excellent short-term solution. The people who know what they're doing can take charge and lead the rest of us to a good end, provided we just shut up and follow. If you look at history, Stalin accomplished wonders using this approach with the two 5-year plans from 1928 to 1937. He took charge and turned the USSR from a backwards farming nation to a world superpower in 10 years.
Of course, none of us remember Stalin for that.
We must remember that although the people up high are smart, they are still human. They are subject to the problems that come along with being human, like being prone to errors.
The free market outlasted the Soviet's block. Why? I am no historian, but my guess would be that giving people the freedom to pursue what they want, without telling them how to do it allows for a society that is much more adaptable to the change.
The same parallel can be drawn back to programming. Lisp and COBOL came out at roughly the same time. Where is COBOL now? As legacy software on machines for companies too stubborn to get it re-written with something more modern (I'll say with good reason, since they'd probably just use Java or C# or something that will be obsolete in 20 years). Nobody learns COBOL nowadays, unless they have to. Where is Lisp? Being taught to first-year undergrads at one of the most well-respected technical institutes in the world. It seems that the more flexible language has outlasted the not-so-flexible one.
We can lock programmers in boxes all we want, but they will constantly find ways to work around it. They come up with improvements, or replacements, and that is how things evolve. You think we would be doing object-oriented programming if we just kept listening to the up-highs? You think we'd even be using higher-level languages? One thing I like about Ruby is it gives you the opportunity to explore new things, to experiment with new ideas.
Sure. People will come up with bad ideas. Even really smart people. Remember that last time you went out drinking and thought it would be a good idea to keep drinking more? Probably didn't seem like such a good idea the next day.
The bad ideas will usually get ignored, and fade into time. By telling programmers that they probably won't be able to come up with good ideas and shouldn't bother trying, then you are dooming them to a life of programming mediocrity. But if they try something new and fail, and you just "tousle their hair and encourage them to keep trying", then who knows? They may come up with something neat.
The good things however, produced by the nobodies of the computer world (who ever heard of David Heinemeier Hansson or Bram Cohen before they put out their good ideas), that help better the rest of us. There are lot's of things out there that are produced by famous people, however I think that with the vast majority of cases, the good idea is what brings them out of the masses (ie. all of us) to stardom. What's keeping the rest of us from doing the same?
1As I was reading Jeff's post I was wondering what Reg would think of this if he read it.
Then I get down to the R's, and read Reg Braithwaite's predicted1 response to Jeff's post: My analyst warned me, but metaprogramming was so beautiful I got another analyst. Here, Reg states that things like monkey-patching and programmers being allowed to tweak their tools results in many failures, but in some successes. Basically the successes brought to us from the freedom are well worth the failures.
I've written on this dichotomy before. In Reg's post, he draws a parallel between this and the Renaissance-age church vs. science debate. Another example from more recent history is the comparison between Soviet authoritarianism and Western capitalism. Jeff takes a more conservative, communist style approach that allowing people to do what they want is bad, and that we should be given orders (or guidance, depending on how you look at it) from up high (aka language designers, super smart computer scientists). Reg takes the other side and says that given the freedom, people will write horrible things - but people will also write beautiful and useful things.
The idea that change is bad, leaders should be the one's taking charge, etc. is an excellent short-term solution. The people who know what they're doing can take charge and lead the rest of us to a good end, provided we just shut up and follow. If you look at history, Stalin accomplished wonders using this approach with the two 5-year plans from 1928 to 1937. He took charge and turned the USSR from a backwards farming nation to a world superpower in 10 years.
Of course, none of us remember Stalin for that.
We must remember that although the people up high are smart, they are still human. They are subject to the problems that come along with being human, like being prone to errors.
The free market outlasted the Soviet's block. Why? I am no historian, but my guess would be that giving people the freedom to pursue what they want, without telling them how to do it allows for a society that is much more adaptable to the change.
The same parallel can be drawn back to programming. Lisp and COBOL came out at roughly the same time. Where is COBOL now? As legacy software on machines for companies too stubborn to get it re-written with something more modern (I'll say with good reason, since they'd probably just use Java or C# or something that will be obsolete in 20 years). Nobody learns COBOL nowadays, unless they have to. Where is Lisp? Being taught to first-year undergrads at one of the most well-respected technical institutes in the world. It seems that the more flexible language has outlasted the not-so-flexible one.
We can lock programmers in boxes all we want, but they will constantly find ways to work around it. They come up with improvements, or replacements, and that is how things evolve. You think we would be doing object-oriented programming if we just kept listening to the up-highs? You think we'd even be using higher-level languages? One thing I like about Ruby is it gives you the opportunity to explore new things, to experiment with new ideas.
Sure. People will come up with bad ideas. Even really smart people. Remember that last time you went out drinking and thought it would be a good idea to keep drinking more? Probably didn't seem like such a good idea the next day.
The bad ideas will usually get ignored, and fade into time. By telling programmers that they probably won't be able to come up with good ideas and shouldn't bother trying, then you are dooming them to a life of programming mediocrity. But if they try something new and fail, and you just "tousle their hair and encourage them to keep trying", then who knows? They may come up with something neat.
The good things however, produced by the nobodies of the computer world (who ever heard of David Heinemeier Hansson or Bram Cohen before they put out their good ideas), that help better the rest of us. There are lot's of things out there that are produced by famous people, however I think that with the vast majority of cases, the good idea is what brings them out of the masses (ie. all of us) to stardom. What's keeping the rest of us from doing the same?
1As I was reading Jeff's post I was wondering what Reg would think of this if he read it.
Jul 9, 2008
Using SVN Effectively
After working a bit on websites where we use SVN as a version control system, I've been thinking that it is actually rather difficult to use it effectively, especially when you're programming in Windows.
Take this example. You have a group of programmers, a web server, and an SVN repository (which may or may not be on the web server). The programmers program away, doing their thing, occasionally updating and committing their changes as they go along. They upload their changes on occasion to see if what they want to do works.
There is a major problem with this approach. Suppose one person uploads a change, sees it doesn't work exactly as planned, makes a tweak to another file, uploads that one and sees things now work. But before committing, somebody else working on one of those files modifies it and uploads it. Now the main site might not work, mainly because people are overwriting each other's changes. This is incredibly annoying! I'm speaking from experience here. On a small team it isn't so bad because people probably aren't working on the same files, but as your team gets bigger it becomes more and more likely that something like this will occur.
This is the wrong way to code. It leads to bugs everywhere that will continue to re-appear. Sometimes, if the programmer hasn't realized that somebody has overwritten their changes and begins wondering why their code doesn't work anymore, they spend time trying to track down the bug. This is a waste of programmer effort that could easily be avoided. Here's how:
Everyone needs their own development space. With their own database information, memcached, etc. Completely independent from one another. This is way easier to do with Linux, because you can just install Apache/MySQL/etc. on your local machine and do everything you want there. With Windows you can do this, but it is a fair bit clunkier I find. Under Ubuntu you just go "sudo apt-get install apache2 mysql-server ..." and you're set.
First, you update and commit. That way, you have the most up-to-date version of the repository. Then make your changes. Make sure they work. Then update, resolve any conflicts that may appear. Make sure your code still works. Then commit. Then put it on the server somehow, either by using the SVN repository on the server and doing an update, or something. Don't upload your changes to the server while you are working on them!
Even better would be to do this with unit tests, that way before you commit you can run the unit tests to see if your code still works.
If you want to save your changes to the repository, but don't want to merge it with the main version, you can always branch. That's what branching is for.
I do find some things with SVN to be annoying. Branching is a bit annoying to do. Having to set up repositories is annoying, especially if you don't have write-access to the SVN server. You need to request a server admin create you a repository and set it all up.
I've been looking into using git for my projects instead of SVN. It seems to be much easier to use, and lots of geeks are getting excited about it. This usually means that it is awesome, and I should be checking it out to see if it is indeed awesome.
Take this example. You have a group of programmers, a web server, and an SVN repository (which may or may not be on the web server). The programmers program away, doing their thing, occasionally updating and committing their changes as they go along. They upload their changes on occasion to see if what they want to do works.
There is a major problem with this approach. Suppose one person uploads a change, sees it doesn't work exactly as planned, makes a tweak to another file, uploads that one and sees things now work. But before committing, somebody else working on one of those files modifies it and uploads it. Now the main site might not work, mainly because people are overwriting each other's changes. This is incredibly annoying! I'm speaking from experience here. On a small team it isn't so bad because people probably aren't working on the same files, but as your team gets bigger it becomes more and more likely that something like this will occur.
This is the wrong way to code. It leads to bugs everywhere that will continue to re-appear. Sometimes, if the programmer hasn't realized that somebody has overwritten their changes and begins wondering why their code doesn't work anymore, they spend time trying to track down the bug. This is a waste of programmer effort that could easily be avoided. Here's how:
Everyone needs their own development space. With their own database information, memcached, etc. Completely independent from one another. This is way easier to do with Linux, because you can just install Apache/MySQL/etc. on your local machine and do everything you want there. With Windows you can do this, but it is a fair bit clunkier I find. Under Ubuntu you just go "sudo apt-get install apache2 mysql-server ..." and you're set.
First, you update and commit. That way, you have the most up-to-date version of the repository. Then make your changes. Make sure they work. Then update, resolve any conflicts that may appear. Make sure your code still works. Then commit. Then put it on the server somehow, either by using the SVN repository on the server and doing an update, or something. Don't upload your changes to the server while you are working on them!
Even better would be to do this with unit tests, that way before you commit you can run the unit tests to see if your code still works.
If you want to save your changes to the repository, but don't want to merge it with the main version, you can always branch. That's what branching is for.
I do find some things with SVN to be annoying. Branching is a bit annoying to do. Having to set up repositories is annoying, especially if you don't have write-access to the SVN server. You need to request a server admin create you a repository and set it all up.
I've been looking into using git for my projects instead of SVN. It seems to be much easier to use, and lots of geeks are getting excited about it. This usually means that it is awesome, and I should be checking it out to see if it is indeed awesome.
Jul 6, 2008
Google's App Engine
I don't know how long this has been around, but I've recently discovered Google's App Engine, which is a free hosted web application system. It's funny, because just the other day I was thinking of creating a small web app for playing a simple game and was wondering, "Where would I host this?" I could use freegamage.com, but since that project has mostly been a failure I doubt I will be renewing the domain.
This is pretty neat. You get 500MB of storage for your app, not sure if this includes databases but most likely. If all you're doing is a basic app with a few images here and there, this is easily enough. You also get enough bandwidth to handle approximately 5 million hits per month. That's more than I'd need for any site I'd make on my own time, and if I was getting 5 million hits per month I'd probably be able to make enough through advertising to host my own site somewhere else.
To use it, you just download a copy of the Google App Engine SDK and extract it. Voila, you have a rudimentary web app! It comes with a basic web server and database, so you don't even need to install anything - except Python, but if you're on Ubuntu it comes with Python anyway. On other platforms it's fairly simple to install Python, just download and run the installer. There are a bunch of scripts too that handle updating the framework to a newer version, uploading your app, etc. And all you need is your Google account.
You get access to Google's webapp framework. This is a simple Python framework that gives you basically everything you need to create a web application, including templating and database support. They say they will be releasing a version for other languages soon, but Python is a good language and I'm more than happy to be using it (this also gives me an excuse to learn Python).
After exposure to Smarty, I decided that I hated templating engines (I don't really consider eRuby a templating engine). However, after making a framework of my own, I thought that maybe a templating engine isn't such a bad thing - especially where efficiency comes in. The webapp framework uses a simple templating engine (same one as Django) that ties in rather well with what you're doing. So no complaints here.
An excellent addition to this is that it ties into Google's user network. If you are making an application that requires authentication, you just use the user's Google account. Since most people have one of these already (and those that don't should have one, Gmail alone is worth it) you don't need to keep track of users and all that. You don't need to write the "forgot password" section, since Google has taken care of that already.
One interesting thing is that they don't use SQL for their database. It's not even a relational database. In fact, they don't even call it a database, it is called a datastore. I'm not really certain how it works internally, but it says it uses "Google's scalable infrastructure", which is good enough for me! The framework provides a little query engine for the database that uses GQL, an SQL-like language. It seems to be a bit more object-oriented than SQL, as instead of rows, the queries return objects. Again, I'm not sure how this all works internally, but I don't really care at this point.
On Python: It's neat. I've used Python here and there in the past, learned the syntax and all that, but this is a bit more in-depth and I'm learning some of the differences between Python and Ruby. Of course, the more annoying aspects are the ones you notice: having to put self in the parameter list for every method, and I always forget to put a colon at the end of block things like if/else.
What do I like? It's hard to find things that I like about it, I haven't really done enough to go "oh, that's neat!" I do like tuples, something that I missed when going from C++ to Ruby (C++ doesn't have tuples, but I liked using std::pair). Python makes this kind of thing fairly elegant compared to C++.
I don't really have any comments on the indentation style of Python. It would probably be annoying if I didn't already indent like Python wants you to. The only difference is not putting the end keyword or closing curly brace, which does tend to make code cleaner and eliminates the annoying syntax errors of "expecting kEND, found $end" or "unexpected end-of-file".
Syntaxes aside, in the Ruby vs. Python debate I would probably say neither is better, they just adopt different philosophies (Python's one-way-to-do-it vs. Ruby's you-can-do-whatever-you-want). And unless you're an advocate of one of these, I suspect that the language you like better is the one you pick up first.
So yeah, I would recommend you check this one out if you're a web developer. It will probably make your life easier, at least if you have a cool idea that you want to try out.
This is pretty neat. You get 500MB of storage for your app, not sure if this includes databases but most likely. If all you're doing is a basic app with a few images here and there, this is easily enough. You also get enough bandwidth to handle approximately 5 million hits per month. That's more than I'd need for any site I'd make on my own time, and if I was getting 5 million hits per month I'd probably be able to make enough through advertising to host my own site somewhere else.
To use it, you just download a copy of the Google App Engine SDK and extract it. Voila, you have a rudimentary web app! It comes with a basic web server and database, so you don't even need to install anything - except Python, but if you're on Ubuntu it comes with Python anyway. On other platforms it's fairly simple to install Python, just download and run the installer. There are a bunch of scripts too that handle updating the framework to a newer version, uploading your app, etc. And all you need is your Google account.
You get access to Google's webapp framework. This is a simple Python framework that gives you basically everything you need to create a web application, including templating and database support. They say they will be releasing a version for other languages soon, but Python is a good language and I'm more than happy to be using it (this also gives me an excuse to learn Python).
After exposure to Smarty, I decided that I hated templating engines (I don't really consider eRuby a templating engine). However, after making a framework of my own, I thought that maybe a templating engine isn't such a bad thing - especially where efficiency comes in. The webapp framework uses a simple templating engine (same one as Django) that ties in rather well with what you're doing. So no complaints here.
An excellent addition to this is that it ties into Google's user network. If you are making an application that requires authentication, you just use the user's Google account. Since most people have one of these already (and those that don't should have one, Gmail alone is worth it) you don't need to keep track of users and all that. You don't need to write the "forgot password" section, since Google has taken care of that already.
One interesting thing is that they don't use SQL for their database. It's not even a relational database. In fact, they don't even call it a database, it is called a datastore. I'm not really certain how it works internally, but it says it uses "Google's scalable infrastructure", which is good enough for me! The framework provides a little query engine for the database that uses GQL, an SQL-like language. It seems to be a bit more object-oriented than SQL, as instead of rows, the queries return objects. Again, I'm not sure how this all works internally, but I don't really care at this point.
On Python: It's neat. I've used Python here and there in the past, learned the syntax and all that, but this is a bit more in-depth and I'm learning some of the differences between Python and Ruby. Of course, the more annoying aspects are the ones you notice: having to put self in the parameter list for every method, and I always forget to put a colon at the end of block things like if/else.
What do I like? It's hard to find things that I like about it, I haven't really done enough to go "oh, that's neat!" I do like tuples, something that I missed when going from C++ to Ruby (C++ doesn't have tuples, but I liked using std::pair). Python makes this kind of thing fairly elegant compared to C++.
I don't really have any comments on the indentation style of Python. It would probably be annoying if I didn't already indent like Python wants you to. The only difference is not putting the end keyword or closing curly brace, which does tend to make code cleaner and eliminates the annoying syntax errors of "expecting kEND, found $end" or "unexpected end-of-file".
Syntaxes aside, in the Ruby vs. Python debate I would probably say neither is better, they just adopt different philosophies (Python's one-way-to-do-it vs. Ruby's you-can-do-whatever-you-want). And unless you're an advocate of one of these, I suspect that the language you like better is the one you pick up first.
So yeah, I would recommend you check this one out if you're a web developer. It will probably make your life easier, at least if you have a cool idea that you want to try out.
Jul 4, 2008
Some Good Reads
Some good books that I have read recently that I recommend (for programmers):
- Effective C++, 3rd Edition by Scott Meyers. Don't stop reading now if you're not a C++ programmer. The value of the book is highest for C++ programmers, but there are many things in here that apply to other languages, like Java and Ruby. It is tips on how to effectively use the many language features to avoid writing buggy code, to write more maintainable code, good uses of the standard libraries, etc.
Reading this book really helps you appreciate the language and libraries and how well engineered they are. Either that, or it makes you appreciate <insert your favourite language here> because you don't have to deal with all the low-level details that C++ deals with.
The value is obvious to C++ programmers, but what about people using other languages? The book gives tips on how to avoid memory leaks. Other languages have memory leaks too, but in a different way. Suppose your code is very complex, with nested loops, etc. You may forget to remove references to variables that are no longer needed. Oops! Out of memory. Then make some explicit unset() calls here and there and the memory problems go away. I've seen this happen in PHP a lot. I thought it was a garbage collected language! I can imagine this would also be the case in Java or Ruby.
There is a lot of info on OO design and programmer etiquette when using references, constants, etc. This stuff applies to other languages as well.
So even if you don't program in C++, I would say check this one out. I have a copy if anybody wants to borrow it. If you're a C++ programmer though, I would recommend you buy this guy so you can refer back to it when you need to. - Structure and Interpretation of Computer Programs by Harold Abelson and Gerald Jay Sussman. This is an introductory programming textbook at MIT and is available for free at the link I provided. Now you may be thinking, "I already know how to program!" This may be the case, but an intro course at MIT is probably much different than an intro course at most other universities. For example, the language taught is Scheme, not Java (most schools that I know of teach Java as a first language). Why? My interpretation of their reasoning is this: all programs in any language are effectively two things lower down: data and processes that manipulate that data. Scheme (along with most functional languages, but Scheme does it more obviously) blurs the distinction between the two and lets you see the program for what it really is. After all, Scheme code is essentially written as a parse tree, which is what pretty much all programming languages are expressed as internally.
So why do I recommend this book? It's free. It was written assuming no programming knowledge, and written to teach. It contains exercises (good exercises) to get you going. Scheme is also free, as is Dr. Scheme, an excellent editor for the language. Finally, knowing how to program in a functional language will make you a better programmer in non-functional languages. I saw this in myself when the functional programming light-bulb went on in my head. I can imagine you could see it in yourself too. - Any book on design patterns. The above book lets you see the essence of your programs, but this one teaches you how to design your programs in nice, manageable ways.
Jul 3, 2008
Linux at Work
About a month ago I wrote a post about using Linux in the workplace (it was Ubuntu, of course). I set up Ubuntu on a virtual machine and used it for coding instead of Windows. I still had to use some programs in Windows because I use two monitors and I could only figure out how to use one of them with the virtual machine. No problems really, although it sucked when I wanted to move a window from one monitor to the other.
However, I've now been moved to another department. Although they still develop for a LAMP stack, their code is much more complicated than the one I was using and I can't run it in a virtual machine without the system running out of memory (even with 128MB of RAM allocated to PHP alone).
My first idea was to use Samba to mount my network drive under Linux and continue development from there. Unfortunately, this didn't work and I'm not sure why. I remember doing it a while back when I first set up the virtual machine, but it's possible that some configuration settings changed, maybe the versions of Samba, who knows.
So now I'm back to developing LAMP applications under Windows. job_satisfaction--. And I'm surprised at the change. I feel...inefficient. Even missing things like symlinks means that I have to do more work. I don't have direct access to anything, so I can't play with settings in memcached or Apache to figure out what needs to be done.
I'm actually somewhat surprised that I feel this way. Originally I felt that it wouldn't be much different, or that I'd even be worse off giving up some of the bells and whistles that come with the Windows versions of things (TortoiseSVN has no equal in Linux, at least none that I've found). Ultimately though, I find the freedom in using Linux is so much better. Developing for a LAMP stack in Windows I feel like there is a ball and chain around my leg.
However, I've now been moved to another department. Although they still develop for a LAMP stack, their code is much more complicated than the one I was using and I can't run it in a virtual machine without the system running out of memory (even with 128MB of RAM allocated to PHP alone).
My first idea was to use Samba to mount my network drive under Linux and continue development from there. Unfortunately, this didn't work and I'm not sure why. I remember doing it a while back when I first set up the virtual machine, but it's possible that some configuration settings changed, maybe the versions of Samba, who knows.
So now I'm back to developing LAMP applications under Windows. job_satisfaction--. And I'm surprised at the change. I feel...inefficient. Even missing things like symlinks means that I have to do more work. I don't have direct access to anything, so I can't play with settings in memcached or Apache to figure out what needs to be done.
I'm actually somewhat surprised that I feel this way. Originally I felt that it wouldn't be much different, or that I'd even be worse off giving up some of the bells and whistles that come with the Windows versions of things (TortoiseSVN has no equal in Linux, at least none that I've found). Ultimately though, I find the freedom in using Linux is so much better. Developing for a LAMP stack in Windows I feel like there is a ball and chain around my leg.
Subscribe to:
Posts (Atom)