Ruby is:
- when OOP replaces common sense;
- when people write "begin end begin begin end end..." instead of code;
- when program is so slow, that you can have a tea party, while it multiplies two 10x10 matrices;
- when code like 12.5.integer? or 3.times {puts "Ruby rocks!"} considered beautiful.
# This is a block. It can be passed to a function like so `function your-block' and is called within that function with `yield your-bar'
{|bar| bar.foo}
# This is a proc. It is called like so `your-proc.call' and it can be assigned to a variable or passed to a function directly.
proc {|bar| bar.foo}
# This is almost the same as a proc.
lambda {|bar| bar.foo}
# This is a method. It is called like so `foobar.baz your-bar' and it can't be passed to a function directly.
def baz(bar)
bar.foo
end
>>15
After all these $global_var &proc $~[1], $!, $>, $@, $&, $+, $0, $~, $’, $`, $:, $*, $?... Haskell starts to look sane.
Name:
Anonymous2012-01-16 12:48
Haskell on Huskies.
Name:
Anonymous2012-01-16 12:50
If it ain't Lisp, it's crap.
Lisp is shit.
Name:
Anonymous2012-01-16 13:41
- Ruby indulges obfuscation: Ruby has no keyword/optional arguments, so you'll have to use hash parameters as a substitute. This is an idiom that comes from Perl. Ugly, Perl-looking code, like proc {|obj, *args| obj.send(self, *args)} or (0..127).each { |n| p n.chr }, considered beautiful. Quirky variable names (partially due to naive environment design): @instance_var, @@class_var, CONSTANT_VAR, $global_var, &proc, $~[1], $!, $>, $@, $&, $+, $0, $~, $’, $`, $:, $* and $?. If A is [1,2,3] and B is [10,20,30], then A+B is [1,2,3,10,20,30], when you probably wanted [11,22,33]. A good amount of your code will consist of begin end begin begin end end...
- Faulty syntax. Ruby cant distinguishing a method call from an operator: "a +b" can be both "a(+b)" and "a + b" - remove the space to the left of "+" or add a space to the right of "+", and it will be parsed as an addition. Ruby's expressions terminate by a newline and you have to implicitly state that the expression is not over, using trailing "+" or "\". That makes it easy to make a dumb syntactic mistake by forgeting to continue line. It also encourages putting everything onto a single line, producing messy looking code.
- Slow: JIT-compiling implementations exist, but they're still slow and incomplete, due to Ruby's complexity and bad design, which make Ruby difficult to optimize compared to other dynamic languages, like Lisp. For example, Ruby has to accomodate for somebody in another thread changing the definition of a class spontaneously, forcing compiler to be very conservative. Compiler hints, like `int X` from C/C++ or `declare (int X)` from Lisp, arent possible either.
- Ruby's GC is a naive mark-and-sweep implementation, which stores the mark bit directly inside objects, a GC cycle will thus result in all objects being written to, making their memory pages `dirty` and Ruby's speed proportional to the number of allocated objects. Ruby simply was not designed to support hundred thousand objects allocation per second. Unfortunately, that’s exactly what frameworks like Ruby on Rails do. The more objects you allocate, the more time you "lose" at code execution. For instance something as simple as 100.times{ ‘foo’ } allocates 100 string objects, because strings are mutable and therefore each version requires its own copy. A simple Ruby on Rails ‘hello world’ already uses around 332000 objects.
- OOP: Matz had a bit too much of the "OOP is the light and the way" philosophy in him, in effect Ruby doesn't have stand-alone functions and Ruby's blocks can't be used in exactly the same way as usual closures.
- Ruby (like most other scripting languages) does not require variables to be declared, as (let (x 123) ...) in Lisp or int x = 123 in C/C++. If you want a variable private to a block, you need to pick an unique variable name, holding the entire symbol table in your head. This also means that Ruby can't even detect a trivial typo - it will produce a program, which will continue working for hours until it reaches the typo - THEN go boom and you lost all unsaved data. Local and global scopes are unintuitive. Certain operations (like regular expression operator) create implicit local variables for even more confusion.
- Non-othogonal: {|bar| bar.foo}, proc {|bar| bar.foo}, lambda {|bar| bar.foo}, def baz(bar) bar.foo end - all copy the same functionality, where Lisp gets along with only `lambda`. Some Ruby's features duplicate each other: print "Hello", puts "Hello", $stdout<<"Hello", printf "Hello", p "Hello", write "Hello" and putc "Hello" -- all output text to stdout; there is also sprintf, which duplicates functionality of printf and string splicing.
- Ruby as a language supports continuations via callcc keyword. Ruby's callcc is incredibly slow, implemented via stack copying. JRuby and IronRuby don't have continuations at all, and it's quite unlikely they will ever get them. There were also support breaches in mainline Ruby, where Ruby 1.9 has not supported continuations for a while. If you want your code to be portable, I'd suggest not using Ruby.
- Ruby was created "because there was no good scripting language that could handle Japanese text". Today it's mostly Rails hype and no outstanding feature, that makes the language, like the brevity of APL or simplicity and macros of Lisp. "There is some truth in the claim that Ruby doesn’t really give us anything that wasn’t there long ago in Lisp and Smalltalk, but they weren’t bad languages." -- Matthew Huntbach
# Why would I even bother trying to write
# an optimal sorting algorithm with such
# a slow language, I have no idea.
# Just look how horrid line 6 is
class Array
def quicksort
if self.length<=1
self
else
# This next line of code is horrible
# It isn't even the same as
# array=[self]
array=Array.new(self) # Nightmares, man!
pivot=array.pop
less=array.select{|element|element<=pivot}
greater=array.select{|element|element>pivot}
less.quicksort+[pivot]+greater.quicksort
end
end
end
I do admit, I like type inference, blocks, complete immersion into OOP, but I find some things ugly, like blocks, singleton methods, Object methods used to access private ("object") variables, and of course the horrid:
class << self
Oh, and the Complex class makes fractions if given integers. Ugly
besides some quibbles (eg "Ruby cant distinguishing a method call from an operator"
well, shouldn't operators essentially be methods/functions? plz let me set the fixity/precedence or whatever like haskell does) this copypasta is a nice smashing of Ruby.
the question then, is, if it has all these flaws, why is it popular?
>>24 besides some quibbles (eg "Ruby cant distinguishing a method call from an operator" well, shouldn't operators essentially be methods/functions?
Please, read original article: http://www.cs.auckland.ac.nz/references/ruby/doc_bundle/FAQ/FAQ.html
Ruby works hard to distinguish method calls from operators, and variable names from method names. Unfortunately, there's no way it can get it right all the time. In this case, ``a +b'' is parsed as ``a(+b)''. Remove the space to the left of ``+'' or add a space to the right of ``+,'' and it will be parsed as an addition.
>>34 The {} is parsed as a block, not a Hash constructor. You can force the {} to be treated as an expression by making the fact that it's a parameter explicit: p({}).
Horrible.
>>37
occasionally a postfix if or while reads better
Name:
Anonymous2012-01-17 0:44
>>38 occasionally a postfix if or while reads better
A good reason to fuck up whole syntax.
Name:
Anonymous2012-01-17 2:34
All accusations towards Ruby are just ridiculous and are factually inaccurate! It is important that as a community we debunk these myths and unjustified criticisms. An even better road to take would be to provide examples of how computationally complex problems can be dealt with efficiently in Ruby, highlighting the best practices and the existing workarounds.
A religious community is emotionally easy to attack and may produce inopportune responses in defense of whatever has been questioned. Over the past three years I’ve heard a few bad things about Ruby and I’ve seen all sorts of responses, which in some cases were simply overreactions.
Ruby is a wonderfully designed language. The Ruby and Ruby on Rails communities have a lot of passion. We love our language, created by a very cool guy (and maestro of humbleness) in Japan. We love our framework authored by a Danish GAP model, and we really enjoy the spirit in the community. We have the best non-paid marketing department in the world. We started the revolution which is powering most of the new social websites out there.
Ruby on Rails is the single most important and valuable technical solution, language and tool for software problems.
>>34
>Unfortunately, there's no way it can get it right all the time. In this case, ``a +b'' is parsed as ``a(+b)''. Remove the space to the left of ``+'' or add a space to the right of ``+,'' and it will be parsed as an addition.
and coffeescript thought this was a great idea
``fixing'' javascript by following the same design process:
1. steal bad ideas from other languages
2. steal good ideas from other languages, but cripple them
3. brag about these innovative ideas. guys, look! closures! does your language have these?! i bet not! i hope you love closures because you're going to be using a whole lot of them to fix the variable scoping we fucked up!
Name:
Anonymous2012-02-25 18:20
>>24
Lisp is going through a sort of recurrence – just look at how many Clojure jobs that are going. I get called almost once a month about jobs using... Lisp.
;) I might prefer to work in Smalltalk, but hey, Lisp is beautiful too.