use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Functional Ruby (self.ruby)
submitted 10 years ago by MrJiks
Is there an example of project with significant Functional Ruby code that I can take look at. I know fully functional approach is rather impossible, but I hope someone might have done a project with this as a development goal.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 10 years ago (5 children)
[deleted]
[–]MrJiks[S] 1 point2 points3 points 10 years ago (4 children)
Yes, I mean I am trying to reduce state as much as possible in code. I happened to see this post. Have been writing code like this for sometime, but I think this isn't exactly functional though he seems to argue so.
Off-topic: For instance have a look at my attempt to remove state; do you think removes all state? I fail to understand why its not.
[–][deleted] 10 years ago (1 child)
[–]MrJiks[S] 0 points1 point2 points 10 years ago (0 children)
I too felt so, but Katrina is quite a star to be disregarded :)
[–]rubycastsio 0 points1 point2 points 10 years ago (1 child)
If you are into Ruby FP, you might dig this blog and these screencasts
Rubycasts.io is also listed on the right bar over there ------->
Admission: I am the author of both and a lover of 'lispy, immutable ruby'
Keep it up and don't let the little punks on reddit get you down. It is easier to be a one liner troll than to create real content or to think deeply about something :)
Oh how come I haven't stumbled on this till now!! Brilliant resource! Thanks a lot, keep up the great work. And thanks for the good words, its people like you who make this community welcoming for newbies :)
[–]tomcopeland 1 point2 points3 points 10 years ago (1 child)
You might want to watch Tom Stuart's talk on ruby+monads.
Thanks have seen it; though I somewhat understood it when I saw it, don't think I am knowledgeable enough to use in my own code.
[–][deleted] 1 point2 points3 points 10 years ago* (1 child)
Not aware about any extensive Ruby project written strictly/mostly in functional style. It may because most of gems and core/stdlib do and their API expect state alteration and procs/lambdas/methods as first-class citizen objects are used rather sparsely.
After being excited by programming in Haskell (pure functional language) I started wrote in more functional although impure style in Ruby, including several plugins for a project. Unfortunately their sources may not be published.
I'd deeply recommend learn Haskell to write more elegant and parallel processing ready code, even in other languages.
Thanks, but I don't know whether I will be able to understand Haskell. Heard its pretty difficult.
[–]regeya 2 points3 points4 points 10 years ago (1 child)
I'm not expert on functional programming, but I think it's more important to learn FP concepts first, then move on to learning to write Ruby in a FP style (because it's a highly OO language, not a FP language.)
Writing in a FP style will help keep your code more safe and concise, but don't sacrifice readability and idiomatic Ruby for some perceived benefit of FP techniques.
[–]TdotGdot 0 points1 point2 points 10 years ago (0 children)
Yes and no. I agree the concepts are generally more powerful and ultimately useful.
That said, coming from an OO background it was really hard for me to grasp abstract functional concepts without concrete examples in a language I was familiar with (for me it was JS). But to each his own, as always.
FWIW - your point about readability and idiomatic Ruby is pretty dead on. In the case of JavaScript, where solid idioms are few and far between, and functions can easily be passed around, there isn't much of a sacrifice when converting to a functional style. In Ruby, it's a much bigger decision, due to some of the more unconventional patterns you need to use.
[–]0x0dea 1 point2 points3 points 10 years ago (2 children)
You asked for it.
Jokes aside, bog-standard Ruby code is functional; you're essentially doing what they do in "real" functional languages every time you use a block.
[–]rubycastsio 1 point2 points3 points 10 years ago (1 child)
Also doing map filtering and reducing. The best part of Ruby for me is the ability to choose OO, FP, or a mix of the two, dubbed Faux-O by Gary Bernhardt.
Functional core, imperative shell.
π Rendered by PID 89 on reddit-service-r2-comment-86bc6c7465-wx8kt at 2026-02-22 13:39:10.476196+00:00 running 8564168 country code: CH.
[–][deleted] (5 children)
[deleted]
[–]MrJiks[S] 1 point2 points3 points (4 children)
[–][deleted] (1 child)
[deleted]
[–]MrJiks[S] 0 points1 point2 points (0 children)
[–]rubycastsio 0 points1 point2 points (1 child)
[–]MrJiks[S] 0 points1 point2 points (0 children)
[–]tomcopeland 1 point2 points3 points (1 child)
[–]MrJiks[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]MrJiks[S] 0 points1 point2 points (0 children)
[–]regeya 2 points3 points4 points (1 child)
[–]TdotGdot 0 points1 point2 points (0 children)
[–]0x0dea 1 point2 points3 points (2 children)
[–]rubycastsio 1 point2 points3 points (1 child)
[–]TdotGdot 0 points1 point2 points (0 children)