Huh? Javascript? Xul? What are they?

by jasonyeo

As you are fixing bugs on mozilla projects, you would encounter these two languages, namely javascript and XUL. Many might not be familiar with them so here are some guides and resources to help you when you are fixing such bugs.

Javascript Resources

First up, javascript != java. Do not confuse them. They are entirely different languages. When I am fixing javascript bugs, the first place I will go is Mozilla Developer Network. Since you are working on the mozilla platform, it would definitely make sense to go to mozilla’s javascript standard. Other browser may implement it differently so I will generally discourage people to look for javascript guides/docs elsewhere. (Please do not go to W3Schools. See w3fools.) If you really wanna learn javascript from scratch, you might wanna check out codeacademy. You might also wanna look at Mozilla’s own re-introduction to javascript.

Printing Output in Javascript

There are some techniques we use when we debug code. Firstly, it is pure eyeballing. If you are gonna eyeball the code, do use MXR to do it. The syntax highlighting helps. Although I know there are some good developers who tend to only use their eyes to debug code, IMO this is a terrible way to debug code. Another technique we should use is the usage of print statements. In javascript, we do it by using alert()statements. It generates a pop-up with whatever you pass in as argument. Another way to do it is by dump() messages. This function outputs to the terminal. See MDN’s write up about it.

Enter Venkman. The javascript debugger

Venkman became my best friend when I am dealing with javascript code. It is kinda like the javascript’s gdb. You can see the values of variables, set breakpoints and step through code. It is extremely useful. It is basically an add-on for firefox and thunderbird. Download it here.

XUL Resources

Basically, XUL is XML. XUL files are where you define the layout of the program. Kinda like how HTML does it. Yes, both of them are really similar. Since XUL is a mozilla technology, I would recommend you to go to MDN for help. They have a XUL school and a XUL reference documentation.

A DOM Inspector Calls

You might have heard of firebug or the Chrome browser’s html inspector. The DOM inspector works the same way like them but it is used to inspect both html and XUL. If you are working on layout bugs, you can’t live with it.

Conclusion

When you are working on bugs in open source projects, always remember to RTFM (Read The Friendly Manual). Do get used to the MDN docs when you are working on these two languages. If you are still in doubt, don’t be afraid to ask! You may approach me (:jyeo), the tutors in CP3108 or any of the developers in irc.mozilla.org. Have fun squashing those bugs!

Advertisements