Best functional programming language

I'm learning haskell and having a good time with it. What functional programming languages do you like Jow Forums?

Attached: lambda.png (1024x1024, 19K)

Other urls found in this thread:

letoverlambda.com/index.cl/guest/chap5.html
twitter.com/NSFWRedditGif

i heard they are aslower than normal programming. what's the point?

OCAML
>i heard they are aslower than normal programming
Only if you are a retard who can't into tail recursion.
>what's the point?
It's perfection unlike other programming languages

F# for interoperability with c# and great portability.

Haskell's good too but I have a lot of problems with the ecosystem and tooling. Still use it in a lot of personal projects though.

But F# is slow as shit, might aswell just use C# seeing as it got some functional programming shit recently and its fast as fuck

What is a functional programming language?
Why should i learn it?

c# is still extremely poor for fp. No discriminated unions (painful visitor pattern), no records (so an incredible amount of boilerplate making immutable objects with equality), very verbose type system.

If its so bad why is every non-functional programming language adopting more and more functional practices, huh? Brainlets will soon realize that fp is the path of light and seek redemption.

Scala is quite comfy desu

>slower
Not really, by default FP languages are way better with concurrency and multi threading, and can call C/Rust/C++ where single threaded performance would be needed anyway.
Go make a multi threaded application that maps over an array, using all cores on any computer, and then inside that spin up each index of the array as it's own process while you perform the operation on it.


I can do this with like 5 lines of elixir :)

If you want to be productive
>OCAML, Erlang

If you don't want to be productive
>Haskell, Clojure

If you're a ruby brainlet
>Elixir

If you're stuck in enterprise and you're forced to use Scala
>Scala

>FP languages are way better with concurrency and multi threading
Back up ridiculous claims like this by peer reviewed studies that prove this statement.

fsharp literally compiles to the same code as c# it just has some extra abstractions that may be slower.

Google "BEAM VM" and you'll be introduced into a world of perfect concurrency and fault tolerance.

If you want a "peer reviewed study", you can look at anything released by the devs at any of the large companies running things like whatsapp or discord serving millions of concurrent users with low latency and an entirely distributed system that restarts itself.

OCaml. And I'm paid to use it everyday.

what is the genuine benefit of functional programming for enterprise software and why/how does functional provide it?

Can you elaborate more what do you do at your work?

reliability
productivity

>Can you elaborate more what do you do at your work?
No. I'm probably the only one on earth who does what I do with OCaml, so i would be equivalent to tell you who I am.

context-less buzzwords. please describe what you mean and HOW fp provides the benefit

static strong typing, sum types, controlled side effects

>no cache coherency
oh no no no

all of those are provided in C++ (side effects does require proper engineering)

>proper engineering
>C++
Impossible by definition.

No thanks fag
I prefer Logic Programming

maybe more people would use FP if it stood up under questioning

So use C++ and don't use OCaml. It's clearly not for you.

Prolog gave me cancer

whats the benefit of using FP? im genuinely interested, but your answer will need to be reasonable

Scala is great, especially with Spark

That wasn't cancer it was giving you user.
What it was doing, it teaching you to think things through.
I know, as a brainlet it must be a new and strange sensation that hurts, but you'll get used to it.

No side effects, some things are more succinctly expressed(and some are less). It allows thee compiler to do some different kinds of reasoning on your program.

We don't want your kind using it and shitting it up.

Erlang is cute.

Please help me i have a homework to do in prolog for my univ. The question is easy but i'm stuck :

I need to write a predicate Poem with 2 arguments which does this :

?-poeme([_A, _B, _B, _A, _C], Poeme).
true.
Poeme = [[le,roi,de,la,pampa,retourne,sa,chemise]
[pour,la,mettre,à,sécher,aux,cornes,des,taureaux]
[et,fermentent,de,même,et,les,cuirs,et,les,peaux]
[le,cornédbîf,en,boîte,empeste,la remise]
[si, la, cloche, se, tait, et, son, terlintintin]]

I already did the predicate "versPourRimes" which associates a sentence to a rhyme :

ex : versPourRimes([le,beaune,et,le,chianti,sont-ils,le,même,vin],in).

The predicate "paire_rime" which returns true of two verses have the same rhyme
paire_rime(U,V) :- versPourRimes(U,R),versPourRimes(V,R),U\==V.

So i'm stuck with the predicate "poem" which returns true if the Poeme you enter follows the same pattern as the layout.

For exemple poem([A,B,B],Poeme) will return false if the last two verses are blank.

Keeps everything simple, everyone using the language follows a very strict set of rules, so doing the correct thing is so easy, everyone is on the same page, even your tests are on the same page as a function itself.

>input data
>some data transform inside the function
>output new data

That's it, no bullshit confusing functions that mutate or change things across multiple files, no stupid inheritance or worrying about crazy design patterns, you just use a function. You just pipe them together, and create an easy to read list of transforms, where you can then go in and read each function 1 by 1, but if they're named properly you won't even have to.

You can write in a functional style in any language, just an FP language will have all the defaults in place that make the most use of it, like they'll use linked lists because it's a recursive data structure, and you can solve a lot of problems recursively with pattern matching.

Learn OCaml, and ask your question after.

>it's not slow because it can call C!
The absolute state of faplets

first genuine answer, thank you

what use cases would you say FP is particularly suited for? for example, i can imagine doing a GUI or DB would be very difficult

Functional languages foster a highly recursive style which matches well the needs of proofs-by-structural-induction.

The Isabelle theorem prover, for example, lets you define functions in a language somewhat similar to haskell, prove properties about it, and then export the function definitions to haskell to actually run the thing. So there's a pretty strong argument there for using FP in safety critical systems, I think.

More generally, functions are the fundamental building blocks of mathematics, and that's a result of centuries of trial and error. It's not so strange to think it'd end up being a fundamental to computer science as well.

>Google "BEAM VM" and you'll be introduced into a world of perfect concurrency and fault tolerance but horrible code and dev practices
erlang tales are cool but the reality being them is developers on suicide lines developping/debugging this horrible code mess.
I spent 3 years working with erlang for a big telco, I masturbated all night when they told us we were switching to C++ for new products.

Well elixir exists to solve that exact problem, by cleaning everything up and making the language more friendly.
But if people write a mess, it doesn't matter what language they write in, they're just bad developers and would make a mess anywhere, and those that come after have to deal with it.

All of them have a place, and I like all of them.
But at the moment, Clojure keeps me employed, and in general I'm more biased towards lisps.

not the user you're replying to, but I'll try to provide rationale:
when you're working with persistent immutable data structures, concurrency and multi threading are easier since you don't have to bother with locks, synchronizers, shared resources.
A good FP language will also provide you with syntax that handles it nicely when you do actually need to share resources between threads, like Clojure's atoms, refs, agents and channels.
So better doesn't have to mean faster, it can mean easier to develop and less bug prone.

>Well elixir exists to solve that exact problem, by cleaning everything up and making the language more friendly.
this was in 2013 and elixir was nothing more than a toy language meanwhile C++11 was released as a game-changer.
>But if people write a mess
I'm talking about the language syntax, it's so random it's clear that this is not a programmer that designed it.
It was a pain to teach/mentor interns because none of them had prior exposure to erlang and it's a pain to get non-phd people to work with such tool.
C++ is easier to pick and it's easy to find the best practices and to write modern and robust code while being faster than erlang vm.

FP-only languages are doomed from the start, I prefer bringing FP features into procedural world as it's easier for human to write/read code and it generates pretty much the same asm (or of similar quality).
I prefer getting things done quick and not doing overtime/crunch because my job is not my life and I certainly don't want to spend too much brain power to please billionaires shareholders.

>I prefer getting things done quick
Oh, and I yes, all my life I notice that people using imperative language get things done quick.

Attached: sheldon-sarcasm.png (461x453, 261K)

if only std::function was pure

I agree, FP languages are indeed an acquired taste, I wouldn't really say "doomed", but they'll always be less popular because of the simple fact it's different.

I wish that it wasn't that way, and FP was more popular, but if I want to get shit done I do have to use JS or some other popular language in an FP style, it just saves so much time and I can enforce the rules myself, while keeping all of the good parts of just importing libraries or whatever.

Really it's just a catch 22 where FP languages aren't popular because they lack libraries to get stuff done, and there's nobody to make the libraries because it's not popular.
The languages themselves are often great, but the ecosystem is what is the problem really.

Solution: use clojure and leverage all of Java's libraries

XSLT

This, but I prefer Elixir :)

javascript

because FP is the low hanging fruit when it comes to unimplemented features in traditional programming languages.
Otherwise people would have to actually come up with novel ideas on their own.

Haskell Stack is barely functioning cancer, how anyone manages to get work done on it is a mystery.

if you stick to an lts then it pretty much just werks

What I don't understand is how anyone could have approved of the concept of an LTS for an entire ecosystem
what are you gonna do, version the whole planet?

>I spent 3 years working with erlang for a big telco
no you didn't

>muh performance
In 95% of the cases, you don't need blazing fast cpu-time performance, and it's better to prioritize correctness and functionality.
That said, while most functional languages generally _are_ slower than, say, C++ or Fortran, purity greatly helps with concurrency, as pointed out.
The truth is, writing fast, efficient programs is hard no matter what langiage you use, and the language is only part of the bigger picture.
People who think you get performance for free just because you use a certain language are deluded.

What is "normal programming"?

>needing "peer reviewed" studies for basic common sense

what's the best functional programming language to make an ascii roguelike?

OCaml.

I was created to solve cabal hell and it can't do that without providing long term support. Haskell has a long history with many books and papers written in older versions of the language, so it is useful to have a system which will make it easier to go back and run earlier things in the future.

Good choice user, Haskell is comfy, I also like Scala from time to time, although it's not purely functional

Writing fast and efficient programs really isn't that hard. I don't know why people keep repeating this meme. Understand your problem, research solutions, if there are none, consider the characteristics of data access, consider what general algorithmic forms suit your problem, implement, and continue to refine until you have acceptable performance. Frankly I would consider any software which doesn't go through this process to be malformed and not worthy of being released.

Also the attitude of throwing away performance considerations is exactly why modern software is bloated and slow, despite the fact that CPUs have been getting exponentially faster for years.

>functional
Kek based retard. Computers are imperative and stateful. The entire universe is stateful. If you want functional why dont you research mathematics and solve problems formulated as mathematical inquiries? Oh, right. Youre probably a CS grad. Kek. You can barely do calculus or algebra, not too mention topology, analysis and set theory. Whats it like having low IQ?

What use is a fast program if it isn't correct, or is so difficult to reason about that you can't extend it without the risk of breaking it?
The prevalence of interpreted languages, leaky abstractions, and flavor of the month frameworks has more to do with modern software being slow than functional programming. Most compiled languages are reduced to LLVM anyway these days. So any language can be pretty fast assuming the language designers and compiler writers are competent, two areas where academics excel.

Anyone who believes this is a meme has never developed a true high performance application (and I mean in domains where top of the line performance really is needed, such scientific modeling where heavy parallelism (100+ threads) is usually required, and synchronization alone is a bitch).
If your definition of "high performance" is how fast a meme script can FizzBuzz, yeah, writing fast code is easy, just use a language with a faster implementation. But this is also one of the many places where you don't really care either way at the end of the day unless you have severe autism.

>Computers are imperative and stateful.
Logic gates are stateless. State itself is an abstraction.

I kind of get the idea of FP, but what's the point of purity when real world tasks are impure anyway?

I refuse to believe that fighting with GHC's incomprehensible errors for hours is better than a slightly increased possibility of bugs.

>What use is a fast program if it isn't correct, or is so difficult to reason about that you can't extend it without the risk of breaking it?
It's not. My point is that a program should be correct, specialized, easy to reason about, and performant, and actively suggesting that any of those should be neglected is a big part of why things are fucked. For example;
>The prevalence of interpreted languages, leaky abstractions, and flavor of the month frameworks has more to do with modern software being slow than functional programming.
The prevalence of these things is also wrong, because, as you say, they make things difficult to reason about, and (in my opinion) they are too generalized to achieve any application specific performance advantages.
>Most compiled languages are reduced to LLVM anyway these days. So any language can be pretty fast assuming the language designers and compiler writers are competent, two areas where academics excel.
This I'm okay with, although I think the reliance on LLVM alone is a bad idea, and I think it would be worth investing in LLVM-equivalents which focus on stack-machine and queue-automation models as well. I think the overwhelming dominance of register-based architectures prevents potential specialized innovations from improving efficiency, safety and formal correctness.

Also I've seen how the mainstream has fucked up plenty of other good ideas in programming language design, and I have no doubt it will do similar to FP concepts. I don't think FP is bad, by any means, I just think it has a specialized role and that companies adopting it and changing parts of it to fit their desires will ultimately result in the thing you are clearly passionate about being corrupted slowly over time (just like OO has been for many of its former advocates)

All functional languages should be purged from this universe. Especially piece of shit lime Racket and Lisp

>computers are only logic gates
Wew lad

Lisp is the least functional programming language in existence. letoverlambda.com/index.cl/guest/chap5.html

They literally are, though. What else is there?

I was speaking about the case of general applications dev, which was what they were trying to get at. It's implied that particularly difficult subjects will still be difficult. That's obvious, user. But for business applications, it is not difficult to reduce bloat and inefficiency to a minimum.

>what is a hard disk
>what is a flip-flop

I will never use Haskell again because stack, cabal, and nix are unusable fucking trash.

If you search for anything about GHCJS, there are people complaining about how impossibly difficult it is to get started. Of course you and I are too smart to get tripped up by something as simple as setting up a GHCJS environment, right?

Nobody but the most powerful of wizards are capable of installing and using GHCJS. I've been working with Linux system administration and development operaitons for years in a professional capacity, but it took me over 12 hours of active work to get GHCJS working - and that was after giving up my pride and installing it via `reflex-platform`.

I thought to myself, "I'll just use Purescript or even go back to Javascript if I really have to. I can't stand to deal with GHCJS again." But I love Haskell, so maybe I could use Hakyll to set myself up with a fancy new blog and have extensibility while working in Haskell. Sounds like a dream!

`stack install hakyll` - fails because ??? on Debian 9 Stretch (using the latest version of stack)
`stack install hakyll` - fails because ??? on Arch Linux (fully updated system packages, latest version of stack)

There's no reason for this. If Haskell can't manage to make these libraries or packages available and usable through Stack or Cabal, the developers of these packages really need to stop advertising that "stack install XYZ" will ever install XYZ. It almost never does.

Why the fuck aren't Haskell developers using Docker yet? Here's a Dockerfile:


FROM haskell
RUN stack install hakyll

You already know it doesn't fucking work. But you could spend another 200MB downloading and installing 8.6.4 inside of that docker container with the --install-ghc flag. There is no 8.6.4 Docker. But guess what? Let's pretend we do that. We spend the time waiting for 8.6.4 to build inside of this. LRUCACHE ERROR :D

I'd rather eat shit and use OOP than deal with this garbage ever again.

A big problem in software in general is that there seems to be a widespread black and white mentality with regards to software bloat.
Most people think that the appropriate response to software that really is bloated and slow is software that is lightweight and fast, but lacks so many basic features that you need 10 different commands to do basic things, therefore being "un-bloated" only by virtue of being small, but not necessarily better designed.
This is also reflected in autistic language discussions: it's either compiled C, C++ which are fast and lightweight, or "bloated" and slow interpreted languages such as Python, Ruby...
Functional languages such as Haskell, the ML family (and to an extent also the Lisp family) show that there is a third way: you CAN have useful abstractions, with a rigid type system which enforces catching many bugs at compile time, or flexible metaprogramming capabilities, and which can be compiled to pretty fast code. No, not as fast as C++, Fortran or other fast languages as of now, but still much better than most interpreted ones, and there is some slow, albeit steady progress in that area.
Software such as Emacs also reflects this "third way" when it comes to software: it can provide many features and still be modular and extensible, without being a massive bloated monolith.

Attached: 1530857945017.png (1920x1080, 3.14M)

A flip flop is quite literally built out of basic logic gates to memorize a single true/false signal, like all bistables.
Hard disks, like pretty much all hardware, do use logic gates at the most basic level to actually function.

F# is raped by ms only for benefitting the abomination called C#. It's vile and disgusting

How is developing in Clojure? How's the ecosystem? Been thinking about messing around on some personal projects with it. I work in enterprise with Scala so functional programming is well understood, and I'd mostly try doing some computational geometry stuff for the challenge of writing some new optimization solvers.

Scala is my current favorite. Having access to all of the shitty java libraries makes it easy.
Used to develop erlang, I prefer a static type system though.

>Especially piece of shit lime Racket and Lisp
Lisp is mostly an imperative language with some functional sprinkled in. Lisp development is a far cry from the FP mentality, it's more concerned with metaprogramming and flexibility than purity and transparency.

You can get cache coherency in pure FP.
If you're clever, check out Futhark.

Flip-flops, and all electricronics, are actually continous systems, current is constantly flowing into and out of components and there is no hard 1 or 0 but a range of voltages instead. Digital circuits are an abstraction built upon analog circuits to make them easier to reason about. In a sense, circuits make more sense when viewed from a functional perspective than an imperative one.

Attached: 6E4AD92F-DA43-40FD-AE54-EF701F1D78E2.png (524x512, 19K)

Lisp was functional when it was invented, this was a time dominated by assembly and FORTRAN so what it offered was completely beyond anything else at the time. It was the first language with first class functions as far as I’m aware and was capable of implementing most of the features we would associate with a functional language today. Mutation is something most functional language allow in practice anyway. It may be a bad style, but you can also write Haskell like C if you use do and IO everywhere and that’s perfectly legal.

As the other user said, functional languages are nice for formal verification.
>GUI
Actually, if you just take a look at all these trendy javascript frameworks, they are based on functional reactive programming.
>DB
You mean implementing a database engine? I know there are some people doing that but I don't know how well they're doing. Well, there are some very cool things around databases in functional programming. Starting from leveraging the type system to ensure that your queries are valid, up to some magic which I don't really understand yet like acid-state.
>what use cases would you say FP is particularly suited for
I'd use it everywhere where it's not bad to use it. I think that thinking in terms of data transformations which you can compose instead of procedures that perform arbitrary side effects is much easier (which appears to be contrary to what most people think) and it definitely is more friendly to a compiler. I like to assess the comfiness of a language by the frequency of it making me repeat myself. Functional languages are very comfy in that measure. I feel I can express my ideas very concisely. At some point you reach a limit so you go deeper. Higher-kinded types, type classes, functional dependencies, dependent types... Yet it all fits together as it's all built on the solid foundation of lambda calculus. So going back to why I wouldn't use a functional language:
>memory-constrained environment
>hard real-time requirements
Garbage collector
>performance-critical code
As in you need to write heavily optimized C/C++
>lack of libraries for the use case
This happens. Like people didn't know how to make GUI in a functional way for a long time. And they still aren't sure. Some languages already assimilate the ideas but for example Haskell still doesn't have "the way" to make GUI.

There is also the matter of Rust which actually is a functional language but doesn't have a garbage collector but I don't know much about it.

javascript

Haskell is comfy. I tried Coq recently but was disappointed a bit. Like some things don't turn out as nice as they were supposed to and it often feels like I'm doing too much work for the results I'm looking for. Gonna keep learning it though.

JavaScript is a HIGHLY functional programming language. Where Haskell has HUGE problems with expressing understandable code, JS ships with Map and Filter functions on almost every prototype. Plus, Slack was written in it and slackwear is the most highly patched operating system running important business applications like Facebook and Sony.

Attached: 619913A9-8C8B-4C3F-A47A-A32B3A2E381F.jpg (1500x1379, 146K)

In lisp functions are first class objects, thus lisp is a functional language.

>Lisp is the least functional programming language in existence.
This can't be true unless you believe C to not even be a programming language (which is true), but you'd still be wrong.

>How is developing in Clojure?
Pleasant. It's a lisp with linked lists, vectors and maps.
>How's the ecosystem?
The Clojure core libraries are great.
YMMV with third party libraries, some are good and some are amateurish, but it's still good for enterprise software.
You can also use the entire Java ecosystem because you got interop, so if you end up missing something from clojure you can wrap some java lib.
>Scala
Keep in mind Clojure is dynamic and has less syntax.
There are also some subtleties regarding the performance of numerical operations, so use type hints, unchecked math, etc.

Woke
But I studied EE and I agree with you.
Simply, every Moore machine can be written recursively:
STATE[n+1] = F(STATE[n], INPUT[n])
OUTPUT[n] = G(STATE[n], INPUT[n])
No reason this couldn't be expressed in functional programming.
Or logical programming, for that matter (see all HDLs)

imperative/oo

I'm enjoying Chicken so far. Scheme that compiles to C is neat.