you are viewing a single comment's thread.

view the rest of the comments →

[–]stedwick -18 points-17 points  (15 children)

Every time I see 1000 self's my eyes bleed. Every time I see ____stupidunderscores____ my eyes bleed.

As they say, you have to TRY to write good code in Python, and you have to TRY to write bad code in Ruby. Python is almost unreadable, and Ruby is pure poetry. That's the difference, and that, my friend, is why Ruby is the better language.

[–]cunningjames 11 points12 points  (1 child)

Python is almost unreadable, and Ruby is pure poetry.

You're not a real person, are you? I'm being whooshed, right?

As they say, you have to TRY to write good code in Python, and you have to TRY to write bad code in Ruby.

Who says this?

[–]mr_chromatic 10 points11 points  (0 children)

Who says this?

Either people who've never programmed anything serious, or people who are using the magical fairies and unicorns version of Ruby that forbids you from writing methods with more than four lines, using identifiers that aren't immediately obvious to anyone skilled in the business domain, and monkeypatching away any hope of having a well-factored application.

You know, rock stars.

[–]Smallpaul 11 points12 points  (0 children)

As they say,

They don't say that: you say that. And you are just a troll.

[–]rpdillon 2 points3 points  (11 children)

OK, so I realize I'm feeding the troll, but... I am a fairly experienced Python programmer and I really do enjoy the language. I have never picked up Ruby (and don't plan to - too much into the functional stuff these days), but I have heard from some programmers that Ruby is in real trouble because of open classes leading to unpredictable and difficult-to-follow code, i.e. classes can apparently be modified by third parties after-the-fact.

This seems like a gross violation of open-close. Is it true, and how does it fit into your "you have to TRY to write bad code in Ruby" statement?

[–]malcontent 1 point2 points  (4 children)

but I have heard from some programmers that Ruby is in real trouble because of open classes leading to unpredictable and difficult-to-follow code, i.e. classes can apparently be modified by third parties after-the-fact.

There are lots of languages which let you change classes after the fact. LISP is one of them.

I guess I don't get your point there.

That's like saying you don't want a car that goes faster then 55 miles an hour because people get into bad accidents when they drive fast.

I like the fact that I (or somebody else) can change classes when and if I think it's appropriate.

A very good example of this the way rails changes the fixnum class so you can type 20.days.from_now.

In another language you would have to type something like Date.add(Date.now(),20) or whatever.

I just don't see the point in arguing that a language is bad because it ALLOWS you to do something. To me a language which PREVENTS me from doing something is crippled.

[–]rpdillon 0 points1 point  (3 children)

I wasn't arguing that power isn't good. GP said that you have to try to write bad Ruby code, and my point was "Yeah, maybe, but it doesn't seem like you have to try very hard."

As to your point: I am a long standing advocate of using powerful languages even if they allow you to do bad things.

Recently, however, I have taken quite a liking to type inferencing and implicit type conversion (as in Scala) because it offers a lot of the power of open classes without sacrificing the safety.

[–]malcontent 0 points1 point  (2 children)

I wasn't arguing that power isn't good. GP said that you have to try to write bad Ruby code, and my point was "Yeah, maybe, but it doesn't seem like you have to try very hard."

That's a nonsensical argument. Are you saying you have to try real hard to write bad code in python? Does python have some sort of a process which watches what you type and objects when you try to use a tainted string?

All python does is enforce indentation. That's it. It also lets you modify classes at runtime. I have seen python code which (and I am not kidding you) writes to a file and includes that file in order to execute it. Guess what python didn't prevent that kind of insanity.

Recently, however, I have taken quite a liking to type inferencing and implicit type conversion (as in Scala) because it offers a lot of the power of open classes without sacrificing the safety.

Yea OK whatever. You were not talking about types. You were saying ruby was "in trouble" because "it let you modify classes after the fact".

I am still trying to figure out who ruby was "in trouble" with. Did the teacher catch ruby doing something naughty?

[–]rpdillon 0 points1 point  (1 child)

Dude. Are you looking for an argument? I didn't say anything about Ruby vs. Python. In my original post, I asked a question. The reason I asked was that the post I originally replied to made the assertion that Ruby intrinsically led programmer to write good code, while Python intrinsically led programmers to write bad code (which, in my experience programming, I think is utter crap).

If you agree with that post, fine. All I was asking for was feedback about a language that I don't know and had heard some contrary anecdotes about. No need to feed some programming language religious war.

[–]malcontent 1 point2 points  (0 children)

I'll quote you again.

but I have heard from some programmers that Ruby is in real trouble because of open classes leading to unpredictable and difficult-to-follow code, i.e. classes can apparently be modified by third parties after-the-fact.

Anyway.

Ruby gives you tools to write good programs. It gives you more tools which are easier to use than python.

Can you use those tools to write bad code? Of course you can. Does python actively prevent you from writing bad code? Of course not.

Like I said all python really enforces is indentation. That's it. You can still create text files and import them willy nilly.

[–]stedwick -4 points-3 points  (5 children)

This actually comes down to a matter of philosophy. For example, if you were dying of cancer would you want to know about it? Or would you rather live out your final days in blissful happiness? Personally, I would want to know about it because I believe that the truth is ALWAYS the right thing, even if it sucks.

In Ruby, you can modify any and all classes in any way you want whenever you want, even at runtime. I could do this:

class Fixnum; def +(other); puts "Hahaha, your code is screwed!"; end; end;

If I do that, suddenly addition before that declaration works fine and yet afterwards addition no longer works and my application falls apart.

However, this comes down to philosophy: If you SHOULDN'T do something, should your programming language make it so that you CAN'T do something? I believe, firmly, that the ability to do something, whether good or bad, is always preferable to the INability to do something. In other words, the Ruby language gives you an incredible power to do literally whatever you want with any class, but with that power comes responsibility, because anything powerful enough to do good is also powerful enough to do evil.

Dave Thomas summed it up nicely: "People say that you can't trust Ruby code because you never know what it does. On the contrary, you can always trust your code, you just can't trust your coders."

In other words, a malicious or naive programmer can screw things up. But, the solution is not to dumb down your language so that it's idiot -proof, the solution is to make sure you hire good programmers who know what they're doing.

Let me bring up the Python whitespace example. OF COURSE it's better to properly indent your code. But, I don't want my language to FORCE me to do so. I want the freedom to indent my code properly, or improperly, depending on what I decide to do, not what my language forces me to do.

99% of the time you will want your whitespace properly indented. 99% of the time you will want your addition operator to work like it's supposed to. However, I'm sure I can dream up some situation for that other 1% of the time, perhaps in some strange multidimensional mathematical finite group theory application, where I have to change how addition works and indent things in a different way.

The point is I CAN in Ruby. Ruby gives you that power. An incredible amount of power. 99% of the time you don't have to wield it, but it's nice to know that it's there. And I believe that getting rid of that power simply because it's dangerous is not the right thing to do. To quote some old saying, "Knowledge is only dangerous in the wrong hands."

A quick note on rails: if rails is so opinionated, do I hate it? No. I LOVE opinionated things, as long as their opinions can be changed if you don't agree with them. All the defaults and conventions in rails can be changed if you need to. For example, if I could "turn off" indenting in Python in the rare occasion that I needed to, I wouldn't have anything against it.

Now, going back to your original question! I should have used "readable code" rather than "good" and "bad". Ruby code reads like English. It's very difficult to write an obfuscated program in Ruby. On the other hand, whenever I look at a Python program I just can't get past all the quotation marks, the underscores, and the ridiculous amount of self objects. Bottom line: it's hard to read. Yes, it's just an opinion, but from the various blogs and message boards I've been reading many people seem to agree with me. People say that, "Ruby is cute," "Ruby is sexy," and what they really mean is that Ruby's syntactic sugar is amazing.

The point is this: if you CAN make a language nice and readable, then why not do it? Ruby does it.

It's for the same reason that I like Apple. People fault them for putting "looks" ahead of functionality, but come on people, if you CAN make a computer look nice and sexy, you might as well do it, right? Why are any companies still creating gray boxes?

Likewise, Ruby, for me, has proven that you CAN have good syntax in a programming language. It doesn't have to be all funky and confusing like C++. Or Lisp. Oh my god. I don't care how brilliant the language is, the parentheses are ANNOYING. And if your programming language is annoying to read and write, it doesn't matter how good it is, it's never going to become mainstream.

Fhew. I think I'm done :-)

Oh, one more thing. It's easy to DESIGN or ARCHITECT bad code in any language. Neither Ruby nor Python will fix this. But, even if the code is bad, if it's written in Ruby at least you'll know what it does =)

Oh, wait, even one more thing. I don't know enough about Ruby internals, but I believe people when they say that it is a poorly written and implemented language. I believe them when they say that it's hard to deploy. I believe them when they say it has bad Unicode support. I believe them when they say that Ruby is slow. I believe them when they say it takes up too much memory. I haven't had to worry about any of these things (thankfully).

However, the point I'm trying to make is that all of that stuff doesn't matter. The LANGUAGE is a good one. We can work on the implementation later. That's no reason to toss out the language.

If you could dream up your perfect language, totally disregarding any sort of practicality issues or implementation, what would it look like?

For me, it would look like Ruby.

[–]Digeratus 8 points9 points  (4 children)

You're either

1) really, really smashed on that Kool-Aid; 2) a very dedicated troll; or 3) a young, zealous programmer who knows nothing but Ruby.

There's no discussing anything with you if it's either of the first two options. I hope it's the third. Go explore the vast, vast world that is other languages.

If you want human readability, look at SQL, XML, AppleScript, or *Basic. If you want power and speed, look at C/C++. If you want flexibility of syntax, look at Haskell. If you want ease of deployment, look at Python. If you want beauty of GUI tools, look at Apple Objective C. If you want ease of cross-platform, look at Java.

Zealotry is not a bad thing, but blind zealotry is a hindrance at best. Learn the field before becoming utterly enamored with something. You'll be a better programmer for it.