- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Math.min(*array)
Or
Math.min.apply(null, array);
Admin
Kudos for not using the Frist word!
Admin
Aaah, the wonders of the open space. I (and my headphones) know them well.
Admin
This is why companies can't have nice things
Admin
Leaving aside the basic lack of understanding why do people feel the need to reinvent the wheel like that? Just google it and look for the best answer? There's almost no problem we'd routinely encounter that hasn't been adequately solved by someone else before.
Mind you, with JavaScript (like VBA and some others) you do need the judgement to wade through a lot of wrongness to find the truth!
And open-plan, pffft, stop insulting our intelligence and telling us it's to do with team-work and collaboration when we all know it's about floor space per desk and saving money. Oh, and petty middle manglers who want to be able to pace around looking at everyone's screen to make sure they aren't goofing off on DailyWTF rather than churning out code.
Admin
I cringe every time I read "collaboration" in a job description because of incidents like this. You're never allowed to be smart in those situations. Directives always come from management or the worst developer with no involvement from anywhere in between. Then they can't figure out why the product is terrible, late, or, both.
Admin
Go away
Admin
Things like "half-open cubes" and "no specialists" sound good on paper.
But computing is one of the few industries that has never been done on paper.
(yes yes punch cards etc, don't let reality get in the way of a witty comment (attempt))
Admin
There's no timeframe given. Java & Javascript both existed before Google.
Admin
Ah, Google That's how I learned about thedailyWTF.com Luckily I was clever enough to realize this isn't a site with best practices or we would have been in a lot of trouble :) (would have made a fun submission, though)
Admin
I think the lowest value seems to be Dalton's IQ.
Admin
No, what Max should do is find another job
Admin
We are all DevOps now!
Am I the only one who thinks that in another 5-10 years having people who are focused on discrete areas of application development (front-end, middle-tier, testing, deployment, etc.) will be the next trendy thing?
Admin
I once read a humorous list of "Real Computer Scientists ...," which included the following,
"Real computer scientists never work in anything less dynamic than a #2 pencil." :-)
Admin
Right. This was Javascript, right, for the front end? I certainly hope the web page isn't displaying a list of 30000 values. Don't assume that a reduce with its interpreted call to another function is faster than a dedicated internal sort without testing it.
Admin
"Why do people feel the need to reinvent the wheel like that?"
It's worse than that here. If they were merely reinventing the wheel, they'd be writing a small function to iterate over the array once while keeping track of the smallest element seen so far which would run in O(n) time still. What they're doing is reinventing the square wheel.
Admin
"Full Stack" usually good (seriously!)...however the way companies adopt (transition) is almost always horrible (and this is a good example).
Also a big fan of collaboration, but again often it is done poorly. Having group space and private space (not necessarily dedicated to a person) is quite often near optimal, but found in less than 5% of environments.
Admin
I kept expecting the solution to involve sorting the array for each comparison.
Admin
Meh, that's not too bad. It's the difference between n & n log n. I expected them to find a n² algorithm.
Admin
Ah, the ever popular approach of getting "Full-Stack" developers by just calling everyone Full-Stack developers. My last role was one of those; mostly it means you end up with the devs doing the PMs jobs and the project managers trying to do dev work. You can probably guess the results.
Admin
Further WTF is the author calling it an n(lg n) operation....he doesn't understand big O notation any more than his colleague.
Admin
The underlying WTF is that nobody went to school. There they would have have been taught all about sorting, and how long it takes. It is one of the first lessons given (see Knuth). Some of the "first principles" should be studied. Those that hack away at Excel and Access just think they "know", but they actually don't. They don't even have the foresight to use some of the tools (google is your friend!).
Yes, for the most part, sorting is an n*(log n) operation. I suspect that with this task, the sort (on the same data) might be used for other purposes, but then WTFery would come in, and a sort would be done multiple times. Oh, well....
Admin
I'd say, it's probably closer to reinventing the trackball. Sure, it can be set up to work like a wheel, but it does a lot more than it needs to if it's just going to be a wheel, is still relatively impractical for the purpose, but is useful in other circumstances (i.e., sorting a list is more useful than a square wheel). It does (more-or-less) solve the problem, just adds a lot of cruft that people will have to deal with down the line as things get more complex.
To put it another way, I can find a lot more uses for a sorted list than for a square wheel.
Admin
Do you have to go to school to observe that when you're looking for a minimum value in a list, you typically point your finger at the list, and trace through it, noting the lowest value you've seen?
It seems like most coders write algorithms like a retarded toddler with puzzle pieces, randomly banging them together until something looks like it fits.
Admin
Oh, and why do people seem to think object construction is free? This is absurdly common, even in loops:
{ v:k for k, v in foo.items() }[x]
Admin
Why would you ever be returning an array to the front end that's long enough that it matters how you sort it?
Admin
That's exactly how I work with regular expressions.
Admin
I think the issue is a choice between two approaches of equal effort is the least efficient one.
Admin
+1 for mentioning HO scale.
Admin
Damnit, don't describe my way of coding. Then I'll have to compete with other no-skill 'developers' who just jam frameworks and code together until I get the damned return codes I was looking for! What next, you'll tell them how to copy and paste stackoverflow? Well joke's on you- I cover my tracks by renaming the variables and functions. Ha!
Admin
... and Max calmly backed up all the personal content on his machine onto his thumb drive, cleared down his email, logged out of his computer, put all his personal effects from his desk into his briefcase, and walked out of the office never to return.
Admin
The real WTF is expecting a language to have a built-in function for EVERYTHING and then your brain falls out if there isn't one for what you want to do.
Admin
why was Max, the disruptive one, the only one of the three who sounded remotely like he even knows what programming is?
Admin
...one of my interview questions is about the work environment. If it isn't at a minimum full-height cubes, I'm probably not interested.
Admin
here you go: https://jsperf.com/wtfarray
Admin
-1 for not knowing it is called H0.
Admin
Thanks, that's actually useful - and does prove Max's point as I suspected it would. Just out of curiousity, could you add reduce using Math.min(a, b)?
Addendum 2017-07-25 15:41: Specifically,
var smallest = a.reduce(Math.min);
Admin
If you want the minimal element, surely you shouldn't ask Max.
Admin
Well, filter as a method on Javascript Arrays did not exist before Google ;) It was defined in ecmascript 5.1 in 2011. http://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.20
So we know Google existed :D
Admin
Eeh, running this on mobile safari 7 gives me reduce as the slowest at 300kops per sec, sort at 1100kops and the loop, which is what I expect anyone not particularly familiar with js would try first at a much faster 4200. So, max is wrong?
Admin
+100 on your closing paragraph. (About open-space offices being a cruel joke.)