by vincent-toups · 6y ago · 0 comments
Ruby, in contrast, seems like an absurdly complicated concatenation of weird features and strange syntax. When I look at Ruby my eyes glaze over with all the unnecessary syntactic doodads and peculiar abstractions. Why anyone would want to complicate their lives with all that silliness is beyond me.
And yet Scheme languishes and Ruby, for a time, anyway, burned brightly. I'm clearly the weird one.
My experience is the precise opposite. Ruby seems more consistent and straightforward than any other non lisp language I’ve used. Ubiquitous blocks and “everything is an object” gets you very far.
Compare nested list comprehensions in python to chained map/select calls in Ruby:
lesson for lesson in [school.Lesson(downloaded) for downloaded in api.downloads()] if want(lesson)]
vs
api.downloads.map{|download| School.Lesson.new(download)}.select{|lesson| want(lesson)}
Or compare the many varied required ways to do something with an array in python vs Ruby:
len(array)
“;”.join(array)
array.append(x)
Vs
array.length
array.join(“;”)
array.append(x)
Genuinely confused what you refer to with “unnecessary syntactic doodads.” Examples?
You could do filter(want, map(school.Lesson, api.downloads()) in Python.
Blocks are not objects. So much for "everything is an object". At least, this is my understanding, I may be wrong?
def foo(&block)
puts block.class
block.call
end
foo do
'bar'
endConsider the natural human languages- they're far from being straightforward uniform compositions of extremely simple abstractions. They have weird syntax, and a lot of redundancy.
Now, some of it is historical legacy, but not all. The language doesn't just have to be easy to analyse semantically - it also has to be easy to parse. And while parsing identical nested brackets is easy for a machine, humans prefer more variety for their pattern matching inputs.
Languages like Perl, on the other hand, feel right at home with the English language. There’s a deep history of all these different things from many different places that have been bolted on over the years. It’s incredible that we can say anything at all, let alone write amazing works in it.
Sounds like a human (natural) language to me ...
I suppose it can be said that Scheme is very simple but hard for many, while Ruby is very complex but easy for many.
“Human design” isn't “human designed” but “designed for humans”, and, more specifically, “deidned for the way human brains naturally work” rather than “deidgned for ivory-tower ideal of how brains should work”
> Ruby, in contrast, seems like an absurdly complicated concatenation of weird features and strange syntax
And, in that respect, is a lot like natural languages, which are quite often complex analytically/descriptively, with near-duplicate features, leveraging implication, etc., etc., etc.
“The Rules” that matter become the patterns that the simple rules allow or imply, and all the nuances of when one is better than another.
# For a bank,
if ($authorised) {
allow_entry();
}
# vs. a shop:
allow_entry() unless $person->is_smelly();
The language lends itself to how you may normally say it in English, emphasizing the common case. That isn't to say all the syntactic noise is justified, but I guess one's noise is other's attempt at being more expressive.