Matthew Daly's Blog

I'm a web developer in Norfolk. This is my blog...

8th June 2010 10:24 pm

First Steps With PHP

I’m currently working on my very first website for anyone other than myself. It’s a simple brochure-style website advertising a friend’s chalet at a seaside resort, which she wants to be able to rent out, and includes a simple contact form so that people can get in touch to ask questions or make a booking enquiry. Now, at present Python is the only programming language I know at all well that’s useful for server-side scripting, but I decided to have a bash at building it using PHP, since that’s pretty well supported and there’s loads of tutorials and resources for teaching PHP to newbies, as well as innumerable third-party scripts and libraries. Also, PHP’s such a popular language that you can’t really get away from it if you want to get into web development - I see loads of PHP jobs advertised but very few Python ones. So I figured it’ll be useful to have picked up a little PHP.

I got the form working, and I’ve added reCAPTCHA support to it to help prevent spam. All in all the form is working well, and it didn’t take a great deal of PHP knowledge to write the script. I’m already pretty confident that it’s a language I can work with in future, possibly even on a professional basis. That said, I can already tell that I will never like working with PHP as much as I like working with Python - the syntax is far less elegant than that of Python, and the object-orientation looks and feels much more clumsy to me.

There’s plenty of things I’d like to be able to do that require PHP, so I will be learning it thoroughly at some point, although I have no plans to do so immediately - I’m about to do my JavaScript Fundamentals exam later this month, and after that I’ve got to learn Perl, so it’s not till I get that done that I’ll be learning PHP properly. In particular, I’m really interested in Wordpress theme development - I want to build a theme of my own for this blog since that’ll say more about my abilities than an off-the-shelf theme, and it also happens to be an increasingly marketable skill.

15th May 2010 5:27 pm

Is Dreamweaver the Best Choice for Developing Your First Website?

If someone asks you to name an application for creating web pages, the chances are that one of the first things you’ll think of is Adobe Dreamweaver. While it may not have quite as much mindshare as its Creative Suite stablemate Photoshop, it’s still regarded as the premier application for creating web pages.

However, that status leads to many novice developers, or ordinary people who just want to set up one website, thinking that they need to use it, and that’s completely wrong. At work we have an intranet with a discussion forum, and someone with no experience of creating web pages was asking for advice on the best application to use to create a website, and of course someone suggested Dreamweaver, something I strongly disagree with.

So, if you’re wanting to build a basic website, and are thinking Dreamweaver might be the way forward, you might want to bear these points in mind:

  1. HTML was intended right from the start to be reasonably easy to use, so why not just write HTML? I learned the basics in a weekend, and there’s plenty of good resources around, so rather than shell out for a copy of Dreamweaver, just get a book about it and work through that. It’s a useful skill to know and it costs a lot less, and the resulting web page will be easy to maintain. Granted it may not be that impressive to start with, but there’s nothing stopping you refining it over time.

  2. You probably don’t need to mark up web pages yourself at all. There are many excellent content management systems that make it easy to build a website yourself without having to write any HTML or CSS at all. Wordpress is capable of static pages and blogs, is easy to theme, and can be extended with plugins. Drupal or Joomla are also possibilities, so the chances are it’s not necessary to hand-code the page at all.

  3. If you’re only after a basic site and you don’t have any interest in creating any other web pages, but you want something that looks professional, then forget Dreamweaver and hire a freelance web designer to create the page for you. For a small site they’ll probably cost less than buying a copy of Dreamweaver, they’ll be able to create a much more professional-looking result and they’ll be able to help you with other issues that arise.

  4. Is it the most cost-effective WYSIWYG editor for what you want? The world is full of WYSIWYG HTML editors, many of which are free, others of which are a lot cheaper than Dreamweaver. Okay, you could just use a trial version of Dreamweaver for free, but what about if you want to edit your site later on after your trial has expired? And yes, you probably could use a pirate copy, but is it really worth the bother when something else will probably do the trick? Some great alternative HTML editors include:

There are many more cheap or free HTML editors around, which make great alternatives to Dreamweaver for inexperienced users.

  1. Dreamweaver is a powerful tool, but it’s not a magic bullet - it won’t make you able to create a great website, any more than a copy of Microsoft Word will make you a great writer. Dreamweaver’s a professional application, with a price tag to match, and it takes experience to use it properly. In the hands of an experienced web professional, Dreamweaver can create a great website, but in unskilled hands the results are going to be less than satisfactory.

What do you think? Is Dreamweaver a good choice for making your first (or indeed only) website, or not?

10th May 2010 8:15 pm

Why You Should Try Vim

I’m a huge fan of the Vim text editor. I have the key bindings burned so deep into my head I keep reaching for the Escape key at work when I want to move around in a document in Microsoft Word, or hitting J to try and move down. In short, I’m incurably hooked on this wonderfully powerful text editor, and if you’re still using something like gedit, TextEdit, or (god forbid!) Notepad, then I want to get you to think hard about switching to Vim!

I first started using Vim nearly two years ago. At the time, I had a fair grasp of HTML, but hadn’t really gotten into programming as such. I had my Eee PC 2G Surf with me most of the time, but didn’t have regular access to the Internet, and didn’t have a full-sized laptop available for much of the time. The main text editor I’d used to date was Kate in KDE3.5.

One day I decided that, for lack of anything else to do, I was going to run through the Vim tutorial (accessed by entering vimtutor) in a terminal on my Eee PC. It was weird to start with, but I soon got used to the unusual-seeming key bindings. As a touch-typist, Vim worked really well for me since it meant I didn’t have to move my hands off the keyboard at all, and the arcane-sounding keys soon became second nature. When I started work on the Site Development Foundations part of my CIW Foundation course, naturally I used Vim, and it worked well for both HTML and CSS documents, and of course the more I used it the more proficient at it I became.

Then when I first started learning Python, Vim really came into its own. The syntax highlighting is a real help, it’s extremely fast to move around in and edit a document, and the autocompletion, while perhaps not quite as good as that in a language-specific IDE, was good enough for most purposes. I’ve since used Vim for coding in HTML, CSS, Python, JavaScript and C, as well as editing configuration files in various Unix-like operating systems, and it’s been an excellent editor for all of these. I’ve barely scratched the surface of what it can do, and I already couldn’t imagine using anything else.

So, why should you use Vim? Here are just a few of the reasons.

Vim is everywhere

If you’re running Mac OS X, a CLI-only version of Vim is included, and you can get a graphical version called MacVim as well if you need it. Most Linux distributions include either Vim or another vi clone by default, and if not it’s available from your distribution’s repositories. If you’re running another Unix flavour, again you almost certainly have Vim or another vi clone, and if not you can get one. And if you’re on Windows you can grab a copy too. If you use a text editor like Kate, gedit, or so on, then you can’t guarantee you can get it on other platforms. With Vim you can.

Also, the fact that Vim is a CLI application means that even if you have to edit something via SSH or Telnet, you still have access to a text editor you know well and can work just as well as you would with a GUI.

Vim is flexible

If you’re using Vim, you can rely on it to edit files in virtually any programming or markup language you like, making it easy to adapt. Learning Ruby? You can do it in Vim. Now you want to learn Java? Again, Vim will do the job. By allowing you to use a familiar environment for virtually any programming language you may want to learn, Vim means you’ll be productive quicker in a new language than you would be if you had to use a different text editor to the one you’ve used before.

Vim is fast

If you know how much faster touch-typing is than hunt-and-peck typing, then you’ll have some idea of why Vim is faster than regular typing. Because Vim uses the home row for navigation, and in general is designed so you move your fingers as little as possible, it’s faster than just about any other text editor you can name. The key bindings are deceptively simple to remember for the most part, as it’s your fingers that need to remember them, not you brain.

Vim doesn’t require the use of a mouse to navigate, nor does it require you to move your hand to the cursor keys. It also allows you to jump through a document as many times as you want - for instance, to go down 9 lines, you just enter 9j. And it’s easy to search for specific words and navigate to them.

Vim is easy to customise

By editing your .vimrc configuration file, you can easily modify how Vim works for your own needs. You can easily change settings to suit your working habits better, such as setting it to work with a mouse, add line numbers, change the colour scheme for syntax highlighting, change the key bindings etc. Vim can also be extend by use of scripts and plugins. Once you have it set up the way you want, it’s easy to move all your settings to another computer.

Vim always has a way to make things easier

One of the best things about Vim is that, because it’s a solid, mature product, someone’s usually thought of a way to do whatever you want to do, quickly and easily. For instance, recently I was writing a JavaScript function to rate passwords for security, and I decided to get a list of bad passwords off the Web. I soon found one, but it was in excess of three thousand entries long, and I had to edit it to put them all into an array as individual strings, enclosed by quotes and separated by commas, ideally each on a line by themselves. This would have been an incredibly tedious task if I had to do it manually, so I did a little digging and discovered how to create a macro in Vim. This made it trivial to perform this task with only a few keypresses.

Vim is tightly integrated with the command line

Vim makes it easy to run other shell commands without leaving, by entering :!, followed by the command you want to run from the shell. This means it’s easy to run or compile a program you’ve just written without leaving Vim, so you don’t lose your place. When you’re done, you’re sent straight back into Vim, exactly where you left off.

Vim behaves like a GUI application

Yes, Vim may normally be a command-line application, but it still manages to pack in many of the niceties of graphical applications. You can split the screen horizontally or vertically, or open new files in new tabs. It’s even possible to use it with a mouse in most cases.

These are just a few of the reasons why I love Vim, and if you haven’t already tried it, or if you’re still using a less-powerful text editor, then I urge you to give it a go. Yes, the learning curve can be a bit steep, but it’s well worth it in terms of boosting your productivity. It works well for hand-coding HTML and CSS, or for programming in almost any language you can think of. You can get started today - if you’re using Linux or Mac OS X, it’s almost certainly already there waiting for you, and on Windows it’s just a download away. Try launching the tutorial by entering vimtutor in the shell, and work through it, and you’ll find yourself getting used to it surprisingly quickly. Or why not try Cream, essentially a preconfigured version of Vim that has a shallower learning curve? If you use a text editor at all, you really should give Vim a try.

10th May 2010 12:52 am

New Hosting

I’ve now gone and switched to paid hosting, and have dumped the old static site in favour of a Wordpress-powered blog on my own domain. I’ve found Wordpress to be an extremely flexible and powerful solution, far superior to Blogger, and I’m really excited about the possibilities of a self-hosted blog, so I’m really looking forward to establishing myself here! At some point I intend to create a custom theme of my own, but for now this one will do fine!

As I mentioned previously, I’ve changed the emphasis of the blog towards web development. I’ve also now made a number of other improvements - comments are now powered by Disqus, to facilitate easier sharing of posts and making it easier for people to reply to me via blog posts of their own.

Enjoy!

Recent Posts

Full-text Search With Mariadb

Building a Letter Classifier in PHP With Tesseract OCR and PHP ML

Console Applications With the Symfony Console Component

Rendering Different Views for Mobile and Desktop Clients in Laravel

Making Wordpress Less Shit

About me

I'm a web and mobile app developer based in Norfolk. My skillset includes Python, PHP and Javascript, and I have extensive experience working with CodeIgniter, Laravel, Django, Phonegap and Angular.js.