Hacker News new | past | comments | ask | show | jobs | submit login
Tom, Dick & Harry (jasq.org)
153 points by ubasu on Feb 6, 2013 | hide | past | favorite | 66 comments



Author here. Story is loosely based on my real life. As in, I was/am the Harry. At bofa, my previous employer, I tried to be a nice quant & find math-y solutions to what turned out to be plain accountancy problems that a simple nested sql query or a stored procedure could have solved.

So I quit, and here at my current employer, once again I mess around with monoids, rings & vector spaces, though I'm not really sure how any of this adds to my employer's bottom line:)

Matter of fact, my latest pull request (http://bit.ly/14EXMaA ) allows you to do weird shit like

      add("twenty three", 
           "two million three thousand four hundred fifty five")

  to get "two million three thousand four hundred seventy eight", because add is defined like so -

      def add(a:String, b:String):String =       EnglishInt(EnglishInt(a).asInt+EnglishInt(b).asInt).get


Thanks for sharing your story.

> Tom was a PHP/JS programmer. He worked on rapidly prototyped web-apps and didn't give a rat's ass about efficiency.

Although I'm happy you quit and did not get fired, know this now does pull some of the poetry out of the above line, which I had previous read as some sort of backhanded a compliment given the other (fictionalized) ending.

Perhaps I'm being overly-sensitive but Harry comes off as really looking down your nose at "good enough". For example, there certainly seems no love lost on you and Tom fictionalizing (?) the character as Dick's "secretary."


You'd think a reasonable math person--or any halfway competent programmer--would not throw in a call to math.random in the definition of their monoid! (Or, really, deep inside any normal code at all.) He deserved to be fired just for that :P.

Anyhow, if we're playing at parables, chances are Harry took advantage of the job market and his knowledge and went to work for a trading shop or hedge fund, making more money than any developer at the old company (150,000, really?) and not being hated for knowing stuff. And hopefully using a nicer language like Haskell or OCaml.

Also, if Dick's a "systems" programmer, chances are his code would actually be written in C, longer than the monoid Scala code and harder to read. It would be fast though.


I agreed. Harry can't talk about a Monoid with that non well-defined function. He deserved to be fired :D

(As I pointed out in my comment: http://www.jasq.org/2/post/2013/01/the-mathematician-the-mon...)


If Dick is a systems programmer, his code would look pretty much exactly like Harry's, except he'd call it a priority queue of capacity 1.

And he'd have written it over breakfast, while Harry was still pondering the side problem of analytically defining the volume of his bath tub :)


> You'd think a reasonable math person--or any halfway competent programmer--would not throw in a call to math.random in the definition of their monoid!

Yeah, just pick 'a'; if he was in the database before 'b' chances are that he is the one who has been with the company for the longest time; and if that's a lie then is just as random as math.random anyway.


Am I the only one who finds the requirement ambiguous?

Oldest guy who has been at the company the longest time? If I got a requirement like that I would first push back for a clarification, i.e., if employee A is older but employee B has been with the company longer, which is more of a candidate for elimination?


Interestingly, Dick's code is by far the fastest using those implementations. For a sample size of 1,000,000 employees (to highlight the efficiency difference):

Tom (sorted version): 1510ms

Dick (min-linear version): 113ms

Harry (monoid version): 995ms


If it's fair for you to benchmark this, it's surely also fair for me to point out that in a lazily-evaluated language (Haskell!), Tom's approach is O(n) and equivalent to Dick's. :)


That's true if you pick the right sort algorithm. I'm not sure if it is true of whatever happens to be in Data.List; I wouldn't be surprised either way.


I find that to be pretty typical - naive solutions are bad for Big-O reasons. If you solve the math on paper and implement a straightforward algorithm, you get the fastest possible solution. If you push some of that math into the type system of your language, you get something that should be Big-O equivalent to the fastest possible solution, but the machinery of the type system never gets fully optimized away. There might be other advantages, though, of having that machinery - your compiler might be able to detect errors in your code, or you might be able to use higher-level constructs to make more concise code. Maybe.


So the ultimate point is the futility of spending any time optimizing a solution to a problem that at most requires 2 seconds to run.


I don't think the point is the implementation itself, just what the author finds interesting in a problem. After all the 'plus' operator just does a series of ordered comparisons like the minBy solution does.


Sure. However, it does represent problems I've seen before with "overly" (subject to the person, I guess) complex solutions that end up being significantly less efficient. In this case, the problem is actually the `.toSet`, which forces a second iteration of the dataset. If the Monoid class was rewritten (yes, to be less mathematically pure) to use Seqs, it's nearly identical performance (as expected) as the linear solution.

Fun performance graph: http://i.imgur.com/2rOvb6V.png


That is interesting. Personally I didn't find framing the original problem as monoid enlightening at all, but that's what I thought the author was getting at.


If the point is that Harry solved the problem but failed to consider the politics of the solution, and so was fired, wouldn't it make more impact if he was the only one to declare that the Boss should be fired, instead of all three of them doing so?

If that isn't the point, then I don't know what the point is meant to be.


I believe the point is that he was fired because he spent a full day coming up with a complex solution to a trivial problem and that when he eventually did arrive at a solution, it was impossible for everyone else to understand and verify.


And the fact that it being a monoid is actually irrelevant to the solution. It is a lattice with an artificially created lower bound [1], which does induce a monoid structure via its join operation, but by thinking about it as a monoid, you abstract out the one relevant property (ordering!) that you actually care about.

[1] Assuming that there aren't any duplicate elements, in which case it technically isn't either a lattice or a monoid, unless you consider equivalence classes modulo attribute equality.


You're fired.


Fortunately for me, I do actually work in computer algebra. :)


    "Well", Harry said, "If you are asked to add 
    two employees, return the guy who is older. But 
    if both of them are the same age, then return the 
    guy who has been with the company  the longest. 
    But if both guys have been working for us for the 
    same number of years, then return the guy with the 
    lowest salary. But if they both earn the same as 
    well, then just randomly pick one over the other"
I didn't think that was very hard to understand or verify.


Except the obvious: why the hell is he "adding" employees, and what does that even mean?


Who knew there was such a bias against mathematics on Hacker News?

The basics of abstract algebra need to be disseminated more widely. These are not hard concepts.

Adding employees means exactly what it was defined to mean in the article. It's an associative binary operation.


Since my point obviously flew straight over your head: the problem is not whether we understand monoids, or even that "Harry" used monoids to solve the problem, but that he's using completely inappropriate terminology to try to explain his solution to non-technical people.


Actually, he's using completely appropriate terminology. Your mathematical education is just sufficiently limited that you don't know that. Rather than getting angry, you'd think your reaction would be to absorb the new information.

To me, your complaint is like someone saying it's inappropriate terminology to discuss time complexity in big-Oh notation, because we're programmers, not mathematicians.


It still doesn't make sense to call it 'add'. Please tone down the condescension.


I apologize for the condescension. I just think these are concepts worth knowing and that they shouldn't be looked down on so much. A lot of people are never going to learn this stuff if they dismiss it so quickly. And that holds back not just themselves but anybody they work with who does understand this stuff.

One of my favorite quotes about software development is that the hardest part of it is not being clever. The flip side, though, is that even the simplest things can seem clever to those who don't have the same breadth of knowledge. In this case, Harry had a solution that seemed clever, but really wasn't that crazy at all. None of his colleagues understood it, but they should have, because it was actually extremely simple.

What's ludicrous about Harry's account isn't his solution or his notion of "adding" employees. It's that he understood these concepts and still took a day to put it together (or that he completely glossed over the more obvious approaches). He wasn't productive at all.

Anyway, as for the terminology, it's just a common name for an associative binary operation on a set with an identity element. If you've never seen it used in this way, I agree that it can seem bizarre, but the more you think about it the more you'll realize it is in line with a generalization of the sort of addition you do on integers.


Haha, poor choice of words there. When he says "adding", he really means "apply a binary operation A • B, which returns A if ....".

The key point is: Once you can define a binary operation which is associative, and an identity element I for which A • I = A, you can consider using monoids.


Well, lets say you have 3 elements (1,2,3) with 2 being 0. So since 2 is 0, 1+2=1=2+1, 2+2=2, 3+2=3=2+3. With me so far ? So what's 1+3 ? Well, it cannot be 1 because you could then cancel the 1's and 3 would become 0, but 3 isn't 0, its 2, because we just said so. 1+3 is obviously not 3, because by the same reasoning of cancellation, you'd end up with 1 equals 0, which it ain't cause 2 is 0. So by the weird magic of Niels Abel, 1+3 must indeed be 2. Because it just can't be anything else, yeah ? You only have 3 elements to play with, and 1+3 better be one of those. Similarly, you can work it out that 1+1=3, 3+1=2 and 3+3 =1. That completes your Cayley table and you can collect your paycheck and go home to wife and kids, because with 3 elements your Cayley has 9 slots. But when you have 10,001 employees, your Cayley will have 100 million slots. Unless you have a rule to fill those slots, you won't be able to fill the Cayley. "Adding employees" is simply a rule to fill the Cayley. HTH :)


This is where scala and C++ differ. In C++, if you overload operator+ to do something, the typical response is "what does that even mean???". In scala, when you write a function called plus that returns one of its arguments, the response is "oh, of course, that's a really cool great idea."


That part is actually a good layman's explanation of how the monoid here works. But then he goes on to talk about seeding a catamorphism with an identity employee.


I was going to call your comment ridiculous but then I reread and saw that he actually did spend an entire day on it. Wow. Removing the trivial if chain you only have five lines! And it's not doing anything crazy, just a fold.

Let me put it this way: If I was the boss and Harry had spent the day learning about functional programming then okay sure whatever. But if he knew all the concepts he was using and spent the entire day just to pick one then there is a serious problem.


Exactly. If you're getting paid $60 an hour, you just wasted $500. Someone who knows SQL (or in this case Scala) could do this problem in seconds. "didn't give a rat's ass about efficiency." is a bit redundant - you're running the query once and you're getting paid by the hour.

That being said, the manager asking a math major to do an information science task seems a tad incompetent.


I thought the point was to show that every problem has multiple solutions. And even when you think you have the most elegant solution it's worth thinking about it again.


Read the title and was sure it was going to be some bullshit management recipe for turning the place around.

Anyway if spoilers employee number 7435 was the boss and they have 10K employees and none with more than 6 years of tenure or making over 150K, Harry is lucky to be out of that place.


Maybe it was just an framing story to illustrate three approaches to the same problem; maybe mainly to give an example of a monoid... I have no idea, but I did like Harry's explanation:)


I was hoping this was someone who actually thought that was a good idea, not a dig at math nerds who know what a monoid is.


At least one moral of the story is "Clever solutions are bad when a less clever solution can accomplish the same task".


The 'clever level' of a solution doesn't necessarily speak to it's maintainability which I would consider one of the strongest things to consider.


The author mentions that he was Harry in another comment, so a little of both


After the title switch, this link is essentially opaque. This has to be automated. No one would carefully consider whether this title was more informative than the preview title and decide it is.


Out of interest, what was the original title?


I don't remember exactly, since it was a paraphrase of something in the article. It was close to "Fire the oldest guy who has been at this company for the longest time and is still not making six figures."

Now, admittedly, it's a little baity in that people who click might expect an age discrimination screed, rather than a programming parable. But even so, I think it's obviously better than "Tom, Dick and Harry".


Thanks


>Fire the oldest employee who is not making six figures

And, if you're in the U.S. and the employee is over 40 years old, you automatically set yourself up for an age discrimination suit.


While I agree that is what is supposed to happen, it rarely does. My father worked for a company for 30 years and was fired for age discrimination (his reviews were always good, well liked at the company). He basically wrote everything there was for training new employees at the company as well and was the head of their training department.

However, they brought in a new HR director and CEO that wanted to "shake things up" and the HR guy had a buddy from his former company that wanted to come in and work with him and happened to do a similar job that my dad did. You can probably guess what happened next, my father was fired without much of a reason. Those in executive positions that could have stood up for him were either in the minority or retired, so he had little help to back him up.

My family pushed him to sue, but he felt pressured into taking their severance package because he had to support my brothers and my mother and was worried about his prospects of getting a job in his 50s at another company (despite having a Bachelor's and Master's degree from well-known schools). He ended up taking the severance and waived his right to sue (at least according to the agreement he signed). He was also afraid that suing would blacklist him from employment elsewhere and it was hard for him to bring himself to sue the business he once loved. Coming from the age when many were loyal to their companies, even if the company was not loyal to them, he just couldn't do it.

Since then, he's applied at numerous employers for similar jobs to his own as well as other ones he could segue into. However, no one wants to hire him basically because of his age despite no intentions of retiring anytime soon. Now, he works a low wage job he could get without a degree from a university and it just kills me to see him like that. My only wish is to eventually grow my own business enough I can hire him myself so he can do something more respectable. He's not a huge tech guy like me so getting him into software development with me is a bit more than possible, but he's a smart guy that would fit into many other business and training related roles. However, those roles are something I can't pay for when I'm either working for clients, my own projects or with a friend right now.

Although age discrimination is against the law in the US, it's much more complex than it appears for most cases and suing is a difficult question that could hurt as much as it could help. I've always been reluctant to talk about my father's ordeal, but I felt I had to get it off my chest at some point.

edit: few grammar errors


True, most discrimination suits are not cut-and-dried, but a document that says "Let's fire the oldest worker that makes less than six-figures." is the smoking gun most cases salivate for.


The sample code doesn't show up for me, but I don't agree that using foldl is some kind of weird egghead solution. You don't need to know about monoids in the abstract to write that code.


You may need to unblock scripts from jasq.org.


It seems like all of the programmers interpret the business decision backwards. Doesn't the company want to eliminate the biggest cost center (greatest salary under $100k), not the smallest cost center (least salary over 35 years old)?


Maybe in a small company. In a company with any size the difference of 20k-30k isn't very much in the overall scheme of things. Generally what a company will do at that point is keep the more senior employees with the assumption that they know more and are more likely to keep things going with less help.


Ha, you'd think right? I think the reason the oldest, lowest salary employee was fired first was because he/she would have made the least contribution to the company. If that employee had done a great job, then he/she should technically have the highest salary.


I feel like the punch line was ruined. Harry should have been the employee whose number was selected.

The boss thing is cool, but it just doesn't fit with the suspenseful and ironic narrative that is being set up.


Hm... I read through this twice before it occurred to me that it was sarcasm. Does it say more or less of me that I really wanted there to be some deep truth in there about monoids or foldLeft()?


None of the sample code is rendering for me.


If it were the company I'm working in, the problem neatly reduces to "Fire the oldest engineer".


I'm sorry, this may sound like a stupid thing to say given that I understand absolutely nothing about the maths involved in this joke/parable/whatever-the-fuck-this-is, but seriously, "Fire the oldest employee who is not making six figures?!" I must be missing, something, right? Seriously? Please god someone explain to me how this isn't as unbelievably dickish as it sounds.

What sort of terrible, euthanasia-based, Logan's run-like, horrific fascist company are you describing in this bizarre little parable, and how come more of you people aren't looking at this with horror?! Are you so interested in the maths that the fact that the narrative surrounds it is so completely fucked invisible to you?! It's like a bloody survivalist post-apocalyptic zombie horror company. I'm surprised none of you are advocating mulching the thirty-five year old and using him to fertilize the office plants!

Why don't we shift it around a bit, Republicans are a bit dumb, right? And they care about money a lot. So if they're not earning 100k, they're definitely shit! Or maybe women? Not many of them are engineers, so clearly if they're earning too little, it's probably because their breasts get in the way of the keyboard.... Oh hang on, no, those things I just said were crazy insane. Like firing a thirty-five year old who doesn't earn very much.

There are people in the world who don't want loads of responsility, don't want to rise up a company and still do good work. People who want to spend time with their family and not work twenty-four seven and still do good work. There are people who are valuable holders of institutional knowledge, but are content to be junior engineers or whatever. If they do a good job, who the fuck cares how old they are?! How is that even relevant?!

And while we're at it, have you ANY idea how entitled this makes engineers in Silicon Valley sound?! I mean, engineers in the rest of the US don't make half as much money as the ones in the Bay Area. Even in London, a very expensive city, most engineers are not earning the equivalent of $100k within a few years of leaving college.

This story and the responses to it WEIRD ME OUT. It sounds like something that young dicks in the banking industry would talk about to make themselves feel really important. "Yah cos like he was only bringing home like three-hundred grand and he was like thirty five, so what a loser, right? Ha Ha. We totally got him fired and laughed at him because he's like totally old and by the time I'm thirty five, I'll be totally different because I'm really amazing and special and important, right??"

This whole thing is so depressing. Ive been wondering to myself for a while why it is that such a large proportion of twenty-somethings in tech around SF behaved like such idiots, and this has made me wonder even more. I'm halfway seriously thinking after reading this that all sensible companies should start thinking about how you should always fire any engineer under thirty earning more than 100k because, lets face it, they're fucking precious, self-important, entitled, whiny little unproductive fuckers who can't keep their genitals to themselves, get drunk too often during the week, and who've never had to do an honest days work for a reasonable salary and will remain smug, boorish twats until the day a proper grown up gives them the spanking they so clearly need.


Hey...relax. It was a thought experiment. No need to blast it.

What you are apparently so shocked by, and what you describe as "unbelievably dickish," is actually fairly common throughout the United States. A concurrent problem is the difficulty older people have in finding jobs after such a thing.

Do I agree with it? No, I'm not saying that. But your other examples are much more outlandish and, frankly, not on the same level of injustice. You seem to be crying out against this with the same passion that consumed many people during the Occupy Wall Street protests - this has been happening for a long time, it's not a recent development, and just now you are demonizing it to a much greater degree than it needs to be.

Again, I'm not saying you should be happy about it. But your parallel examples aren't parallel at all. It's age discrimination, yes, but what are you changing by posting this huge rant? And whose mind are you changing?

The author of the blog post wasn't trying to implicitly advocate for ageism. He wasn't make it a de facto axiom of proper business protocol just because he included it in his example. It's just a real world example.

My underlying point here is, in your shock at what is really a common phenomenon, you seem to have missed the point of the post itself. In fact, you have the opposite reaction...it was actually supposed to be a bit amusing, my friend.


My point was that thinking that thirty five year olds are old, that the goal of life is to make six figures plus, and that at any point it is reasonable to fire people because of their age... Well, these things are indicative of completely idiotic pre-teens with completely privileged and stupid priorities. That almost no one here even registered that it was weird to do those things, to me suggests that the people reading it are also bizarre privileged idiotic pre-teens.

It's being a bizarre privileged idiotic pre-teen that I'm pointing out is dickish - holding these beliefs, thinking they're even vaguely sensible or reasonable - to me these are people that need to be told that they're behaving poorly.

You may think its just the way of the world, but I'm suggesting, you know, maybe not being so self-involved and maybe recognizing that being in the first fifth of your career does not make you de facto the best person in any given room, and more importantly, something that you'll pass through relatively quickly before you get another forty years of being patronized by children.


At the very end, the person so chosen turns out to be the CEO. Does that affect your appraisal?

I share most of your sentiments and I see why this article triggered this response from you, but I think it's out of proportion to what's actually being said in this particular article. This is 99% thought experiment, 1% bad humor, and yes, you have to read the whole thing to get to the joke.


Of the three solutions, minBy is the only one likely to handle the empty sequence/database case at all gracefully. Returning a fake "zero" is particularly awful.

It probably doesn't matter much since it's a throwaway problem and the database is known not to be empty, but it bugs me.


10,000 employees all making over $85,000? Where do I apply?


Real math majors find all this weird category-theoretic jargon in programming pretty dumb. Just so you know.


Real math majors are also some of the last people I'd ask about programming--if they care about it at all, it's just as a means to an end.

If a math major was interested in programming itself, in the meaning of programs or in neat abstractions for programming, they'd be in theoretical CS instead.

Do real math majors find the category theory in physics pretty dumb too?


Yeah, this is basically my point. You're more likely to find Harry's kind of silliness among CS people than math people.


"No true Scotsman" and all that. The dual major in my FP group is the only one besides me that cares about category theory. The rest are CS majors and don't care. Just so you know.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: