Functional programming

Is functional programming the next big thing?
Between Haskell, OCaml and a Lisp, which one is worth learning?

Other urls found in this thread:

elm-lang.org/blog/farewell-to-frp
twitter.com/NSFWRedditVideo

no
logic programming is
check the tiobe index
fp is neat and definitely something of value, but the more you look into it the more you find out that a majority of the benefits show up at a point that's basically just imperative programming with functional abstractions.

All of them?

But lisp is trash.
Go OCaml then try a few times to learn Haskell.

>logic programming
Prolog?
>All of them
I mean relatively to their real-world applications.
I know OCaml is used in finance. Not sure about Lisp or Haskell.
I'm interested in Lisp though because I've heard of its syntactic "minimalism" and it seems very interesting.

I think most programming languages that people actively discuss are worth screwing around with for a few hours, FWIW.

Lots of great programmers respect Haskell and Lisp, and not because they're used heavily. Very strict static typing and learning to write stuff without side effects is really neat. So is the homoiconicity of lisp.

Just play around with them and if you feel it, make something cool!

Probably not the "next big thing" considering these have been around forever. People are rediscovering static typing though, just look at typescript.

>Probably not the "next big thing" considering these have been around forever
Sure, but ML is starting to take off.

Bump

No
As a person who worked in a company where FP was used actively.
Development time was incredibly slow with most of our good programmers debating for hours on end how a 4 line function should be written.
Worse even being that introducing a new developer to our code base would take weeks if he/she was decent at the language at hand.

Not to speak of the horrific pain if one of those functions needed to change or god help you if you needed to refactor something.

After 1 whole year of this the CEO had enough of it because the development speed was so slow and hiring standards got to insane levels.

>junior position
> 3 years Haskell expirience
> masters in CS
> Must be currently employed
>1 year building enterprise level code
> capable of doing full stack aswell
>must be willing to spend 9+ hours a week on company projects in spare time.

After the CEO said no, the CTO and 5 others were fired.
Now they run on C++ and things are running smoothly from what i heard.

How do places like Jane Street manage to use it (very) effectively? There must've been something you guys were missing.

Money.
If you can pay for enough good functional programmers, sure it will work out in some way because you can elevate slow development time by having a large amount of programmers.

The company i worked at simply didn't have the money to afford that number of programmers to make it worth while.

And as functional programmers tend to be a bit full of themselves, they could affort 3 c++ developers at senior level for 1 medior haskell developer.

>I'm interested in Lisp though because I've heard of its syntactic "minimalism" and it seems very interesting.

Lisp is definitely interesting and fun.
As a suggestion, try a more FP oriented lisp (like Scheme or Clojure).

That implies that they would make the choice of using FP despite it being sub optimal. Yet JS allegedly has very good results with OCaml.
>pay enough for good functional programmers
As far as I know, they don't require their developers to have experience with OCaml specifically, or even FP (as stated on their interviews blog). As for the number of programmers, less than 500 people work for them worldwide and most of them are researchers, not programmers.
Of course JS might just be an outlier, but even then it's an example of FP being used in a successful company.
>functional programmers tend to be a bit full of themselves
Is there a reason for this?
Is Common Lisp less pure than Scheme?

>Must spend 9+ hours a week working in your spare time.

What the fuck? Isn't this egregiously retarded?

>Is Common Lisp less pure than Scheme?

Well, all lisps are technically impure.

The thing is, it's very easy to write imperative code in CommonLisp.

You'll definitely find yourself writing more FP in Scheme and Clojure.

>which one is worth learning?
Idris

>all lisps are technically impure.
Is Haskell the only truly pure functional language?
Is it impossible to program imperatively in Haskell?

>Is Haskell the only truly pure functional language?

Well no, there are others, such as Idris.
But, Haskell is the only one that is known by more people than the author and his pals.

Best logo in the history of tech.

That's not the Knights of the Lambda Calculus

If you learn a Lisp, learn Clojure. F# is worth. Haskell is good for learning core concepts, but I wouldn't spend all day in a production environment fighting it.

What are some actual fields that make heavy use of functional programming anyway?
Even machine learning uses mostly C++ and Python.

>is there a reason for this
As FP requires a lot more thinking about code than actually writing it, thus making them think that they are up there with people like mathematicians and the like, and will demand to be paid like them.

CS probably

CS is vast. That's like saying "engineering".

>Prolog?
FUCK
PROLOG
SHIT
HNNFPPFFF

What's wrong with it?
I don't know much about declarative languages. But Prolog seems to be popular in AI.

>What's wrong with it?
that my assignments are due Aug. 20 and I'm not even 10% in, it's obscure, it's shit, I hate it

>But Prolog seems to be popular in AI.

LMAO. Maybe in undergrad AI courses. Nobody is using fucking Prolog for real AI/ML research.

What are you studying that requires Prolog?
Why is that? What's Prolog useful for aside from education then?

Functional programming languages are just general purpose languages.
Haskell for instance is a general purpose language with a really strong type system and makes functional abstractions on top of operations with side effects. That's every good for when you want something to work correctly, as a lot of problems are caught on compile time.

Facebook for instance use Haskell for their spam filter. They also made Haxl a Haskell library for data access on remote server and Hack (runs on HHVM, written in OCaml) which is a fork of PHP with Haskell inspired features.

lel one of my former professors once implemented a model checker in prolog TWICE

>What are you studying that requires Prolog?
It's just a BSc in general CS (dev-oriented, not meant for research), there's a course about every paradigm ever, we're doing CLisp/Python/C/Prolog/OO C++/PHP&JS...

Yes it's shit but can't get employed without at least a bachelor here

Huh. Why would they teach Prolog instead of SQL for the declarative part of the curriculum? Seems odd since the latter is much more useful generally speaking

Because they probably have a course dedicated to the mathematical theory and practical implementation of databases.

well there's databases 101, 102, 201 and 202 also
there are almost no mathematics (high school level calculus mainly but I still struggle) nor science so they overload with random IT courses, it's a bachelor for math retards

It's more an IT bachelor than CS, they make no distinction here ("Informatique")

t. Frenchman

>Frenchman
What school are you at if you don't mind telling?
Given how low in math most CS programs are in France, how do students manage to build the necessary foundation for graduate computer science if they wish to pursue a master's/PhD?
I worry I'll be unable to apply for grad school because of that shit.

Lisp has been dead for the last 40 years.
OCaml is decent but no multithreading.
Haskell is the most promising choice. But functional programming has also been the "next big thing" for a while now and nothing came from that so you're better off learning what everyone else uses instead

>What school are you at if you don't mind telling?
paris 8 (saint-denis of the ghetto)
>Given how low in math most CS programs are in France
that's not true tho, most of them are more or less math bachelors with slight programming topping
I struggled hard to find one without maths, had to search 600km away (I'm not from Paris)

I don't really care becoming a java test monkey, I just don't want to wash dishes in restaurants or deliver pizzas anymore

So lisp is a functional programming. language? Well then, since lisp came out in the early 1960s, functional programming is not the next big thing. It is the fifty years ago thing, lol.

You deliberately chose the program with the least math? Though I guess that makes sense if you don't care much for theoretical CS.
>most of them are more or less math bachelors with slight programming topping
Fuck. I'm going to Niel's meme school in a few months, so I'm basically fucked aren't I?
>I don't really care becoming a java test monkey
The job market in France is really different from the US.
You can make it pretty easily by doing fullstack web dev from what I've seen.

>I'm going to Niel's meme school in a few months, so I'm basically fucked aren't I?
nah the maths are light there but I couldn't make it to 42, I have to work aside to pay rent (I had my Bac 7 years after dropping school, free candidate) and they study 40-60h a week, but I would have loved it

Indeed you may struggle for hardcore CS research masters but you'll have no problem getting into a software dev master IMO

good luck with 42

>You can make it pretty easily by doing fullstack web dev from what I've seen.
Yeah I'm learning some PHP and Java EE on the side, preparing certifications (Symfony/EE/Zend), we'll see

Still washing dishes in restaurants as we speak so anything would do

That's too bad. The 40-60 hours thing is probably heavily dependent on your prior experience with C though.
>hardcore CS research masters
Well I want to study AI. 42 says they have classes on that subject but I don't know if they're good.
And thanks m8, good luck to you as well.
>PHP and Java EE on the side
Yeah that's cool. French developers are getting on the "JS for everything" trend as well, so maybe that could help if you want to be as employable as possible.
In which year are you in your bachelor's?

If you are in France, some of you know if private schools like Efrei, Epita, Epitech are worth? Is it a meme too ?

42's model seems very similar to Epitech (intensive C and C++ courses being the most obvious example) except the latter has professors.
Epita is an actual engineering school and it seems pretty well-ranked.
Though for CS the best is probably Dauphine

FP is a bunch of shit

> muh purity
> muh side effects
> "it is very easy to prove a functional program"

These are reasons only an academic would think of.

C/C++ just let you do whatever you want. The only proof I need is if it does what the fuck I want it to do.

As long as it doe- user received signal SIGSEGV

Should I clojure?

No. 99.99% of Clojure work is just dealing with horrible Java libraries and Clojure's terrible error messages. Most of these "hosted" languages are fucking garbage in real world use.

All the OOP languages nowadays are taking ideas from FP.
OOP itself is something of a clumsy mix of procedural and functional programming.
So it's good to know, you'll be writing better code if you learn a functional programming language. But I don't think it'll ever take off entirely.

All of them are. Haskell has the least practical use though. I'd suggest learning Haskell last.

How does Lisp have more practical use than Haskell?

You can pimp your Emacs with it.

At least you can use it to rice Emacs.

Fug, the text box went out of focus when I pressed enter.

Lisp has cool macros (I think it's worth learning just to see how awesome they can be) and can be used as a scripting embedded language (see GNU Guile). If you want to have a scripting language inside your program, I think that some kind of Lisp would be the best choice. It's easy to parse (like, you just parse parentheses) and can do pretty much anything you want. Even if you make a specific dialect for your program that doesn't do what the user wants it to do, he can just implement his Lisp in your Lisp with macros and do whatever he wanted to do.

I used it for a couple of months until I gave up. It's the worst Lisp out there.

>next big think
>haskbell and lisp died probably before you were born
>OCaml is a joke

yea

>haskbell

I've never seen a productive programmer use either vim or emacs.
The only time I've seen them used in a professional environment was by a sysadmin who did jack shit all day.

Haskell is a meme and wont win any traction out of academic environments.
Granted it makes things shorter but also more dense. A good language for algos, but bad for anything useful.

Its also quite verbose. E.g.: try to parse an integer
>(read 5)::Int

I'm hating it more and more.

For a beginner I'd recommand elm

It's practical (you can write web applications with it), simple (not many features) and pure.

In a way it's like Haskell but simpler and actually useful.


I'd also recommend elixir if you want to do anything on the backend.

> using dynamically typed anything in 2017

elm is statically typed, not sure what you mean?

If you meant elixir, then yeah, that's my biggest issue with it as well

Is Erlang a meme?

Pretty much.

That example isn't good. You need to tell that you want to read something and you need to tell that it's supposed to be an int. The alternative in other languages could be something like
> readInt "5"
> Read.Int "5"
> Integer.read "5"
I don't think any of those is better in any way. I find the Haskell way the cutest.

And actually, I think that Haskell syntax is pretty compact.

I'd agree that it's difficult to make actually useful programs in Haskell though. I wouldn't say it's bad, but just difficult. I think that Haskell is a very good language for research and thus it has many libraries that implement pretty new ideas and are difficult to use due to unfamiliarity and sparse resources to learn from. If you want to make a program with GUI, you probably would want to learn FRP (which I really like so far) and that's just another thing to learn on top of base Haskell and that's where I see the difficulty.

No.
Erlang is pretty cool. It's the only concurrency model that actually works well in practice.
If you don't like the syntax, check out elixir

Wait a moment, let me correct myself. I realized that the Haskell way is actually better because you can skip the type annotation if it's known from the context. Damn, that was obvious.
> read "5" + 1

No, functional programming is a pure meme.

you should never use read in practice, see:
Prelude> read "a" + 1
*** Exception: Prelude.read: no parse

>be supposed to make a presentation about FRP for a seminar
>the professor suggested Elm or Reactive Banana
>pick Elm because it looks simpler
>read the official Elm guide, make some examples myself, do the presentation
>some time later want to check out FRP in Haskell
>see some presentation on FRP from one of the Elm creators
>it actually is much deeper than what I saw in Elm
>it's what I saw in Reactive Banana
>now my presentation appears so shallow
I thought that an official guide to the language made around FRP would cover the concept well. It was a shameful mistake. I think they didn't want to scare away the webdevs.

That being said, Elm is pretty comfy indeed. I agree that it feels kinda like simplified Haskell. And apparently it does allow the "deeper" kind of FRP, it just wasn't covered in the guide.

This must have been some time ago. Elm is no longer based on FRP.
This changed in elm 0.17, you can read about it here:
elm-lang.org/blog/farewell-to-frp

It's still a reactive programming model, but not FRP.
The change was really good for elm, it's now even simpler without sacrificing power

>In which year are you in your bachelor's?
Well I had my bac in 2014, made a year in LEA because I can into English (thanks 4chinz), dropped because it's shit and then I'm in my 1st year at age 25. I know it's pathetic but hey, better late than never.

>French developers are getting on the "JS for everything" trend as well
Well I wouldn't mind a test job in some ESN/SSII so Java/PHP it is but yeah I use JS for various APIs anyway, I could learn some Node

They're great but I don't have the funds

Well, fuck, so that's why. It was after that update. Yes, it did feel much simpler than FRP libraries and yet very capable.

Also, reminder that compilers transcribe everything into ASTs

Oh well, then you were badly advised by your professor

He himself said that he didn't really know much about FRP and that it would be cool if he could learn something about it. The seminar as the whole was about handling side-effects in functional programming.

I love Ocaml. Favourite language by far and now with bucklescript I can use it instead of disgusting JavaScript.

Yeah, except you don't know OCaml, yet alone use a transpiler to JS.

Well the way elm handles side effects is also really interesting, so I'm sure you learned something new along the way.
It might not have been helpful for learning FRP, but knowing elm is a useful skill to have, as it gives you a sane alternative to JavaScript.

You are not making any sense. They just said they loved OCaml, but you claim they don't know OCaml? Why would you claim that?

Also, every compiler is a transpiler...

>except you don't know OCaml

Odd assumption to make.

because no one does OCaml

>Le StackOverFlow Poll :DD Most xX::PoPuLaR::Xx Language??? ToP 5 : Le HASKELL !! xD le OCaml not that far !
>Github : OCaml and Haskell repos : none also no stars

yeah Sup Forums and its permanodevs are experts in these nolibs languages I bet

>>Le StackOverFlow Poll :DD Most xX::PoPuLaR::Xx Language??? ToP 5 : Le HASKELL !! xD le OCaml not that far !
Do you need an ambulance?

...

>I know OCaml is used in finance
Yeah, right. Two companies using it is huge, unlike haskell which almost every finance institute uses to some degree.
OCaml is worth learning not because of its use in the industry, but because it's a pragmatic approach to functional programming and it feels fucking amazing. Also because of things like Coq and HoTT. I personally use it for scripts that run as root and few tools that were trivial to write with the module system and GADTs.
If you really, really want to learn lisp (worth it imo), go with scheme.
It has been used in the industry since it was released. That you don't see it being as popular as java is not evidence of it not being used. The reason for that is, that when you hire an ocamler, you hire him for life and, that the projects we work on are not as trivial as "airbnb for washing-machines". If you had been anywhere near avio, astro or finance, you would have known that functional programming is very well-established in the industry. Here at well full of honey, we use Coq and have a team that writes OCaml extensions to it. I have been pressing the management to contribute to open-source, but the company is very hostile towards it in the higher management. We also do most of our specs for the C guys in haskell. But of course, you won't usually see us hiring for these positions, you have to work up to it and it's a lifetime commitment. The other issue is, almost everyone here has a PhD in either applied math or CS, so it's pretty restrictive. But that's the thing, you don't need 500-man team to do the work, we barely have 20 people and we're among the most productive departments in our branch of company.

>smalltalk
thinking_emoji

>PhD in either applied math or CS
You work in quantitative finance?
Are PhDs unofficially mandatory in your field?

>unlike haskell which almost every finance institute uses to some degree

Not really. Like Ocaml, the amount of Haskell used in finance is greatly exaggerated. Even C.S. has basically stopped using it and moved to F#.

I thought the most used languages in finance were C++ and Python, followed by R, MATLAB, and then OCaml/Haskell.

Ocaml and Haskell are still very rare. Like most of the industry, C, C++, Java and C# are the most popular by a massive margin. Python, R and Matlab are used quite a lot as well but usually just for quick problems and quick exploration of a domain.

>Ocaml and Haskell are still very rare.
Is it because only the top firms use them? Or just because more popular languages are simply more adapted to the task?

Indeed. But just getting to work with the events gave me some insight on how to approach FRP.

Most of the top firms don't use them. It's usually smaller players like Jane Street that do.

> Or just because more popular languages are simply more adapted to the task

I think it's mostly just inertia. Software development in finance isn't really that much different than it is elsewhere. Easier to hire people, better library support, good performance, good IDEs, debuggers and profilers etc.

>It's usually smaller players
Is there a reason for that? Why would they choose to use those languages if, as you say, it's easier to use the more popular ones?

Not anymore. I began my career there, i've been working in avio and aero for the past 5 years. PhDs are not mandatory in the field, but in my department of formal methods, they are. As for finance, MSc in applied math is satisfactory for most positions.
At the time i was working in finance, which isn't that long ago, most banks here in europoor were using haskell to some degree. I agree the amount of code is small, but again, that's because of the efficiency of the paradigm and that finance is pretty much the best-case scenario for functional. We rewrote 740k loc java monstrosity to roughly 15k in haskell, but that's an extreme case and the downside is, no one without a firm grasp of haskell and some type theory will be able to work on it.

Smaller players can afford high-riscs experiments. It's that simple.

What pushed you to change careers?
>applied math
Is CS fine? I've seen some job offers on indeed be explicit about them wanting a PhD, so it seems common.

Some of the places have highly respected programmers like Yaron Minsky that will really push for their pet language. He pushed hard for Ocaml and it worked out so they continued using it.

Most places don't have someone like that and most programmers will continue to use what's popular because pushing for something that's niche is extremely risky career wise.

I felt i didn't really put much use to my mathematical skills in finance. Of course in higher positions, i might get to use some graduate-level methods but, getting there takes too long. Working in aero i get mathematically challenged almost every day. We have to wade through a lot of research because, developing an environment around proof assistants calls for it. For example, we're working with IAS on applications of HoTT. That alone is PhD-worthy project but, we just started last year and the work has been feeling pretty much like i'm back in academia. I love it,there's no way i would have been able to work with higher mathematics in finance, unless i got to work for rentec or somesuch. Even then, my opinion is that HoTT is much more involved than some novelties in anal and measure theory.
Asfor CS, it depends on the field. For finance, you're going to be handicapped. For aero, you're probably going to be favoured if you want to get to formal methods- you guys have things like temporal logic and hoare mandatory, afaik. It was just skimmed over in applied math. For the low-level guys, most of them are CE or EE masters, but CS is no handicap there.
And don't take PhD requirements too seriously, i've applied to such position with BSc during studies and they took me. No idea why it's there when the math is undergrad-level.

>didn't really put much use to my mathematical skills
What position did you have that didn't require much math? This is surprising since quant finance is usually described as math applied to finance, even for developer jobs.
>no way i would have been able to work with higher mathematics in finance
What is the reason for how long/difficult it is to get to the same point in finance? I mean aeronautics/aerospace is a pretty critical field as well.
Do you work for a contractor?
>rentec
Are they overhyped?
>For finance, you're going to be handicapped
Why? Even for front office dev jobs? As I understand it there's a gap in knowledge (and pay) between researchers and developers in quantitative analysis
>i've applied to such position with BSc during studies and they took me.
Are you from an elite college?
>No idea why it's there when the math is undergrad-level.
They say it's because working there is similar to working in a research environment, and a PhD proves that you're able to handle that. What do you think of this statement?