[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]

/fpt/ - Fun(ctional) Programming Thread

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: 308
Thread images: 25

File: 1482154745406.png (369KB, 2700x1800px) Image search: [Google]
1482154745406.png
369KB, 2700x1800px
Next-level programming thread!

What are you going to learn today?

Resources on:
>Erlang
http://learnyousomeerlang.com/content
>Haskell
https://en.wikibooks.org/wiki/Haskell

More resources on more languages to come!
>>
>>58076404
>using fringe languages

Good luck with your life.
>>
What's the point of Erlang when you know C?
>>
>>58076439
What's the point of C when you know Haskell
>>
How do we convert imperative programmers?
>>
File: diva91.jpg (3MB, 3507x2257px) Image search: [Google]
diva91.jpg
3MB, 3507x2257px
>>58076404
>stealing my rare picture
Rude desu
>>58076439
Building scalable, fault tolerant systems?
>>
>>58076404

Nice 404..

Here's a good ressource for Elixir:
http://chimera.labs.oreilly.com/books/1234000001642/index.html
>>
>>58076474
that's what Ada is for
>>
>>58076439
It's shorter:
https://youtu.be/xrIjfIjssLE?t=71
>>
>>58076480
>Ada
Pure meme-language that no one uses
>>
File: diva112.jpg (103KB, 736x1104px) Image search: [Google]
diva112.jpg
103KB, 736x1104px
>>58076495
https://www.youtube.com/watch?v=p1LjmDCOM-8&
Pretty good music video, I was thinking of showing it to Joe Armstrong but I would just look like an autist harassing him on campus
>>
>>58076497
It's never memed anywhere. How is it a meme language?
>>
>>58076505
good choice anon
>>
How do logic languages differ much from functional languages?
>>
>>58076480
Ada isn't made for fault-tolerant distributed systems. Ada excels at fault-tolerant real-time systems.
You want Ada in your car and Erlang to handle web traffic or telecommunication.
>>
>>58076507
"meme" has become synonymous with "joke" with younger people, they're saying Ada is a joke language not that people post about it often.
>>
>>58076959
In logic languages you write a set of rules.
In functional languages you write a set of functions that you can combine to transform data like a long pipeline.

Logic languages are great at expressing rules of systems, for instance game rules. One of my friends once made a language made to describe card games, and he did it as a logic language.
Worked out really well. We even thought about how to express board games, like chess, in it through stacks of cards to represent physical dimensions..
>>
>>58076975
Ada is used for distributed systems.
The institute for distributed systems at my uni uses mostly Ada.
>>
>>58076505
He actually links to that video on his github page.
>>
>>58077092
Cool, didn't really think people wrote Ada that much more.
But Erlang is used for 50% of the world's telecommunication. Why would you use Ada instead of Erlang for this? Erlang was designed for this.
>>
>>58077162
Because dynamic typing is pig disgusting
>>
>>58077093
Cool, didn't see it. I hope he has the course about distributed systems when I take it
>>
>>58076458
We don't. We enjoy the fact our salaries pay higher because of the niche and enjoy our wonderful pure functional algorithms.
>>
>>58077540
you need a balance
it has to be common enough that jobs exist
>>
>>58077555
You're right but in big cities I've had no trouble finding Scala/haskell jobs. Also the barrier to entry is higher for functional Langs.
>>
>>58077572
>big cities
So all your extra money goes into the higher rents
>>
>>58077572
but what if i want to live in a comfy majority-native english town
>>
I'm learning haskell and it's very different from imperative languages. It looks like an advanced calculator.

So, what is haskell used for? I code vidya as a hobby, and haskell doesn't seem to be the right tool to make, say, an mmo.
>>
>>58077605
Generally the salaries are high enough to make the rents irrelevant. Currently Scala pays extremely well .
>>
File: 112.png (72KB, 992x693px) Image search: [Google]
112.png
72KB, 992x693px
finally an actual programming thread
>>
>>58077618
It's a general purpose programming language.
You can use it for whatever you like.

Remember that it's garbage collected though, so it can never be as fast as C.
>>
>>58077617
Unfortunately this is the con with niche tech.

>>58077618
Server side Haskell would do really well for an mmo. The idea is stateless so you can instantly scale servers if you get a spike in players
>>
File: benchmarks.png (30KB, 512x288px) Image search: [Google]
benchmarks.png
30KB, 512x288px
>>58077631
It's not even as fast as Java or Go
>>
quick piece of information that people in this thread will so obviously overlook. bram cohen wrote the first bit torrent client in haskell - the first ever implementation of the bit torrent protocol was written in haskell - as in a groundbreaking piece of software that is used to download upwards of millions of files everyday was written in haskell.

really makes you think.
>>
File: 1479060927420.png (751KB, 1274x1308px) Image search: [Google]
1479060927420.png
751KB, 1274x1308px
>>58077666
>anti Haskell poster
>literally Satan
Get out of God's thread
>>
>>58077679
Huh?
He used Python.
>>
Fpt what are your favourite functional programming books?
>>
>>58077685
It's not my fault that even an Apple developed language performs better than Haskell.
>>
>>58077757
optimised haskell could outperform java
>>
>>58077776
Then come back when it does.
>>
>>58077788
i'm back
>>
What kind of programs do you write in functional languages? Analyzing huge amounts of data?

I get the feeling that a functional program basically has one very specific task, is that correct?
>>
>>58077810
Post your new benchmarks.
>>
>>58077817
No, functional programming is very general purpose.
>>
>>58077618
You wouldn't use it for vidya. Functional programming is a great paradigm for manipulating static sets of data in an abstract way. Video games involve mutating sets of dynamic state and passing it around to other actors. Also, there's not enough libraries for it in Haskell and that's going to be your primary need for making video games unless you feel like spending a year reinventing the wheel on your own.
>>
>>58077824
I don't mean functional programming, I mean one single program written with it.
So I don't expect something like a web browser to be written in a functional programming language but rather something like grep or cat or a component in a bigger program.
>>
>>58077862
Functional programming can definitely be used for that, because it's composable. I'd say using something like grep or cat is a kind of functional programming.
>>
>>58076422
>using normie languages

Good luck with your sanity.
>>
>>58077861
Coroutines and state monad. To play devil's advocate. Not sure how well it would perform. But xmonad is written in Haskell.
>>
bump

inb4 >side effects
>>
>>58076455
>>58076439
What's the point of Erlang, C and Haskell when you know PHP?
>>
>>58078690
Erlang, C and Haskell are enjoyable
PHP makes you want to kill yourself
>>
>>58077656
>Server side Haskell would do really well for an mmo. The idea is stateless so you can instantly scale servers if you get a spike in players
HAHAHAHAHAHAHAHAHA

sorry but HAHAHAHAHAHAHAHAHAHAHA
>>
>>58077861
>>58078041
FRP

https://github.com/ocharles/netwire-classics
>>
>>58077817
>I get the feeling that a functional program basically has one very specific task, is that correct?
Every program basically has one specific task. (Well, except for the mobile market, where ‘apps’ need to sell ‘experiences’)
>>
>>58077862
You can use functional languages to write the same types of programs that you can write with any other language
>>
>>58078704
>making an asteroids clone means it's suitable for an MMO
I already know about FRP. Is this a joke post? Anyone can make an asteroids clone in their language of choice. Doesn't make it good for an MMO.
>>
>>58078725
Well, I'm not really sure what your question is. Which part of an MMO are you trying to implement and what are you stuck on?
>>
>>58078725
Functional programming is good for any application
>>
>>58078780
I'm: >>58077861
>>
>>58078853
Mutation is easy in FP and pure FP
>>
>>58078853
You claimed state is not possible in FP. We provided multiple examples otherwise. Not sure what else you're still unsure about?

btw, the only reason you wouldn't write an MMO in Haskell is because of GC pauses. Same reason you wouldn't write it in any other language with GC
>>
>>58078966
>You claimed state is not possible in FP.
Nope, I didn't. I don't see the point in arguing that though, since I also regularly use functional programming languages and the last thing I'm interested in is entertaining debates about what people think you should or shouldn't be doing with them. Unfortunately, real-time (vs. turn-based) mmo's aren't one of them.
>>
>>58079039
>Unfortunately, real-time (vs. turn-based) mmo's aren't one of them.
Yes, because of GC pauses. If you could make a GC-free funtional language (is such a thing possible?) it wouldn't be an issue
>>
Can someone explain to me the difference between the imperative and functional paradigms? Without mentioning state.
>>
>>58079165
In imperative you program in a way similar to how your computer works.
In functional you pretend your computer shuffles mathematical expressions around.
>>
>>58079165
The opposite of imperative is declarative, not functional

Imperative: You describe how to accomplish the result you want
Declarative: You describe the result you want to attain
>>
>>58079165
Default behavior in

imperative:
 
x is 5
y is 5
x = x + y
x is 10


functional:
x is 5
y is 5
x = x + y
Error: x already bound to 5
x' = x + y
x' is 10
x is 5
>>
>>58079678
>immutability is the only difference between functional and imperative
>>
>>58079678
This is the dumbest post I've read all day
>>
>>58079690
Read the post more carefully lad.
>>
>Enter thread
>See erlang
>Leave thread
Bye.
>>
>>58079813
It's as musch functional, as Haskell, y'know.
>>
>>58079813
How did you write this if you left the thread? Your post doesn't make a whole lot of sense.
>>
>>58079678
Now mention the other differences.
>>
>>58079165

http://www.eecs.ucf.edu/~leavens/ComS541Fall97/hw-pages/paradigms/major.html
>>
We have enough thread splitting, get back into /dpt/ and stop being autistic, the lot of you.

>>58079752

>>58079752

One board, one programming general.
>>
>>58079940
Newfags, ladies and gentlemen.
>>
>>58077656
>Server side Haskell would do really well for an mmo
>implying haskell compile in quantum-machine cone instead of regular machine code as any fucking programming language does in the end
>implying haskell ins't made using C in the core
>>
>>58080181
>implying your OS doesn't use a kernel programmed in C
>>
Could someone please explain the difference between procedural and functional programming? I'm dumb
>>
File: anal beads.png (64KB, 509x291px) Image search: [Google]
anal beads.png
64KB, 509x291px
>>58080384
Have you ever made a burrito?
>>
>>58080384
mainly higher order functions
>>
>>58079823
Something something monads, promises.
>>
>>58080192
It doesn't
>>
>>58078697
>C
>Enjoyable
C and PHP are literally the exact same language.
>>
>>58077666
What does it mean when a candlestick has multiple wicks like that in Go, Fortran, Chapel, et al.? Shouldn't it just be one long upper wick?
>>
>>58077618
>Vidya functional
>not OCaml
u dun goofed.
>>
>>58077685
Haskell is objectively the worst functional programming language. Prove me wrong.
>>
>>58080600
x :: HaskellIsTheBestProgrammingLanguage
x = x
>>
>>58080557
Just because you're too big of a pussy to handle a proper language like C doesn't mean it's bad.
>>
reading this thread I feel like asking: is worth learning Haskell? or should I stay with clojure?
>>
>>58080702
Yes
>>
>>58080702
No
>>
>>58080722
>>58080731
wtf?
>>
>>58080762
https://en.wikibooks.org/wiki/Haskell
>>
>>58080519
What OS anon?
>>
>>58080816
Apple Macintosh OS X
>>
>>58080849
XNU is written in a mix of C and C++
>>
>>58080972
But it isn't. It's written in Objective C and C++
>>
>>58080987
both written in C
>>
>>58081009
So? The OS itself isn't
>>
>>58080762
https://en.wikibooks.org/wiki/Clojure_Programming
>>
>>58081062
Is Clojure really this slow?
>>
>>58081069
>functional + jvm
yes
>>
>>58077618
I hear Insomniac games uses lisp a lot or their games. I think Crash Bandicoot is the one people always mention.
>>
i like a lot of aspects of functional programming, but not enough to use a functional language.
>>
>>58081418
What does hold you from using?
>>
>>58081069

To be fair, Clojure takes some time to get "ready", but then it's pretty fast. So if you measure smaller tasks, the startup time will count, for bigger tasks it will outperform many other languages.
>>
>>58081657
>php
>ecma script 4
>haskell
>>
>>58077017
Well, for real.

I'm trying to get into Erlang, and its Prolog heritage really shows.
It feels like Erlang is an over-powered version of Prolog with features to be more usable for functional programmers.
>>
>>58082176

No, not really.

To understand Erlang you need to understand one thing:
Erlang was designed to create reliable distributed systems. It came to be a functional language because it made sense, but it was more like a "coincidence" than a primary design goal.

>http://erlang.org/download/armstrong_thesis_2003.pdf

You will understand this better when you look at the elaborated error handling model of Erlang. Prolog/Haskell don't really care about errors, they try to make programs as "correct as possible" (a little bit oversimplified here) and if it fails, you did something wrong.

Erlang has the paradigm "Fail fast and noisely, fail politely". It does not advocate what it calls "defensive programming", rather it assumes errors can always happen - note that we are talking about distributed systems here, so think about a hardware/transmission issue for example. So Erlang embraces errors and gives a lot of options how to react on that error. Other processes get a notice that one process died (and why) and can either try to restart it or die themselves or whatnot. But that's only the "first line of defense", there's a lot more things. Read about workers, supervisors and the supervision tree.
>>
File: asuka13 plugsuit.jpg (146KB, 880x1249px) Image search: [Google]
asuka13 plugsuit.jpg
146KB, 880x1249px
>>58082513
And just to add about "Fail fast and noisely, fail politely", you should fail noisely for the log, fail politely for the user (i.e. for the normies using your product)
>>
>>58082513
Scala akka has a lot of this stuff and more .
>>
>>58076404
Hey /g/
how can i convert a mp4 to gif?
any sites you recommand?
>>
>>58083445
>akka
What is this? part of scala?
>>
>>58081069
It's not that slow once it's going, but JVM startup time is several seconds.

It's not a language for quick scripts you'd call from the shell.
>>
>>58084020
It's like webservices in native scala.
You can cluster it too, and it has an actor system.

http://www.scala-lang.org/old/node/242
>>
>>58084324
oh looks pretty swell. something like reactive programming I guess. I've heard of it. Dont know much.
>>
>>58077861
Actually, games don't have a lot of mutation going on. Typically you want to be making a new version of the state instead of modifying the current one in place. While under the hood it's best to ping pong between two states, reading from one and writing to the other, this is something that is easy to do in FP by running a pure state to state function in such a way that it mutates existing state (just not the one it's reading from).
>>
I wanna learn Elixir but I want a project to work on so I can see how it's like using it on a real world application.

>On-demand encrypted chatrooms supporting both user credentials and anonymous users

Would you use something like that? create a chat room, get an address and use it to invite people. You can delete the chatrooms when you want and they are gone for good.
>>
>>58077861
>>58084524
To elaborate:
A standard, robust game loop uses a fixed step for game logic and a variable step for rendering, audio, etc. For the fixed step you ping pong between two instances of the game state, reading from one and writing to the other. For the variable step you are reading both states so you can interpolate them and then doing further processing using only temporary memory and immutable asset data.

There is never a circumstance where you mutating something in-place, you are always reading from one thing and writing to another.
>>
>>58084576
Add threaded discussions and a very thin embedded client and you've got yourself a viable alternative to chatango.
>>
As for materials, here's the page on F#:
http://fsharp.org/learn
>>
Is haskellbook.com worth getting?
>>
>>58077861
>unless you feel like spending a year reinventing the wheel on your own
Sounds fantastic. I need an excuse to do that since I love reinventing the wheel as much as possible
>>
>>58085452
No. Use this one instead.
http://learnyouahaskell.com/chapters
>>
File: 1481784742027.png (368KB, 498x707px) Image search: [Google]
1481784742027.png
368KB, 498x707px
learning her right now
>>
>>58085546
Not a great resource tbqh.
>>
File: a7b.png (295KB, 986x1356px) Image search: [Google]
a7b.png
295KB, 986x1356px
There's something magical about FP, you just know that if you show the code to some OO pleb they will look at you like you are some kind of genius.
>>
C/Python faggot here, I want to get into FP, which language and resource would be best to learn the basics and go from there?
>>
>>58085963
Scala or Erlang/Elixir for real world applications
I would advice you against falling for the /g/ meme and learning Haskell.

You can google book reviews yourself if you're not retarded.
>>
>>58085452
There's a pdf online somewhere. Check the archives (not the on-site archives) for /dpt/
>>
>>58085452
>>58086292
And it's definitely better than LYAH
>>
>>58086306
What's wrong with LYAH?
>>
>>58086720
It's a bit out of date and is kind of cringy
>>
File: 1444840632524.gif (2MB, 254x196px) Image search: [Google]
1444840632524.gif
2MB, 254x196px
>>58085117
>able to interface with .NET libraries, get a shit ton of GUI options out-of-the-box
>basically have to learn C# if you want to do anything involving a GUI
Shit, man. I dunno. I'm using it now and it's actually a good language, but having to learn another language if you want to use anything besides console applications seems like a pain.
>>
Should I learn Erlang or Haskell?
>>
>>58084020
To expand on what the other anon said it's basically the actor model on the JVM.

In my mind it isn't perfect but it gives you all sorts of goodies like back pressure, clustering, streaming data etc etc.

It also has an http module as well as a camel module (Apache camel being a lib that allows integration between lots of different services I.e email FTP amqp etc etc.)
>>
>>58086884
Haskell, it has types
>>
>>58086808
dude, c# is just c, that's why it has a c in it, the # part I don't know about
>>
>>58086768
no its not
youre outdated and cringy

also, is common lisp dead?
>>
>>58086884
Do you like sucking cock or getting fucked in the ass?
>>
Haskell always looks like magic when I see code of it, so I'm gonna try and learn it.
>>
>>58080617
Stockholm syndrome
>>
>ML niggers *still* think functional programming is synonymous with type systems
Sad!
>>
>>58087286
That's because Haskell is puzzle-oriented programming.

Just wait until you discover APL though.
>>
>>58087488
APL is a fucking nightmare.

Or maybe it's just the massive legacy codebase I have to work with every week.

Also the shitty implementation it was made in.
>>
>>58087488
what does this mean?
>>
>>58087474
It's only because FP actually listens to PLT
>>
File: att85.jpg (60KB, 588x625px) Image search: [Google]
att85.jpg
60KB, 588x625px
Reminder that concatenative programming is superior to both functional programming and object oriented programming
>>
>>58087030
Why not both?
>>
File: trending.png (31KB, 1004x668px) Image search: [Google]
trending.png
31KB, 1004x668px
>>58087488
>>58087636

>Search GitHub for trending APL
>What the fuck

This is a meme language right?
>>
>>58088884
How many fucking keybinds do you even need to comfortably write that? Or is there a keyboard layout which does this?
>>
>>58088974
They have special keyboards for it.
>>
File: dialup.jpg (77KB, 1220x525px) Image search: [Google]
dialup.jpg
77KB, 1220x525px
>>58088974

Well I went looking for how to learn APL and I get this

>pick one of these time limited trial downloads to use as your APL interpreter
>>
File: 600px-APL-keybd2.svg.png (57KB, 600x183px) Image search: [Google]
600px-APL-keybd2.svg.png
57KB, 600x183px
>>58088974
>>
Learning Common Lisp, gonna write my website in it
>>
>>58087911
It means that a good deal of Haskell at first glance is indeed "magic": a sleight of hand that brushes away undergrad textbook problems with three clicks of the heels. It's only when you try to actually do something useful with it that its true nature rears its head.
>>
>>58089548
such as
>>
File: 1482040963752.jpg (394KB, 1050x1400px) Image search: [Google]
1482040963752.jpg
394KB, 1050x1400px
I'm currently learning Scala. What kind of projects could I build that would help me get a development job with it? I'm a seasoned web developer
>>
>>58091520
>a seasoned web developer
You're not a real programmer, in other words?
>>
>>58091520
Read the red book.
>>
>>58088884
APL is a mistake
>>
>>58091520
Did you do frontend or backend web development?
>>
>>58081069
Clojure is slower than Haskell for about half the tests, the other half it is faster: http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=ghc&lang2=clojure
>>
>>58091579
Fuck off

>>58091667
Thanks

Mainly looking to build some things which will provide proven experience in working with the common frameworks, not just the language itself. But something worthwhile that I can produce.
>>
>>58091704
Both. The only reason I do "web" development is because there are about a hundred times as many jobs available. I can do regular programming just fine.
>>
>>58091707
the haskell versions could be faster in each case, e.g. replacing lists of boxed types with unboxed char arrays
>>
>>58091745
You could try doing web development with Scala.
Or write a parser using parser combinators.
>>
>>58091707
>This program I wrote in Clojure and compiled with this compiler on this hardware runs slower than this Haskell program I wrote and compiled with this other compiler on this hardware
>>
>>58085963
Clojure for the Brave and True is pretty sweet: http://www.braveclojure.com/

Clojure itself is a really nice language too, and has all sorts of neat tricks to keep your code really terse and readable at the same time. Its concurrency support is also pretty much unmatched, and you can often get concurrency for free.

>>58087011
>is common lisp dead?
No. Qucklisp is actually seeing it grow quite a bit recently.
That's not to say that it is as common as it's name implies though.
>>
>>58091707
>Clojure is slower than Haskell for about half the tests,
So, Haskell is slower than Clojure for about half the tests?
>>
>>58091817
>>58091762
>>
>>58091817
That is indeed what I said.
>>
Best beginner functional language?
Also best resource for said language?
>>
>>58091904
Haskell
https://en.wikibooks.org/wiki/Haskell
>>
Why do FP books go from boringly trivial to mindfuck in a few chapters?
>>
>>58091904
lyah.com

>>58091969
Did you try learn you a haskell?
>>
>>58091969
What's the issue?
>>
>>58091994
That even C++ has a smoother learning curve.
>>
>>58091759
Thanks, I'll have a look.
>>
>>58092015
What problem are you having?
>>
>>58091969
They don't. They are just meant for people with a, at least, average notion of computer science and mathematics. Not for code monkeys that want to write the "next big thing".
>>
>>58091969
Also, what problem are you having?
>>
>>58091969
>>58091987
>Did you try learn you a haskell?

Fucking this book. It was so easy for several chapters, then all of a sudden it becomes rocket surgery. Is it just the book? Or is the language itself really that hard?
>>
>>58092082
>>58092110

Nothing, it's just that it's annoying how they hold your hand at first and then they just throw you to the lions. Real World Haskell is particularly bad at this, it's like the authors expect readers to be used to that ridiculous syntax after only a few weeks of functional programming.
>>
>>58092139
Not just that one, Programming in Elixir is just like that. And a few other books I read on Haskell were the same.
>>
>>58092144
Can you please explain what the actual problem is and stop saying "it's hard"?

>ridiculous syntax
Are you learning C?
>>
>>58092144
Functional programming is really simple is you know the basics of mathematics and CS.

I've never read real world haskell, but I think you could benefit from a introductory text in CS or mathematics.
>>
>>58092139
I thought you meant each chapter started out easy and became hard as fuck.
I'd recommend not reading any further and just try doing something in Haskell, you will learn how to use functors, applicatives and monads one day.
>>
>>58092139
No, it just means you hit the limit of your intelligence

I don't remember LYAH having any particular difficulty spikes. It was pretty straightforward when I went through it, everything built on top of previous concepts
>>
>>58087911
It's a meme by /dpt/ Java shills.
>>
>>58092144
The only real syntax Haskell has is do-notation and list comprehensions. Also type stuff.
>>
>>58092239
No, it's literally just one guy.
>>
File: 1481216013451.jpg (221KB, 953x988px) Image search: [Google]
1481216013451.jpg
221KB, 953x988px
lol remember when that one moron tried to claim that haskell would compile into faster code than C? LMFAO
>>
>>58092820
>implying this isn't true
show me one C program that's faster than idiomatic haskell code and i'll tell you why it doesn't count
>>
>>58092850
nigger, C statements literally get translated to their assembly counterparts in a sane compiler. LMFAO.. please, it's just not possible.
>>
Faggottional Programming
>>
>>58092882
>C statements literally get translated to their assembly counterparts in a sane compiler
wanna know how I know you don't know C OR assembly?
>>
>>58092906
lol ur really dumb
>>
>>58092940
the C abstract machine is not remotely low level
>>
File: 1482180179840.jpg (11KB, 200x200px) Image search: [Google]
1482180179840.jpg
11KB, 200x200px
>>58092959
u dont really KNOW when to stfu do u?
>>
File: 2579283.jpg (12KB, 255x186px) Image search: [Google]
2579283.jpg
12KB, 255x186px
>>58092982
>a frogposter
why am i not surprised
>>
>>58076404
Why can we use google to learn everything except coding? Coding needs books for some reason.
>>
>>58093464
capitalism

authors wanna rip you off with their programming books
>exceptional C++
>modern C++
>more exceptional C++
>more modern C++
>effective exceptionally modern C++
>second and third edition
>>
>>58093464
>>58094122
lmao what you can't learn SHIT on google
all good learning resources for anything are on books or papers
>>
>>58094226
>you can't search books on google then download them
>>
>>58092274
there's the "lowercase java shill" (me) and then believe it or not there are a few others who also aren't on the java-hating bandwagon. C# is literally an inferior copy of java where they took java and modified it without understanding the design principles that made java the success that it is. C++ and java are literally the best languages and you have no reason to use C# over C++ and/or java. haskell/etc are just irrelevant shitlangs.
>>
>>58077666
what benchmark
>>
File: 1451337320315.jpg (25KB, 400x386px) Image search: [Google]
1451337320315.jpg
25KB, 400x386px
>>58077666
>Haskell computations produce a lot of memory garbage - much more than conventional imperative languages.
>it's not uncommon to produce 1gb of data per second
>>
>>58095277
This isn't /dpt/, this is /fpt/.
What are you doing here?
>>
>>58095277
>and you have no reason to use C# over C++ and/or java
Yes, I do.

C# is more enjoyable to use and write.
It's less verbose than Java.
LINQ is far superior to Java's streams.
It works like a charm with Azure resources.
I find Visual Studio to be better than IDEA in many ways, and Eclipse is clunky as all hell.
VSTS is extremely easy to use compared to Git, and has a great integration with VS.
Xamarin dev is far easier than regular Android dev, with the bonus points that a large chunk of common code can be also used for the iOS version of something.
And more!

C++ is fine if I need to get a performant library component, but I'll be damned if I'm going to use that as my main language for every little thing.

I like C++ for some things, C# for most, and I don't see a reason to use Java when C# exists.
>>
>>58095383
i was linked to here from /dpt/ but you're right i'll leave you alone so you can have your safe space here without shitting up /dpt/ too much
>>
>>58076404
(defn exponents
"rases a base to a power"
[base power]
(def total base)
(loop [pass 1]
(if (< pass power)
(do (def total ( * total base))
(recur (inc pass)))
total)))

(defn powers
"Raises a number to a power and appends all given powers into a vector"
[base power]
(def total base)
(def factors [total])
(loop [pass 1]
(if (< pass power)
(do (def total (* total base))
(def factors (conj factors total))
(recur (inc pass)))
factors)))


I couldn't find an exponents function so I wrote one, took longer than it probably should have and it's clunky as hell but I'm pretty proud of it
>>
>>58095405
No, /dpt/ is a programming thread.
FP can go on /dpt/ if it wants.
But non-FP can't go on /fpt/

Think these things through anon
>>
>>58095421
Is that Clojure?
>>
>>58095434
if there is too much smug FP fedora tipping in /dpt/, there will be retaliation
>>
>>58077631
what exactly is the main performance impact of garbage collection?
>>
>>58095377
What are you quoting?
>>
>>58095487
https://wiki.haskell.org/GHC/Memory_Management
>>
File: Screenshot-ClojureBrave.png (182KB, 605x800px) Image search: [Google]
Screenshot-ClojureBrave.png
182KB, 605x800px
>>58095441


...


yes

I picked up the SICP, and I'll get to it next, but it was about as dry as a camels fart, pic related was on sale on no starch and I picked it up, I'm actually enjoying it a lot, I'm not *new* to lisp in that I've known about it forever but I'm just now getting around to really learning it
>>
>>58095421
(defn pow [base power] (Math/pow base power))
>>
>>58095510
Much as I appreciate what Clojure is trying to do, 'recur' just makes me vomit into my mouth a little.
>>
>>58095481
Regular interrupts, so you couldn't make a high performance triple A game, for instance
>>
>>58095559
If I'm being entirely honest I don't understand every function in that script, and I'm not even fucking sure what recur is doing, I just know that you use it when you need a loop to loop
>>
File: rare grill.jpg (8KB, 229x220px) Image search: [Google]
rare grill.jpg
8KB, 229x220px
>>58094854
>>58094854
Do you really search for books on google?
>>
>>58095559
>>58095619
why does recur make you so nauseous?

I'll have to admit this is my first language outside of python or lisp, I've written a bit of C but I wouldn't call my self that competent ah ih
>>
>>58095639
>Python or lisp
>lisp

That's supposed to say Lua
>>
>>58095628
No, I search for them on Bing.
>>
>>58095619
>>58095639
JVM doesn't have tail call elimination, so instead of optimising away the stack of true recursion, every function definition 'magically' binds the symbol 'recur' to itself, and this form is translated into an iterative loop.
>>
>>58095669
I am shocked at two things, the first being that I actually understood that fucking sentence, I must actually be learning

The second is how MOTHER-LOVING RETARDED that sounds
>>
>>58095669
Wait so does recur go back to the loop, or does it go back to just after (defn function ?
>>
>>58095544
no bulli pls

I'm new at this
>>
>>58095662
>>
>>58095704
The reason is mainly no one felt the need for it years ago. You can just write a loop and the idea was most people would. You can however do this at compilation to byte code time. However clojure is interpreted and the JVM was build originally for Java.

Scala has tail rec optimisation.
>>
what the fuck i can't run elixir escripts on windows why is this OS so trash for programming
>>
>>58091787
haskell has concurrency, much better because IO is contained
>>
>>58095776
This. In Common Lisp (and many other sane examples), the policy is this: if your implementation doesn't provide TCO, and you're worried about that stack, just write it using imperative iteration.

'recur' is just ugly.
>>
>>58095829
There is also trampolining.(spelling?)
>>
>>58095829
Is there an alternative within clojure that I should use instead?
>>
File: vVsjW9D.jpg (115KB, 1024x768px) Image search: [Google]
vVsjW9D.jpg
115KB, 1024x768px
>>58096165
Don't be silly, I don't know Clojure.
>>
>>58096314
>frog posted
>doesn't know something
Like poetry.

Don't worry, anon, it's OK.
>>
>>58096314
Is the issue inherent to clojure? Or is it just that they needed clojure to compile on JVM?
>>
I lazily prepare for new thread.

>Elixir
http://chimera.labs.oreilly.com/books/1234000001642/index.html
>Erlang
http://learnyousomeerlang.com/content
>F#
http://fsharp.org/learn
>Haskell
https://en.wikibooks.org/wiki/Haskell
>Lisps
>>Clojure
http://www.braveclojure.com/foreword/

What am I missing?
>>
>>58095628
Usually ddg. i always find what I want. What do you recommend?
>>
>>58096368
>doesn't know something about Clojure
I'm okay with that.
>>
>>58096690
>>58096372
?
>>
This thread is a joke. Fit for joke languages.
>>
>>58096658
libgen
>>
>>58080181
It is easier to make scalable code in functional languages, because >muh no side effects, which he has explained in the second part of his post that you conveniently forgot to quote. I don't understand why so many retards who have never touched a functional language come to a thread dedicated to functional programming just to shit on it.
>>
>>58081023
wow, retard
>>
>>58096894
THX XD
>>
>>58077656
>mmo
>stateless
>>
>>58097420
what state would be relevant for the server??
>>
what have you ever done with a functional language?
>>
>>58097561
Mexico, maybe, since they less possibly would want to take your server down.
>>
>>58097593
XXXXXXXDDDDD
>>
>>58097561
literally everything, otherwise it would be too easy to cheat
>>
>>58097632
>cheat
who would do such a thing :^)
>>
>>58097590
I made myself feel good
>>
>>58097590
a chatbot on haskell
>>
>>58097699
>on
how about you program yourself a functional dictionary
>>
>>58077776
True. And you don't need to be a wizard to achieve it, just make sure your recursive functions are tail recursive and that's half the battle done. Lazy evaluation also makes it very efficient.
>>
>>58096634
F# would be better if it integrated with WPF or another GUI solution better. I've never worked with C# before and the realization that I'll need to wrap anything I do in C# if I want to create something more than a static console application is a bit of a hassle.
>>
F# or another language for a faggot who just wants to see what functional langs are about?
>>
>>58085690
I fully disagree, it's an amazing resource especially for people just getting started with FP.
>>
>>58097731
sorry senpai fp fried my brain now i can only shitpost in bad grammer
>>
>>58079678
Why would I want to use a language where I can't update variables?
>>
>>58089270
Update: I wrote my website in CL
https://gitla.in/iitalics/ji-common-lisp/tree/master
4chan is throwing out my real URL because Im using a free domain name
>>
>>58098036
You can, it's just not the default behavior. Read the post.
>>
>>58086884
both.
Also add elm and elixir
>>
>>58098036
It's easier to write concurrent programs in a programming language in which functions have no side-effects, because it means one process can't change data used by another process in an unforeseen way. It is also easier to hunt for bugs and reason about the way your program works.
It may seem to also cripple the language, but it does not. In Erlang, processes can communicate via message passing, and you don't need to update variables when you have recursion.
>>
>>58098186
Is that really better than locks and blocking? That sounds really shit for memory.
>>
>>58091904
elm
>>
>>58095808
install gentoo and gtfo
>>
>>58096634
elm
>>
>>58098203
It guarantees no race conditions. Is also easier to reason about when you realise all of the values you see will never suddenly change.
>>
>>58098314
What's good resource for elm?
>>
>>58098323
https://guide.elm-lang.org/
>>
>>58098203
>Is that really better than locks and blocking?
I don't know, because I haven't written concurrent programs in "normal" languages.
>That sounds really shit for memory.
To me it seems like functional languages and non-functional languages are used for different things, like you wouldn't write a video rendering program or anything high-performance in Erlang, but you would write a program that needs to run 80000 processes concurrently (like a webserver or something).
>>
>>58098170
>both
No. Erlang/Elixir is good for telcos, so if he's interested in that area it has a real world application. But Haskell is literally good for nothing.
>>
>>58098366
go home, you're drunk.
both are great languages. Each is good in their own niche
>>
I have a feeling I will need to find this out for myself but can someone explain to me the real benefit of macros in lisp? I fully understand that macros are an extension of the language but why not just write a function? What's the benefit?
>>
I tried to make a list of functional languages from "easy to learn" to "hard to learn".

Any thoughts?


>Erlang

Small and simple if you only learn the language itself. If you want some more action, you got to learn the OTP library which is just as big as Erlang itself. Cool virtual machine, but most jobs are telecommunication.


>Elixir

Modern version of Erlang, it can use every Erlang library since it gets compiled to Erlang code. It add some interesting features and makes the language "better", i.e. when it comes to I/O. God tier language for Web Development (Phoenix framework), but not that many Jobs.
Some Erlang knowledge might come in handy for Elixir.


>F#

Good language, probably most "C-like" of all functional languages. No "killer feature" like the other languages, but rather easy syntax.


>LISP / Clojure

Somehow functional, somehow not, since it has slightly different design goals (homoiconic language). Little theory, but the notation is kinda special, some people get used to it, others don't.


>Haskell / OCamL

More mathematically oriented languages. Pretty deep theory behind it, easy to start with but pretty hard to master.


>Scala

The "C++ for functional guys", powerful and supports a lot of concepts/features, but very complex and difficult on a higher level.
>>
>>58098453
so you can make new constructs
>>
>>58098767
But why would I want that? For instance I could macro in a switch case, but then surely lisp should provide this anyway?
>>
>>58098851
but it also lets you implement things like first-class SQL syntax (like LINQ), embedded logic languages (MiniKanren), object systems (CLOS), etc. if you have very repetitive code that you want custom syntax for you can use macros (example could be declaring functions f1 to f10 based on a certain pattern and putting them in global scope)
>>58098744
Scheme is by far the easiest to learn. I would say F# has some good killer features (type providers, for example). OCaml also is much easier than Haskell if you're coming from an imperative background -- it shouldn't be any harder than F# since they're essentially forks of the same language
>>
>>58098924
So basically it gives you the ability to write language extensions that improves readability etc of code? Things that would normally be too niche for a language to have?
>>
>>58098390
There are zero real applications for Haskell, no company will hire you and for your own projects there will by another language able to do what you want but easier or faster. Haskell is an elegant abomination.
>>
File: .gif (1MB, 229x300px) Image search: [Google]
.gif
1MB, 229x300px
>haskellfags are being btfo'd in haskellfag thread
What a real joke of language.
>>
>>58098980
macros essentially is code syntax generation
and certain codes get generated based on certain patterns

you could condense 700+ lines into 3, and reuse those 3
>>
>Making a game
>Decide to use chicken scheme
>Won't compile on windows
>Decide to write the base code in C and script it with Guile
>Guile won't compile on windows and there are no available binaries
Give me one reason why I shouldn't just write everything in C.
>>
>>58098453
Unfortunately most examples out there are incredibly simplistic so it's difficult to see any advantage.
Here's one of the better examples I've seen.

https://www.youtube.com/watch?v=5FlHq_iiDW0
>>
>>58099040

Use Tiny Scheme to script. Do not use MSVC to compile; use mingw-w64 instead.
>>
>>58098744
>"C-like"
I wonder what does it mean.
>>
>>58098992
Facebook's spam filter is entirely built on Haskell.
>>
>>58095722
recur goes to whichever is closest.
For example, here is a function that collects all unique instances of a Regex from a file:

(defn extract-jisho-links
"Extracts all of the jisho: links from an org-file into a set."
[org-file]
(with-open [rdr (io/reader org-file)]
(loop [lines (line-seq rdr)
acc #{}]
(if (empty? lines)
acc
(let [searches (map second (re-seq #"\[jisho:([^\]]+)\]" (first lines)))]
(recur (rest lines) (apply conj acc searches)))))))


In this example, even though the (recur ...) call is in a (defn ...), it will target the (loop ...) because it is closer.
>>
So, I've been working a job where I actually get to 'learn' C# and interact with the code on a daily basis. I have access to the solutions and all via VS, and I understand what most of the syntax is meaning/doing (this is my real first programming experience, but I'm starting to like the challenge).. However, I don't quite grasp this on a 'bigger picture' level. Looking at controllers and the solutions leaves more to be desired. I think I need some reading material. Is there a book for .NET programming that anyone recommends?
>>
>>58101063
Not offhand, though the /dpt/ might be able to help you: >>58099323
>>
Pft, everyone's talking about Erlang and Haskell, but not mentioning Scheme.
>>
>>58104027
It's shit.
>>
>>58104027
Is Scheme the only Lisp-1 language?
>>
>>58104027
I'm seeing lots of Clojure too, but most of it is either people criticizing it poorly or badly defending it.

It makes me kinda sad really.

So, what's neat in the world of Scheme?

>>58104371
Clojure too, yo.
>>
>>58095421
Oh, I posted a thing about this here >>58101792
I saw it in the /dpt/ first
>>
>>58076458
>>58077540
>not converting OO programmers
>not showing them their ways are retarded and bringing true enlightenment

stop fighting brehs, the true enemy is over there
>>
>>58104490
>converting OO programmers
I don't want to let them anywhere near our beautiful languages
>>
New thread:

>>58105321
>>58105321
>>58105321
Thread posts: 308
Thread images: 25


[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.