Static Checking

Reference URL: http://web.mit.edu/6.005/www/fa15/classes/01-static-checking/

Static Typing

  • Java is a statically-typed language. The types of all variables are known at compile time. The compiler can therefore deduce the types of all expressions.

  • Python and JavaScript are dynamically typed languages. Checking is differed until runtime.

  • Since bugs are the bane of programming, especially when involved with a large piece of code, a statically typed language helps by having the compiler prevent a large class of bugs from infecting your software - bugs caused by simple type incompatibilities and so forth.

Static Checking

Static checking allows the compiler to automatically find bugs even before the program runs. The kind of checks and errors that it can find are:

  • syntax errors, such as punctuation or incorrect words

  • wrong names to a function

  • a wrong number of arguments to functions

  • wrong argument types passed to functions

  • wrong return types.

Why Java

When creating enterprise applications, it is more common to use Java compared to Python or JavaScript because:

  • Safety: Java has static checking which contributes very much to writing code that has less bugs. It is certainly possible to write safe code in dynamic languages such as Python, however, it is easier to understand what you need to do if you learn how in a safe, statically-checked language such as Java.

  • Ubiquity: Java is widely used in research, education and the industry for a reason. It provides a rich set of libraries, functions and the tools necessary to deploy to containers and the cloud. These are all comprehensively testing to ensure that work with each other without clashes, unlike 3rd party libraries used in Python that have not necessarily been tested to ensure they work with each other.