- 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
Frist?
Admin
I've got a bit of a LITHP
Admin
Keep it thimple, thtupid.
Admin
I swear, at least half the time I see map-reduce it's used to solve a problem that really doesn't fit an acceptable use case of map-reduce.
Cargo cult programming I guess
Admin
Whoops, didn't mean to suck "this holds true for a lot of map-reduce stuff" into the quote
Admin
firtht
Admin
Things like this are why I wish that they had NOT put functional programming into java, etc.
If people write the sort of trash (that is perpetually featured here) using simple for-loops, then this example is only the tip of the iceberg of what we can expect as they start (mis)using functional programming.
Off the top of my head, imagine how someone might bastardize a for-case in FP...
shudders
Admin
Please don't shout Lisp. It's no longer 1960.
Admin
This function commonly known as "iota"
Admin
How about, you know, just writing a frigging for loop?
Admin
I think new Array(99) wouldn't work: map skips not explicitly set elements, so it would become a very big no-op. It could be interesting as a red herring, though.
Admin
On the rare occasion where I have to write a for()-loop in JS, I have to look it up. And I'm not joking. The situation just doesn't come up often as I use underscore.js which has nicer iteration primitives.
Admin
That's far too long. I prefer the shorter Array.from(Array(99)).forEach((e,i,a)=>{..});
In case we have anyone here who has yet to dig deep into ECMAScript (or JavaScript to normies), constructing an array via the Array constructor generates an array with a length but no elements. Attempting to forEach over this will yield nothing as it's absent of elements. Array.from is designed to take an array or list-like-object and convert it into an array, with missing elements filled in with an 'undefined' value.
So if you want to forEach over a new array, you need to construct the array, turn it into a proper array and then use forEach, map, reduce, etc over it.
Admin
So when you make an array using the Array constructor, you have to first turn it into an array before being able to use the Array methods on it? Did anyone think this through?
Admin
No, I'm sure nobody thought it through. Just went right ahead and wrote the spec off the top of their head, made it up as they went along.
Admin
Sometimes I wonder if LISP would have helped make hard computer science problems easier if it didn't use those stupid parentheses and instead had a more human-readable way to do nesting (which might have urged more people to use it regularly instead of abandoning it in disgust after a first look (because humans just aren't used to seeing parentheses nested multiple levels (basically, you should never underestimate the importance of good syntax in a language (it is called the law of triviality (also known as the bike-shed effect (and also known as "Wadler's law in computer science))))))
Addendum 2017-06-19 11:57:
See what happened? I was so preoccupied getting the parentheses closed properly I forgot to close the quote.
Admin
Try not to cut yourself on all of that edge.
Admin
I believe another language used something other than parentheses to indicate statement nesting.
Folks still complain about it.
Admin
Not wholly sure there's a "reduce" in there. Difficult to be certain, because it's anonymised, and those bits inside the eventual curly brackets could very well contain an accumulator or other lambda-captured mechanism for "reduce."
But, I don't think so. There is no context to this at all. My guess is that it's a single joker who got bored and felt The L33T coming on.
Nothing to see here, Ma'am. Move along now.
Admin
Is using braces really better than using parentheses? If you're nesting too deep, that's a problem you can get in any language (JavaScript has "callback hell", Linus has the three levels of indentation quote, etc).
Plus, Scheme and some Lisps allow brackets [] as an alternative syntax to parentheses for when you want to be more distinct.
Admin
So, as shown here, TRWTF is JavaScript. And we all know this!
Admin
"Haskell during an interview marked you as a cut above the hoi polloi"
What marks you even higher is knowing that, since "hoi polloi" means "the masses", there is no need to add "the" before it.
Admin
I would have disagreed with the sentiment on functional features in imperative languages being bad before I ran into this LINQ statement a year or two ago:
var value = SomeDictionary.Where(w => w.Key == someKey).Select(s => s.Value).First()
Admin
It's got to the point where I just don't know what the kiddies mean by all this nonsense the throw around.
Functional programming. So, a program that performs a function. Don't all programs do that? A program that uses subroutines that are functions that return a result. Well, there's nothing exceptional about that, been doing that for more than three decades, foobar(x,y,RETURN z).
Agile programming? Yes, I'm very agile in my programming, I can program around any task.
etc.
Admin
It's so lovely trying to step through something like that ina debugger, sheesh... Keep it very, very simple please.
Admin
Every "but the parens!" anti-Lisp argument I've seen in my life so far has been from someone who hasn't used it enough to be allowed to whine about it.
Is() { this { any { better(); }; }; } ?
Any argument you can give for or against a braced monstrosity can be used in the same way for a Lisp program!
Admin
What it an allusion to languages that indicate nesting with braces, or those that do so with spaces?
Admin
This reminds me of that joke about asking how to add two numbers on StackOverflow and the response being "use JQuery"...
Admin
Admin
I bet it was something along the lines of this what they were thinking.
First allocate 99 spots of memory in a row.
Now you can fill in the 99 bits without having to resize the array each time
Admin
You can also do Array.from({ length: 99 }).map(...)
More compact, more meaningful... still worse than a classic for, though.
Admin
Touché
Admin
From Mirriam Webster:
"Since hoi polloi is a transliteration of the Greek for "the many," some critics have asserted that the phrase should not be preceded by the. They find "the hoi polloi" to be redundant, equivalent to "the the many"—an opinion that fails to recognize that hoi means nothing at all in English. Nonetheless, the opinion has influenced the omission of the in the usage of some writers. ... But most writers use the, which is normal English grammar."