Introduction for Non-Programmers
I have been using the Java computer language since 1996.
A computer language is a
way of specifying a recipe for calculations, e.g. to teach a computer
how to compute
Canadian sales tax.
Java has been a remarkably
successful language, the most successful of all time in terms of the
number of devices it runs on from cell
phones, to laptops, to desktops to giant mainframes. It is installed
in 400 million
Android devices alone. It is unusual in that once you write a Java
program it will run unmodified on any computer
with any browser and pretty well any operating system. Even programs
written for Java 1.0 will still run without
modifications or recompilation. It was invented by Sun Microsystems.
The Oracle database people then bought Sun
out. It is friendly to programmers in that usually won’t let you
make a mistake and when it does, it is
quite specific explaining what went wrong when the consequences of
your error manifests. Its main drawback is
verbosity, but
IDEs (Integrated Development Environments)
help compensate for that. You can use it and write programs in it
without spending a dime. Even the editing
tools and databases are mostly free. It is the ultimate free lunch,
nay, free banquet.
Introduction for Potential Java Programmers
There are two sorts of answers required to the question What
is Java?, one for
people unfamiliar with any computer language and one for those who
already speak some computer language.
- Java is a tool that lets you direct the computer to do
computations, keep track of things or draw graphs.
Many of the more complex animations and calculating tools you see on
the Internet are Java Applets running
inside your browser or are Java Servlets running on server machines.
The main advantages of Java over other
computer languages are:
- It was designed for the web.
- Java programs run unmodified on any computer (without even
recompiling — converting the
human-friendly *.java form of the program to the
machine-friendly *.class/*.jar form). With ordinary
computer languages, you need a separate version of each program
specially modified for each platform.
- Java programs have an elaborate safety net to prevent them
from doing any damage to themselves or
others. The other commonly used languages have no such safety
net.
Why learn Java? It might be sufficient to know that there are three
Java jobs waiting for every Java
programmer.
- Java is a computer language like a stripped down C++
that has been
designed so that its object modules can run unmodified on many
different platforms. Its primary characteristics
are safety and security. The language was originally named Oak, but
it turned out that name was already taken.
Over coffee, somebody suggested Java as a replacement. Since
programmers are the occupationally prone to
caffeine addiction, the name seemed auspicious. James Gosling is
considered the father of Java. More recently
Bill Joy and Arthur Van’t Hoff are seen also as the Java
illuminaries.
Oracle currently provides Java with the Solaris Operating
Environment, Microsoft Windows, Apple and Linux
platforms. Other vendors provide Java for other platforms.
Advantages of Coding A Project In Java
- WORA (Write Once, Run Anywhere).
You don’t even need to recompile or relink
for each platform. The same class files run everywhere.
- Java is supported on a huge number of platforms.
- There is an enormous standard class library and all kinds of three
third party class libraries.
- Java is free of freakish features. This comes from being
WORA.
- Java can run with Hotspot or Jet native compilation, generating
machine code better than that produced by
assembler programmers.
- Java class files are compact.
- Java lets you postpone many decisions until run time that in other
languages must be specified at compile
time.
- You can get all the tools you need to develop and deploy without
spending a dime.
- It won’s let you access an initialised variable. C++
programmers
weep with envy who have to put up with variables initialised to
random values.
- Garbage collection is automatic. You can’t have a memory
leak.
- You can’t use an method on an object that does not support
it, or on a null
reference.
- You can’t index an array with an out-of-bounds index.
- It is object-oriented. You can create classes that are a minor
variation on another without cloning code
that would soon get out of sync with the original.
Disadvantages of Coding A Project In Java
- It is controlled by Oracle/Sun. They have been well behaved up to
now, but there is no guarantee they
won’t decide to screw their customers in future.
- It is verbose.
- Did I mention it is very verbose.
- Operators work only on primitives. You must use clumsy words like compareTo for objects.
- Getters and setters require a verbose syntax. They could use the same readable syntax used for directly accessing member variables.
- The run time is quite slow to start, unless you use native
compilation.
- Generics are an embarrassing kludge. They are incompatible with arrays
and serialization.
- The language does not validate units of measure. It will let you
add a value measured in meters to one
measured in feet without complaint.
- There are very few shortcut alternatives to spelling out common
patterns longhand and very limited
facilities in the language to create you own shortcuts. For example,
it takes a whole paragraph of code to hook
up a button to the code that handles what happens when you press it, though lambdas have improved this instance.
- The Swing
GUI (Graphic User Interface)
forces you to work an a very low level, spelling out reams of detail
about every element on screen. Coding
and maintaining this takes
far far
longer than writing the supporting computational logic. There is
nothing equivalent to
CSS (Cascading Style Sheets)
style sheets for handling layouts.
- If you have a piece of code that computes two values, you cannot
encapsulate it into its own method because
a method can return only a single value, not a tuple.
- There is no keyword on a method or variable declaration that you
can search for with a text-editor search
or a primitive parser.
- Java often uses the word illegal when they mean invalid.
You’d think anyone who graduated from the second grade would know the difference.
- {} are used to enclose everything. If you ever get them
unbalanced, it is a nightmare to figure out what matches what.
There should at least be a special keyword to end a method or loop.
Learning More
Java is head and shoulders above other languages in security. There
was one
major hole discovered and
immediately fixed in 2012-06. That broke
Java’s record of 16 years without a
security hole.
Java’s detractors danced about claiming the Java itself
was too dangerous to use, even though its
record is far better than any other programming environment. Windows
itself had tens of thousands of holes
detected.
The breach was not even completely Java’s fault. The Java sandbox
hole exploited a hole in
browser security accessed via Java. It is no co-incidence his happened
during the transition from Sun to Oracle
control of Java.
SecureList put out an advisory, which is still available,
explaining that the problem has been fixed, but
using language that might, to the lay person, suggest Oracle did not
properly fix it or that users would have to
do something special to get the repaired version.
The Java security problem has been fixed, but a
new vulnerability has emerged call the 0-day exploit. It has
only been partially fixed. Until it is, it is wisest to turn off
Applets, unless using them on trusted sites or
on your local machine.
On the other hand, JavaScript has no security at all. It is in no way
related to Java. Using that Java-ish
name was a dishonest attempt to piggyback on Java’s good
reputation. ActiveX, JScript and ECMAScript have
similar problems.
Any application you install can do
anything it wants to any of your files, no matter
what language it is written in. With applications, the author of the
program, either through incompetence or
malice, is the risk, not the Java runtime. Java is no exception. The
concept of security applies to code you run
automatically merely by clicking something in the browser. Java has
three types of online program:
- unsigned Applet Very safe. Cannot look
or write you your disk files. It cannot find
out even the most basic facts about you. See wassup
to
discover the safe properties are that it
can determine. Programmers refer to this
as the Java Sandbox since programs are
severely restricted to completely innocuous
actions.
- signed Applet If approval is granted, it
can do anything a application can do,
unless you specify what limitations you want to place on it in your
policy file. You have extremely fine
control of the privileges you grant.
- signed Java Web Start If approval is
granted, it can do anything a application
can do.
There are two ways Java code can be digitally signed:
- Java code signed with a real certificate
guarantees the code has not been
tampered with and that a company like Verisign or Thawte guarantees
who the author is and that they have
checked him out.
- Java code signed with a self-signed
certificate guarantees the code has not been
tampered with and that the author is someone with access to upload a
copy of his public key to the same website
you got the code. It assures the program has not been modified or
damaged in any way since it was signed.
Java also internally always does consistency checks so it cannot
accidentally do damage. Other languages
don’t even try. The trashing of Java is primarily politically
motivated. People who use inferior software
programming systems tend to spread lies (without knowing if they are
true) about Java presumably to excuse their
own poor quality software.
Java Applets have inherently much superior technology for client side
computing. Nothing else has a sandbox.
Nothing else is so scrupulous about signing for dangerous code.
ActiveX has signing, but does not enforce it.
Nothing else is so compact. What happens when Java stumbles is a bit
like Mercedes-Benz doing a recall for a
potentially dangerous problem, then the Yugo owners chorusing that
this means the Yugo must be superior to the
Mercedes.
Books
Book referral for The Java Programing Language, fourth edition
|
recommend book⇒The Java Programing Language, fourth edition |
by |
Ken Arnold, James Gosling, David Holmes |
978-0-321-34980-4 |
paperback |
publisher |
Prentice Hall |
published |
2005-08-27 |
This is not The Java Language Specification, the formal language specification. This is not a suitable book for beginners. The fifth edition, 978-0-13-276168-0, is due out 2013-04-11. |
|
Greyed out stores probably do not have the item in stock. Try looking for it with a bookfinder. |