geekhack
geekhack Community => Other Geeky Stuff => Topic started by: vasouv on Mon, 14 October 2013, 18:08:14
-
I'm taking an online course from Berkeley, and we're using Ruby. I'm really starting to like it, it's so much easier to code something than let's say Java.
Granted, I have some experience in Java but not that much, I'm finding Ruby really fun to write programs in, the syntax is really easy to grasp and closer to how a human understands a concept.
Most of the times I still "think in Java" and my code isn't "Rubified" but man I like the language!
-
I am a Python lover but Ruby has such a strong following I know I should give it a try sometime. I have always avoided it because it looks so much like Perl, which I absolutely hate.
-
I like Ruby. The Smalltalk constructs like inject are great. Shame I don't use scripted languages :\
-
I went from php to ruby and was amazed, I really love Ruby. I use it for all my projects. rails, sinatra, and jekyll mostly.
I am a Python lover but Ruby has such a strong following I know I should give it a try sometime. I have always avoided it because it looks so much like Perl, which I absolutely hate.
I really want to try python as a ruby lover :P
-
I've heard a lot about Ruby - mostly good.
But I'd like to try Lua next.
-
I've heard a lot about Ruby - mostly good.
But I'd like to try Lua next.
Yes, come to the Brazilian side of scripting languagues!
-
I like Ruby. The Smalltalk constructs like inject are great. Shame I don't use scripted languages :\
I don't know Ruby so I went and looked up inject. Found (http://blog.jayfields.com/2008/03/ruby-inject.html)this basic example...
[1, 2, 3, 4].inject(0) { |result, element| result + element } # => 10
Compare to the equivalent python...
>>> reduce(lambda x,y: x+y, [1,2,3,4])
10
both of them are ugly to look at I guess, but the Python is at least a bit closer to what I expect from an FP perspective. The examples get weirder from there. I don't know if I could ever come around to that block notation with the |input| output stuff...
-
I like Ruby. The Smalltalk constructs like inject are great. Shame I don't use scripted languages :\
I don't know Ruby so I went and looked up inject. Found (http://blog.jayfields.com/2008/03/ruby-inject.html)this basic example...
[1, 2, 3, 4].inject(0) { |result, element| result + element } # => 10
Compare to the equivalent python...
>>> reduce(lambda x,y: x+y, [1,2,3,4])
10
both of them are ugly to look at I guess, but the Python is at least a bit closer to what I expect from an FP perspective. The examples get weirder from there. I don't know if I could ever come around to that block notation with the |input| output stuff...
Smalltalk is not a functional programming language. Sure, it has blocks (which are lambdas) but the intent was not to be readable from a functional perspective.
Also, it's much cleaner like this:
>> [1,2,3,4].inject(:+)
-
or like this:
sum([1,2,3,4])
:)
-
or like this:
sum([1,2,3,4])
:)
Oh yes!
But that is not possible on smalltalk XD
-
I'll be honest, I keep hearing good things about Ruby, but I have yet to experience them myself. I've tried learning the language many times, and always get sick of it in fairly short order. Personally, I find the language unpleasant to read and visually unappealing. Too many constructs, too many ways to do things. It's slightly more readable Perl (This is my opinion only, and I realize a lot of others don't share it).
That coupled with the fact that (as far as I know) there's some pretty steep performance issues with it makes me want to stay away.
-
I'll be honest, I keep hearing good things about Ruby, but I have yet to experience them myself. I've tried learning the language many times, and always get sick of it in fairly short order. Personally, I find the language unpleasant to read and visually unappealing. Too many constructs, too many ways to do things. It's slightly more readable Perl (This is my opinion only, and I realize a lot of others don't share it).
That coupled with the fact that (as far as I know) there's some pretty steep performance issues with it makes me want to stay away.
I think reading ruby flows nicely usually. I also think I like ruby a lot because I don't/haven't really use any other language other than php.
I think im gonna learn go or scala next.
I've never ran into any performance issues with my web applications. They don't get a lot of load though.
I figure if you need a high performance application you probably wont/shouldnt be using ruby.
-
Ruby's a gateway drug. It'll take you onwards into learning scheme or haskell. And then you'll be lost, my friend; hopelessly lost. The world of imperative programming will recede into the distance, and you'll find yourself writing code without mutations, without loops, without ifs. All this talk of "for" loops will be but a distant memory, a memory of a time when things were more complex.
And, finally, you may end up understanding continuations, or even monads.
On a more serious note, it's a good enough language, with a slight performance caveat. Functionalish but it looks close enough to imperative to make teh switch relatively easy. If you're doing web stuff with it, I'd suggest merb rather than rails, though.
-
Ruby's a gateway drug. It'll take you onwards into learning scheme or haskell. And then you'll be lost, my friend; hopelessly lost. The world of imperative programming will recede into the distance, and you'll find yourself writing code without mutations, without loops, without ifs. All this talk of "for" loops will be but a distant memory, a memory of a time when things were more complex.
And, finally, you may end up understanding continuations, or even monads.
On a more serious note, it's a good enough language, with a slight performance caveat. Functionalish but it looks close enough to imperative to make teh switch relatively easy. If you're doing web stuff with it, I'd suggest merb rather than rails, though.
I don't get why Ruby would take you to functional languages instead of serious OO...
-
Ruby's a gateway drug. It'll take you onwards into learning scheme or haskell. And then you'll be lost, my friend; hopelessly lost. The world of imperative programming will recede into the distance, and you'll find yourself writing code without mutations, without loops, without ifs. All this talk of "for" loops will be but a distant memory, a memory of a time when things were more complex.
And, finally, you may end up understanding continuations, or even monads.
On a more serious note, it's a good enough language, with a slight performance caveat. Functionalish but it looks close enough to imperative to make teh switch relatively easy. If you're doing web stuff with it, I'd suggest merb rather than rails, though.
I don't get why Ruby would take you to functional languages instead of serious OO...
My thought exactly. Ruby is very OOP, and OOP is really the ideological opposite of FP.
-
I don't get why Ruby would take you to functional languages instead of serious OO...
My thought exactly. Ruby is very OOP, and OOP is really the ideological opposite of FP.
Bull****. Absolute and total bull****. It's perfectly possible (and, I might suggest, preferable) to write functional programs in an object-oriented style. Or vice versa. The problem in understanding comes from the fact most commonly used "OO" languages are squarely planted in the imperative programming style. Anton said it better than me, though.
(http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html)The venerable master Qc Na was walking with his student, Anton. Hoping to prompt the master into a discussion, Anton said "Master, I have heard that objects are a very good thing - is this true?" Qc Na looked pityingly at his student and replied, "Foolish pupil - objects are merely a poor man's closures."
Chastised, Anton took his leave from his master and returned to his cell, intent on studying closures. He carefully read the entire "Lambda: The Ultimate..." series of papers and its cousins, and implemented a small Scheme interpreter with a closure-based object system. He learned much, and looked forward to informing his master of his progress.
On his next walk with Qc Na, Anton attempted to impress his master by saying "Master, I have diligently studied the matter, and now understand that objects are truly a poor man's closures." Qc Na responded by hitting Anton with his stick, saying "When will you learn? Closures are a poor man's object." At that moment, Anton became enlightened.
Ruby, unlike most object-oriented languages in common use, has first class closures and higher order functions. Not only that, but it's idiomatic to use them, viz
[1,2,3].map{|x| x+1 }
Yeah, 'inject' should be called 'reduce', and the syntax can be a bit hokey (as with any curly-bracket language, see, for example, C++0x lambda forms), but it's a first step towards the light :)
-
Uh, what? Since when isn't OOP based on side effects, which happen to be the exact opposite of functional programming?
-
OOP does not have to be based on side effects, although almost all current implementations are.
For example : this document (http://okmij.org/ftp/Scheme/oop-in-fp.txt), and particularly the link at the end, directlky linked here (http://pobox.com/~oleg/ftp/Scheme/pure-oo-system.scm), which implements a workable, entirely functional, oo system with encapsulation, identity, inheritance and polymorphism, all in 17 lines of scheme. With exactly zero assignments or mutations.
-
I don't get why Ruby would take you to functional languages instead of serious OO...
My thought exactly. Ruby is very OOP, and OOP is really the ideological opposite of FP.
Bull****. Absolute and total bull****. It's perfectly possible (and, I might suggest, preferable) to write functional programs in an object-oriented style. Or vice versa. The problem in understanding comes from the fact most commonly used "OO" languages are squarely planted in the imperative programming style. Anton said it better than me, though.
You can combine FP concepts and OOP concepts into one language. This is one of the big reasons I like Python so much. But I stand by my statement. It's not bull****. The whole point of objects is encapsulating state with code. Methods are supposed to modify a state in ways that the outsider may or may not know about. FP functions are supposed to produce output based only on the input. Like he said, side effects.
You can code in a OOP style with C, if you wanted. You can code in a FP style with Ruby, if you wanted. That's why I said "ideological", as in they differ in their ideals.
-
Ruby's a gateway drug. It'll take you onwards into learning scheme or haskell.
i started learning ruby after mastering scheme and haskell. gave it up after reading a few dozen tutorial pages.
-
FP functions are supposed to produce output based only on the input.
in pure functional languages. and if memory serves me well, the only pure functional language you can actually write real-world programs in is haskell.
there are practical impure functional languages (like clojure) and languages that combine oo and functional paradigms (like ocaml, common lisp, scala).