News for hackers. Stuff that matters.
Re:O-notation considered harmful (use Analytic Combinatorics... by freework on Sunday February 10, 2013 @03:52PM (#5197844)
Most of the time, if you're thinking about big-O, you're practicing pre-mature optimization. Just write the code using your language's sort() function. If by profiling you determine the call to sort() is a bottleneck, then AND ONLY THEN should you consider analyzing the big-o implications of the different sort algorithms.
Re:O-notation considered harmful (use Analytic Combinatorics... by thirsteh on Sunday February 10, 2013 @04:22PM (#5197964)
I strongly disagree. Good developers have a sort of Big-O intuition at the back of their minds that automatically tells them that the nested for loop they're writing to find a string in an array, and using an array in the first place, might not be the right approach.

Big-O applies to a hell of a lot more than just sorting algorithms, and no language lets you ignore the varying degrees of complexity that come from the choices you make.

Good developers consider Big-O implications all the time, without explicitly thinking about it. They don't ignore it.

Re:O-notation considered harmful (use Analytic Combinatorics... by meaty on Sunday February 10, 2013 @04:53PM (#5198094)
I think this is the most elegant set of reasons.

We actually test incoming staff to make sure they are aware of complexity by giving them programming tasks that they can hang themselves with by using the wrong data structures or algorithms.

Re:O-notation considered harmful (use Analytic Combinatorics... by dinkumthinkum on Sunday February 10, 2013 @04:26PM (#5197976)
No, that's not true. That may be true if your whole world is making CRUD apps but there is a whole world out there. People use the phrase "pre-mature optimization" as a crunch to not understand how computers work.
Re:O-notation considered harmful (use Analytic Combinatorics... by paulgb on Sunday February 10, 2013 @04:52PM (#5198086)
Exactly. If you're building a todo list maybe you can ignore complexity, but if you're working on a data pipeline and you ignore (at least an intuitive sense of) O-notation, it will bit you in the ass.
Re:O-notation considered harmful (use Analytic Combinatorics... by slurgfest on Sunday February 10, 2013 @06:28PM (#5198435)
People also use the phrase "premature optimization" to make a perfectly accurate observation about eager, costly optimizations which may be obviated by changes or have no meaningful relationship to any business need.

Is there really any good reason not to focus optimization on areas it will make a difference, and guide it with actual profiling results?

Re:O-notation considered harmful (use Analytic Combinatorics... by 10098 on Sunday February 10, 2013 @04:52PM (#5198087)
This. I can't comprehend it when people use sort() to find the min/max element instead of a linear scan. And yes, I've seen it happen.
Re:O-notation considered harmful (use Analytic Combinatorics... by lucian1900 on Monday February 11, 2013 @07:33AM (#5200461)
That's not a particularly bad example, only O(n) vs O(n logn).
Re:O-notation considered harmful (use Analytic Combinatorics... by philhippus on Sunday February 10, 2013 @06:20PM (#5198410)
So Donald Knuth was trying to get out of understanding computers, got it.
Re:O-notation considered harmful (use Analytic Combinatorics... by Derander on Sunday February 10, 2013 @06:31PM (#5198442)
The actual quote reads: "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil."

O(n) vs O(n^2) is not a small efficiency for non-trivial data sets. This is the point that was being made. Many people forget that the quote hinges on the word "small" and then use that as an excuse to disengage their brain when it comes to basic things.

Re:O-notation considered harmful (use Analytic Combinatorics... by dinkumthinkum on Sunday February 10, 2013 @08:57PM (#5198888)
That's an extremely simplistic, sort of childish response. No one besmirches Donald Knuth.

Taking a quote, out of context really, and using it everywhere as some sort of justification, nay, an unthinking reflex, is, indeed, using it as a crutch.

Re:O-notation considered harmful (use Analytic Combinatorics... by freework on Sunday February 10, 2013 @07:56PM (#5198703)
99% of everything is CRUD
Re:O-notation considered harmful (use Analytic Combinatorics... by jiggy2011 on Sunday February 10, 2013 @07:06PM (#5198578)
It seems impossible to talk about Big O without comparing sorting algorithms. I guess this is because every college course on the planet compares sorting algorithms for half the semester.

If you have code which does a database query, parses some result and then generates HTML based on that; this is an algorithm. If your Javascript walks the DOM finding elements then that is an algorithm.

These things all have associated computational costs which will scale depending on the input size.

Re:O-notation considered harmful (use Analytic Combinatorics... by lucian1900 on Sunday February 10, 2013 @04:20PM (#5197958)
However, it is often important to keep in mind how a particular functionality will scale. Complexity is an excellent way to gauge that.
Re:O-notation considered harmful (use Analytic Combinatorics... by martinced on Sunday February 10, 2013 @04:41PM (#5198042)
Writing correct code is about chosing correct data structures for the problem at hand as much as "coding".

And chosing the correct data structure comes down to understanding the performances (using Big-O / best-worst-average or Analytic Combinatorics) of the operations you're going to perform and the algorithms you're going to use on these data structures.

It really sucks to have to refactor a codebase because some coder thoughts that lists would have been great there when actually a bi-dir map was what was needed (and vice-versa).

Re:O-notation considered harmful (use Analytic Combinatorics... by mjcohen on Sunday February 10, 2013 @06:30PM (#5198437)
Algorithms + Data Structures -> Programs.
Re:O-notation considered harmful (use Analytic Combinatorics... by guard-of-terra on Sunday February 10, 2013 @05:04PM (#5198140)
It's not only sort. Any loop with function calls inside can be a source of runaway complexity.