Author Topic: Ruby Programming Language  (Read 3979 times)

0 Members and 1 Guest are viewing this topic.

Offline vasouv

  • Thread Starter
  • Posts: 88
  • Location: Greece
Ruby Programming Language
« 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!

Offline metalliqaz

  • * Maker
  • Posts: 4951
  • Location: the Making Stuff subforum
  • Leopold fanboy
Re: Ruby Programming Language
« Reply #1 on: Mon, 14 October 2013, 18:18:46 »
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.

Offline lcs

  • Lover of Grape Drank
  • Posts: 669
  • Location: Brazil
  • はやく
Re: Ruby Programming Language
« Reply #2 on: Mon, 14 October 2013, 18:22:15 »
I like Ruby. The Smalltalk constructs like inject are great. Shame I don't use scripted languages :\

Offline codyeatworld

  • * Destiny Supporter
  • Posts: 944
  • Location: Bay Area, California
Re: Ruby Programming Language
« Reply #3 on: Mon, 14 October 2013, 18:37:27 »
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




Offline rowdy

  • HHKB Hapster
  • * Erudite Elder
  • Posts: 21175
  • Location: melbourne.vic.au
  • Missed another sale.
Re: Ruby Programming Language
« Reply #4 on: Mon, 14 October 2013, 19:30:46 »
I've heard a lot about Ruby - mostly good.

But I'd like to try Lua next.
"Because keyboards are accessories to PC makers, they focus on minimizing the manufacturing costs. But that’s incorrect. It’s in HHKB’s slogan, but when America’s cowboys were in the middle of a trip and their horse died, they would leave the horse there. But even if they were in the middle of a desert, they would take their saddle with them. The horse was a consumable good, but the saddle was an interface that their bodies had gotten used to. In the same vein, PCs are consumable goods, while keyboards are important interfaces." - Eiiti Wada

NEC APC-H4100E | Ducky DK9008 Shine MX blue LED red | Ducky DK9008 Shine MX blue LED green | Link 900243-08 | CM QFR MX black | KeyCool 87 white MX reds | HHKB 2 Pro | Model M 02-Mar-1993 | Model M 29-Nov-1995 | CM Trigger (broken) | CM QFS MX green | Ducky DK9087 Shine 3 TKL Yellow Edition MX black | Lexmark SSK 21-Apr-1994 | IBM SSK 13-Oct-1987 | CODE TKL MX clear | Model M 122 01-Jun-1988

Ị̸͚̯̲́ͤ̃͑̇̑ͯ̊̂͟ͅs̞͚̩͉̝̪̲͗͊ͪ̽̚̚ ̭̦͖͕̑́͌ͬͩ͟t̷̻͔̙̑͟h̹̠̼͋ͤ͋i̤̜̣̦̱̫͈͔̞ͭ͑ͥ̌̔s̬͔͎̍̈ͥͫ̐̾ͣ̔̇͘ͅ ̩̘̼͆̐̕e̞̰͓̲̺̎͐̏ͬ̓̅̾͠͝ͅv̶̰͕̱̞̥̍ͣ̄̕e͕͙͖̬̜͓͎̤̊ͭ͐͝ṇ̰͎̱̤̟̭ͫ͌̌͢͠ͅ ̳̥̦ͮ̐ͤ̎̊ͣ͡͡n̤̜̙̺̪̒͜e̶̻̦̿ͮ̂̀c̝̘̝͖̠̖͐ͨͪ̈̐͌ͩ̀e̷̥͇̋ͦs̢̡̤ͤͤͯ͜s͈̠̉̑͘a̱͕̗͖̳̥̺ͬͦͧ͆̌̑͡r̶̟̖̈͘ỷ̮̦̩͙͔ͫ̾ͬ̔ͬͮ̌?̵̘͇͔͙ͥͪ͞ͅ

Offline lcs

  • Lover of Grape Drank
  • Posts: 669
  • Location: Brazil
  • はやく
Re: Ruby Programming Language
« Reply #5 on: Mon, 14 October 2013, 21:38:22 »
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!

Offline metalliqaz

  • * Maker
  • Posts: 4951
  • Location: the Making Stuff subforum
  • Leopold fanboy
Re: Ruby Programming Language
« Reply #6 on: Mon, 14 October 2013, 23:11:30 »
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 this basic example...

Code: [Select]
[1, 2, 3, 4].inject(0) { |result, element| result + element } # => 10
Compare to the equivalent python...

Code: [Select]
>>> 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...

Offline lcs

  • Lover of Grape Drank
  • Posts: 669
  • Location: Brazil
  • はやく
Re: Ruby Programming Language
« Reply #7 on: Tue, 15 October 2013, 05:39:58 »
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 this basic example...

Code: [Select]
[1, 2, 3, 4].inject(0) { |result, element| result + element } # => 10
Compare to the equivalent python...

Code: [Select]
>>> 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:

Code: [Select]
>> [1,2,3,4].inject(:+)

Offline metalliqaz

  • * Maker
  • Posts: 4951
  • Location: the Making Stuff subforum
  • Leopold fanboy
Re: Ruby Programming Language
« Reply #8 on: Tue, 15 October 2013, 07:09:14 »
or like this:
Code: [Select]
sum([1,2,3,4]):)

Offline lcs

  • Lover of Grape Drank
  • Posts: 669
  • Location: Brazil
  • はやく
Re: Ruby Programming Language
« Reply #9 on: Tue, 15 October 2013, 07:10:29 »
or like this:
Code: [Select]
sum([1,2,3,4]):)

Oh yes!

But that is not possible on smalltalk XD

Offline daerid

  • Posts: 4276
  • Location: Denver, CO
    • Rossipedia
Re: Ruby Programming Language
« Reply #10 on: Tue, 22 October 2013, 01:22:19 »
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.

Offline codyeatworld

  • * Destiny Supporter
  • Posts: 944
  • Location: Bay Area, California
Re: Ruby Programming Language
« Reply #11 on: Tue, 22 October 2013, 04:55:14 »
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.




Offline tufty

  • Posts: 347
  • Location: French Alps
Re: Ruby Programming Language
« Reply #12 on: Tue, 22 October 2013, 08:33:02 »
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.


Offline lcs

  • Lover of Grape Drank
  • Posts: 669
  • Location: Brazil
  • はやく
Re: Ruby Programming Language
« Reply #13 on: Tue, 22 October 2013, 10:16:07 »
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...

Offline metalliqaz

  • * Maker
  • Posts: 4951
  • Location: the Making Stuff subforum
  • Leopold fanboy
Re: Ruby Programming Language
« Reply #14 on: Tue, 22 October 2013, 10:31:08 »
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.

Offline tufty

  • Posts: 347
  • Location: French Alps
Re: Ruby Programming Language
« Reply #15 on: Wed, 23 October 2013, 02:49:59 »
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.

Quote from: Anton van Straaten
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
Code: [Select]
[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 :)

Offline davkol

  •  Post Editing Timeout
  • Posts: 4994
Re: Ruby Programming Language
« Reply #16 on: Wed, 23 October 2013, 06:05:15 »
Uh, what? Since when isn't OOP based on side effects, which happen to be the exact opposite of functional programming?

Offline tufty

  • Posts: 347
  • Location: French Alps
Re: Ruby Programming Language
« Reply #17 on: Wed, 23 October 2013, 06:21:20 »
OOP does not have to be based on side effects, although almost all current implementations are.

For example : this document, and particularly the link at the end, directlky linked here, 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.

Offline metalliqaz

  • * Maker
  • Posts: 4951
  • Location: the Making Stuff subforum
  • Leopold fanboy
Re: Ruby Programming Language
« Reply #18 on: Wed, 23 October 2013, 06:49:43 »
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.

Offline iri

  • Posts: 1031
  • Location: England
Re: Ruby Programming Language
« Reply #19 on: Tue, 29 October 2013, 03:57:41 »
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.
(...)Whereas back then I wrote about the tyranny of the majority, today I'd combine that with the tyranny of the minorities. These days, you have to be careful of both. They both want to control you. The first group, by making you do the same thing over and over again. The second group is indicated by the letters I get from the Vassar girls who want me to put more women's lib in The Martian Chronicles, or from blacks who want more black people in Dandelion Wine.
I say to both bunches, Whether you're a majority or minority, bug off! To hell with anybody who wants to tell me what to write. Their society breaks down into subsections of minorities who then, in effect, burn books by banning them. All this political correctness that's rampant on campuses is b.s.

-Ray Bradbury

Offline iri

  • Posts: 1031
  • Location: England
Re: Ruby Programming Language
« Reply #20 on: Tue, 29 October 2013, 04:00:34 »
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).
(...)Whereas back then I wrote about the tyranny of the majority, today I'd combine that with the tyranny of the minorities. These days, you have to be careful of both. They both want to control you. The first group, by making you do the same thing over and over again. The second group is indicated by the letters I get from the Vassar girls who want me to put more women's lib in The Martian Chronicles, or from blacks who want more black people in Dandelion Wine.
I say to both bunches, Whether you're a majority or minority, bug off! To hell with anybody who wants to tell me what to write. Their society breaks down into subsections of minorities who then, in effect, burn books by banning them. All this political correctness that's rampant on campuses is b.s.

-Ray Bradbury