Coding For Fun

Sometimes when I’m coding for work, I feel like it’s lost all it’s fun. At work, we sometimes have to work on boring projects. For me the boring projects are the ones where I don’t even have to think about what I’m doing. The tools, the framework, the existing libraries are enough that I can get the job done without even really thinking about it. The kind of project where you can just go straight for 2 hours of programming, compile once, run it, and it just works, no fixes needed.

Now when you can do this, you at least you know you are doing something right. Because not everything you have to do should be some kind of epic battle to get stuff done. Trudging into new territory. But that doesn’t mean it doesn’t drown your spirits when the only thing you’re doing it just going through the movements to get the code into the computer.

I really enjoy going out and exploring new tools, new languages, new language features, new anything, because it really makes me think. It opens up your mind to new possibilities. A developer who doesn’t code for fun is usually not a very good developer. If you can’t take pleasure in exploring programming, learning new techniques, discovering unexplored territory, then you’re going to have a lot of trouble staying on top of all the new technologies.

If you find yourself getting bored with coding, just go out and try something completely new. Program a type of application that you have never programmed before, in some language that you aren’t that familiar with. Exploring new avenues in development will take your mind off the day to day drudgery that your job is, and really help to bring the fun back into programming.

Don’t Fight The Tools

I’m a .Net developer by profession. So it’s only natural that I hate PHP. OK, I don’t hate it, but I find it quite frustrating. I think that the reason that this is, is because they are just so different. They take a completely different approach to accomplishing the same thing. So when I go to program something in PHP, which I don’t do that often, I try to write .Net code in PHP. This is very difficult. In the latest project I did, namely, this blog, I tried to do the exact opposite. I decided to write my PHP to make it look like PHP. To me, it seems a little unnatural. Mixing in logic and presentation. Mixing in database access code with presentation. Basically creating no layers between anything. Get some data from a database, output the data with HTML tags interspersed with the data.

PHP has added a lot of stuff to try to get away from it’s humble beginnings. They’ve added objects, namespaces, frameworks for doing MVC or other types of architectures. But I find that all of it is kind of done poorly. Without getting into too much of a rant, it seems like PHP is just trying to add features, just to be like the big boys. But in the end, it makes everything look inconsistent, and gives people a bad impression. Nobody complains that C doesn’t have classes, interfaces, and namespaces. If you want that, go find another language. PHP could have taken a lesson from that, but alas it’s too far gone.

It’s really similar to this Ask Slashdot article. The first post sums it up. Don’t try to write C++ or Java in Javascript. Similarly here. Don’t try to write .Net in PHP. And I wish PHP would just be happy being PHP.

The coming celebration of non-general purpose computing

This is a little bit inspired by The War on General Purpose Computing by one of my favourite authors, Cory Doctorow. I greatly respect his work, and see some very important ideas in his article. But I just can’t stop thinking, about how most people don’t really want a general purpose computer. Most people have no intention of writing programs to run on their computer. Don’t get me wrong, I’m a developer. I couldn’t imagine having a world without computers that I could write and run my own code on. But most people aren’t developers. For people who don’t write their own programs, the fact that a computer will do whatever you tell it to, is, well, problematic.

Think about the whole problem with viruses and malware. In some cases, there are bugs in programs that allow things to run without the user intending to run them in the first place. Open network ports with buffer overflow vulnerabilities allow things to come in over the internet, and just run on unsuspecting computers. While some viruses, many of the more prevalent ones, have infected machines over the years in this manner, there’s still a lot of viruses that infect computers from people just clicking on the file to run it. You can display warnings before running anything that comes from the internet, you can lock down user accounts, and display even more warnings when an application requires administrator privileges, but users will still let it execute anyway, because they were promised smiley icons, or a crack for some game they couldn’t be bothered to pay for. And so the general purpose computer runs said program, even it it’s a program that will cause no end of problems for this general purpose computer.

I think this is the reason why the iPhone is such a big hit. You constantly hear developers and technology enthusiasts whine about how the Apple walled garden is evil, and causes so many problems, with apps that can’t get approved, or apps that were approved, and then mysteriously removed afterwards for seemingly nonsensical reasons. But many people love the walled garden. There are a few things at play here. First, applications are reviewed by Apple employees before being placed on the App store. So there’s a good chance that a malicious program wouldn’t make it past the approval process. Second, you have to pay money to get your app on the app store. So if someone were to write a virus and it go through the approval process, then Apple might have a not so hard time tracking you down. Thirdly, even if the app did get published, and assuming the developer used false credentials so they couldn’t be caught, the app could still be quickly removed from the store as soon as it was found to be malicious. Before it could cause too much damage People love their iPhones because they don’t have to worry about malware anymore.

The other kind of non-general purpose computer is the game console. People love these too. Not counting hardware problems like the infamous red ring of death, people generally don’t experience any problems with these machines. You never hear about people having to format their Xbox or run a virus scan on their Wii. Again these machines have no problem with viruses because they only programs they run are the ones that are vetted for by MS, Sony, Nintendo, or whoever else makes the console.

I don’t think most people care if they can run any program, including ones they write themselves. As long as they can find applications that do what they need them to do, it doesn’t matter that they can’ write their own applications, because they have no desire to do that. I think that the desktop PC is headed this way too. Regular people just can’t handle general purpose computers. I don’t mean that in a negative way. In the same way I could care less about how my furnace, fridge, or oven works on the inside, and I care even less to tinker with them to work outside their original specified uses, most people don’t care how their computer works, and don’t care to be able to reprogram them. To these people, computers are just another appliance.

Now, I guess the final point. Does all this mean the end of general purpose computers. Not on your life. That boat has already sailed. The genie is out of the bottle. Computers are simply too ubiquitous and too well understood to ever get to a point where it is not easy to get a general purpose computers. Take a look at the Raspberry Pi project and you might see what a mean. A very small group of people, producing only 10,000 computers is able to sell a true general purpose computer for only $35. Now, it’s not the most powerful computer, but it’s fully internet capable, can play high def video, and has enough power to play Quake 3. There’s enough computer enthusiasts out there that general purpose computers will never be unavailable. But I don’t doubt there will be a day when most houses do not own a general purpose computer, but instead run some appliance type computer that the user can’t program, but which meets all their needs. And then the users will be happy. And so will the geeks, because it means we won’t have to fix their computers anymore, because they got yet another virus on their machine, even though they swear the didn’t run anything they shouldn’t have, again.

Sending Email With Telnet

Here’s a very interesting piece of information. You can send an email message by typing commands directly to the mail server. The protocol used to send email all over the world is simple enough that a human can type it out on their keyboard. Using a program called Telnet, you can send an email the same way that your mail client such as Outlook or Thunderbird would do. The conversation looks something like this (I’m using -> to denote what the user types, and

-> HELO mail.example.com
<- 250 Welcome to the mail server
-> MAIL FROM:sender@example.com
<- 250 Continue 
-> RCPT TO:recipient@example.com
<- 250 Continue
-> DATA
<- Please enter message. enter a single period followed by a "." to complete sending
-> SUBJECT: This is my message subject
-> 
-> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-> Curabitur elit justo, pretium ut lacinia non, dapibus eu magna. 
-> Duis nunc quam, lacinia sit amet hendrerit ac, malesuada in magna.
-> Duis dapibus elit a nisi ultrices dictum semper sem scelerisque. 
-> Nulla arcu lacus, placerat eu vehicula et, malesuada nec magna. 
-> .
<- 250 Message accepted for delivery

 

That’s basically it. Every email message that gets sent anywhere can be sent like that. In fact, the only thing you can send over email is text. All those pictures, or other attachments that are sent over email actually have to be encoded to type-able text using MIME. And because of this, the attachment will take 1/3 more space than the original file when sent over email. That is, a 300 KB email attachment with actually require 400 KB to be sent over the internet.

I just find it amazing how long email this simple protocol has stood the test of time. Sure things have been tacked on, to allow for authentication with the server, as well as a few other things, but not much. Makes me think of one of my favourite software development rules. Do the simplest thing that could possibly work.