Typos Killing Your Code?
One of the most frustrating things that programmers have to deal with is typos. If you forget something regarding syntax or accidentally misspell a variable name, your program can start doing weird and wonderful things or spitting out errors that are less than helpful.
A friend of mine Jonathan Snook recently wrote about this on his blog.
Here’s the code that wasn’t working for him:
Can you see the issue with it? It took me a while to figure it out, and I tried not to read ahead, and once I realized what the issue was, I couldn’t stop seeing it. Unfortunately, if this was part of a many thousand line file, you might never be able to find the error in forrest of code.
if this was part of a many thousand line file, you might never be able to find the error in forrest of code
If you’re more observant than I you’ll notice that the second A is missing in javascript. Without a proper MIME type, browsers don’t process the script leaving you with…nothing. Imagine my amazement when none of my functions worked, with no error messages, no nothing.
I have often forgot to throw in closing quotations in items, or a semi-colon in my PHP that has lead to errors on the screen that were less than helpful. This is always the issue when creating vast amounts of code. Your attention to detail has to be at one hundred percent, or you will find yourself pulling out your hair.
Of course you can build in error reporting that can help with this issue, and there are extensions for Firefox that might help in debugging, but I definitely recommend that developers use an application that does syntax highlighting for their code, as it will sometimes make errors apparent by a line being the “wrong” colour. I currently use Crimson Editor on my Windows box, and Smultron on my Mac. Both applications are free, lightweight and powerful.
Better still though, according to Jonathan and others, are applications that help with completing your code.
The two most popular suggestions seem to be E - TextEditor for Windows and TextMate for Mac. Neither are free applications, but both seem to be considered valuable by a myriad of people.
What are your favourite light-weight, advanced text editor applications, and please, no Dreamweaver.









Want an avatar? Get a gravatar! • You can link to this comment
I have started using Coda since I switched to a Mac. I also think that Dreamweaver had gotten a bad rap. If you are using it in design view, I would absolutely not recommend it. But if you are using it in code view, it is very powerful and useful. The code completion hints, advanced search and replace options, and automatic tag closing are just some of the powerful features.
Want an avatar? Get a gravatar! • You can link to this comment
The two applications I use are TextMate and Dreamweaver for heavy coding (the code hinting is awesome in Dreamweaver - especially when you’re hammering out CSS). I second Trevor’s notion that Dreamweaver gets a bad rap. Dreamweaver is in no way a light-weight text editor though. I don’t work with javascript that often, but the validate syntax, and being able to run the code from within TextMate has been a life saver. I tried a couple of freebies and then made the move to TextMate when I started learning Ruby. I have it plugged into Fetch so I can make quick edits while leaving the file on the server. It also plugs into Transmit in the same manner. If developing on a Mac, it is turning into an essential piece of software.
Want an avatar? Get a gravatar! • You can link to this comment
i remember an instance where i misspelled ‘div’ as ‘dic’ and felt really dumb when i caught it 30 minutes later.
Want an avatar? Get a gravatar! • You can link to this comment
Work paid for BBEdit and I’ve been happily using it for years. It’s expensive though. I think if I had to pay I’d end up with TextMate. From my experiences with the demo, it’s great.
The only gripe I have so far about TextMate is that it’s a little wonky displaying type. BBEdit’s Monoco 9 is crystal clear, but TextMate’s 9 seems too tiny and not very clean even with anti-aliasing off. Not sure why. The TextMate default is 12pt and seems unnecessarily huge to me.
I can’t benefit from Coda in our LAMP environment with Subversion. Both BBEdit & TextMate have built in Subversion support but I think TextMate’s implementation is nicer.
Want an avatar? Get a gravatar! • You can link to this comment
This is very true when dealing with web languages and even more so when dealing with higher end languages (Java, C++, C#, Python & etc.). As frustrating as these things are its important to remember that it’s absolutely necessary that your code is spelled correctly. I remember starting out with php and beating myself up senseless with those pesky “T_ELSE” errors. Today it’s a rare occurance. Ironic thing is that I’m learning Java and the compiler catches absolutely everything. Hope one day I look back and laugh! The best solution to this problem in my opinion is to get into good habits from day one.
For mac I recommend a program called Coda from panic (it’s amazing how much streamlines your work flow) and for windows I recommend Komodo IDE.
Want an avatar? Get a gravatar! • You can link to this comment
I think Notepad++ is a great text editor, for windows, and it`s free..it`s a great tool and it has useful plugins, that can really boost up your process.
Want an avatar? Get a gravatar! • You can link to this comment
For windows only

I really like NotePad++. It has some great features (code folding beeing my favorite) and a bunch of plugins, I can say that is my editor of choice
Recently I tried the Aptana IDE for CSS + Javascript (Ajax) + XTML and it does a really awesome job! I most definitely recommend it, although it may be slower than the average editor…
It may be helpful to try also: PSPad and a href=”http://tswebeditor.tigris.org/” title=”tswebeditor”>tswebeditor.
Want an avatar? Get a gravatar! • You can link to this comment
What about characters you can’t even see ” ” (ALT+0160)
My text-editor of choice (Editplus) is setup to show a little faint marker for every tab/space so I can see them at a glance.
But when PHP was moaning about content being sent before headers were sent I couldn’t see anything that might be getting output, thats because the character was invisible - not invisible as in a space, but just not there at all >.<
(it is the equivalent of nbsp as far as I can tell as you can use multiple instances of them in your HTML and they don’t get reduced to a single instance)
Now that took some amount of debugging to find!
Want an avatar? Get a gravatar! • You can link to this comment
or maybe they do!?
Want an avatar? Get a gravatar! • You can link to this comment
I recently left a trailing comma in some javascript, the file was huge, and I had no idea where my problem was, I used komodo edit to check the syntax, and it found the error straight away.
Its free as well.