News for hackers. Stuff that matters.
Re:How to Pass a Programming Interview by jerf on Tuesday March 08, 2016 @03:04PM (#11248104)
"Or had to find the O(x^n) and replace it with O(x^2)"

The other thing that really seals the deal for me as an inferior interview question is that you don't need to have a clue what O(x^n) is to wrap some code in a simple time call, see that the code you think ought to run in microseconds is running in seconds, by visual inspection notice stupid nested loops, and fix it. Self-taught programmers may not be able to say "O of exx to the enn" but that doesn't stop them from fixing it.

So... seriously, what good is the question anyhow?

Re:How to Pass a Programming Interview by JupiterMoon on Tuesday March 08, 2016 @04:53PM (#11249040)
I would recommend going through some undergrad CS datastructures and algorithms lectures to any self taught programmer. My process of reading code improved dramatically. And the big O concept is, once you wrap your head around it, an intuitive way to think about speed. Also once you've timed your code and found the slow bits you need to know how to speed it up, not all speed ups are as simple as unnesting loops.
Re:How to Pass a Programming Interview by vpeters25 on Wednesday March 09, 2016 @11:16AM (#11253779)
Same here. last week I was sent a Codility test, tried the demo and failed miserably.

Then I noticed the test was expressing constraints using time/space complexity, concepts I was completely unaware about for my previous 15+ years in the profession.

So now I am reading about algorithm theory face-palming at the realization I have reinvented the wheel many times during my career instead of just re-using a PhD. researched algorithm.

Re:How to Pass a Programming Interview by tomjen3 on Tuesday March 08, 2016 @03:31PM (#11248349)
What if it isn't stupid code? What if it is straight forward and simple and looks correct but is just slow because it has to traverse a list instead of using a hash-table or some other data-structure. You can't get there by intermediate steps, you have to rip out the code that uses it and rewrite it with a hashmap. You can only do that if you know the space complexity and when a hash and a list is appropriate.
Re:How to Pass a Programming Interview by jerf on Tuesday March 08, 2016 @08:21PM (#11250185)
"You can only do that if you know the space complexity and when a hash and a list is appropriate."

You seem to be confusing "knows how to say 'oh of enn squared'" with "the loop gets slow when I iterate over a lot of things". One is generally a product of education, the other, merely experience.

The idea that a thing can only be learned in a classroom is perhaps in the top ten most pernicious ideas in the modern world, and probably one of the more surprising ones to show up in that list. You do not need special courses to discover that your code runs slowly, and as I've seen often enough, having had those special courses does not confer immunity against writing slow code.

Now, I am also a believer that formal education has its place, and if you are going to get a formal education in computer science, big-O analysis absolutely must be part of it or you are literally missing out on an entire rather important sub-discipline. But the idea that it's some sort of touchstone between Good and Bad programmers is just ludicrous nonsense. Slow code is slow. There are abundant tools that can be used to figure out why. If you can't work out why your O(n^3) loop is running slowly after a couple of years of practicing the art, you don't need formal education, you need a different job.

Re:How to Pass a Programming Interview by bottled_poe on Tuesday March 08, 2016 @09:07PM (#11250366)
I've found that employees who are able to discuss the benefits of certain data structures and their associated time complexity are generally able to solve problems quicker than those who struggle to discuss these fundamentals. That said, the thing that matters most to me when hiring programmers is proof that they can write decent code.
Re:How to Pass a Programming Interview by democracy on Wednesday March 09, 2016 @02:45AM (#11251501)
My thoughts exactly, a bit suprised seeing it on HN
Re:How to Pass a Programming Interview by sklogic on Tuesday March 08, 2016 @04:58PM (#11249084)
Are you going to profile everything for the entire nearly infinite range of possible input values, including all the pathological cases?
Re:How to Pass a Programming Interview by pjscott on Tuesday March 08, 2016 @07:28PM (#11249941)
This is a very under-appreciated point. If you profile a program on non-pathological input, the profiler won't tell you what's going to explode later on when your program hits a rare case that you hadn't expected. Theoretical upper bounds don't have this problem.
Re:How to Pass a Programming Interview by Retra on Tuesday March 08, 2016 @10:00PM (#11250595)
It demonstrates that you have a passing familiarity with probably _the_ most fundamental tool of the trade.
Re:How to Pass a Programming Interview by sgift on Wednesday March 09, 2016 @01:48AM (#11251357)
The most fundamental tool of the trade is a profiler. The tool which is used in reality to find performance problems, unlike BigO, which is used in theory to find performance problems. Does BigO help? Sure. Is it the silver bullet people seem to think it is? No.
Re:How to Pass a Programming Interview by kafkaesq on Thursday March 10, 2016 @12:52PM (#11260669)
The tool which is used in reality to find performance problems, unlike BigO, which is used in theory to find performance problems.

Sorry, but this is just wrong.

I can guarantee you that BigO is very often used not "in theory", but in practice, to find real-world performance problems. And not having "situational awareness" of certain commonly occurring complexity profiles can be a significant source for performance headaches and technical debt.

One trivial-seeming, but frequently occurring example: not knowing when to use hash maps.

In fact, many people solve performance problems (including both those where order-of-magnitude performance really is the most important factor, and various other kinds) not by using a profiler but by, you know, understanding the code and thinking about it. Being as profilers, while they can tell you a lot about certain kinds of performance issues, are still generally quite limited in what they can tell you.

Is it the silver bullet people seem to think it is? No.

Of course not, and I've never heard anyone saying that it was, either.

Re:How to Pass a Programming Interview by Retra on Wednesday March 09, 2016 @07:01PM (#11256550)
It's not a silver bullet, it's only a model of the problem. If you profiler tells you some code is slow, you can model why it must be slow by using big-O. In fact it's the standard way of explaining such things. Without it, you must spend your time babbling about special cases.

It's like, yeah, you don't "technically" need to know any 2+ syllable words to be a programmer, but you're really not helping yourself by avoiding them.

Re:How to Pass a Programming Interview by RogerL on Tuesday March 08, 2016 @07:51PM (#11250043)
Big O took about 15 minutes to teach. Sure, it went on and on a bit because a rigorous class will introduce proofs, but you are absolutely right - it's a trivial concept, and often flawed in practice (list is supposed to be faster for random inserts/deletions according to big O, but in practice they are almost always slower).