you are viewing a single comment's thread.

view the rest of the comments →

[–]trident765 4 insightful - 2 fun4 insightful - 1 fun5 insightful - 2 fun -  (5 children)

Modern scum seem to derive extreme pleasure from being presented with features that have a very narrow set of applications. The second way may save a few characters of typing in one of the rare cases where the function only needs to be one line, which I imagine is why modern scum love it. They like the idea that there is a designated feature for writing one-line functions.

[–][deleted]  (4 children)

[deleted]

    [–]fschmidt[S] 4 insightful - 2 fun4 insightful - 1 fun5 insightful - 2 fun -  (0 children)

    I missed this and I want to respond to it. First, Javascript is not used primarily as a functional language. Javascript's functions aren't really functions, they are closures. The difference is that closures have state while functional languages are stateless. I would describe Javascript as a table/closure language like Lua and my Luan. Javascript "objects" are misnamed and are really tables (maps). Javascript's object-oriented features have always been a grotesque hack.

    If I want to sum an array in Luan:

    local sum = 0
    for _, v in ipairs(a) do sum = sum + v end
    

    More verbose than:

    local sum = reduce( a, function(x,y) return x+y end )
    

    But the first is clearer to me and is more efficient.

    I haven't followed tech ideas in about 20 year since they are all crap, but I do hear mentions of this asych stuff which I assume is some glorified map-reduce. Anyway, there is no valid reason to handle DB requests this way, they should just be done sequentially (in a civilized multi-threaded language). There are valid use cases for map-reduce like gathering a lot of HTTP requests, but this is rare and so this should be as verbose as possible to make clear what is happening.

    [–][deleted]  (2 children)

    [deleted]

      [–]trident765 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (1 child)

      The functions should just be given names and then async.parallel can be called in a single line.