[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Functional Programming
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 43
Thread images: 7
File: functional languages.png (115 KB, 719x543) Image search: [Google]
functional languages.png
115 KB, 719x543
oop babbies pls go
>>
File: scala.gif (16 KB, 635x282) Image search: [Google]
scala.gif
16 KB, 635x282
>>46870125
missed one
>>
>>46870125
>oop babbies pls go

>posts ocaml, js, and f#
>>
File: 1412119435468.gif (385 KB, 254x144) Image search: [Google]
1412119435468.gif
385 KB, 254x144
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 (10 KB, 141x162) Image search: [Google]
131254281485911.png
10 KB, 141x162
>js
functionally retarded
>>
File: 1416504987498.png (153 KB, 894x894) Image search: [Google]
1416504987498.png
153 KB, 894x894
>>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 (488 KB, 400x300) Image search: [Google]
a meme.gif
488 KB, 400x300
>>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 (50 KB, 489x561) Image search: [Google]
1424230031321.jpg
50 KB, 489x561
>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 replies: 43
Thread images: 7

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.