• Frist (unregistered)

    Frist?

  • Cornify (unregistered)

    I've got a bit of a LITHP

  • Quite (unregistered)

    Keep it thimple, thtupid.

  • Blerg (unregistered)

    This is easier to explain if you look at it backwards This holds true for a lot of map-reduce stuff.

    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

  • Blerg (unregistered) in reply to Blerg

    Whoops, didn't mean to suck "this holds true for a lot of map-reduce stuff" into the quote

  • bvs23bkv33 (unregistered)

    firtht

  • snoofle (unregistered)

    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

  • "Please Don't Shout Lisp" guy (unregistered)

    Please don't shout Lisp. It's no longer 1960.

  • Andy F (unregistered)

    This is where it's nice to fill in the gaps with something like Underscore – http://underscorejs.org/#times , even if under the hood it basically just uses a for() loop.

  • Bert (unregistered)

    This function commonly known as "iota"

  • just me (unregistered) in reply to Andy F

    How about, you know, just writing a frigging for loop?

  • Hanzito (unregistered)

    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.

  • gleemonk (unregistered) in reply to just me

    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.

  • johnshow (unregistered)

    I don't think that name dropping is such big problem. I found research about functional coding - www.casestudywriter.org , and if you don`t confident that you right, read it

  • Whosy (unregistered)

    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.

  • Bert (unregistered) in reply to Whosy

    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?

  • Andy F (unregistered)

    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?

    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.

  • kurkosdr (nodebb) in reply to "Please Don't Shout Lisp" guy

    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.

  • Dereleased (unregistered) in reply to Whosy

    normies

    Try not to cut yourself on all of that edge.

  • Another Anon (unregistered) in reply to kurkosdr

    I believe another language used something other than parentheses to indicate statement nesting.

    Folks still complain about it.

  • Sole Purpose of VIsit (unregistered) in reply to Blerg

    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.

  • Lisp Weenie (unregistered) in reply to kurkosdr

    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.

  • Herby (unregistered)

    So, as shown here, TRWTF is JavaScript. And we all know this!

  • Katastrofa (unregistered)

    "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.

  • I *am* a robot (unregistered)

    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()

  • jgh (unregistered)

    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.

  • El Dorko (unregistered)

    It's so lovely trying to step through something like that ina debugger, sheesh... Keep it very, very simple please.

  • Bert (unregistered) in reply to kurkosdr

    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!

  • Watson (nodebb) in reply to Lisp Weenie

    What it an allusion to languages that indicate nesting with braces, or those that do so with spaces?

  • Patrick (unregistered) in reply to gleemonk

    This reminds me of that joke about asking how to add two numbers on StackOverflow and the response being "use JQuery"...

  • MZH (unregistered) in reply to kurkosdr

    An interesting bit of history from the forums: https://what.thedailywtf.com/topic/21661/rip-java-in-the-enterprise/114

    In short, the current form of LISP was only supposed to be an intermediate representation of the program. There was a more Haskell-like syntax that was abandoned early on. LISP is harder to read and write because the code is literally an abstract syntax tree, which is usually the output of a compiler or preprocessor.

  • urkerab (nodebb) in reply to Whosy

    That's far too long. I prefer the shorter Array.from(Array(99)).forEach((e,i,a)=>{..});

    [...Array(99)].forEach((e,i,a)=>{..});
    
  • Catprog (unregistered) in reply to Bert

    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

  • MaxArt (unregistered) in reply to Whosy

    You can also do Array.from({ length: 99 }).map(...)

    More compact, more meaningful... still worse than a classic for, though.

  • Whosy (unregistered) in reply to urkerab

    Touché

  • Bella (unregistered)

    Also, furthermore, the individual you approach for help might not have the essential assets available to him, subsequently, be not able help you out monetarily. A considerably more secure alternative is apply for a budgetary credit that can give you moment money to bolster any monetary need in the middle of two continuous paydays. Check Cashing

Leave a comment on “Highly Functional”

Log In or post as a guest

Replying to comment #:

« Return to Article