News for hackers. Stuff that matters.
Re:Javascript Arrays and Functional Programming by arkadiytehgraet on Thursday August 03, 2017 @09:10AM (#14919190)
TL;DR author provides an example of map, filter and reduce functions in JS.

I have been wondering lately what is the value of articles like this. They do not convey any meaningful idea, they do not offer any useful insight on underlying matters; why do people even write something like this, except to litter the Internet even more? Anyone, who is distinctly familiar with functional programming or even just with the concept of higher order functions, surely knows those three basic primitives; those, who are not, would benefit much more from the basic concepts of first-class functions etc, than this random abrupt post.

Re:Javascript Arrays and Functional Programming by acdha on Thursday August 03, 2017 @09:50AM (#14919531)
Someone on the internet wrote something but you don't like it. The appropriate reaction is to be quiet and go read something else.

Slagging the author for giving something to the world for free doesn't help anyone and it's almost certainly going to discourage the sharing which everyone on the internet has benefited from.

Re:Javascript Arrays and Functional Programming by Blackstone4 on Thursday August 03, 2017 @09:18AM (#14919243)
From my comment below: "Thank you for this! I've been learning JS for React and .reduce, .every and .some are new to me! Super helpful"

I feel like learning is always easier in smaller bitesizes and the person wrote something very clear and digestible. Sounds like it wasn't aimed at more advanced programmers like yourself

Re:Javascript Arrays and Functional Programming by such_a_casual on Thursday August 03, 2017 @09:46AM (#14919500)
The blog post has tremendous value to the right audience, no doubt about that. But it's worse than worthless for its actual target audience because the article makes those people feel like they're supposed to get it, and they probably feel shitty when they don't (I did). Even though they shouldn't. No one expects you to read that blog post and get it if you've never used Map or Reduce before. It's misleading and disheartening to the target audience. It's a pretty easy fix. Just change who you're talking to.
Re:Javascript Arrays and Functional Programming by brudgers on Thursday August 03, 2017 @12:01PM (#14920718)
When I discovered Array.map, I already knew about map/filter/reduce. The reason it was a discovery is that the bulk of Javascript resources used for(){} loops and in those few places where map/filter/reduce were used, many implemented map/filter/reduce as library functions because Array.map etc were not always part of Javascript...I think Mozilla added them at some point based on how I found out about them.
Re:Javascript Arrays and Functional Programming by kaishiro on Thursday August 03, 2017 @09:35AM (#14919392)
Man, I had just worked up the nerve to start a personal dev blog but you've just scared me straight off.
Re:Javascript Arrays and Functional Programming by mattferderer on Thursday August 03, 2017 @09:51AM (#14919537)
I highly encourage you to start a blog for yourself, not for any assumed audience. You'll gain important skills.

* Better understanding the topic by trying to re-teach it

* Improve writing skills. Programming is basically writing but with even crazier grammar freaks.

* Employers interested in possibly hiring you will have a better idea of what you know & enjoy

* Provide yourself (and possibly your company) with documentation for the future.

Lastly if you need encouragement by someone more established than me, here's Troy Hunt at NDC Oslo 2017 - https://www.youtube.com/watch?v=-MUhcgXBj_A

Re:Javascript Arrays and Functional Programming by bshimmin on Thursday August 03, 2017 @09:41AM (#14919461)
You should do it, even if it's just for your own benefit!

(It's unlikely it'll benefit arkadiytehgraet, but he probably finds that with a great many things.)

Re:Javascript Arrays and Functional Programming by jarrettch on Thursday August 03, 2017 @03:23PM (#14922888)
Don't let this scare you.

When I first started learning this stuff, I started a blog. I made maybe 3 posts before giving up on it, thinking about how much I didn't know, how that everything I could write about at the time was probably covered elsewhere and better, etc.

Several years later I regret giving up.

A lot of writing is writing for yourself. Obvious benefits to that, one of which is hopefully you get better at communication, which is huge in life in general, not just a career as a dev on a team.

Another is learning through teaching or keeping a record. I've probably forgotten a bunch of things over the years that, had I written them in my blog I may remember, or at least know where to find the post instead of scouring the internet looking for another post by someone else that I used to helped me solve a problem.

Potential employers may like seeing a blog as well. You can tell someone you're passionate about x, but where's the proof of that passion? It may not be the most in depth blog like Dr. Axel Rauschmeyer's, but it'll still show what you know. And you never know who's reading, so you may help someone in the process.

The internet is already filled with "litter" or useless things. But if you're getting use out of it then that's the main point to focus on.

Re:Javascript Arrays and Functional Programming by lgas on Thursday August 03, 2017 @09:43AM (#14919475)
Who cares what other people think? Do what you want.
Re:Javascript Arrays and Functional Programming by arkadiytehgraet on Thursday August 03, 2017 @10:23AM (#14919813)
I have wanted to start a personal dev blog myself for quite a while, but each time I think of a suitable topic, I immediately recall an article or a post that is already better than anything I could write myself on the matter.

If you think you have something valuable or interesting or just funny to share, that either was never discussed or written about or you know you can do better, then you absolutely should blog about it and do not let haters like me stop you.

As for the original article:

* It should have been named just "JavaScript arrays and higher-order functions" (I get that using term functional programming is very catchy nowadays, but I am trying to talk about quality here, not clickbaitness)

* As it is aimed for people unfamiliar with the concept and coming from more imperative background, where first-class functions are either not present or not that popular or handy to work with, an introduction (even the most gentle one) would be very suitable

* Then the introduction of filter/map/reduce functions would be in place, ideally compared in place with imperative implementation of the same task

* The best way to make sure a reader understands how each of this functions works is to make them implement each one of them, even the naive implementation would suffice

* Finally, you could provide some reasonably unobvious usages of any of the functions, e.g. insertion sort done with fold-only.

Re:Javascript Arrays and Functional Programming by Can_Not on Friday August 04, 2017 @09:25AM (#14928465)
> I have wanted to start a personal dev blog myself for quite a while, but each time I think of a suitable topic, I immediately recall an article or a post that is already better than anything I could write myself on the matter.

Sounds like you should be curating a list.

Re:Javascript Arrays and Functional Programming by pryelluw on Thursday August 03, 2017 @09:41AM (#14919457)
Dont let idiots scare you away. Go ahead and do it. If you meed help ping me (check profile).
Re:Javascript Arrays and Functional Programming by nxsynonym on Thursday August 03, 2017 @09:18AM (#14919241)
While it may not be valuable to the vast majority of people, it was probably valuable to the author at least.

The article is not ground breaking or even front page worthy, but that doesn't mean it's the litter of the Internet. At absolute worst it's an exercise in thinking about a subject and trying to explain it to others.

Re:Javascript Arrays and Functional Programming by brudgers on Thursday August 03, 2017 @09:29AM (#14919337)
The future is already here -- it's just not very evenly distributed.

When I first started reading Hacker News, I had never heard of functional programming...or Python.

Re:Javascript Arrays and Functional Programming by johnstew on Thursday August 03, 2017 @10:22AM (#14919811)
I'm not sure why you feel the need to bash this person. If you already know the concepts then go read something else. Instead you took the time to write this shitty comment.

This may not provide value to you and thats completely fine. This does however provide a lot of value to the author and to others.

Writing technical thoughts in a way that is simple and understandable is a skill and I think this author did a great job of that.

Also its the internet I can write posts for myself all day long and guess what? Ain't shit you can do about it. I'll keep littering the internet with these "random abrupt posts".

Re:Javascript Arrays and Functional Programming by roboguy12 on Thursday August 03, 2017 @11:57AM (#14920676)
Here's an example of why it's useful for me to see articles like this on HN. I'm an engineering manager, and someone on my team recently joined who wasn't very familiar with these more functional styles. I offered to explain to him benefits of declarative styles like this vs imperative, but he said he learned better by reading. He asked if I had any articles that I'd recommend about the topic, and since I've seen this, I'll send it his way.
Re:Javascript Arrays and Functional Programming by yen223 on Thursday August 03, 2017 @10:55AM (#14920089)
What's the value of comments like this?
Re:Javascript Arrays and Functional Programming by cx1000 on Thursday August 03, 2017 @10:53AM (#14920067)
And yet here it is, upvoted, clicked, and commented on by enough people to make it to the front page of a highly competitive news aggregator. It's easy to forget what it's like to not know something I guess, but clearly there are enough beginners still out there who find this type of post useful.
Re:Javascript Arrays and Functional Programming by such_a_casual on Thursday August 03, 2017 @09:38AM (#14919427)
I'm sorry to say that I completely agree. As a "here's how you do X in javascript" this is a great post. However, the conclusion clearly shows that this post was not aimed at people who already know how to use map and reduce: "Functional programming is a great tool and will drastically improve your productivity...."

It's like someone showing you multiplication and saying. See look how useful it is! See look how simple and easy it is to understand! I still don't know multiplication, or even addition for that matter.

Map and reduce are things you build up to by doing recursive functions over and over again. They are not something you learn from reading an article. Just like you can't read an article and suddenly know how to solve problems with long division.