News for hackers. Stuff that matters.
Re:Functional Programming Jargon by greydius on Sunday July 24, 2016 @12:40PM (#12153745)
I took a (mandatory for cs) class in college that introduced these concepts. For a long time I thought that was a normal part of cs curriculums, but it seems not.

Also, its very strange to see these concepts illustrated with Javascript. I imagine thats something like trying to learn Chinese using the roman alphabet. Not that it can't be done, but a lot of important details are necessarily missing.

Re:Functional Programming Jargon by segmondy on Sunday July 24, 2016 @01:17PM (#12153875)
Your mistake is in thinking that most developers have gone through CS, I do like to wager that we have more developers today without a CS background than those with a CS background. Therefore, things like these are new to them. I actually think that Javascript is a great way to teach these concepts because those developers without CS backgrounds are less likely to be writing lisp or haskell code, and more likely to know Javascript.
Re:Functional Programming Jargon by adamkittelson on Sunday July 24, 2016 @03:48PM (#12154533)
I think that touches on one of the problems with hiring in tech. People tend to think things they learned earlier chronologically are simpler or more fundamental and necessary building blocks in order to be competent at the things they learned later. So we have programmers with CS backgrounds rejecting programmers without who would be perfectly capable of doing a particular programming job because they get tripped up on some algorithm or data-structure quiz that has no relation to what they'd actually be doing on the job (and could be quickly learned if and when it did).
Re:Functional Programming Jargon by chriswarbo on Sunday July 24, 2016 @04:34PM (#12154754)
> People tend to think things they learned earlier chronologically are simpler or more fundamental and necessary building blocks in order to be competent at the things they learned later.

That would explain why C is still so prevalent, as opposed to being 'yet another language from the 70s' ;)

Re:Functional Programming Jargon by pjmlp on Sunday July 24, 2016 @05:48PM (#12155067)
I guess it depends on the country.

On my own, if you don't come from CS or EE background you hardly will get through HR.

Re:Functional Programming Jargon by rankam on Sunday July 24, 2016 @07:35PM (#12155504)
Curious, could I ask the country? I've lived in both the US & UK and would say that the vast majority of companies I've been involved with (via employment or simply interviewing) haven't cared about my degrees, but instead care about what I've worked on in the past and what they perceive I could learn/add to the company.

NB I don't have a CS or EE background.

Re:Functional Programming Jargon by pjmlp on Monday July 25, 2016 @12:19AM (#12156446)
Portugal.

Without a degree very few companies will bother.

In France, Germany and Switzerland one should at very least have a technical experience level and written references from past jobs.

Re:Functional Programming Jargon by eru on Monday July 25, 2016 @01:14AM (#12156595)
It's good we (still) have free-ish movement of labour within the EU. (And closer to the ideal of free in IT than in almost any other sector.)
Re:Functional Programming Jargon by pjmlp on Monday July 25, 2016 @03:02AM (#12156978)
Well, kind of.

There is also the language barrier.

Not many accept working in English, and we had some customers from well known multinationals that only upper management was willing to use it.

Besides the degree, knowing multiple languages and soft skills really helps.

Re:Functional Programming Jargon by seishun on Sunday July 24, 2016 @01:18PM (#12153885)
>I imagine thats something like trying to learn Chinese using the roman alphabet.

So basically, completely normal and reasonable? (see http://languagelog.ldc.upenn.edu/nll/?p=10554)

Re:Functional Programming Jargon by DeadReckoning on Sunday July 24, 2016 @10:22PM (#12156083)
I also found that comment incredibly ironic :P
Re:Functional Programming Jargon by Dr_tldr on Sunday July 24, 2016 @05:54PM (#12155084)
> Also, its very strange to see these concepts illustrated with Javascript. I imagine thats something like trying to learn Chinese using the roman alphabet. Not that it can't be done, but a lot of important details are necessarily missing.

I think you're being sincere in expressing a common attitude within the Lisp/FP community, but it's an unfortunately limiting attitude. It would appear strange to an ancient Sumerian to see the Epic of Gilgamesh translated into English, but the translation is far more accessible and thus far more influential than the original.

I'm a front-end dev and I got into Clojure and Elm because of some books/libraries for functional programming in Javascript. It's doubtful I would've ever had enough interest to learn if no one in those communities made an effort to translate some of their concepts into a language that I already use.

Re:Functional Programming Jargon by wruza on Monday July 25, 2016 @12:16AM (#12156437)
>I'm a front-end dev and I got into Clojure and Elm because of some books/libraries for functional programming in Javascript. It's doubtful I would've ever had enough interest to learn if no one in those communities made an effort to translate some of their concepts into a language that I already use.

That's the way most front-end devs learn new things. People talk about FP attitude here, but it is no-www attitude actually.

Re:Functional Programming Jargon by nchelluri on Sunday July 24, 2016 @11:34PM (#12156313)
> It would appear strange to an ancient Sumerian to see the Epic of Gilgamesh translated into English, but the translation is far more accessible and thus far more influential than the original.

well said!

(i'd have found es5 more accessible still.)

Re:Functional Programming Jargon by vacri on Sunday July 24, 2016 @05:32PM (#12155013)
> I imagine thats something like trying to learn Chinese using the roman alphabet.

Chinese kids learn chinese characters by learning the roman alphabet first. Primary-school kids in China learn pinyin, which then helps them to learn chinese characters.

Re:Functional Programming Jargon by Waterluvian on Sunday July 24, 2016 @01:12PM (#12153843)
JavaScript lends itself really well to functional programming, no?
Re:Functional Programming Jargon by wereHamster on Sunday July 24, 2016 @01:42PM (#12153999)
Not really, no. Example: partial function application does not feel nearly as natural as in in Haskell.
Re:Functional Programming Jargon by altcognito on Sunday July 24, 2016 @01:52PM (#12154033)
The reason they use JavaScript is because it's known by many and the examples can be tried without downloading/having an additional compiler. There are at least two dozen concepts on the list there - the value of illustrating new concepts for some with a known quantity far outweighs the downsides of having to start with a fresh environment.

I will say though for the exact cases you mention, they probably should be clear why this isn't exactly the concept as described.

Re:Functional Programming Jargon by gaius on Sunday July 24, 2016 @01:55PM (#12154043)
Re:Functional Programming Jargon by Waterluvian on Sunday July 24, 2016 @03:31PM (#12154465)
It's definitely no Haskell. But if you wanted to do FP in JavaScript, it wouldn't be a painful ordeal, no? Well, ES6 and newer at least.
Re:Functional Programming Jargon by catnaroek on Sunday July 24, 2016 @05:34PM (#12155018)
Functional programming puts the static structure of a program at the forefront: types, invariants, equations relating inputs and outputs of processes, etc. JavaScript doesn't do this very well. In fact, even C++ does it better than JavaScript. Nobody would in their reasonable mind call C++ a functional language, right?
Re:Functional Programming Jargon by justinhj on Sunday July 24, 2016 @10:05PM (#12156024)
In Javascript functions are first class objects, there are closures, and higher order functions. Having a garbage collector makes it easier to implement persistent data structures. I've always thought that despite it's weird corners it's actually a powerful and flexible language. You can see that in the article, because in just a handful of lines of code it is able to express all of these ideas in an accessible way. I'd be interested to see a C++ version of this.
Re:Functional Programming Jargon by catnaroek on Sunday July 24, 2016 @10:37PM (#12156122)
> functions are first class objects

Programming languages have procedures, not functions. (Yes, even Haskell. Consider the possibility of divergence.) Functional programming is a style that:

(0) Emphasizes values over physical object identities.

(1) Emphasizes procedures that compute functions - mappings from values from a domain, into values from a codomain.

(2) Discourages distinguishing between procedures that compute the same function.

Functional languages are languages that facilitate and encourage functional programming. Does JavaScript? IMO, it doesn't even do (0) very well, which is a precondition for discussing whether it does (1) or (2) well.

> garbage collector, persistent data structures

Don't conflate “purely functional” with “persistent”. Purely functional programming can deal with ephemeral data structures just fine - using substructural types. In the other direction, there exist persistent data structures whose implementation internally uses imperative assignment.

> powerful and flexible

Those are desirable qualities in a language, but they are orthogonal to whether the language supports functional programming.

> express all of these ideas in an accessible way

JavaScript doesn't even make it easy to talk about structurally equal values. Since everything is mutable, the only notion of equality that the language will actually respect is equality of physical object identities.

Without the ability to talk (soundly) about structural value equality, you can't formulate algebraic laws (e.g., the monoid or group laws), which is the basis for equational reasoning - one of the key benefits of programming in a functional style!

Re:Functional Programming Jargon by drewgross on Sunday July 24, 2016 @11:05PM (#12156213)
You can have weakly/dynamically typed functional languages (most lisps for example) just like you can have strongly/statically typed procedural or OO languages, like Fortran or C++.

Haskell the language also knows nothing at all about invariants, and the language will happily let you make something a Monad even if it doesn't obey the right laws. The culture and libraries of course take invariants quite seriously, but some aspects of the Javascript culture also take invariants quite seriously, like Promises for example.

Re:Functional Programming Jargon by catnaroek on Sunday July 24, 2016 @11:19PM (#12156258)
> You can have weakly/dynamically typed functional languages (most lisps for example)

I would call Racket a functional language. Common Lisp? Nope.

> Haskell the language also knows nothing at all about invariants

I'm aware. But I'm not talking about mechanically enforcing equational laws. I'm talking about the ability to state them in the first place. For this, you need a sufficiently rich value language, where, for example, the list [1,2,3] is always the list [1,2,3] regardless of where it resides in memory.

In JavaScript, [1,2,3] isn't a list. It's an expression that, when evaluated, constructs an object whose initial value is one particular list, but its value at another point in time might be a different list. Furthermore, if you evaluate [1,2,3] twice, you get completely different objects. Although the objects are first-class, the list values aren't, so you can't (soundly) formulate any equational laws about lists. And object identities have an equational theory so weak (“everything is equal to itself and nothing else”) that it's completely useless.

Re:Functional Programming Jargon by clarus on Monday July 25, 2016 @02:39AM (#12156882)
I think in any cases you will have to define your notion of equality in the mathematical language you use. Indeed, even in Haskell, the equality operator returns a Haskell boolean but not a proposition, and cannot cope with equality on functions (I guess).
Re:Functional Programming Jargon by catnaroek on Monday July 25, 2016 @03:06AM (#12156991)
> I think in any cases you will have to define your notion of equality in the mathematical language you use.

The point is that I can reason about equality of ML and Haskell expressions in ML and Haskell themselves, with a few minor extensions (e.g., the usual laws of arithmetic, applied to pure `int` expressions), whereas reasoning about equivalence of JavaScript programs requires carrying out the entire reasoning process in a separate metalanguage. The latter is obviously far more tedious, which is why programmers have largely given up on actually reasoning about JavaScript programs, preferring testing as an alternative.

> Indeed, even in Haskell, the equality operator returns a Haskell boolean but not a proposition,

Equality testing (a runtime operation, only valid for types with decidable equality) is different from propositional equality (a type constructor on its own, which can be used on any type). See https://existentialtype.wordpress.com/2011/03/15/boolean-bli... for details. Haskell doesn't have a propositional equality type constructor.

> and cannot cope with equality on functions (I guess).

Indeed, and, in any higher-order language, this is a feature, not a bug.

Re:Functional Programming Jargon by clarus on Monday July 25, 2016 @04:38AM (#12157274)
> whereas reasoning about equivalence of JavaScript programs requires carrying out the entire reasoning process in a separate metalanguage

I do not see how you can reason about Haskell in Haskell either, as this is a programming language and not a proof language (maybe I am missing something?).

> Haskell doesn't have a propositional equality type constructor.

This is what I meant. Since with both Haskell and JavaScript you will need to define a propositional equality, in my experience this does not help that much to have a better decidable equality.

Re:Functional Programming Jargon by catnaroek on Monday July 25, 2016 @10:14AM (#12158789)
> I do not see how you can reason about Haskell in Haskell either, as this is a programming language and not a proof language (maybe I am missing something?).

http://www.haskellforall.com/2013/12/equational-reasoning.ht...

http://www.haskellforall.com/2014/07/equational-reasoning-at...

The reasoning is entirely carried out by replacing Haskell expressions with contextually equivalent ones.

> Since with both Haskell and JavaScript you will need to define a propositional equality

No, you need much more than a propositional equality to be able to reason about JavaScript programs. If you try to use Haskell-style equational reasoning on JavaScript objects, you can only pick between your reasoning being trivial (because every object reference is only equal to references to physically the same object) or unsound! So if you want a more useful notion of program equivalence, you'll have to use a separate logic (e.g. Hoare logic) or axiomatic system (e.g. Dijkstra's predicate transformer semantics) for reasoning about imperative programs.

Re:Functional Programming Jargon by DeadReckoning on Sunday July 24, 2016 @10:32PM (#12156105)
It is by far the best mainstream language for functional programming.
Re:Functional Programming Jargon by keithnz on Sunday July 24, 2016 @06:02PM (#12155112)
yes, I think it does, it's not a pure functional language so you can break out of functional programming easily ( and accidentally ). But nothing really stops you from doing FP or playing with FP concepts. There's some nice core FP libraries like Ramda for JS. Also we are seeing more and more application libraries that are taking a more functional approach. Could they have used a specific functional programming language? sure... But, I think that might of missed the target audience. Most haskell / lisp / Ocaml / etc etc programmer would be comfortable with these terms already.
Re:Functional Programming Jargon by palunon on Sunday July 24, 2016 @07:27PM (#12155458)
Once you get far enough with template metaprogramming, C++ start to look like a slow version of Haskell with horrible syntax and cryptic error messages...
Re:Functional Programming Jargon by bjz_ on Sunday July 24, 2016 @07:03PM (#12155370)
> For a long time I thought that was a normal part of cs curriculums, but it seems not.

Alas, not all CS programs are created equal. Many skip entirely over FP because it isn't 'what the industry does'.

Re:Functional Programming Jargon by GFK_of_xmaspast on Sunday July 24, 2016 @12:49PM (#12153779)
Pinyin is a thing that exists tho?
Re:Functional Programming Jargon by whorleater on Sunday July 24, 2016 @03:27PM (#12154444)
Pinyin's existence is as a stepping stone, and misses out on a lot of interplay between words. Pinyin negates how you can separate Chinese characters into different symbols, such as the Chinese character '鮮' ('xiān' in pinyin), is the combination of '魚' ('yú') and '羊' ('yáng'). It's certainly not impossible to learn Chinese through pinyin, but it would be an odd choice.
Re:Functional Programming Jargon by DeadReckoning on Sunday July 24, 2016 @10:08PM (#12156035)
It's not an odd choice. I've never heard of anyone learning Chinese as a second language who doesn't use pinyin at least for the first few years.
Re:Functional Programming Jargon by GFK_of_xmaspast on Sunday July 24, 2016 @10:47PM (#12156145)
I'm not convinced that there are enough hanzi that decompose nicely like that to make up for all the other issues.
Re:Functional Programming Jargon by 208Gi on Sunday July 24, 2016 @04:51PM (#12154832)
Pinyin doesn't negate Chinese characters. It's just tackling another issue - sounds and tones.
Re:Functional Programming Jargon by wereHamster on Sunday July 24, 2016 @12:54PM (#12153788)
> Also, its very strange to see these concepts illustrated with Javascript.

Indeed.

And I don't like it at all. It seems as if everybody is afraid that web developers won't understand the concepts if they are expressed with mathematical symbols instead of JavaScript functions.

Re:Functional Programming Jargon by Waterluvian on Sunday July 24, 2016 @01:14PM (#12153854)
Honestly I want both. The mathematical expressions, and an implementation in any language. I never took math in university and am woefully deficient. But the past few years proved to me that I'm 100% capable of learning the concepts.

I just really sorely need examples in a syntax I understand.

Re:Functional Programming Jargon by wereHamster on Sunday July 24, 2016 @01:30PM (#12153955)
Syntax is easy to learn if you know the mathematical concepts. The other way around... not so much.
Re:Functional Programming Jargon by k__ on Sunday July 24, 2016 @03:42PM (#12154506)
all those symbols in haskell aren't really helping, even if the syntax is easy to learn...
Re:Functional Programming Jargon by eru on Monday July 25, 2016 @01:22AM (#12156634)
Most of the funky symbols in Haskell are library defined operators. You can define your own in a single line of code. They behave just like functions, just with an infix syntax by default, instead of prefix.

You can use Hoogle (eg https://www.stackage.org/lts-6.9/hoogle?q=%3E%3E%3D) to look them up.

It's a bit daunting at first. But most code actually only uses operators from at most a few libraries. Once you understand Monoid, Applicatives and Monads and their operators, you'll be doing OK.

There are alphabetic names for their operators. But they are not used much---working programmers prefer the symbols. Alas, learning wouldn't be much easier with them either, because most of the work is in understanding the concepts. People would complain just as much about the cryptic names as about the cryptic symbols.

(The only mainstream library that really goes crazy with the symbols is 'lens'.)

Re:Functional Programming Jargon by k__ on Monday July 25, 2016 @05:01AM (#12157352)
hm maybe you're right.

I saw one of the problems was, that I had higher math in German and some translations aren't straight forward (monoid -> halbgruppe) so I often thought things I knew were entirely new concepts.

Re:Functional Programming Jargon by eru on Monday July 25, 2016 @07:41AM (#12157952)
Oh, if you had some higher math you are already ahead of the game. (I did the same, but I got lucky and had heard of Monoide even in German.)

Yes, it's a bit of a shame that some things are so abstract that we can really give it good names. For example, the operation in the monoid is just any old operation that's associative. What name do you want to call that? I don't see anything that improves on the little Kringel that we make on the black-board, or the <> that Haskell uses.