[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

So... Is functional programming the next big thing, or is it

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 153
Thread images: 15

File: Haskell-purple.sh.png (16KB, 650x650px) Image search: [Google]
Haskell-purple.sh.png
16KB, 650x650px
So... Is functional programming the next big thing, or is it just something that's gonna vanquish soon? It seems to me like it's going to be a big turning point in the programming world. What does /g/ think about it?
>>
>>61670060
I enjoy F#, but there is no way my team/enterprise will embrace it.
>>
It's a useful style of programming thats existed for a bajillion years. Its just gaining a lot of attention because of hipsters.
>>
>>61670070

it's gaining attention because if your systems are sufficiently formalized you can automatically generate tests or detect bugs/security flaws
>>
>>61670060
FP is catching on like crazy right now, but the thing is that we're not even at peak functional programming yet, there's a lot of concepts that are still only barely catching on in popular languages. I think it still has a ways to go before it "peaks" and only then will we see if it's just hype or if it's actually here to stay.

>>61670070 is right that most functional programming concepts have been around for a long time and people have just ignored them, but a lot of type theory and category theory has only recently been realized by actual programming languages. Also, there is tons of academic shit that gets published as papers but never sees the light of day, will people dig those papers up and realize they're actually onto something? Who knows.

"The computer revolution hasn't happened yet" - Alan Kay
>>
>>61670060

Can someone explain to me what functional programming is?

it sounds like it's just about passing function pointers around, but there's got to be more to it than that with all the self-congratulatory wankery about the elusive "monad" and all the other bullshit I don't understand and am not sure about whether I need to understand it.
>>
>>61670160
Programming that's actually functional rather than just boiler plate code.
>>
>>61670160

functional programming has little to do with pointers, you can write a functional system on a piece of paper using category theory or lisp or whatever other higher order function system and implement it straight on hardware, the core idea behind functional programming is Determinism

https://en.wikipedia.org/wiki/Determinism

functional programming's goal is eliminating "boilerplate" code and knowing exactly what your system will be doing given its parameters, defining the consequences and constraints of a system in a way that can makes automation easier and encourages code reuse

the original invention of compilers was a functional way of addressing low level hardware programming, the invention of programming languages was a functional way of making it easier for humans to read and write code, and there a different ways to approach functional programming that balance human readability against formal definition

but basically, if you're not programming is some sort of functional mindset you're going to end up not reusing code properly, writing unnecessary code, your programs will be harder to automatically test, or your programs will have undefined behavior

the lambda calculus is one way to do this, encourage human readability and you end up with Lisp, encourage more rigorous specification and you get Haskell, though any mathematical formalism for specifying code that takes into account the algebraic constraints of a program is a form of functional programming
>>
Is it worth learning functional programming than? I'm currently on college for Computer Science and I'm trying to learn new things and trying to trace a professional path, so my question actually is: is it possible to make a living with FP? And if so, is it the same as "common" programming paradigms?
>>
>>61670314

>is it possible to make a living with FP?

some day it may be impossible to make a living /without/ using FP, it is an exponentially more robust way of specifying systems

I am a freelance software developer and use functional programming for all of my projects, and in my previous salaried or contract position used functional programming to automate my work or fix shoddy imperative implementations

>is it the same as "common" programming paradigms?

even imperative languages are converging towards functional programming techniques, pretty much every "new" feature added to more common languages is a shoddy implementation of a functional programming concept, ie C#/Java/javascript have lambdas/closures/higher order functions
>>
>>61670361
Not just lambdas, if you look at e.g. C# async/await, it's basically just monads, same with Java Optionals and Streams. In the last few years we've seen every single language add lambdas because they are obviously extremely useful. I predict that in the future monads will be the next functional feature to catch on. When people become more accustomed to programming functionally generically and w/o side effects, the idea of monads should be easier to grasp.
>>
>>61670393

can you try to explain what a goddamn monad is?

you say async/await/promise etc is basically a monad, but is it? every other source talks about type, and those have nothing at all to do with type
>>
>>61670578

https://en.wikipedia.org/wiki/Monad_(functional_programming)

Monads are hard to explain because they are intentionally an extremely high level abstraction
>>
>>61670578
A monad in X is just a monoid in the category of endofunctors of X, with product × replaced by composition of endofunctors and unit set by the identity endofunctor.
>>
>>61670681
>>61670661

how about this you fucking mongoloids:

a monad is a class that contains a method which accepts a function as argument, and applies that function to its fields.

IS THAT SO FUCKING HARD?
>>
I don't "get" functional programming
Can someone point to a basic way to help?
Lisp looks cool
>>
I'm learning fp with scala and I don't get clue about functional architecture. Are there any patterns like in oop? Why in books about FP they're using classes? Are there classes and objects in FP? How does typical program written in FP looks like from point of architecture? Is it just functions and definitions of data structures for it(so it looks like procedural code)? Can there be functions in data structures?
>>
>>61671690
Learn you a Haskell for great good or programming in Haskell
Lisp is alright but isn't really a "functional" language, just a multiparadigm language that lends itself to functionality
>>
>>61671690
LISP dialects and Haskell/ML/etc. are completely different things. LISP is good because of "everything is defined by (function ...)" and meta-programming, the others are for great because of their powerful type systems.

>>61671756
Yes, biggest project I wrote was a front-end in PureScript and it looks pretty "procedural" from the bird's eye view. Each file defines some data types and functions that work on these data types... and then you have some logic in your main function glueing it all together.
>>
>>61671812
So no objects? Simply functions and data structures like in procedural programming but just with immutability, hof n sheet?
>>
>>61671214

>class
>method

check out this idiot
>>
>>61671214

this is not a correct definition
>>
>>61671828

if you think about objects and classes long enough you realize they're just lists or lists of lists

functional programming does not require immutability but it does benefit from it
>>
>>61670292
there's no way a majority of 'programmers' out there will be able to handle this.

No fucking wonder /g/ loves it.
>>
>>61671828
Yeah, and then you use all the stuff Haskell type system offers to build abstractions.

OCaml is another story, they have modules and objects that are very OOP-like.
>>
>>61670292
Your post explaining functional programming was barely fucking readable, i highly doubt it produces more readable code than object oriented design.
>>
>>61671214
Sounds really really easy to fuck up...
>>
>>61671214
The "method" is not even a method. It exists outside the "class" and is related to it only by its signature.
So yes, that was fucking hard.
>>
>>61671896
This shit will never catch on desu. Its only for self employed developers or those on the spectrum.
>>
>>61671910
So what's the key point? Where is border between functional and procedural code? I can see this difference in oop
>>
>>61670292

Mostly right from a theoretical perspective.

But for me, practically, thinking about writing programs in a functional style encourages highly understandable, testable, and therefore durable code.

A function should do one thing well. A function should not have more than a couple lines.

Show me a beautiful piece of code that isn't simple. It doesn't exist.
>>
>>61671911
>>61671947

t. horse breeders right after the invention of the automobile
>>
I think OOP languages will continue to absorb features from functional languages rather than functional languages becoming popular.
>>
>>61670160

it's normal programming except the goal is for it to work like math.

You don't keep track of where the program is.

Instead, you define things and think of them as mathematical definitions.

It is made with the type of autist who likes generating functions and recurrences and number theory and shit in mind.

>>61670314

You would learn a language like Haskell for fun and never make a penny off of it.
>>
>>61671911
>object orientated
>readable

o i am laffin
>>
File: Spark-logo-192x100px.png (6KB, 192x100px) Image search: [Google]
Spark-logo-192x100px.png
6KB, 192x100px
>>61670060
> So... Is functional programming the next big thing,
It's one of the big things going forward, not "the next" big thing. It'll probably be relevant until we stop using multi-core or distributed systems or come up with a fundamentally new way to using them somehow.

But it's almost more pic related that is used in production than Haskell.
>>
>>61672058
> It is made with the type of autist who likes
... running a program across more than one machine or more than one core.

That's the actual big thing driving adoption now, not the concern for correctness or even the natural reuseability that functions have (you can't really go wrong with taking pure functions "out of context", they work everywhere).
>>
>>61670115
What papers senpai? I really want to read them but all I know is staring at the sci hub search bar...
>>
>>61671955

Functional always returns a value, never changes it. Using functions. Any tacos
>>
>>61672058

>the goal is for it to work like math

in the sense that math is reliable and easier to automate yes, are all functional languages exactly like Haskell or Coq? No, in Lisp the core element is the s-expression, in Erlang the core elements are messages and processes

>You don't keep track of where the program is.

In proper, systems critical functional programming you DO keep track of program state, but yes, in beginner haskell tutorials you aren't juggling placeholder variables

>It is made with the type of autist who likes generating functions and recurrences and number theory and shit in mind.

You do not need to be an autist to understand functional programming, if Haskell seems too difficuilt for you to understand, Lisp is a language that combines both imperative and functional techniques that serves as a good introduction to functional programming.

>never make a penny off of (functional programming)

I'm 23 and I'm self employed doing functional programming. In my previous positions (been doing professional programming since I was 16) I used functional programming to automate everything and fix issues in imperative systems.


>>61672125

functional programming won't stop being relevant until AI systems can traverse the formal spaces of functional systems automatically and make all of our programs for us based on neural inputs

>>61672167

In Lisp you can create functions that return other functions, but also change the state, there are many gray areas in functional programming.
>>
>>61670160
I think the defining characteristic of functional programming are immutable data, just like mathematics which is static and immutable
Q: Given x = 1 + y and x = 2, what is the value of y?
A: y = x - 1 = 2 - 1 = 1
Test: 1 + y = 1 + 1 = 2 = x

In imperative programming data can change in anytime
x := 2;
y := x - 1; // y == 1
x := 1; // because we can and data is not immutable as it should
(1+ y == x); // FALSE, because x mutated
;
This data immutability along with all the mathematics unlocks interesting qualities, like functions returning functions (see functional analysis), type inference and polymorphism and operator overloading that makes sense (in mathematics you don't deal with trivial shit like types, you just define +:X x X -> X and *:R x X -> X, where X is a set), lazy evaluation (being able to define infinite arrays and treating them like they are calculated even though they are not because they are immutable, just like mathematics) and using recursion and pattern matching (like mathematics) instead of iteration and loops.
>>
>>61672187

Sure, but functions are just another value, as for changing states, I suppose most languages aren't pure anything.
>>
>>61671955

Well, both functional languages and procedural languages have structures modelled on mathematical functions. Where they differ is in how far they take the analogy - procedural languages have intermediate values and are made up of multiple steps, and a functional language function is simply a map of input values to output values without intermediate steps..

Functional programming is characterised by lots and lots of recursion. There's nothing else.
>>
>>61670060
Next big thing since 1950.
>>
>>61672038
functional programming has been around since before the paradigms we use today you retard
>>
>>61672187
>functional programming won't stop being relevant until AI systems can traverse the formal spaces of functional systems automatically and make all of our programs for us based on neural inputs
That would still mean functional programming remains relevant.

You are talking about current humans becoming obsolete, not FP.
>>
File: david-full-front.jpg (52KB, 322x600px) Image search: [Google]
david-full-front.jpg
52KB, 322x600px
>>61672200
You are thinking functions in the bastardised way imperative programming languages taught you and not in the pure mathematical way.

Mathematical functions are objects that describe (not calculate, nor return) how each object of one set correspond to objects of another set. Functions don't mutate anything, they just exist. If you don't understand the properties of a set you just select (select, not create, in mathematics you don't create anything, you just select things from all those that exist) a function that corresponds objects of the unknown set to objects of the known set and eventually you uncover the properties of the unknown set.

The state never changed. Even when the set was unknown the properties of it were well defined and static and they never changed, you just discovered them.

Programmers think they are inventing stuff, creating things the didn't exist before, while mathematician know they discover stuff, things that existed long before them and will exist long after them. Mathematics is all about immutability and never changing state.
>>
File: 1420739097579.png (123KB, 785x757px) Image search: [Google]
1420739097579.png
123KB, 785x757px
>literally can't write an in place algorithm
>>
>>61672199
> in mathematics you don't deal with trivial shit like
a properly defined syntax. Mathematicians wasted each other's time for centuries with that one, particularly when you didn't stay within one or another field only.

Only now that computers will block your path on ambiguous definitions (including types) for which you should just pick the better one we actually get an increasingly (but not yet completely) sane syntax for maths in programming languages.

Should have been done ages ago, though.
>>
>>61670060
It's neither the next big thing nor is it going to vanquish. It's always been very useful in many situations and will continue being, just because of its simplicity, conceptual stability and mathematic approach familiar to anyone decent in maths.
>>
>>61672380
>Mathematics is all about immutability and never changing state.
BS. Very standard maths has variables.

Even if mathematicians very often take the functional approach to describing things, it's not always the case by any means.
>>
>>61672406
>Very standard maths has variables
The variables in math don't change. They are pure and not the ugly mutable things imperative programming language variables are.

When the professor asks you "what is the value of x" you don't change the value of x. x is well known before even you show the problem. What the professor really ask you is to correspond x to a value from the set of numbers.
>>
>>61672440
> The variables in math don't change
They do. You are completely allowed to change a variable inside a function based on an argument to the function or whatever.

That is the same shit as with imperative programming. Elevating conventional maths to being actual FP makes no sense. It is not.
>>
File: FOR LOOP.png (12KB, 156x76px) Image search: [Google]
FOR LOOP.png
12KB, 156x76px
>>61672440
lol
>>
>>61672470
>You are completely allowed to change a variable inside a function based on an argument to the function or whatever.
Nobody does this.
>>
>>61672470
>You are completely allowed to change a variable inside a function based on an argument to the function or whatever.
Once a variable is bound it can't be bound to another value. Keep in mind that a function is just a template for creating an expression, f(1) and f(2) are different entities.
>>
>>61672495
Yes, they do. Both physicists (...ultimately the co-authors of maths 'cause valid standard maths is ultimately designed to always work in actual reality) and mathematicians.
>>
>>61672518
Give me an example.
>>
File: 1491212354819.jpg (19KB, 288x240px) Image search: [Google]
1491212354819.jpg
19KB, 288x240px
>>61672518
>'cause valid standard maths is ultimately designed to always work in actual reality
>>
>>61672526
Has already happened >>61672472. See how this is even something where "i" is reassigned a different value after the initial number 1?

Anyhow, happened a lot of times at uni too, but I no longer have these notes.
>>
>>61672552
The i is bound to different values in different sub-expressions. It's not the same i, it's "scoped" differently.
>>
>>61670060

>Is functional programming the next big thing, or is it just something that's gonna vanquish soon?

It's not the next big thing but it's a nice tool for some problems. And it's not so good for other problems.

Basically functional programming is good when you have fixed "things" and want to easily add "operations" on them. If you add new things, you have to painfully rewrite function definitions.
OOP is good when your operations are fixed and you want to add "things" (with different states) easily, i.e. OOP is much better for programming games. But when you want to add functionality to things, it's often pretty difficult and you have to use interfaces, mixins and/or editing many class definitions.


>>61670160

There is no clear definition for all programming languages. But it's centered about the thought to reduce mutable data (you will always have mutable data, i.e. all I/O is mutable).
This is to reduce "stateful" programming as much as possible.

In "real" functional programming you have no control variables, but things like iterators and generators. Many things are similar, but the way you look at it is slightly different.


>>61670578

Say you want to reverse a string. You can't change strings. But a string is only a list of chars. And you can rearrange those list elements. So mr. Monad comes, breaks this list into char pieces, rearranges those pieces backwards and glue them to a list again. Then we have another string.

Monads are like reachers which enable you to look at "things" in a certain way.
>>
>>61672187
I'm very new to this. I have worked with some 'normal' programming.. Gotten used to classes and how they work, inheritance and such..
I looked for 'lisp' and there are a lot of different versions.. I would like to learn functional programming, where should I start?
>>
>>61672552

This guy is right:
>>61672585

The big difference is, that "normal" programming everything is always a function of time. So you can stop at a given momment and ask: "now what is the value of x RIGHT NOW".

In math everything happens at the same time. Even if you include "time" as a variable t and integrate over it, you don't walk along this line and sequentially raise the value. No, you add everything "at the same time", so to say.
>>
>>61672662
OOP is pretty much only good for giant inefficient corportations that operate on a monkeys-on-typewriters business model and need to prevent incompetent but cheap labor from shooting each other in the foot. In the modern sense, at least; I doubt Alan Kay had Java in mind.
That said, non-functional programming that isn't OO is still usually more versatile than FP.
>>
>>61672701
read sicp
>>
>>61672710

This is the typical writing of functional fanboys that think there is a silver bullet in computation, a "one size fits all" solution. But there isn't.

For some problems a lambda calculus language is just terribly cumbersome while a turing machine handles things much more gracefully.

Let's be honest:
A microprocessor is a stateful thing. You have flags, even flip-flops are basically statefull. At the lowest level your beautiful Haskell programm turn into ugly assembly full of GOTO statements.

I'm not saying functional programming isn't a usefull abstraction, but it's only an abstraction. Look at it like a tool, not like a religion.
>>
>>61672814
>A microprocessor is a stateful thing. You have flags, even flip-flops are basically statefull. At the lowest level your beautiful Haskell programm turn into ugly assembly full of GOTO statements.
Circuits are functional. A transistor implements a pure function. Logic gates are purely functional. Clocks and registers are imperative abstractions over functional constructs.
>>
>>61672836
Enjoy your clockless registerless cpu,
>>
>>61672814
This desu. Still waiting for functional fags to show me some fast and efficient numerical algorithms dealing with matrices and similar.
>>
>>61672879
I'll enjoy my clockless registerless FPGAs. The turing machine isn't as fundamental as you think.
>>
>>61670060
>Is functional programming the next big thing
>next
Uhm, functional programming was big in the 50s and 60s and have somewhat faded into obscurity now.

>or is it just something that's gonna vanquish soon?
It's never going to go away, since many FP concepts are unironically good.

>It seems to me like it's going to be a big turning point in the programming world
The "big turning point" has already been around for some 20 years. All modern multi-paradigm programming languages incorporate functional concepts in varying degrees.
>>
File: 1486007700381.png (1MB, 660x1010px) Image search: [Google]
1486007700381.png
1MB, 660x1010px
>>61672922
>The turing machine isn't as fundamental as you think.
Yeah it's just by far the most popular model of computation.
>>
>>61672836

But it all starts with the CPU. The CPU has a Clock rate. It runs through his BIOS, loads up libraries, detects hardware..
All in all a very stateful process.

FPGAs are a good example. They are purely logical. But it's better to use them for isolated problems instead of being the "master control programm" in the background.

The most successfull functional langauges are those where you can opt in to use non-functionalcode if you want to. There are only very few exceptions to this, i.e. Prolog being used in flight transfer.

Functional programming tries to avoid all side effects, and that's why it's so great and usefull:
Because it's incredibly difficult to understand all possible states of your code. OOP had to come up with exceptions getting wrapped about difficult parts to intercept "stupid states". And yes, that's hacky and unclean. But often it works much better than you would expect. Sometimes side effects are just the simpler solution.

So personally I think it's important to learn functional programming and to avoid it whenever it makes sense - but not always.
>>
>>61671929
not put it in the box but put a box around it. The floor values and ceiling values are implied.
>>
>>61672703
> In math everything happens at the same time.
Nope. There clearly are sequential steps in there.

But sure enough, I challenge you to show me the device or person who can "make it all happen" at the same time.

I obviously know you can't but I also already almost know it won't *ever* work because as far as we can tell, our maths is even *invalid* at scales lower than Planck time. It fails to describe anything correctly. All necessarily sequential maths ONLY works when individual steps take at least one Planck time unit.
>>
Imperative programmers are the econ majors of compsci.

If you aren't familiar with FP, you aren't a computer scientist.
>>
>>61672922
Yeah, the Church-Turing thesis isn't fundamental at all. Spotted the liberal arts major. Are you gender studies by chance?
>>
File: hasklel.png (13KB, 300x225px) Image search: [Google]
hasklel.png
13KB, 300x225px
>>61673379

>Nope. There clearly are sequential steps in there.

Yes and no. Math functions usually operate on sets. Even if the set are unordered or have a different order.

For example let's talk about the pic here:
>>61672472

What do we have? We have a function that takes an one argument (n) and returns one value: n*(n+1)/2. We have the i (which is "every number in questions") and we have the upper bound (n), but we do not have a accumulator variable. It all happens "concurrent".


This becomes more obvious when we write the sum as integral (a sum is simply a special case integral). And even more obvious when we change from Riemann integral to Lebesque integration.

In the end the formula in the pic as more like calculating an area, very unlike we would make a summation in our head. Humans can only do "procedural" math in their head.
>>
>>61670115
>FP is catching on like crazy right now
It is?
>>
>>61670060
Using it just for the sake of using it.

However, if you want to write something dealing with datastreams, parsers or stateless applications in general, functional languages might be better suited for your needs. For state-retaining programs they suck ass.
>>
>>61675751
Fuck, I meant to write "Using it for the sake of using it is just memeing"
>>
File: 1501150900961.png (6KB, 300x300px) Image search: [Google]
1501150900961.png
6KB, 300x300px
>>61670060
>s functional programming the next big thing
it's been going strong for decades, newfags are just now catching up to it
>>
>>61672814

>A microprocessor is a stateful thing. You have flags, even flip-flops are basically statefull. At the lowest level your beautiful Haskell programm turn into ugly assembly full of GOTO statements.

the irony of this statement is that all the major hardware engineering firms are switching to functional specifications for automated verification

this poster is full of horsehshit
>>
>>61670060
>So... Is functional programming the next big thing, or is it just something that's gonna vanquish soon?
No its not the next big thing, it is already here and the hype is fading slowly.

>It seems to me like it's going to be a big turning point in the programming world.
No, you have bad forecasting abilities. Lisp and haskell have been around since always. They are only useful for certain problems, which are not the kind of problems you encounter in the corporate world, but the ones you usually see in academia, robotics and telecommunications.

Most general purpose languages have lambdas, filter/map/reduce, and function as objects support, but these are not enough to code only in the functional paradigm, because you would need laziness and other features that you can't easily add to an existing language without breaking compatibility.

And then there are the web devs monkeying around react/redux because they think its a better way to code in JS (kek)
>>
>>61672380
And this kind of shit right here is why functional programming will never catch on.

People in general hate maths.
>>
File: 1500305685419.jpg (48KB, 522x522px) Image search: [Google]
1500305685419.jpg
48KB, 522x522px
functional programming is the top of the top. No other superior

How do you think you are gonna program all of those processors in a concurrent way. You're gonna have to use immutable datastructures goofus
>>
>>61680692
with mutexes and locks
>>
>>61677794
> tfw they wrote a HDL in Haskell
http://wiki.bluespec.com/
>>
>>61680955
It's a natural fit.
>>
My company saw a significant increase in productivity and decrease in bugs by switching to just higher order components for certain abstractions.
I'm not sure about other concepts but everyone at my company and client company are in love.
>>
>>61678291
Pure functional programming, sure. First class functions, declarative systems, and composability are all common.
>>
>>61672892

compiler optimizer research is almost completely functional programming these days you fool
>>
>>61670096
Some classes of bugs. I bet you people will be just as stupid as the coders as far as logic errors are concerned.
>>
>>61682633

if your system is formalized from the semiconductor crystal lattice up there ain't much room for bugs m8
>>
>>61670060
>>>/reddit/
>>
>>61670060

Pure functional programming will never hit the mainstream, it's simply not a practical paradigm.

That said lots of languages use functional programming concepts to great advantage, and this is where it has made traction.

There's a reason Haskell is only popular in academia, where you don't have to actually write programs that work, just write about writing programs which may work.
>>
>>61683555

>compilers without inline assembly will never hit the mainstream, it's simply not practical

>Haskell is only popular in academia

haskell is only popular in academia because most programmers are brainlets, or lazy, experts in high speed trading, security analysis, bioinformatics, hardware architecture, AI, and just about every advanced field of systems development are adopting it
>>
>>61683602

LOL, the reason Haskell isn't used outside of academia is because you can't spend a week trying to figure out the magical incantation which will make the compiler generate efficient code, inb4 'look at my fibonacci sequence'.

It's truly something which only works in academia, where you can spend two weeks on how to most elegantly avoid side effects in your code and then impress your teacher.

In the real world you need to create efficient code in a timely manner, because here development cost money.
>>
But muh games
>>
>>61672243
historical accident man

FP WILL WIN
>>
File: C9TRqQMWAAAtin6.jpg (29KB, 640x640px) Image search: [Google]
C9TRqQMWAAAtin6.jpg
29KB, 640x640px
>>61670060
>variables can't change
>so you have to keep making more variabal
>but then one day you run out of variabele

Checkmate, functional programming.
>>
>>61681040
What does that have to do with my post?
>>
>>61672199
Out of the are several competing definitions of functional programming this is the most productive IMO. Of course, some object to this because you can have immutable data without first-class functions.
>>
>>61684935
>>61672199
But that's retarded.

Why would you set x to be 1? If you didn't, the program would've worked.
>>
>>61684732

nigger can't into the state monad

https://wiki.haskell.org/State_Monad
>>
>>61685005
>runState

I don't think so, pal. Functional programming is supposed to have """NO""" states. Please provide an example the qualifies under these circumstances.
>>
>>61685048

the state can be turned into a function ya twerp noob
>>
>>61685072
I have no idea what I'm talking about.
>>
>>61670292
>human readability
>Lisp
Pick one.
>>
>>61670578
ok, so you have some function.
type1 name(type2)
a monad transforms that into
optional<type1> name(optional<type2>)
where if you pass null you get null.
>>
File: 1492020125760.png (12KB, 225x321px) Image search: [Google]
1492020125760.png
12KB, 225x321px
>>61670292
>a way that can makes automation easier and encourages code reuse
Imagine actually believing this.

>When it comes to code reuse, projects that used an object-oriented approach were able to take more than 70% of their code from previous projects. Subsequently, the projects that used functional design were able to take about 35 percent of their code from previous projects (McGarry, Waligora, and McDermott 1989).

Try harder, functional memer.
>>
File: retards_actually_fall_for_it.png (513KB, 1064x1401px) Image search: [Google]
retards_actually_fall_for_it.png
513KB, 1064x1401px
>>61670060
Don't fall for it. Functional programming is literally the feminine penis of /g/. There's a reason no functional programming language has ever achieved any level of real-world relevance. OOP is the way to go if you wanna find a job and not just write hobbyist code, kid.
>>
File: xkcd.png (98KB, 609x414px) Image search: [Google]
xkcd.png
98KB, 609x414px
>>61686732
>xkcd
>>
>>61686773
It must hurt for you functionaltards knowing that a language like Perl is more relevant than any functional programming meme language will ever be.
>>
>>61686790
>language made by an unironical creationist
>''''''''''''''''''''relevant''''''''''''''''''''
kek
>>
>>61686799
>implying the world wasn't created by God
Sure is fedora in here.
>>
>>61686773
For what purpose did you post that half of a comic
>>
File: haskell_the_ultimate.jpg (58KB, 600x487px) Image search: [Google]
haskell_the_ultimate.jpg
58KB, 600x487px
>>61670160

I'm going to share with you the best book I've found on it. It explains all the secret math shit that makes you feel like a tard when talking to the functional programming gods. Once you get it, the density of the ideas they are expressing in so few words becomes clear to you.

https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/
>>
>>61675227
It isn't.
>>
Here is a god tier video explain functional programming.
https://www.infoq.com/presentations/functional-pros-cons?utm_source=infoq&utm_medium=QCon_EarlyAccessVideos&utm_campaign=QConSanFrancisco2013
>>
>>61677871
Laziness isn't inherent to FP at all. Just look at Scheme.
>>
A pure functional system will never exist.
>>
>>61670060
No one actually knows, fag.
I wish /g/ would stop it with these predict the future posts. They're so fucking trite and hardly lead to worthwhile discussions.
>>
>>61670060
It will be the next big thing if they start teaching it to the pajeets
>>
>>61670292
>the original invention of compilers was a functional way of addressing low level hardware programming
Yeah, no. Stop spreading bullshit, you fucking idiot.
>>
>>61686804
>i don't know what really happened or how it works, so God did it.
>problem solved!
>>
>>61683715
Then why does finance use functional programming if it's inefficient?
>>
>>61686845
>that pic
I want more
What about Lisp
>>
>>61687719
That's a very fair point, anon.
>>
>>61670060
Most programming is functional programming. This has existed since the early 1960s, probably even the 1950s.
>>
>>61672939
This
>>
>>61687001
thanks :)
>>
I've been playing with idris for about a week on an off now and it's quite a bit of fun to see a language with a "higher" level of abstraction than Haskell. Dependent types really do make a difference in both program design and testing and it will be interesting to see if other languages catch on to this too. Linear types are also quite interesting and from what I've read there's interest for idris to have them based of the Clean language's Uniqueness Types. So to my questions...

If implemented, will linear types allow us to finaly write efficient code in languages such as idris, agda, coq, &c. for limited resource platforms such as the arduino, photon, &c. Also will they speed up standard desktop programs or is it not worth the effort? I have heard about MLKit which seems to have a bit to do with this even if it's not directly linear types.

Once FP is efficient enough to not be questioned, will we see a decline in procedural language use similar to that I've seen in the UK with the rise of Haskell, Scala, et al?

The most interesting part so far has been embedding state transition diagrams into code, I'm also wondering if it's possible to have functional programming side with a visual element to aid civil engineering and such by allowing them to construct buidings using a type system such as the one in use in idris to quickly construct building supports without the need for any complex software. I might have lost the point a bit but what I'm essensially asking is if it's possible to have just a constraint library similar to Control.ST where we could define a building as a function and have the program print out schematics, material requirements for support structures and a demo of the structure from something as slimple as the sample below.

house : Building Schema []
house = joined $ fromList
[[Floor 0 $ room 5 4 3 "living" `leftOf` (room 3 3 3 "kitchen" `behind` room 2 3 3 "balcony")]
,[Floor 1 $ r(oom 5 4 3 "play hall" `above` Room "")]]
>>
>>61691401
The example is incomplete and pretty basic as I reached the character limit with my other example.
>>
>>61675227
>Taking anything said here as fact and not just the shitposting of NEETs that it is.

Hello, newfriend.
>>
>>61691451
>Failing to see the obvious changes to modern programming and the push for cleaner languages

Time to get out of bed friend
>>
>>61691481
>FP
>modern programming
Modern programming languages have incorporated FP concepts for literally decades. The whole meme called "multiparadigm" was invented by bootstrapping the concept of higher-order functions onto object-oriented programming.
>>
>>61686845
>Java
>White
Try again. This time, add more curry.
>>
>>61691498
As if methods aren't higher order functions already
>>
>>61691517
>As if methods aren't higher order functions already
They're not.

>In mathematics and computer science, a higher-order function (also functional, functional form or functor) is a function that does at least one of the following:

>takes one or more functions as arguments (i.e., procedural parameters),
>returns a function as its result.
>>
>>61691541
An object with a single method is effectively a first order function. Passing such an object to another method makes that method a higher order function.
>>
>>61691572
*first class function
>>
>>61691572
Yes, that's true. But that doesn't mean that all object methods are higher order.
>>
>>61670314
Sure, functional programming is worth learning to how shit it actually is outside of the meme zone. They'll probably teach you scheme
>>
>>61691590
That's right, but I think you see my point. OOP and FP aren't as dissimilar as FPfags would have you believe. To say it began with higher-order functions being tacked onto OOP is misleading, since OOP is a result of FP principles being tacked on to procedural programming.
>>
>>61691638
>OOP and FP aren't as dissimilar as FPfags would have you believe.
That's the exact point I've been trying to make all along, though. All modern OOP languages are so-called multiparadigm, because they incorporate concepts from multiple paradigms.

>To say it began with higher-order functions being tacked onto OOP is misleading, since OOP is a result of FP principles being tacked on to procedural programming.
That's not true, though. OOP is the result of trying to model real world as close as possible in computer code. Functional programming is the result of trying to apply lambda calculus on computers. The former is very concrete, the latter is abstract as hell. But they share some properties, because they're both invented by mathematicians.
>>
>>61691698
I'm not sure I agree.
>OOP is the result of trying to model real world as close as possible in computer code.
Is it really? OOP is often introduced in terms of hierarchies of concrete things (e.g. some basic animal taxonomy) but that's not how it works in practice.
The way I see it, objects and closures solve the same fundamental purpose as opaque, reusable, composable encapsulations of bound-together data and code.
I think well written OOP looks a lot more like FP than these models of real-world relationships.
>>
>>61691893
>Is it really?
Yes, really.

https://en.wikipedia.org/wiki/Simula

>OOP is often introduced in terms of hierarchies of concrete things (e.g. some basic animal taxonomy) but that's not how it works in practice.
That's because OOP originally was invented for this purpose, but has evolved like programming in general.

>The way I see it, objects and closures solve the same fundamental purpose as opaque, reusable, composable encapsulations of bound-together data and code.
>I think well written OOP looks a lot more like FP than these models of real-world relationships.
That's true, but it is because programmers have become more accustomed to think in abstract ways.
>>
>>61691937
I have to admit, I'm not familiar with "classic" OOP languages like Simula and Smalltalk and only know the modern fare like C++ and Java. I'll take your word for it.
>>
>>61671690
try elm, its very easy to get started and, unlike haskell, very useful.
>>
>>61671756
scala is pretty bad for learning FP, it allows too many no FP-isms. I'd recommand something else to get started, e.g. Haskell or Elm or Elixir
>>
>>61691957
Well, I'm obviously coloured by having had Kristen Nygaard as one of my first professors (before he retired) and that was of course their intentions, but there are other "schools" of object-oriented programming that spawned from that very quickly in the late 70s and early 80s.

But I wholeheartedly agree with your observations on "well written" OOP of today, though.
Thread posts: 153
Thread images: 15


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.