
Hexing the technical interview (2017) - kick
https://aphyr.com/posts/341-hexing-the-technical-interview
======
wpietri
Aphyr is a joy and a wonder: “If it were meant to be illegal,” you remind him
sagely, “Sun Microsystems would have made it unrepresentable.”

~~~
freshhawk
I'm still convinced that the "Clojure from the ground up" series [1] is the
best and most effective language guide/tutorial I've ever read. The level of
understanding at play there, in terms of building the correct mental models in
the right order for a broad audience is excellent.

[1] [https://aphyr.com/tags/Clojure-from-the-ground-
up](https://aphyr.com/tags/Clojure-from-the-ground-up)

------
dang
Acing in 2017:
[https://news.ycombinator.com/item?id=13886626](https://news.ycombinator.com/item?id=13886626)

Hexing a bit in 2017:
[https://news.ycombinator.com/item?id=14050017](https://news.ycombinator.com/item?id=14050017)

Typing in 2017:
[https://news.ycombinator.com/item?id=14078852](https://news.ycombinator.com/item?id=14078852)

~~~
Fellshard
'typing' is one of my all-time favorites. It's pure magic watching him pop
what I suspect are dependent types out of Haskell's type system, and that
prose is just laugh-out-loud magic.

~~~
tylerhou
Dependent types are slightly different — dependent types depend on _values_.
Since Aphyr is working entirely in the type system, there are no values.

Aphyr is abusing Haskell’s _type deduction_ feature.

~~~
Fellshard
True, now it's coming back to me. It blends different orders of kinds (I'm
still probably butchering it).

The abuse makes sense in terms of the type system behaving as a logic / goal-
seeking engine. It does showcase the truly impressive work going in behind the
scenes of Haskell.

~~~
hcs
> It blends different orders of kinds

Orders, kinds, types, sorts, classes, groups, categories, genera, flavours,
colors, shapes... same thing.

~~~
mijoharas
> Orders, kinds, types, sorts, classes, groups, categories, genera, flavours,
> colors, shapes... same thing.

Same thing, to first order.

------
geebee
I understood this was about finding a cycle in a linked list. I wish I could
understand the code part. But the writing part was pretty brilliant.

On another note, I only wish my technical interviews were so simple. People
talk about weeding out those who can’t program but finding a cycle in a linked
list is a prerequisite to the prerequisite for passing the google interview
questions I was expected to do in 45 min at the whiteboard.

~~~
saagarjha
FWIW, I don’t particularly like this interview question since it’s dangerously
close to a riddle. Sorting, graph traversal, and other algorithms are well
covered by undergraduate computer science curriculums, but this algorithm is
basically impossible to come up with unless you know it already and it’s not
even something that you would “know to know”…

~~~
pcwalton
Yeah, it's a terrible interview question because it's just trivia. It's one of
those things where the best response may be "I know this problem. It's called
tortoise and the hare. Do you still want me to do it on the whiteboard?"

~~~
seanmcdirmid
I tried that at Amazon interview where the interviewer gave me the “Alien
Dictionary” problem unmodified. Calling her out on it wasn’t wise, as I’m sure
she torpedoed my chances while still doing decent on the rest of the loop.

~~~
slumdev
An Amazon interviewer once gave me the word ladder problem unmodified.

I am not a recent college grad, and I don't encounter a lot of interesting
algorithm problems in my work, so I had prepared by working through some
leetcode problems. But I had worked through only "easy" and some "medium"
problems because I had the impression they didn't ask the harder ones. I was
able to recognize it as a BFS graph problem and gave the time complexity (and
space complexity, IIRC), but I did not finish it on the whiteboard.

Live and learn. Maybe I'll have another go in six months. Can't argue with the
money and the resume cred.

~~~
seanmcdirmid
Amazon really isn’t that prestigious. Only work there if they have a job that
interests you.

~~~
slumdev
I'm in flyover country. It's certainly prestigious here.

------
OldGuyInTheClub
I didn't understand most of it but for some reason I have now installed Lisp
and am working through a tutorial.

~~~
zelly
This was much more about Java than Lisp. It was just a really out-of-the-way
way of writing Java. Clojure almost made me hate Lisp because of all the
leaning on Java that's done as shown perfectly in this post. Actual Lisp is a
lot more fun.

Install SBCL, pick up a Lisp book from 30 years ago (e.g., Paul Graham's,
Peter Seibel's, Norvig's), and start hacking.

~~~
iLemming
We can keep debating all day long how Java and Javascript suck, but the
massive ecosystems based on these two suckers sadly won't go away anytime
soon.

There are of course languages that are more fun to work with, but at the end
of the day we all have to eat. I would love to see Common Lisp's former glory
to be restored, but sadly the language use in the industry seems to be
shrinking every year.

Clojure is a modern, practical Lisp dialect that lets me use real REPL and
structural editing and at the same time keep my sanity intact, plus I get
paid. Please don't be so harsh about it.

I think having a Lisp as a hosted language was an awesome idea, I'd rather
write (slightly crippled) Lisp that targets multiple platforms and get paid,
rather than "hacking" in a (real) Lisp for free, or even worse - no Lisp at
all.

~~~
zelly
You don't need to apologize for what you get paid to do. Barely anyone gets to
work with the software they would use in their free time. That managers let
you use some language does justify learning it, but it doesn't make that
language better on technical (or aesthetic) merits.

PHP is bad. If you're getting paid for it, it's still bad. So what? People
also get paid to scrub toilets.

Personally, I would rather write Java than Clojure. But I wouldn't quit if I
suddenly had to use Clojure.

~~~
iLemming
I haven't written much Java professionally (I know the language, I've used
it), but I have written tons of Javascript code. I have to say - Clojurescript
just makes much more sense. Java and Javascript are good as low-level
languages for their respective platforms. But if you want to build something
practical, Clojure really is much better.

And by the way, demonstrated Clojure code is very unusual. Nobody in practice
writes anything even close to that. Java interop is baked into the language,
but in practice it doesn't look as scary as in the blogpost.

------
ddevault
See also (x4):

[https://hn.algolia.com/?q=hexing+the+technical+interview](https://hn.algolia.com/?q=hexing+the+technical+interview)

(+2):

[https://hn.algolia.com/?q=typing+the+technical+interview](https://hn.algolia.com/?q=typing+the+technical+interview)

(+1):

[https://hn.algolia.com/?q=reversing+the+technical+interview](https://hn.algolia.com/?q=reversing+the+technical+interview)

But, as far as I'm concerned, these articles could be posted a dozen more
times and it wouldn't be too much.

------
bitwize
One would do well to keep in mind the third commandment of technology
management: "Thou shalt not suffer a witch to live." A.k.a., nobody likes a
smartass, regardless of how good they are. If you interview one, it's a no
hire. If you're unfortunate enough to find out there's one on your staff, it's
pink slip time.

~~~
jacobsenscott
Someone is generally classified as a smartass when the balance of intelligence
is on the smartass side. So this is just giving idiot managers carte blanche
to fire people smarter than they are. For job security I guess.

~~~
soVeryTired
Not sure I agree. I've worked with a few "smartasses" in my time, and it can
be a real pain. Some people are absolute masters of the technical details of a
subject, but fail to see the wider context.

For example, you get developers optimising the hell out of a block of code -
making it unmaintainable in the process - when the real bottleneck is
developer time, not processor time. Or someone builds a giant vector
autoregression model powered by MCMC when a rolling mean would have been
adequate for the task.

 _Build the simplest tool that will solve the task at hand_ is not a mantra
that comes easily to some people.

------
oneepic
Slightly related, since this blog post has inspired me for a while. I would
absolutely love to read a whole fantasy-themed "tome" that treats a
programming topic as a school of magic. Maybe VR/AR is like
illusion/alteration magic. Maybe robotics is the equivalent of summoning, or
beast training, or something; maybe electrical engineering is like smithing or
crafting. Computer history is lore. And so on...

I wonder if there's anything else out there like this idea? If not, I'll make
it happen.

~~~
jameshart
Agree - this style is so rich with possibility. I’m reminded also of the Young
Lady's Illustrated Primer from Diamond Age, which included fairy stories that
taught fundamental computer science. It also imagines a cultural upbringing
where algorithms are the solutions to ancient riddles.

------
staticassertion
Aphyr is also the author of many Jepsen tests, such as this somewhat infamous
case:

[https://aphyr.com/posts/284-call-me-maybe-
mongodb](https://aphyr.com/posts/284-call-me-maybe-mongodb)

Jepsen: MongoDB

Aphyr is an incredible writer and just extremely smart, it is hard to read
anything from him and not come away humbled.

~~~
shaklee3
Aphyr is the author of jepsen itself, and I believe all the tests as well.

~~~
staticassertion
I thought that some others were contributing these days? I was aware that he
was the initial author.

------
iLemming
Awesome. I've read it on my phone. Nice thing about Clojure - like any Lisp it
doesn't care about the width of your screen, it wraps, yet retains
readability.

Who are all those people who constantly whine: "Lisps are unreadable".
Dyslisplexic programmers?

~~~
Doxin
I manage to misplace brackets and parenthesis in python. I fear what sort of
trouble I could get myself into with a language with as many parentheses as
lisp.

Readability is subjective.

~~~
p_l
I have to say that I often have more problem with indentation and the like in
Python or YAML, especially given the insistence that indentation means a
specific amount of specific whitespace character.

The lower level of S-expression serialization kind of resulted in offloading
this task to editor, where it should lie, instead of burdening the developer
with it. That said, even I will admit that without experiencing the fact that
the editor will handle parens for you, one's experience in other languages is
going to suggest bad things. How many of us ended up having to manually count
"end" keywords in Pascal and the like?

Still, with a proper editor (not just emacs), the experience is really, really
different.

------
wolf550e
The author about the writing: [https://www.metafilter.com/166166/Og-to-til-
javanissen#69855...](https://www.metafilter.com/166166/Og-to-til-
javanissen#6985515)

------
ilovecaching
My friend and I both work at FAANG. He told me a story once about how he wrote
the solution for a whiteboard problem in Haskell. Once he was done the
interview asked “great, so do you want to start coding this up?”

------
egypturnash
This is beautiful, and horrifying. A cleverly written tale around some deep
magic.

And yet.

Who among you would hire this witch? Who among you would want to maintain this
kind of code, should this witch move on to challenges more suited to her
skills?

Who among you would dare to meddle with the work of a Real Programmer[1]?

1: [http://www.catb.org/jargon/html/story-of-
mel.html](http://www.catb.org/jargon/html/story-of-mel.html)

~~~
pjc50
It should not be taken too literally. Part of the context is how asking this
type of puzzle question with a simple expected solution is trivialising to
smart programmers; part of it is the question of how many places cargo-cult
difficult interviews because google do it that way but then expect people to
work on CRUD apps with little originality or autonomy. It would indeed be a
disaster to hire someone like this for that job.

On the other hand, there are places where this kind of thing would fit right
in: exploit writing, games development, certain kinds of HPC, cryptography,
some firmware development. And it demonstrates the kind of deep understanding
where being able to _read_ this kind of thing is very useful to puzzle out
some horrendous low-level mess that has been inflicted on you by a vendor. If
it was John Carmack or Richard Feynman doing it, it would be celebrated.

The risk with "rockstars" is they do this stuff when you don't want them to.
Codewitches are much rarer, and have a much better sense of when it's a good
idea. Neither is ever really going to be a "team player" but can deliver
amazing things.

------
Deestan
Just a tip for anyone wanting to write Norwegian words. O and Ø are different
letters. You don't make a word more Norwegian by adding slashes over random
Os.

A coumparisoun would be to change "o" to "ou" tou make sentences louk moure
English.

~~~
iLemming
Clojure is spelled with 'ou' in the UK. #truestory

------
closeparen
He's not kidding about the cafe babe in section 4.1.

>The magic item supplies the magic number identifying the class file format;
it has the value 0xCAFEBABE.

[https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.ht...](https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.1)

~~~
xena
404

------
aidenn0
Can anyone tell me if there is a specific work Aphyr is referencing with the
narration style?

~~~
ddevault
He also appears to reference His Dark Materials, which is my personal favorite
book (or trilogy, but they're one work).

~~~
freshhawk
There is definitely some His Dark Materials (hey, the new show seems to be
doing a decent job of adaptation! I was so nervous) references in there.

Is the wrist scar reference from the series and I've forgotten it or is this
from something else?

~~~
ddevault
Hm, the wrist scars don't remind me of anything in particular. He later
clarifies that the scars make out the letters HJKL around his wrist - so maybe
it's just a gag for that reason.

~~~
freshhawk
That is probably right, found this [1] comment where he explains it. I thought
the torus/ice stuff was a Jemisin reference!

[1] [https://www.metafilter.com/166166/Og-to-til-
javanissen#69855...](https://www.metafilter.com/166166/Og-to-til-
javanissen#6985515)

------
shpongled
Wow, I've never seen this before. Love the writing style - reminds me of
trying to put together things like this in a creative writing class.

~~~
loeg
If you like this you'll love his twitter.

------
TurkishPoptart
I wish I could understand what's going on in this article. Besides a magical
Swede impressing some normie in a hoodie.

~~~
wenderen
Norwegian in this case.

~~~
tjillevippen
As a Swede I can concur to this statement.

------
solipsism
Guess I'll be one of the few to speak up and admit, I just don't get it. I'm
sure I'll be downvoted for it by a dozen people smarter than me who resent my
ignorance.

The prose seems to _resemble_ something dark and beautiful and meaningful. But
if it's meaningful it's lost on me, for the most part. And dark and beautiful
and meaningless is honestly a bit torturous. Like trying to stare at a Pollock
and understand something.

And the bytecode just couldn't be more boring to me. Why is bytecode for this
mundane algorithm interesting?

Someone could do us second class citizens (who I have no doubt are orders of
magnitude more numerous than those who privileged few who get it) a favor by
producing us with a line-by-line analysis. But I guess that would ruin the
feeling of privilege.

~~~
EliRivers
Put down your pre-emptive feelings of defensiveness.

FFS, there's no shame in not understanding something. There _is_ shame to be
had in throwing around accusations of privilege at people who understand
something you don't.

People won't downvote you for not understanding. Some people will applaud you
for saying you don't understand, up until the point they realise you're not
seeking help in understanding, that you're not trying to improve your own
knowledge and wisdom; that instead, you're trying to make yourself feel better
by ascribing yourself some moral high-ground for not being one of those
"privileged" people who understand something you don't. They might downvote
you for being a passive-aggressive child about it.

~~~
solipsism
_Some people will applaud you for saying you don 't understand_

I've been around enough to know how wrong that is. Do you actually believe
this? Honest questions asking for explanation are almost guaranteed to result
in a negative vote sum.

 _instead, you 're trying to make yourself feel better by ascribing yourself
some moral high-ground for not being one of those "privileged" people who
understand something you don't. _

Make myself feel better for what? Maybe I needed to include the /s tags...

~~~
EliRivers
_Honest questions asking for explanation are almost guaranteed to result in a
negative vote sum._

Boo hoo hoo. Oh no, lost some internet points. Anyone whose opinion is worth a
damn will applaud you asking honest questions; especially here, on defensive
poser central.

 _Make myself feel better for what? Maybe I needed to include the /s tags..._

You've gone for the "I wasn't being serious" defense, pretending you didn't
mean it. However, your post wasn't remotely sarcastic and contained far too
much detail and defensiveness, with a tone taking itself very seriously.
You're convincing nobody.

What exactly do you now claim you were being sarcastic about? "The prose seems
to resemble something dark and beautiful and meaningful"; that's sarcasm, is
it? So you're saying it IS something dark and beautiful and meaningful? "And
the bytecode just couldn't be more boring to me." Right, so you were saying
the bytecode was some of the most interesting code you've ever read? If your
post was sarcasm, you're truly terrible at it and should switch to irony or
satire instead. Little bit of literary term privilege there for you to
sarcastically pretend to object to.

FFS, this is the anonymous internet. If you can't be honest with yourself
here, where will you be honest with yourself.

------
winter_blue
This is wonderful. I think Aphyr is going to displace _idlewords_ as my
favorite author.

------
bytematic
Incredible, every line is well-thought-through

------
hprotagonist
see also

[https://aphyr.com/posts/342-typing-the-technical-
interview](https://aphyr.com/posts/342-typing-the-technical-interview)

and

[https://aphyr.com/posts/340-reversing-the-technical-
intervie...](https://aphyr.com/posts/340-reversing-the-technical-interview)

------
_pmf_
Aphyr and the Redis guy are probably my favorite authors of entertaining, deep
technical content (maybe add Raymond Chen).

------
mikorym
Why are there so many hex numbers used? Are they pointers, variables, for
calculation...?

~~~
pjc50
They're raw Java bytecode, passed to the JVM for execution. Some of them are
also variables or strings.

~~~
mikorym
Why does she do that?

I would guess for performance. So you would be side-stepping some of the
compilation?

~~~
pjc50
I suspect in the end it's not much faster, but it _is_ smaller. Really the fun
in the essay is that that's not what any normal person would do as a solution
to that problem, it's a stunt to show off deep mastery.

~~~
mikorym
But in this case, is it mastery?

To me, mastery would be if you can use mathematics to trivialise an
implimentation in a counter intuitive way. I understand that this is a
different kind of mastery. But does the essay write code that is a sign of
mastery, or does it just use the byte code as a talisman? I don't follow the
code so I wouldn't know.

~~~
gknoy
I think it counts as mastery, precisely because it does choose a thing so
counterintuitive that it's past what most of us would even think of as a
possible solution.

I spent many years writing Java, but never took the time to learn how to write
the bytecode (that's why we have a compiler ...). I know that Clojure lets you
call Java classes, but it's a completely crazy, magical, frightening, and
awesome thing to see someone do it by writing their own class loader, and then
writing their own class -- in bytecode! -- to load, when the _simplest_ and
clearest solution would be far from that.

It's a bit like solving FizzBuzz with Tensorflow: terrifying on at least some
level, as it makes it so clear that there's so much more depth I could be
learning, yet exciting for almost the same reasons.

~~~
mikorym
> It's a bit like solving FizzBuzz with Tensorflow

I had to wiki that, but it's a good point. The first thing about NN that
interested me, rather than images or audio or anything like that, is that a
one level NN (IIRC) can approximate any function (by adding more and more
nodes to that level).

I guess the point is also that any really deep rabbit hole is in some sense
better than a selection of random 1000 rabbit holes.

------
krick
It's probably the 3rd time I've read this, and I'm loving it every time.

------
tines
I wish I could write like this.

~~~
kick
You definitely could: writing ability comes with practice, just like
programming ability. I recommend trying to get a solid pace with it!

~~~
saagarjha
I’d probably be too embarrassed with the intermediate results…

~~~
solveit
Good. That means you have good taste and can therefore improve.

~~~
fenwick67
Ira Glass's take on this is so good and I go back to it often when my creative
work is less than satisfactory:

[https://www.youtube.com/watch?v=X2wLP0izeJE](https://www.youtube.com/watch?v=X2wLP0izeJE)

Basically when you work on creative stuff you're drawn to it because you have
good taste, but for a long time your work will disappoint you because of your
good taste.

------
luord
To say I am confusion would be putting it mildly.

------
tshanmu
would be interesting to know if a reallife interview inspired this post! Tim -
are you out there?

------
nathias
glorious

