The Webcomic Hunger Games are in full swing:
- Melody: What type of sorting algorithm did you implement to sort the list of object names? Merge sort? Heap sort? … Bucket sort?
- Richard: Neither. I simply called Java’s “sort” function.
- Melody: You filthy casual.
|
hahaha, “Worse than Bogo Sort”
FIGHT FIGHT FIGHT Kiss Kiss Kiss
First!
*Shot in the face.*
Now, I think that Richard could have improved his programming by balancing what could increase adaptability against what would increase performance for his programs, and only increase short-term productivity for prototypes.
I so hate Java. If you’re not using assembler, you’re not really programming.
BUBBLE SORT!
As soon as you write a routine that does the sort better I will gladly call that instead.
http://knowyourmeme.com/memes/skub
I even like Java and I find that careless. For shame, man.
I can only imagine their religious differences will end in bloodshed when they inevitably end up on opposite sides of the vim/emacs debate, although I’m half expecting her to ask that question only to get “I only use eclipse” in return, at which point our computational messiah returns to the heavens to await us being more worthy of her.
“pro skub” and “anti skub”
Are they actually just not allowed to fight on work premises?
Anti-skub!
Always good to see a PBF reference.
Richard, that is disgusting.
Yep, totally going to be doing it by the end of the month
That is a match made in heaven if I ever saw one.
She ought to know that if the code works and falls within necessary parameters of accuracy and performance, simplicity is best. If a built-in sort function does what you need done without creating significant overhead, it’s best to move on to other things and come back if you need to streamline it. It’s also better to defer to using more well-known constructs to make things easier for your successors to follow your logic, because it’s virtually inevitable that someone else will have to understand your code later on.
I’m with Richard on this one. You spend your time writing sorting algorithms, I’ll be busy getting actual work done.
@ Onihikage:
Definitely on your side here. If it works, use it. If it turns out that it’s slowing things down, then, and only then, consider optimizing it with a more efficient algorithm.
@ SparkSovereign:
Java’s default sorting algorithm as of Java 7 is called Timsort. It’s a hybrid of Mergesort and Insertionsort. It functions by identifying runs of data that are already sorted and using Mergesort to take advantage of this. It is very difficult to do better than Timsort with a comparison sort on arbitrary data. I recommend trying it if you don’t believe me. My old CSCI professor has a sorting competition every year, and the only algorithms that can beat the built in Java sort are non-comparison sorts and multi-threaded sorts.
@ Onihikage & Ajed32: Exactly. Java’s built-in sort is dual-pivot qicksort, which is more than good enough for any code section that doesn’t have critical performance requirements and a data set that satisfies the assumptions of some more heavily optimized algorithm.
….I ship it
Too bad everything else has gone over my head…
@ Seth:
Correction: Rasimpson is right; it’s Timsort in this case, not quicksort. Java only uses quicksort for non-primitive types, where strings are considered non-primitive. The computational complexities are comparable.
@ Seth:
Correction for the correction: That should have read “… quicksort for primitive types…” I’m going to stop now before I make any more mistakes. 😛
guys. If you are going to sort something please use a library. It’s a waste of time and space to do it yourself. And it leaves possibility for errors.
Seth wrote:
The Built in sort is ok for primitive variable
But Failing to define the sort amalgam for a customs object is just sloppy!. Recuse it will sort a deWinter before Colbert when trying to sort becuase z < A the built in Java Sort fuctions assumes when you make you custom object class you will define on what grounds you will sort the objects on.
Java? Well anything in java has a bad performance, so it really doesn’t matter, in C++ on the other hand it might matter. But if possible to use then bucket sort is asymptotically faster, but for object names it kinda doesn’t work well if you don’t know maximum length, so please do the research before doing strips…
“Er. Sorry. I write software for a living; I don’t reinvent wheels.”
DAMMIT RICHARD I TRUSTED YOU
I TRUSTED YOU AND YOU SPRING THIS PRO-SKUB SHIT ON ME
Now seriously, I’m with Richard on this one. If it creates no issues, simple is best; don’t give me that “casual” crap, premature optimization should be considered a personality disorder.
@ roguebfl:
> But Failing to define the sort amalgam for a customs object is just sloppy!
True enough. If you’re not implementing Comparable or Comparator, it’s almost certainly going to come out wrong.
@ Rex Vivat:
At the very least, it’s bad programming. Every optimization eliminates flexibility, which, while trying to implement requirements, will cause you to backtrack unless you’re perfect or the requirements are trivially simple. If you’re optimizing before you’re feature complete, or before you’ve hit a major performance bug during initial architecture, you’re just wrong.
This comic makes me very very glad I quit computer engineering for mechanical engineering. As do all the comments following it.
Calling each other casuals, the first step in a long and beautiful relationship, be it platonic or romantic!
Oh for godsakes, you two, just make out already.
I think computer science, like much of math, has both a theoretical beauty to it and a practical application to it. A good algorithm, like a good mathematical proof, is elegant in its simplicity or power (sometimes both). However, on the practical side, there is not much reason to reinvent the wheel and it is better to use existing code unless there is a specific problem applying it to your program.
Personally, radix sort is my favorite, even if I rarely use it in practice.
Anybody who has heard that “Opposites Attract” will know where this is going.
Lol.
BTW, neither is only valid with regard to choices when there are two and neither is correct. None of those, or simply avoiding that portion of the statement would be correct.
Still, Richard is forgiven for being wrong on multiple levels…
@ AustKyzor:
A lot more will before this plotline is resolved. It’s a whole lot of programming jargon. Except the Skub part. But that’s explained in someone else’s comment. (Or the link therein.)
The last real strip’s P=NP / P!=NP got explained in the writer’s comment. This one refers to Java programming. There are many programmers that insist on coding virtually everything, even where it’s already been done. (Even as far as C++’s PCL.) However, the tendency for those programmers are to get a lot closer to the metal (Assembly or a language like C++ that compiles to native code), though VM-based language (Java, C#, Python, etc.) users can apply to this philosophy too. (My friend’s boss is this with C# and the XNA Framework.)
Most programmers prefer not to reinvent the wheel unless they absolutely have to. (I usually fall into this camp, but not always. I tried to do my own C# implementation of BulletML, for example, even though a MIT-licensed library already exists for it. Slower-loading, faster-running. I failed miserably.) Basically, the task is to get the job done, and let someone else do the optimizations, preferably before we got there. This is how almost everything actually gets done. The hyper-optimizers have their place. (In my opinion, a higher-paying place than I should get as a programmer, regardless of whether or not they get there.) It’s like a BASF commercial. We make the products you use. They make the products you use… better.
@ gamerjoel135:
I know, right?
Soon as I saw their opposing shirts previous strip my first thought was “Introducing… Sandra’s step-mom?”
Java? Java?? Really??
Should have used Python 🙂
It’s so amusing to look through the comments and watch people argue for one side or another.
@ roguebfl:
There’s a difference between implementing a comparator and implementing a sort algorithm. The former, which is what you’re talking about, is often necessary. The latter, which is what the comic is talking about, is not.
Donald Knuth wrote:
Doesn’t need editing.
Before a ship may set sail, it is test for leaks. How such debugging is up to them.
It works. My first programming teacher would often tell us that good programmers are lazy. They don’t reinvent the wheel. If something works, and works well, then use it. Don’t waste time setting up something that works almost as well and takes more time.
She’s cute!
Oh god, two adults of opposite sexes who have conflicting opinions and frequently fight each other… If TVTropes taught me anything, it’s that there is only one possible outcome to this…
ROFLMAO! This is why I love working in SQL Server: we don’t sort, we just index and order by. Saves all that nasty low-level stuff.
Sorting algorithms *shudder*.
I have done enough D1 mathematics for today thankyou… please take whoever decided to make sorting algorithms part of maths away and find a suitable punishment… I’m thinking perhaps having them set upon by a band of savage teenage girls… you know, the ones who torture their prey before feeding.
I have to say that I’m with the Pro Skub guy on this… if somebody’s already created an algorithm for you to use and it is available, why waste time creating a solution to a problem that somebody else has already solved?
I’ll just leave these here:
https://www.youtube.com/watch?v=kPRA0W1kECg
http://www.sorting-algorithms.com/
Why on earth would anyone waste time writing their own sort these days? That level of optimization is rarely necessary with today’s hardware. And most of the time what you write is far slower than the out of the box. Personally. I use Enumerable.OrderBy.
@ Gas Bandit:
Assembler is for wimps. A real programmer enters the opcodes and their arguments in binary directly, i.e. by shorting the address and data bus lines with jumper wires. : )
10101001 01101000 00100000 11010010 11111111 10101001 01001001 00100000 11010010 11111111 00000000
Should have answered bubble……
So Am I the only one to sense new mommy for our main female protagonist?