Questions tagged [ruby]

Questions about Ruby, dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features.

Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto. It was influenced primarily by Perl, Smalltalk, Eiffel, and Lisp.

288 questions
108
votes
10 answers

Why is Python used for high-performance/scientific computing (but Ruby isn't)?

There's a quote from a PyCon 2011 talk that goes: At least in our shop (Argonne National Laboratory) we have three accepted languages for scientific computing. In this order they are C/C++, Fortran in all its dialects, and Python. You’ll notice…
Cyclops
  • 2,167
  • 3
  • 17
  • 20
58
votes
5 answers

get weighted random item

I have, for example, this table +-----------------+ | fruit | weight | +-----------------+ | apple | 4 | | orange | 2 | | lemon | 1 | +-----------------+ I need to return a random fruit. But apple should be picked 4 times as…
fl00r
  • 691
  • 1
  • 6
  • 8
57
votes
3 answers

What is a symbol in Ruby?

I'm totally new to the Ruby world, and I'm a bit confused with the concept of Symbols. What's the difference between Symbols and Variables? Why not just using variables? Thanks.
wassimans
  • 1,173
  • 2
  • 10
  • 12
53
votes
9 answers

Explanation on how "Tell, Don't Ask" is considered good OO

This blogpost was posted on Hacker News with several upvotes. Coming from C++, most of these examples seem to go against what I've been taught. Such as example #2: Bad: def check_for_overheating(system_monitor) if system_monitor.temperature > 100 …
Pubby
  • 3,290
  • 1
  • 21
  • 26
41
votes
3 answers

Are integration tests meant to repeat all unit tests?

Let's say I have a function (written in Ruby, but should be understandable by everyone): def am_I_old_enough?(name = 'filip') person = Person::API.new(name) if person.male? return person.age > 21 else return person.age > 18 …
Filip Bartuzi
  • 565
  • 1
  • 5
  • 13
41
votes
2 answers

Do modern languages still use parser generators?

I was researching about the gcc compiler suite on wikipedia here, when this came up: GCC started out using LALR parsers generated with Bison, but gradually switched to hand-written recursive-descent parsers; for C++ in 2004, and for C and…
eatonphil
  • 561
  • 4
  • 8
38
votes
11 answers

Is it okay to make coding style changes on an open source project that doesn't follow best practices?

Recently, I came across a number of open source Ruby (or majority of it was Ruby) projects on GitHub that when checked with a code analyzing tool like Rubocop, create a lot of offenses. Now, most of these offenses include using double quotation…
user79317
34
votes
8 answers

Ruby but not Rails on my Resume

I have listed Ruby as a skill on my resume becuase I've been programming in Ruby for 5 years while I work on my Ph.D. thesis. I've mostly been using it to implement natural language processing algorithms. I'm starting to look for a job, and I posted…
Ken Bloom
  • 2,384
  • 16
  • 20
28
votes
3 answers

What functionality does WebStorm contain which RubyMine does not?

I am looking at buying Rubymine as I am doing a small amount of ruby, but a large amount of html5/javascript. I was going to get Webstorm as I do have a lot of pure html5/js based frameworks/apps that I am working on, however I then read that…
Grofit
  • 863
  • 2
  • 8
  • 11
27
votes
2 answers

How does using a LGPL gem affect my MIT licensed application?

I am developing an open source ruby application under the MIT license. I am using this license because I don't want to place any restrictions on the users of the application. Also I can actually read and understand this license. I recently started…
corsen
  • 371
  • 3
  • 3
25
votes
8 answers

Ruby on Rails downsides and caveats

This is not an opening gambit for RoR bashing - honest! I'm learning Ruby and the Rails framework. Prima facie it appears to be pretty cool, and a wonderful experience compared to PHP. (In fact, it's reminding me of happier days with C# and…
Matty
  • 1,154
  • 3
  • 13
  • 19
24
votes
3 answers

In what area is LISP's macro better than Ruby's "ability" to create DSL

One of things that makes Ruby shine is the ability to create Domain Specific Languages better, like Sinatra Rspec Rake Ruby on Rails' ActiveRecord Though one can duplicate these libraries in LISP through macro, I think Ruby's implementation is…
OnesimusUnbound
  • 755
  • 8
  • 16
24
votes
8 answers

Ruby or Python?

This question is extremely subjective and open-ended. It might even sound like something I should just research for myself and make my own decision. But I'd like to put it out there and get some thoughts from others. Long story short - I burned out…
Bobby Tables
  • 20,516
  • 7
  • 54
  • 79
22
votes
3 answers

Why do so many languages treat numbers starting with 0 as octal?

I've read Where are octals useful? and it seems like octals are something that were once upon a time useful. Many languages treat numbers preceding with a 0 as octal, so the literal 010 is actually 8. A few among these is JavaScript, Python (2.7),…
Manishearth
  • 688
  • 6
  • 19
21
votes
1 answer

Best Ruby Git library?

Which is the best Git library in Ruby to use? Git, Grit, Rugged, Other? Background: I'm the current maintainer of TicGit-ng which is a distributed offline ticket system built on git, and I've read and heard over and over again that Grit is the one…
Jeff Welling
  • 1,289
  • 1
  • 9
  • 15
1
2 3
19 20