[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 | Click for more| Home]

Functional Programming

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: 43
Thread images: 7

oop babbies pls go
>>
File: scala.gif (16KB, 635x282px) Image search: [iqdb] [SauceNao] [Google]
scala.gif
16KB, 635x282px
>>46870125
missed one
>>
>>46870125
>oop babbies pls go

>posts ocaml, js, and f#
>>
File: 1412119435468.gif (385KB, 254x144px) Image search: [iqdb] [SauceNao] [Google]
1412119435468.gif
385KB, 254x144px
I've got homework to do in haskell. That's the extent of my functional language experience.

Seems like it's pretty wack.
>>
Imperative programmers care about the end results.
Functional programmers care about masturbating over code.
>>
>>46870333
Functional programmers care about writing less code that is readable and intuitive
>>
>JS
ayy
>>
>>46870341
Exactly.

>muh beautiful lambdas and special-snowflake implementation dialects

This is why FP will never be taken seriously outside of academia.
>>
>ocaml, clojure, f#, erland, haskell
what the fuck is javascript doing there

also, what's the purple one on the top left?
>>
>>46870390
>what the fuck is javascript doing there

For shitposting reasons
>>
>>46870390
because javascript is the only successful LISP
>>
OOP: a fedora is a hat.
Functional: a fedora is not a hat, but there's a function that can turn a fedora into a hat.
>>
>>46870390
it's elixir
>>
File: 131254281485911.png (10KB, 141x162px) Image search: [iqdb] [SauceNao] [Google]
131254281485911.png
10KB, 141x162px
>js
functionally retarded
>>
File: 1416504987498.png (153KB, 894x894px) Image search: [iqdb] [SauceNao] [Google]
1416504987498.png
153KB, 894x894px
>>46870125
penor programming language
>>
>>46870387
see how much nicer it is?

void shit() {
int[] nums = new int[100];
for (int i = 0; i < nums.length; ++i)
nums[i] = i;
for (int i = 0; i < nums.length; ++i)
nums[i]++;
}

void good(){
IntStream.rangeClosed(0, 100).map(i -> i+1);
}
>>
>>46870125

Why is functional programming better than object oriented programming?
>>
>>46870492
best is when they are combined
>>
>>46870498
>what is scala
>>
>>46870553
yup, scala is great
>>
>>46870498
Learning Haskell right now and I really can't see what OOP offers other than syntax.
>>
>>46870622
does haskell have traits?
>>
>>46870631
Assuming you're talking about Scala, Google tells me that they're "Similar to interfaces in Java".

I can't say too much but they're probably very similar to type classes in Haskell.
>>
>>46870469
Implying you couldn't have done it using a single loop.
>>
>>46870670
yes, but I'm showing 2 operations here
you can pass the array and stream around in the same way but the functional version is readable
>>
im an oop babby who knows php and js. which functional language should i start with? i know they both technically have some functional properties but id like something more parenthesis heavy i guess
>>
>>46870387
>This is why FP will never be taken seriously outside of academia.
Except all the companies that are already using it. Get fucked you ignorant fanboy.
>2015
>still parroting stupid shit
>>
>>46870387
>FP will never be taken seriously outside of academia
oh lawd
>>
File: a meme.gif (488KB, 400x300px) Image search: [iqdb] [SauceNao] [Google]
a meme.gif
488KB, 400x300px
>>46870387
>FP will never be taken seriously
>>
>>46870663
a class can have any number of traits, and traits can have fields & methods with implementations

seems like in haskell a List of a typeclass can't contain multiple different items, but in scala, traits are simply polymorphic (List[HasAddMethod] can have any instance of any class that has that trait)
>>
>>46870738
not that guy, but I'm not sure what you're trying to get at with that List example
>>
>>46870764
this
https://stackoverflow.com/questions/25956658/the-purpose-of-type-classes-in-haskell-vs-the-purpose-of-traits-in-scala
>>
OOPers eat shit
http://www.pitheringabout.com/?p=693
>>
File: 1424230031321.jpg (50KB, 489x561px) Image search: [iqdb] [SauceNao] [Google]
1424230031321.jpg
50KB, 489x561px
>learning Haskell
>tfw no idea how to google <$> and all of the other symbol functions
>>
>>46870782
OK, I see what you're saying
I'm not familiar with Haskell, but I gather you're pointing out the lack of OO-style type classing
>>
>>46870870
never tried haskell
;_; i have a list of ~20 books/things i want to learn
fuck
>>
You dont need dedicated functional languages anymore, regular programming languages like D, Go and Swift have the same functional features. Recursive functions are a deprecated way of iterating through collections, recursive functions are just as error prone and verbose as imperative looping constructs like for/while loops. Mapping functions and list comprehensions do the same thing as recursive functions more cleanly and implicitly. And since mapping functions (like foreach) are really methods on collections, it really is an OO way of accomplishing the same thing as recursive functions. So when you add high order functions, lambdas, closures to safe languages like D, Go, Swift, they are capable of the same functional programming
>>
>>46870469
int le_fedora_strawman(int i) { if (0 < i && i < 100) return i + 1; }

Now with 99% less memory usage.
>>
>>46871367
no, create a collection of values
>>
>>46871213
ssh, let them continue their "having a hammer and everything looks like a nail" ways
>>
>>46871213
>And since mapping functions (like foreach) are really methods on collections, it really is an OO way of accomplishing the same thing as recursive functions
>pulling stuff out of your arse so you look smar on the interwebs
>>
>>46870207
Pro tip: 99.9% of Scala users are former Java devs who does not employ functional methods in their codes
>>
>>46871513
shame
Thread posts: 43
Thread images: 7


[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]
Please support this website by donating Bitcoins to 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
If a post contains copyrighted or illegal content, please click on that post's [Report] button and fill out a post removal request
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 4Archive shows an archive of their content. If you need information for a Poster - contact them.