Live data from Hacker News

Functional Programming Patterns

slideshare.net

11–20 of 70 posts

Re: Functional Programming Patterns

#11
post #3

I thank the lord every day that the language I work in (Javascript) supports functions! I try to write pure functions as often as possible, so it's easy to refactor the code when I come back three months later. But is there, except for Clojurescript, any true (like Haskell) FP language for browsers? Something that has the tools, and community to back it, so it's viable to actually make projects in it?

js_of_ocaml let's you do ocaml in both client and server, and in a single app, with shared variables. http://ocsigen.org/js_of_ocaml/ As it operates on the byte code you can put any ocaml into the browser, even the compiler itself.

Re: Functional Programming Patterns

#12
post #5
post #3

I thank the lord every day that the language I work in (Javascript) supports functions! I try to write pure functions as often as possible, so it's easy to refactor the code when I come back three months later. But is there, except for Clojurescript, any true (like Haskell) FP language for browsers? Something that has the tools, and community to back it, so it's viable to actually make projects in it?

The most Haskell-like and popular are: - http://www.purescript.org/ - https://github.com/faylang/fay - https://github.com/ghcjs/ghcjs - http://elm-lang.org/ Each has it's own focus and strengths and weaknesses. There is a long page on the Haskell wiki on the subject: https://www.haskell.org/haskellwiki/The_JavaScript_Problem Michael Snoyman gave a really good talk recently which covers GHCJS and Fay: https://www.yout…

PureScript has the advantage that it has a very lightweight runtime and maps to JS quite well.

Re: Functional Programming Patterns

#13

Patterns exist to compensate for a programming language’s lack of expressiveness!

For everybody else that didn't read the presentation, it's about how to remove patterns from your code.

It also carries the best explanation for why one would want to use monads that I've seen.

Re: Functional Programming Patterns

#14
I quite liked the types section, particularly the bit about making illegal states unrepresentable so you can enforce business rules, eg. validating email addresses.

One of the things I'm always thinking when people talk about the merits of various type systems and the problems they solve is: "But I don't have those problems". However, there are a few good examples in there that opened my eyes a little and I'll give type-centric programming a go on my next project. Not necessarily solving problems that I have, but certainly presenting a different, hopefully clearer, way of writing some functionality.

Re: Functional Programming Patterns

#15
post #3

I thank the lord every day that the language I work in (Javascript) supports functions! I try to write pure functions as often as possible, so it's easy to refactor the code when I come back three months later. But is there, except for Clojurescript, any true (like Haskell) FP language for browsers? Something that has the tools, and community to back it, so it's viable to actually make projects in it?

Where did you learn functional style programming? What resources do you recommend?

Re: Functional Programming Patterns

#16
I am currently taking EdX's Intro to Functional Programming mooc, taught by Erik Meijer (with his crazy shirts), which uses Haskell to teach functional programming concepts.

I am wondering if there are any other good resources for teaching the functional programming paradigms. Anybody care to recommend me some resources?

Also, I mainly work with Ruby and Javascript in my full time job. Currently, in school, I use Java (in the context of Android, which is on Java 6) and Objective-C (iOS programming). If anybody has any resources regarding functional programming and the previously mentioned languages, it would be most appreciated.

Thanks people!

Re: Functional Programming Patterns

#19

I am currently taking EdX's Intro to Functional Programming mooc, taught by Erik Meijer (with his crazy shirts), which uses Haskell to teach functional programming concepts. I am wondering if there are any other good resources for teaching the functional programming paradigms. Anybody care to recommend me some resources? Also, I mainly work with Ruby and Javascript in my full time job. Currently, in school, I use Jav…

https://leanpub.com/javascript-allonge is a good resource on (rather basic) functional programming in JavaScript.

Re: Functional Programming Patterns

#20
post #6

A good read, I especially like the parts about error handling and maps/applicatives. They are well-illustrated and tackle some difficult common problems I had shortly after I started using functional languages. The part about functors/monads/monoids is also nice, although I feel like it would be better with the accompanying talk to bind it together a bit more.

By the way, I do think pattern matching could have been discussed more extensively. Pattern matching is one of the reasons I love functional programming so much, since combined with algebraic types they can be much more expressive than imperative control-flow statements (e.g. if-else). For programmers that are used to imperative programming, discovering the power of pattern matching can be quite a hurdle.
Post reply on HN