News for hackers. Stuff that matters.
Re:What's worked in Computer Science (2015) by fhood on Wednesday November 29, 2017 @10:12AM (#15807334)
Well for comparison, GC was a yes right. And basically every popular (modern) language incorporates garbage collection. Functional programming, or at least fairly strict functional programming, still hasn't really caught on. Of the juggernaut languages, C/C++, python, Ruby, Java, JavaScript none are truly functional (I don't use JavaScript but the code I have seen in it doesn't often look functional). Until something like Scala cracks the top 5 I agree with calling it a maybe.
Re:What's worked in Computer Science (2015) by paulddraper on Wednesday November 29, 2017 @11:04AM (#15807821)
What makes Scala decidedly functional and JavaScript or Ruby not?
Re:What's worked in Computer Science (2015) by SatvikBeri on Wednesday November 29, 2017 @11:54AM (#15808348)
I don't think there's any one knock-down criterion, but there are several small things that add up:

-Scala was intended to have strong FP and OO support from day 1

-Scala has very strong support for immutable values and persistent data structures. It's hard to do FP efficiently without these

-Similarly, Scala has built in support for laziness to a significantly greater extent than most languages. This is arguably important because it supports immutability, there are some important mutable algorithms that have no efficient immutable equivalent without laziness

-Strong lambdas (unlike, e.g., Python)

-Many of the major Scala libraries are either written in a heavily functional style or support highly functional APIs, while libraries in most languages do not

Re:What's worked in Computer Science (2015) by charlysl on Wednesday November 29, 2017 @12:12PM (#15808580)
Interesting points well put, thank you.
Re:What's worked in Computer Science (2015) by mateo411 on Wednesday November 29, 2017 @04:48PM (#15811166)
What is a strong lambda?
Re:What's worked in Computer Science (2015) by SatvikBeri on Wednesday November 29, 2017 @09:53PM (#15813091)
Not a standard term – I'm just referring to the ability to do anything in a lambda that you can do in the body of a function, such as defining intermediate values, which is not possible in Python.
Re:What's worked in Computer Science (2015) by zjarek_s on Thursday November 30, 2017 @01:37PM (#15818260)
I think this is nitpicking. In python you can do everything you want in inner functions, they just have to be named. Additionaly there is simple syntax for single expressions, that don't need names. Lack of TCO is a lot bigger obstacle to using more functional style
Re:What's worked in Computer Science (2015) by jerf on Wednesday November 29, 2017 @12:41PM (#15808966)
Also interesting in addition to the other fine replies is that Javascript qua Javascript hasn't actually moved all that much in the past 15 years, and in 2002 JS would definitely not have been a "functional language".

I'd say it's a language whose issues are sometimes something that FP is best at papering over, but as an FP language, it is quite lacking if you're used to something like Haskell, Erlang, or Lisp. I actually put it in the category of OO-FP languages, languages that have a lot of the FP constructs (especially from when Lisp was the epitome of FP) but are primarily object-oriented languages. It's a pretty decent paradigm, but it really ought to be distinguished from FP languages where there are no OO features in them at all, or much more rarely, where they are clearly second-class.

Re:What's worked in Computer Science (2015) by leshow on Wednesday November 29, 2017 @03:24PM (#15810510)
JS had first class functions from the beginning, which I think is one of the major things necessary for FP. Compare that with a language like Java, which did not, and I think still doesn't (lambda's aren't quite the same).

JS doesn't really support traditional inheritance either, so describing it as OO seems odd to me.

Re:What's worked in Computer Science (2015) by jerf on Thursday November 30, 2017 @09:11AM (#15815782)
I consider anything that binds data to methods and has a concept of "data.method()" to be OO. In the OO religion I'm an ecumenicist.

And even within my ecumenicalism, I consider inheritance in the strictly C++/Java sense of relatively little importance, and dropping. Rather than being essential, it turns out to have been accidental, and also arguably a mistake, even on purely OO grounds.

Re:What's worked in Computer Science (2015) by leshow on Friday December 08, 2017 @04:11PM (#15882073)
That's a silly distinction. It's also wrong. Rust 'binds data to methods and has a concept of "data.method()"' and is not OO by any meaningful definition. It's simply sugar for Trait::method(&data).
Re:What's worked in Computer Science (2015) by fhood on Wednesday November 29, 2017 @11:13AM (#15807906)
Well, the first listed paradigm for Scala on wikipedia is functional, JavaScript and Ruby both have OO followed by imperative. And anyways supporting functional programming and being designed for it are not the same thing. Yeah, I can right functional Ruby, but that isn't going to be by initial inclination when writing a Ruby script. It would be for Scala.
Re:What's worked in Computer Science (2015) by charlysl on Wednesday November 29, 2017 @11:42AM (#15808189)
Sure, this is what I meant by natural.

Just one thing: when you write that Ruby script, could one of the reasons why you don't use a FP style be not only that maybe it wouldn't be natural to do so in Ruby, but also that it's unsuitable for the kind of problem you are trying to solve with that script to begin with?

I mention this, because I have the impression that people tend to believe that to solve a programming problem you should use whatever paradigm is perceived as the main one for the language at hand. However, I believe that it's the problem that should dictate the paradigm.

Re:What's worked in Computer Science (2015) by fhood on Wednesday November 29, 2017 @01:01PM (#15809152)
I agree in principle, but rather than the problem dictating the paradigm, I would say it usually dictates the language. If a problem is well suited to a functional implementation then I'll probably break out Scala to solve it.
Re:What's worked in Computer Science (2015) by charlysl on Wednesday November 29, 2017 @09:11PM (#15812880)
I agree, that would be the right to do.

But the thing is, what if you are stuck with a given language, and/or its a biggish complex project where different aspects are better solved with different paradigms?

Re:What's worked in Computer Science (2015) by charlysl on Wednesday November 29, 2017 @11:09AM (#15807879)
JavaScript and Ruby are functional too. Scala supports other paradigms than FP too. They are all multi-paradigm. The difference is that certain programming styles might be more natural in some languages than in others.