The dreaded moment has come. You have made it this far, and now it is time to face the trial. The young man sitting before you has just finished scrawling out an infamous problem on the conference room whiteboard – a trial of iteration and divisibility. This would confound the rookie programmer, but you have a wealth of such victories under your belt.
There is just one problem.
You are a Java programmer by nature; it is the very air you breathe and caffeine you drink. But the age of Java has begun to wane, and your old employment is no more. You must do what you can to survive, and this means you must adapt. This is a Python shop.
You stare blankly at IDLE, taking in the strange orange keywords. A twinge of nostalgia for the off-purple of Eclipse hits you, but you are interrupted by the interviewer.
“Um, are you ready to get started?”
His tone is polite, but you must not let down your guard.
“Yes, yes…”
You reply, but do not take your eyes off the screen.
“Uh, don’t worry about this too much. We just want to get a sense for how you solve problems with Python.”
You take a deep, final breath. You are ready.
Your fingers trained well from years of writing classes and imports by hand, you quickly develop a suitable framework.
You feel slightly comforted at the sight of your work. But it is short-lived, for now comes the difficult part.
Your father was a Java programmer, and imparted much wisdom to you before his retirement. He warned against the serpent’s classes. You recall one saying of his in particular:
“Should you find yourself stranded in a foreign land, carve out a home for yourself.”
You remember a familiar sequence of bytes.
Your heart warms thinking of the youthful days spent poring over the Java Virtual Machine specification, but you must not dawdle. The interviewer is waiting, and you must deliver him nothing but the best.
“Now comes the version…” You mutter, typing away.
Of course, no class is complete without constants. You reckon 24 ought to be enough for the job.
“Now, let’s have some Strings and our class…” The interviewer appears somewhat concerned at your mumbling, but is nevertheless silent.
“Ah, right. We’ll certainly need some code.”
“And our dear friend System…”
“… to get at the standard output, of course.” The bytes are coming naturally now. Like any respectable Java programmer, you know the class file format better than your own apartment.
“We’ll certainly need to print, so…”
“Ah, right. Can’t forget printing integers, too.”
Your fingers are moving at an alarming pace. You know your own limits, but the interviewer appears to be getting increasingly uneasy at the suprisingly loud noises coming from the laptop’s rubber-domed keyboard.
“Oh, almost forgot to wrap the Strings.”
“And our method signature for the final touch…”
Now comes a simple, well-known series of bytes, designed by Sun to give the programmer a little breather.
You smirk at the superclass trick – your father had taught you not to be wasteful, and that any inheritable class will usually do. A classic tactic for any handwritten class file.
It is now time to lay the groundwork for the problem at hand. You do not waver, for all that you should ever need lies available to you in the constant pool.
You have already envisioned the instructions in entirety. You could do the jump offset calculations in your sleep. All that remains is a swift barrage of keystrokes.
All great things, as section 4.1 of the Java Virtual Machine specification tells, must end with an attribute table definition.
You rest for a moment, for the class is done. It has all the handwritten love and care that you wouldn’t get from javac.
Your colleagues told you Python lacks support for Java classes. But you need not worry, for the power of Sun extends to many lands.
You mentally thank the good people of Jython, and turn your laptop towards the interviewer. Seeming to have been contemplating something a bit unpleasant, he snaps back to reality. He glances at the code on your screen.
“O-oh. Right, you’re finished?”
His eyes scan the lines from top to bottom. A look of deep unsettlement begins to show.
“What… what is all this for exactly?” He mutters under his breath, seeming to direct the question at himself rather than you.
“Just some standard Java interop. Using a custom classloader is more efficient here.”
You lean over and type a line into the console.
jython fizzbuzz.py
You are greeted back by a pleasant stream of data.