Table of Contents


A closer look...notice you don't have to say what type of variable you are declaring. In other languages you need to say if the variable is a string, array, what sort of number it is and so on. You might even have to declare what type of number it is. As an example, in Java you'd been saying things like int var=10 which defines the variable var as an integer, with the value 10.

So, why do these other programming languages force you to declare exactly what your variables are? Wouldn't it be easier if we could just not bother?

For short programs, yes. For really big projects with many programmers working on the same application, no. That's because forcing variable type declaration also forces a certain discipline and rigour which is what you need on big projects.

As you know, Perl is not designed for gigantic software engineering efforts. It is all about small, quick programs. For these purposes you don't need the rigour of variable controls as much, so Perl doesn't bother.

This idea of forcing a programmer to declare what sort of variable is being created is called typing. As Perl doesn't by default enforce any rules on typing, it is said to be a loosely typed language, as opposed to something like C++ which is strongly typed.