News for hackers. Stuff that matters.
Re:Advantages of Functional Programming in Java 8 by jerven on Tuesday September 06, 2016 @08:15AM (#12435371)
So Lisp is not a functional language...
Re:Advantages of Functional Programming in Java 8 by bad_user on Tuesday September 06, 2016 @12:17PM (#12437076)
Technically speaking, Common Lisp isn't a functional language, yes. Common Lisp is a multi paradigm language and you can do FP with it if you want. But from my very limited experience with it, it's not the norm.

However Lisp, the original, is based on the lambda calculus and that is very much about functional programming. So surely you can do FP with most Lisps, but whether that's the norm or not is another question.

Re:Advantages of Functional Programming in Java 8 by baldfat on Tuesday September 06, 2016 @08:21AM (#12435401)
So R isn't a functional language...

To be fair the vast majority of people would say that it isn't BUT hidden inside is a very Scheme inspired system that can make pretty functional programs.

http://link.springer.com/chapter/10.1007%2F978-3-642-40447-4...

Re:Advantages of Functional Programming in Java 8 by catnaroek on Tuesday September 06, 2016 @09:00AM (#12435626)
Scheme isn't a very good functional programming language either. Even cons cells are mutable objects with identity: just use eq? everywhere instead of equal?, and use set-car! and set-cdr! instead of creating new cons cells, and you're back to JavaScript.

---

Sorry, can't reply properly, I'm “submitting too fast”.

<ignore>I understand neither the form nor the content of your objection. Is Scheme a programming language? Yes. What does this have to do with whether it supports functional programming reasonably well?</ignore>

Scheme is a higher-order programming language: procedures are first-class objects whose identities can be bound to variables just like any other value. I'm not sure about calling it “functional”, though: the type of procedures isn't fully abstract, because you can query the physical distinction between two procedures that have the same behavior when called. In other words, in Scheme, procedures are objects, but they are not values.

Re:Advantages of Functional Programming in Java 8 by baldfat on Tuesday September 06, 2016 @09:23AM (#12435787)
Scheme is a functional programming language yes?

Sorry but I am an old timer and seeing people blast the paths that led us to where we are is very frustrating to me.

Edit added is a functional

Re:Advantages of Functional Programming in Java 8 by catnaroek on Tuesday September 06, 2016 @08:21AM (#12435398)
Most things in Lisp have an object identity that can be directly manipulated by programmers, so it is indeed not a functional language.
Re:Advantages of Functional Programming in Java 8 by baldfat on Tuesday September 06, 2016 @08:34AM (#12435473)
Technically you are defining a purely functional language and not functional programming.

John McCarthy might disagree with you if he was still with us saying LISP is not a functional language. Here is a great summary of his "Recursive Functions of Symbolic Expressions and Their Computation by Machine" https://swizec.com/blog/the-birth-of-lisp-a-summary-of-john-...

I really think we need a definition of functional programing language. I feel that many just see Haskell and other "pure" functional languages as the only functional programming language when I really don't see that is the point (Also Haskell isn't very pure looking at Monads)

Personal Definition. If you can program in a functional manner and it looks and feel good then it is.

R - More then just this reason but yes JavaScript - Sort of but I would say no if my arm was twisted behind my arm Racket / LISP - Absolutely Python - NO WAY First Class Functions alone don't make a functional language

Re:Advantages of Functional Programming in Java 8 by catnaroek on Tuesday September 06, 2016 @08:35AM (#12435480)
> Technically you are defining a purely functional language and not functional programming.

No, I'm not defining a purely functional language. ML-family languages (Standard ML, OCaml) aren't purely functional, but they have arbitrary compound values, the physical identity of whose in-memory representation is inaccessible - not a part of the abstraction the programmer is shown. And, FWIW, I only call Haskell “almost purely functional”, because divergence is a kind of effect that its type system doesn't track.

In any case, a function is a mapping from values to values, so a decent treatment of a rich collection of values (including compound values) is a prerequisite for a language to be considered “functional”.

> I really think we need a definition of functional programing language.

Here's a very simple definition: A functional language is a value-oriented language with an abstract type of functions, which can only be distinguished from one another up to extensional equality.

> (Also Haskell isn't very pure looking at Monads)

Monads (resp. monad transformers) can be used to embed the abstract syntax of an effectful language into a pure (resp. less effectful) language. That isn't news to anyone.

> Personal Definition. If you can program in a functional manner and it looks and feel good then it is.

I have no idea what you mean by “program in a functional manner”, but, when I do functional programming, I expect to be able to formally reason about my programs without reaching for Hoare logic, which is an insanely complex beast.

Re:Advantages of Functional Programming in Java 8 by bad_user on Tuesday September 06, 2016 @12:24PM (#12437148)
> I really think we need a definition of functional programing language. I feel that many just see Haskell and other "pure" functional languages as the only functional programming language when I really don't see that is the point (Also Haskell isn't very pure looking at Monads)

I consider FP languages to be those that actively encourage an FP style. We live in a pragmatic world with limits, many times we need to work around those limits and working with totally pure code where side effects are modeled by means of monads is sometimes limiting. However, in FP languages the FP style should be considered the default and breaking out of that style should be done for optimization reasons.

The set of features required is not that big. Of course, for static languages, it would be nice if the language had some form of type classes and higher-kinded types, because that goes well with parametric polymorphism, which blends well with FP. But actually, you can't name a certain feature, other than having first class functions maybe. But the community and the available libraries need to encourage a preponderantly FP style.

I can't say exactly what languages are like this, but I can say that Java does not and it never will.

Re:Advantages of Functional Programming in Java 8 by catnaroek on Wednesday September 07, 2016 @08:12AM (#12442662)
Higher-kinded types aren't an absolute necessity, and, in fact, they force you to pick between modularity (abstract types) and type inference: https://news.ycombinator.com/item?id=12331926 . Not a very pleasant choice, a programmer normally wants both.
Re:Advantages of Functional Programming in Java 8 by bad_user on Wednesday September 07, 2016 @02:06PM (#12445616)
Yes, I already said they aren't a necessity, though many people like having higher-kinded types. But then ML/Ocaml folks seem to be doing fine without. I personally prefer having HKT because you can then neatly express well known type-classes for implementing functors, applicatives, monads and many others.
Re:Advantages of Functional Programming in Java 8 by catnaroek on Wednesday September 07, 2016 @02:12PM (#12445660)
You can recover the power of higher-kinded types with higher-order functors (in the ML sense), without sacrificing the compatibility of abstract types and type inference in the core language.

On the other hand, Haskell's type inference algorithm is simply incompatible with abstract types.

Re:Advantages of Functional Programming in Java 8 by tome on Thursday September 08, 2016 @03:21AM (#12450932)
I didn't fully understand your explanation last time. Can you give an example of the conflict between modularity and type inference with HKTs in Haskell?
Re:Advantages of Functional Programming in Java 8 by baldfat on Wednesday September 07, 2016 @07:49AM (#12442508)
I can say that surpisingly R (The fastest growing language with a TON of hate for its warts) is the closest I have seen for your description. Though it really is not a general purpose language.

The closest general purpose language I have been exposed to that fits your description is Racket. Based off of Scheme and has the ability to really make your own language from it, but also has pragmatic pieces to get things done.

Love your definition: However, in FP languages the FP style should be considered the default and breaking out of that style should be done for optimization reasons.

Re:Advantages of Functional Programming in Java 8 by willtim on Wednesday September 07, 2016 @06:15AM (#12442060)
Programming with Monads, e.g. the IO Monad, is pure functional programming. It is a common misconception that it isn't. You have full referential transparency and sound composition, since no effects are actually performed until the computation is run/interpreted.