Boom! Hello! Welcome to
the Mastering X Face to Face talk show; ‘Cut the Crap’. For Tonight’s Talk we’ve got here the compiler and JVM. And they are battling over the question:
“Who’s more important!” Hi! I am Java.
I’m the guy who actually makes a program run. The compiler just gives you a file.
That’s it. Just a file. You can print it out and use it for wall paper, kindling, lining
the bird cage; whatever; but the file doesn’t do anything unless I’m there to run it. Yeah!
You See… I’m the important one here! I don’t appreciate that
tone. You’re way off! And that’s another thing.
the compiler has no sense of humor. Then again, if you had to spend all day checking
nit-picky little syntax violations Excuse me, but without
me, what exactly would you run? Ha! For your information, There’s a reason Java was designed
to use a byte code compiler. If Java were a purely interpreted language, where at run
time, the virtual machine had to translate straight from a text editor source code. Then
the Java program would run, at a ludicrously glacial pace. Hilarious! Java will have a
challenging enough time convincing people that it’s finally fast and powerful enough
for most jobs… I’m not saying you are like
completely useless. Absolutely! But, Hey! Really! what is it that you do? Seriously!
I have no idea! A programmer could just write byte code by hand, and I’d take it. You might
be out of a job soon buddy! Wait a minute! That’s quite
an ignorant perspective. Well; while it is true that, theoretically you can run any properly
fomatted byte code, even if it didn’t come out of a Java compiler. In practice that’s
absurd! A programmer writing byte code by hand? It is like doing your word
processing by writing raw postscript. And I would appreciate it, if you [SNEEZE]
if you would not refer to me as “buddy”. But you still didn’t answer
my question: buddy? What do you actually do? [WHISTLE]
– Impressive! Just kidding! Now Listen!
Remember that Java is a strongly typed language. And that means I can’t allow variables to
hold data of the wrong type. This is a crucial safety feature, and I’m able to stop the vast
majority of violations before they ever get to you. And I also- Seriously! But some still
get through! Look! I can throw Class Cast Exceptions. And sometimes I get people trying
to put the wrong type of thing in an array, that was declared to hold something else.
And- Excuse me! I wasn’t done
speaking yet! And yes, there are some data type exceptions that can emerge at run time.
But some of those have to be allowed to support one of Java’s other important features; dynamic
binding. At run time, a Java program can include new objects that weren’t even known to the
original programmer, so I have to allow a certain amount of flexibility. But my job
is to stop anything that would never could never succeed at run time. Usually I can tell
when something won’t work. For example, if a programmer accidentally tried to use a Button
object as a Socket connection, I would detect that, and, thus, protect him from causing
harm at run time. Easy! OK. Great! Fabulous!
But, what about security? Look at all the security stuff I do, and you’re like, what?
checking for semi-colons? Oh my god! big security risk! Thank Goodness! Ouch! Shocking! Stop bugging me! As they
say, I am the first line of defense. The data type violations I previously described could
wreak havoc in a program if they were allowed to manifest. I am also the one who prevents
access violations, such as code trying to invoke a private method, or change a method
that for security reasons must never be changed. I stop people from touching code they’re not
meant to see. Including code trying to access another class’s critical data. It would take
hours, perhaps days even, to describe the significance of my work. Surprise! Anyway! I have to do that
same stuff too buddy! Just to make sure nobody snuck in after you and changed the byte code
before running it. Sure! But as I indicated
previously, if I didn’t prevent what amounts to perhaps 99% of the potential problems,
you would grind to a halt. And it looks like we’re out of time,
so we’ll have to revisit this in a later chat. Later, alligator! Oh! you can count on it
Buddy! Let’s talk later!