Home » Programming » Archive by category "General" (Page 2)

How a programming language influences your mood

For over 3,5 years now I’ve been programming professionally in PHP. First in PHP4 and about half a year later we finally converted to PHP5. At first I was excited because I could use a lot of new features PHP5 offered such as proper OOP but also Zend Framework.

I started using Zend Framework from 1.5 (currently it’s at 1.10) and have very mixed feelings about it. Yes, it does have a lot of useful libraries such as MVC, basic ACL, Authorization, Input Validation & Filters, Views (with PHP as the templating language, which it essentially was designed for) and more. But ZF had a steep learning curve for me so far has been successfully used in about 5 big webapplications.

However, PHP’s inconsistent function naming, unpredictable order of expected arguments (needle and haystack anyone?), lack of closures/anonymous functions, namespacing, lexical scope and what not makes using PHP a true nightmare. Yes, PHP 5.3 finally supports closures and namespacing, but have you looked at the syntax for both? What a joke. On top of that, PEAR is even a bigger joke. Is someone using it at all?

Running into these issues day by day and knowing it can be easily solved in Perl is very, very depressing. It has totally taken away my desire to program, influencing my desire to program at all and has made my motivation disappear. I’ve truly been wondering if a programming job is really something I want.

The turnaround came when I had a talk with my boss about why we’d still use PHP for future projects. Yes, code reuse is one them but compared to Perl all the additional code I’ve written in PHP that is being reused already exists in Perl at CPAN. To my understanding the use of backslashes to define a namespace in PHP wasn’t really a design choice, but was forced upon because it was too hard to use the double colon or a dot, like many other languages do. On top of that, last time I checked, PHP6 development has been halted because they just can’t get Unicode to work.

Perl already supports Unicode, Perl doesn’t have a weird separation character for namespaces, Perl supports closures/anonymous subroutines, Perl supports lexical scoping, the core list of functions is small, easy to remember and the order of expected parameters is consistent. And it has CPAN.

I was able to convince my boss to start using Perl for future projects because of these given points for both Perl and PHP. What helped though was that he knew of Perl and we’ve also developed some applications in Perl already. One of them a Wx application, a newsletter mailer and some other small scripts. Difference now is that I can use it for webapplications as well.

Now that I’ve gotten the green light to go with Perl for future projects I’m much happier again at work. I’m more motivated to finish the current PHP projects so I can finally start doing some proper Perl work. Programming Perl makes me happy. Moving from PHP to Perl doesn’t mean we’ll be fully dropping PHP. That would be bad and ignorant. Existing stuff will still be supported, improved and extended with new features.

No matter how much you dislike one of the products you support, it’s part of the job. Having stuff you dislike is good actually, because it makes the fun stuff even more fun. For me, PHP makes Perl more fun :-).

Configure Git on Windows to use KDiff3

Something I don’t do often and always forget is how to setup msysgit to use KDiff3 as its merge tool.

To get it done edit your .gitconfig and add the following:

  1. [merge]
  2.     tool = kdiff3
  3. [mergetool "kdiff3"]
  4.     path = C:/Program Files/KDiff3/kdiff3.exe
  5.     keepBackup = false
  6.     trustExitCode = false
  7.  

Hello World!

Just testing if my syntax highlighter works!

  1. #!/usr/bin/env perl
  2. "Hello World!\n";

This seems to be working and after some changes to my themes’ stylesheet it looks a bit better.

How Git made my day with cloning, branching and submodules

So today at work I started working on a website that’s basically a clone of another one. The website to clone has a rather old code base but a fully working control panel with order processing, payment reminders, CRM and more. As the code base for the website itself was way too old I decided that that part should be newly written. Nothing fancy, just loading a few things from a database and displaying it.

The control panel on the other hand has to stay updated for both websites. Feature wise they should stay similar and bugs found in one of the control panels should be fixed in the other. So why not generalize the control panel and make them identically the same? Well, thinking ahead, the target group of both websites is different so there are always going to be a couple of specific features not needed for the other target group.

Before I’ll tell what I did to make this possible I’ll explain the current setup of the first site (the original website being “cloned”).

The original Git repository contained a directory called admin. I cloned the repository to strip out everything besides the admin directory with git filter-branch. I then added this new repository as a submodule.

The new website is, of course, also a Git repository. Since I need the control panel for this website as well I could add a submodule that points to the original Git repository. But that would severely hinder the process of modifying it for the new website. So instead I cloned the control panel repository. In this clone I maintain a branch for the new website. The new website has a submodule that points to this branch.

The benefits that’s giving me this is that I can make all the modifications I want, commit them to the branch created for this. Any updates that should be applied to the other site as well can be cherry picked to the master branch. When done I let the main repository (the one I filtered out of the original website) pull the changes back.

All in all this might sound a bit complicated, but it isn’t really. Thanks to Git I can keep both control panels up to date and safe without too much worries. Thank you Git!

Game Coding Complete, 3rd edition

Game Coding Complete, 3rd editionLast Thursday I’ve made my first purchase over at Amazon and was happily surprised it arrived today. That’s the fastest delivery time I’ve experienced from a webshop not located in my country! So kudos to that.

Game Coding Complete, 3rd edition was what got delivered at my house. I’ve only skimmed through some pages and so far I like what I see. It’s quite a big book with 908 pages so I’m afraid it’s going to take me a while to finish it.

I ordered the book because although I’ve got quite a bit of programming experience, I don’t have much experience in programming games. Sure, I did a couple of small games and prototypes but never gotten much further than that. Since the author, Mike McShaffry, is quite the veteran I thought, why not learn from one of the best?

The book has lots of examples and am eager to start reading it.