In computer science, functional programming is a programming paradigm—a style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. It is a declarative programming paradigm, which means programming is done with expressions or declarations instead of statements. In functional code, the output value of a function depends only on the arguments that are passed to the function, so calling a function f twice with the same value for an argument x produces the same result f(x) each time; this is in contrast to procedures depending on a local or global state, which may produce different results at different times when called with the same arguments but a different program state. Eliminating side effects, i.e., changes in state that do not depend on the function inputs, can make it much easier to understand and predict the behavior of a program, which is one of the key motivations for the development of functional programming.
Functional programming languages have largely been emphasized in academia rather than in commercial software development. However, prominent programming languages that support functional programming such as Common Lisp, Scheme, Clojure, Wolfram Language (also known as Mathematica), Racket, Erlang, OCaml, Haskell, and F# have been used in industrial and commercial applications by a wide variety of organizations. JavaScript, one of the world's most widely distributed languages,has the properties of an untyped functional language, in addition to imperative and object-oriented paradigms. Functional programming is also supported in some domain-specific programming languages like R (statistics), J, K and Q from Kx Systems(financial analysis), XQuery/XSLT (XML), and Opal. Widespread domain-specific declarative languages like SQL and Lex/Yacc use some elements of functional programming, especially in eschewing mutable values.
>JavaScript, one of the world's most widely distributed languages,has the properties of an untyped functional language NO FUCK YOU OP DON'T GIVE THEM AMMUNITION END THE "JS IS FP" MEME NOW REEEEEEEEEEEEEEEEEE FUCKING WEBLETS APPROPRIATING MY CULTURE GET OUT OF MY FUCKING PARADIGM YOU ARE NOT FUNCTIONAL
Leo Rodriguez
I like the pair in lisp. With just SICP and a shit language I was able to write something. Thanks caaddr.
Blake Cook
What's up? You don't like mutable and immutable versions of the same thing all over the place?
Oliver Evans
JavaScript's C-like syntax, including curly braces and the clunky for statement, makes it appear to be an ordinary procedural language. This is misleading because JavaScript has more in common with functional languages like Lisp or Scheme than with C or Java. It has arrays instead of lists and objects instead of property lists. Functions are first class. It has closures. You get lambdas without having to balance all those parens.
David Bailey
...
Wyatt Miller
Functional programming has long been popular in academia, but with few industrial applications. However, recently several prominent functional programming languages have been used in commercial or industrial systems. For example, the Erlang programming language, which was developed by the Swedish company Ericsson in the late 1980s, was originally used to implement fault-tolerant telecommunications systems. It has since become popular for building a range of applications at companies such as T-Mobile, Nortel, Facebook, Électricité de France and WhatsApp. The Scheme dialect of Lisp was used as the basis for several applications on early Apple Macintosh computers, and has more recently been applied to problems such as training simulation software and telescope control. OCaml, which was introduced in the mid-1990s, has seen commercial use in areas such as financial analysis, driver verification, industrial robot programming, and static analysis of embedded software. Haskell, though initially intended as a research language, has also been applied by a range of companies, in areas such as aerospace systems, hardware design, and web programming.
Other functional programming languages that have seen use in industry include Scala, F#, (both being functional-OO hybrids with support for both purely functional and imperative programming) Wolfram Language, Lisp, Standard ML and Clojure.
Alexander Taylor
Scala sucks F# has a terribly limited type system
Hunter Powell
This thread might work better if instead of namefagging quotes barely anybody will read, you would post as anonymous and bring up interesting topics.That would be a good thread.
You could also just make a shitpost that will bring people into the thread to tell that shitposter he's wrong. That might be a good thread if the shitpost doesn't swallow 300 posts.
Just a thought, do as you want.
Camden Moore
Functional programming is for basement dwelling NEETs without a real job.
Alexander Diaz
fuck, marry, kill
Anthony Lee
OOP is for wagecucks
t. functional contractor
Leo Green
Come back to me when Haskell can do physically based rendering of 3D environments at a pace that isn't slow as death.
Jacob Wright
>implying a private construction company won't build better cheaper roads faster where the demand for them is highest
Carson Evans
Marry Haskell, it's pure.
Fuck Scala, the JVM makes me feel dirty.
Kill OCaml, I caught it in bed with facebook.
Mason Ward
Finally making >$2k a month from my f# side project. Feelsgoodman.
Hunter Wilson
Which should I learn?
t. C++/Python brainlet
Austin Morris
Since functional programming is stateless, would this guy like it?
Aiden Parker
You should learn to think for yourself
Luis Perez
Too hard for neckbeard brainlets here. They like trash like c and writing fizzbuzzes in imperative style. No Scala/clojure/elixir/scheme here.
Nolan Moore
Which functional programming language is the most used by industry? I.e. which one will allow me to get a job the most easily. I want to learn that one. I have a feeling it's Erlang? Pls and thanks for help.
James Long
Id say Elixir, Elixir is a huge improvement in syntax over Erlang so it feels like a regular scripting language. It borrowed a lot of ideas from Clojure in how it abstracts over lists. And it adds strings instead of just the ridiculous and unusable byte arrays of Erlang.
Bentley Ross
I'm enjoying Elixir so far but miss the type safety as I now tend to pepper my code with structs, specs, and doctests just to be sure everything is sane (I tend to use Haskell and play with Idris). Other than that I would say it's great, currently translating lisp programs to elixir to get the hang of things plus OTP (might write a lisp repl with phoenix).
Not sure if I should write a macro for chaining the below having it act like a failure monad or just use exceptions and let it die. defmodule Lambda do def eval({:lambda, x, body}, env) do fn(arg) -> eval(body, fn(y) -> if (x == y), do: arg, else: env.(y) end) end end
def eval({rator, rand}, env) do (eval(rator, env)).(eval(rand, env)) end
def eval(x, env) when is_atom x do env.(x) end
def eval(x) do case eval(x, fn(_) -> :error end) do :error -> {:error, :undefined} success -> {:ok, success} end end end
Henry Thompson
Haskell. jk but I wish it waa the case
Logan Cruz
I'm going through Learn You a Haskell... at the moment as an introduction. Is it a good resource? It's recommending the interactive shell but some of the examples it gives are not being accepted by ghci.
Also it's really tested my knowledge of mathematics so far. I learnt set theory basics years ago but it isn't at the forefront of my mind.
Grayson Howard
Scheme --> Common Lisp
Clojure
Gavin Garcia
Clojure, Scala, Elixir, mostly with a few places now picking up Elm for frontend.
Thomas Walker
Why start with Scheme?
Camden Lee
It's one of the easier languages to pickup and one of the most powerful plus there's no end to good books, lectures, and papers for it.
I used lyah to get into Haskell, I liked it. It's not too technical while not leaving the important stuff out. I remember sometimes having had problems with examples not compiling, I don't remember the reasons though.
How does a non wagecuck programmer make money for living annon?
Landon Rivera
All the useful aspects of functional programming have already been cannibalized and inserted into more general programming languages. Heavy immutable focus, lazy loading, tail-end recursion, and (of course) lambdas.
All you really have left is an autistic shitfit any time anyone mentions the word "class."
Connor Garcia
type class
Christopher Cox
Elaborate please. I think it gives you the freedom to spaghetti all over the place, but if you are a good developer it gives you very powerful tools, such as implicits. You can write pure code in scala, it's all up to you. And again, Scala is great for Big Data.
Is Rust capable of functional *style* programming? Is there popular (as in getting a job) fp lang out there that can solve variety of problems?
Blake Morgan
Rust as some essential support for FP (pattern matching, closures, iterators, tail call recursion), but we still don't have good Monad or lenses libraries.
The most popular FP language that can also get you a job is Scala.
Luis Adams
That's why typescript destroys Javascript
Joshua Richardson
Putting a pie inside of some shit does not improve the shit.
Nolan Morales
I've been wondering for some time now, what is the purpose of the lenses library in Haskell?
Gabriel Howard
>but we still don't have good Monad or lenses libraries Wouldn't it be necessary to intoduce higher-kinded types to the language before getting there? The basic functionality is already there for concrete types (.andthen(…)), but it's currently not possible to abstract over that uezs.
Aiden Thompson
it's like an abstraction on fields, so for instance
person.name
with lens, you can have something like "name" which is a first class (it's a regular value) field manipulator, you can do stuff like
person^.name.first.initial -- access the initial of the first part of the name of person
change the name (name .~ someothername) person
use monadstate name .= someothername
etc, it can do other things, e.g. traversals (multiple fields in one), prisms (potential fields), isos, etc
Easton Parker
Very useful, thank you very much.
Charles Gomez
The Lenses library in Haskell is horribly overengineered in my opinion. Have been using microlens and I'm quite happy with it.
Easton Rogers
I learned haskell in college. I never wanted to kill myself that much since then.
Kevin Lopez
almost certainly
i also think something like zoom needs to be built into monadstate because otherwise it doesn't play very nicely
Hudson Price
why is data immutability important? serious question
Eli Hall
Immutability makes it harder to make certain types of errors in your program. It also makes it much easier to test your code.
Nathaniel Gomez
There are no side effects, you dont need to understand how the programs' components interact with each other, you need only to understand the single component. Less prone to error, since every time you call the function f passing value x you will always have y as a result, not true for OO languages like java that rely on internal status of the class.
Isaac Richardson
Haskell hobbyist on suicide watch
Ryder Gutierrez
>Functional programming is also supported Well, if you're going that way then Python, Ruby, Java, Scala, Go, Rust and lately even MATLAB also support functional programming though they don't endorse it.
Weblets are irritating but the quote is correct. >has the properties Most languages right now are a mix and thus have properties of various paradigms.
Nicholas Gutierrez
Either by working as a contractor or turning your own sideproject into something that brings in enough money to live on.
Dylan Sanchez
Learn doing FP in Python.
Logan Scott
Erlang should be pretty high but checking job offers it seems Haskell tops.
>Elixir I don't think web development is industry,
Nathaniel Bailey
Haskell is not a systems language. If you want FP and system programming, use Rust. It's basically a more advanced OCaml.
Aaron Green
dumb frogposter
Landon Gomez
>You can write pure code in scala, it's all up to you. So it's no better than TypeScript. Scala is deprecated.
Grayson Cruz
Scala has a lot more support on FP than TypeScript. It's not haskell tier and i won't even try to defend that, but it has niche and use cases where it excelles and it's better than Haskell. At the current moment Scala is the best option if you want to go big data.
Don't listen to You can write in a functional style on every language, but you will have a very hard time *learning* FP that way.
Isaac Sanders
>seething Haskell hobbyist mad at Elixir professionals
Nicholas Bailey
Elixir seems fine but I've seen it used nowhere besides web development
Caleb Nelson
Last time I checked Rust didn't have tail call optimization. Are you sure about that?
Austin Jenkins
>but it has niche and use cases where it excelles and it's better than Haskell. If you HAVE TO interface directly with the JVM && have Scala programmers available && (gotta ship fast || huge Scala codebase already).
Other than that, no. For JVM work either Frege or Idris are far better languages; even Clojure is at least on par with Scala due to the sheer greatness of their ecosystem and how write-only Scala can be.
I learned haskell's basics, not more, I really should catch up soon. What is haskell's native support on parallelism? As a scala developer I've always loved parallel's collections.
Gavin King
now can someone translate what this fucking nerd just said?
Liam Edwards
Haskell is fucking great at parallelism and concurrency. It sorta uses lightweight threads like Erlang. You can spawn two parallel computations by using the `par` operator.
Leo Williams
it's the most simple and refined essence of functions
Brayden Myers
Which part? I said two things. The first is a stupid coq code, the second is the explanation of why fp is best paradigm.
Jayden Wright
With programming in general, what is more important: CPU, RAM, GPU? How does each factor tie into the others? If you could upgrade your system in one of these aspects, which would it be and why?
Luke Sanders
you sound like a lifer programmer
Logan Allen
>a lifer programmer A what?
Anthony Miller
>coqsucker doesn't know what a lifer programmer is
Samuel Scott
Very interesting.
Gabriel Scott
Is this a "what should I upgrade guys" post in /fpt/?
Tyler Allen
No. This is a 'what should I look for in my next machine because I'm making a start in programming' post. Answer my original question pls user
Daniel Gonzalez
It doesn't seem like fpls get a lot of use on "real" projects, though I believe emacs was written in lisp. Any good examples of commercial programs written in a fpl?
Carter Sanders
This is very vaguely connected to programming in overall and functional programming isn't any more connected to it than any other programming and it doesn't really belong to this thread but I'll tell you what I think since you asked so nicely.
You actually don't need anything special for programming (especially since you said you're making a start so I guess you won't have projects with hundreds of thousands of lines just now). 2010 cum-stained Thinkpad is enough. Compilation times depend heavily on the CPU but you won't have problems with it until you try to compile very big projects. More important is having a machine that actually can run programs you write if you want to make some 3D graphics or something (older integrated GPUs will struggle with 3D graphics). If you want to learn programming in general you'll write undemanding programs and if they run slow on your computer it means you're doing it wrong. If you want to get into 'muh machine learning' then you'll certainly want a good deal of RAM but I don't think there is much programming going on actually.
Hunter Cruz
ROSAMUNDE FRAG DOCH NICHT ERST DIE MAMA
Michael Diaz
The core of Emacs is ELisp interpreter that is written in C. Most of what is considered Emacs is ELisp indeed. Jane Street uses OCaml. I've heard of Haskell being used in banks for critical parts (critical in correctness view point). There is an editor written in Haskell named Yi, but it isn't a commercial project and isn't really mature and I don't know if it's even being actively developed.
Julian Flores
What is fftw?
By the way, nice quads.
Carter Allen
Thank you for the info. I tried finding a more relevant board but gave up after not seeing a programming general thread. >inb4 somebody links me to it and proves i'm lazy/a dumbass
So the general takeaway is go for CPU performance with 4-8gb ram since nothing special is needed and basically pay to attention to the graphics? Thx user xo
>clunky for statement you mean standard and correct for statement
Landon Reed
Generally, you can just wait longer for your program to execute if you have a slower CPU, but if you run out of RAM, you're fucked for good. On the other hand, you shouldn't really write programs that run out of RAM to begin with, maybe only for experimental purposes. GPU is definitely the least important though, unless you specifically want to write programs that use it.
Blake Evans
don't die /fpt/!
Gavin Nelson
Java programmer here, where do I start learning functional programming?