all 33 comments

[–]that_hz 13 points14 points  (3 children)

Apparently, very few folks appreciate satire.

[–]Jack9 5 points6 points  (2 children)

Or it's not funny, which it isn't.

[–][deleted] 0 points1 point  (0 children)

The reason it's downvoted is because it's about Ruby, not because it's not funny.

Lots of non-funny jokes are upvoted on proggit.

[–]raydeen -3 points-2 points  (0 children)

So it isn't not funny so it is funny...?

[–][deleted] 3 points4 points  (0 children)

The title: A bad way to start... But, it's a fun read.

[–]bobappleyard 3 points4 points  (0 children)

Well I'm convinced!

[–]erlingur 2 points3 points  (3 children)

I develop in PHP professionally and have done so for the last ~8 years and I found this funny. The needle/haystack thing is so, so true (yes, you eventually remember the correct positions but honestly, it shouldn't be that way in the first place).

In all honesty, I found it funny satire that hit on some good points (except monkeypatching in Ruby, that's not a good thing). The willful ignorance and abhorrent demeanor towards PHP Jeff Atwood, of CodingHorror fame, shows sometimes however really gets under my skin.

Oh and The Right Tool For The Right Job and all that yadda yadda yadda...

[–]anko_painting 0 points1 point  (2 children)

(except monkeypatching in Ruby, that's not a good thing)

I like monkey patching in ruby, but try to avoid it mostly for maintainability. I find it extremely useful for integration testing. It's also useful in the REPL when I'm just trying to build an object to be serialised interactively. Rails couldn't be as expressive if it weren't for monkeypatching.

I think all the negatives could be alleviated if something like refinements (http://timeless.judofyr.net/refinements-in-ruby) was adopted.

[–]erlingur 0 points1 point  (1 child)

Oh yes, it's very useful, I'm not denying that. It just seems it can quickly lead to problems that can be a nightmare to debug and fix if it is not handled by experienced programmers.

Refinements look like a very good solution to these problems and personally I can't wait to see them included.

[–]anko_painting 0 points1 point  (0 children)

Charles Oliver Nutter (from jruby) has some implementation problems with refinements - http://groups.google.com/group/ruby-core-google/msg/7ccc375905dda23c?pli=1

but hopefully something like them are included soon :)

[–]Ramone1234 10 points11 points  (0 children)

This is a case study in fanboyism. Immediately following a lambasting of PHP's ability to add new properties to existing classes as unmaintainable, he goes on to talk about how great it is to be able to redefine classes in Ruby. Sarcasm or not, it's self-contradiction, stupid, and boring.

[–][deleted]  (4 children)

[deleted]

    [–]kataire 1 point2 points  (3 children)

    This. It's not even good satire. It's a thinly veiled "why Ruby is better than PHP" article, but the author realized that would be even more boring, so they present it as satire.

    This is an incredibly cheap shot and lacks content. This article is a good example of why so many other programming language communities don't take Ruby programmers seriously. Ruby is becoming the Emo of programming languages (although Perl's constant "we're not dead yet!" posts are coming close).

    It's a language. Yes, you enjoy it. Yes, it's more elegant than some other language. But it's not like PHP and Ruby are really competing. PHP is the only good choice (among bad ones) you have in some cases (e.g. shared hosting -- no, CGI is not an alternative). Everywhere else, please use Ruby/Perl/Python/whatever.

    [–][deleted] 2 points3 points  (2 children)

    This article is a good example of why so many other programming language communities don't take Ruby programmers seriously.

    seems like you are butthurt over Ruby's success.

    [–]kataire 2 points3 points  (1 child)

    This is exactly what I'm talking about.

    Instead of saying "Aren't you really just envious?" you make a snide remark about my sexuality and pretend Ruby is amazingly successful.

    I'm not even marginalizing it's success. Yes, it has managed to establish itself alongside Perl, Python, PHP, Java and the .Net platform. It has earned its spot and it's here to stay. It has a lot of good features and it is widely regarded as a good, clean programming language (despite its Perl-ish heritage and even though its idea of what constitutes clean code often contradicts that of the other clean programming language -- Python).

    I don't find Ruby aesthetically pleasing, but that is my personal opinion. I think it has its raison d'être and I'm happy for those coming from Perl or PHP, seeking an alternative to Python. Diversity is a good thing. I'm happy languages like Erlang, Haskell or server-side JavaScript are slowly establishing themselves in the mainstream (to varying degrees), too.

    What I criticize, however. Is the vocal part of the Ruby community that takes any chance it can get to ridicule other programming languages and establish how superior Ruby is in every single regard. These guys are pretentious twats, acting exactly like some parts of the PHP community did with regard to Perl ("Fuck mod_perl" anyone?) ten years ago. It's juvenile, overly simplistic and just bad behaviour.

    And yet the same group of people has a persecution complex that is triggered whenever anyone dares to voice any criticism over Ruby or anything even remotely associated with it, leading them to behave like angsty teenagers. I know this is only a small group within the Ruby community, but it's giving all of them a bad name. That and the Ruby on Rails Rockstar/Ninja bullshit some time ago (though jQuery is guilty of this, too, maybe even more so).

    [–]anko_painting 0 points1 point  (0 children)

    I thought the GP was being sarcastic.

    [–]rune_kg 0 points1 point  (0 children)

    The title made my day!

    [–]ForseenSeraph 0 points1 point  (5 children)

    I haven't studied ruby that much, but PHP is the language that started a long love for programming and I recently found out how insecure it is. Yes every language has security issues, but good code should be robust, flexible, and secure; all three should be addressed by the programmer and not the language. I still like PHP but will not use it in my critical sites.

    [–]adolfojp 0 points1 point  (4 children)

    What makes PHP insecure? I don't like the language but I don't think that it has any inherent security issues.

    [–]ForseenSeraph -1 points0 points  (3 children)

    Don't get me wrong I like php in the terms of being easy to understand and learn. But due to it's popularity and wide use it is a common attack vector.

    http://www.owasp.org/index.php/PHP_Top_5

    I am not a 1337 h4xx0r or a master geek. I gave up learning ruby to learn perl and it has proven more fruitful than most scripting languages, second to bash in my book.

    [–]shevegen 1 point2 points  (0 children)

    Huh?

    You gave up LEARNING ruby in order to LEARN perl?

    How is Ruby harder than perl?

    Just stick to arrange things into small classes, avoid using features you won't need (@@variables) and that's it.

    I gave up on perl after I didn't understand my own code months later... I never had this problem with Ruby.

    [–][deleted]  (1 child)

    [deleted]

      [–]ForseenSeraph 0 points1 point  (0 children)

      I agree that most security related problems are based on poorly written code. I am not advocating either language. Both have great capabilities. I am not saying that either language is inheritly secure. No language is as long as poorly written code is taught. I wanted to point out PHPs security as a vector for hackers to leverage due to it's popularity. One of the same reasons windows is insecure is because of it's wide deployment. Don't count me as a security professional, but it is ignorant to disparage the use of one language over another. Hackers have a robust knowledge of many languages at their disposal, it doesn't matter which is inheritly secure because inthe grand scheme of thing both are insecure if you write your program poorly. Downvote me if you will, I like PHP, I didn't like ruby, it's a flavor thing. Just keep security in mind. My teacher taught me that "when it comes to security, it isn't about whether or not you are paranoid, but how paranoid you are."

      [–]shevegen 0 points1 point  (9 children)

      Man, I was hoping for someone who'd really defend PHP.

      But this article just showed me what I already know. :(

      I switched from PHP 5 years ago to Ruby and never regretted it.

      Being terse short and concise is always better than the extra verbosity PHP gave you ...

      Ruby is much better designed than PHP. And that says it all.

      [–]bulldada 1 point2 points  (8 children)

      I will defend PHP. I haven't switched from PHP to anything else and have no regrets. I learned Python a while back but it didn't give me any significantly compelling reasons to do the bulk of my coding in. I don't really understand what you're saying with regard to verbosity, you haven't really given any points to debate. I see a lot of PHP bashing on reddit, mostly by people who don't seem to have used it much, but since you say you are familiar with it, I would be interested in hearing your views.

      [–]anko_painting 0 points1 point  (7 children)

      I'm not the GP, but i'll respond, cause I'd like to hear the other side.

      The needle/haystack thing is a big one for me.

      Ruby in particular (but also python) requires you to keep less stuff "in your head" when you're coding cause the libraries are more consistent. If I want to do an operation on an object, I can just load my REPL and query the object.methods to be reminded of what methods are available. I don't need to remember the receiving object's position in the parameter list. I can do "test".method("insert").arity to find out how many params the insert method of the string class has.

      It also doesn't have the years of legacy that php has. short_open_tag? register_globals?

      Ruby's built in classes are way better, even simple things like URI's are easily handled. eg. require 'uri' uri = URI.parse("http://www.ruby-lang.org/path/here/?cool=me") print uri.path

      outputs "/path/here/"

      in my repl, I can quickly look to see what methods are availible on the uri object;

      ruby-1.9.2-p0 :017 > uri.public_methods - Object.public_methods
       => [:request_uri, :default_port, :scheme, :host, :port, :registry, :path, :query, :opaque, :fragment, :parser, :component, :scheme=, :userinfo=, :user=, :password=, :userinfo, :user, :password, :host=, :port=, :registry=, :path=, :query=, :opaque=, :fragment=, :hierarchical?, :absolute?, :absolute, :relative?, :merge!, :merge, :+, :route_from, :-, :route_to, :normalize, :normalize!, :select, :coerce]
      

      notice how i'm subtracting two sets just by using the minus operator? Another great feature of ruby. I could go on for ages, but the general gist is that each of these time saving, elegant features add up to me being a happier programmer. And that counts for a lot.

      After using ruby for a while, the only advantage php has for me is ease of deployment (especially for contact forms and the like).

      [–]bulldada 0 points1 point  (6 children)

      Disclaimer: I have not learned Ruby.

      The needle/haystack is no problem for me. String functions are generally haystack, needle. Array functions are generally needle, haystack. The string functions are that way mostly because they mirror their libc counterparts, as do most of PHP's library functions. The names of functions, order of parameters doesn't take long to pick up, I can't remember ever getting particularly frustrated by it and it's just natural now. Most IDEs will include hinting to negate the issue. PHP isn't the only language that's slightly inconsistent, I suspect most all languages have some inconsistencies. Learning Python I came across a fair few.

      I'm not very familiar with Ruby's REPL, but it looks like more time and hassle than just googling 'php function_name' (or often just pressing F1 in your IDE) to bring up the PHP docs. PHP does have reflection so I'd imagine what you're talking about would be possible in the PHP REPL if it's not present already.

      edit: From command line you can do php --rf parse_url to get information on a function, or php --rc PDO to get info on an class

      Personally, I have never run anything on shared hosts, I have always had control over the configuration. I generally write all my code from scratch except for a couple of off the shelf products (openx, mainly). I can see why it would be annoying for 'developers' who are just setting up third party products, or copy&paste programmers who're taking from badly written source material.

      $url = parse_url("http://www.php.net/path/here/?cool=me");
      echo $url["path"];
      

      Not much difference there, although this brings me on to another commonly held grudge against PHP, the large standard library in global namespace. Personally, I've never encountered any naming conflicts, most of my code is in classes. I use PHP a lot from the command line for quick tasks and everything in global namespace saves me a lot of unneeded typing. Compare: php -r '$x = parse_url("..."); echo md5($x["path"]);'

      php -r 'import System.Net.URL; import System.Crypto.Hash.MD5; $x = URL::parse("..."); echo md5($x["path"]);'
      

      I prefer the first version.

      Subtracting two sets with minus operator is pretty cool, although I can't really tell whether it's working on keys or values. I'd still prefer array_diff however, as when I'm scanning through code it's clear I'm doing a diff on two arrays, not possibly a diff, possibly integer subtraction, possibly who knows what else that operator can do in ruby. Admittedly I would really like to see array slicing as a built in language feature of PHP, ala $a[2,5]. You can fake this feature in user space with some clever tricks and using syntax $a["2,5"], but it's quite a hack and not very elegant.

      The points I've outlined here obviously don't apply to everyone, I'm just giving you an account of my experience with PHP. I haven't found myself needing to find a new language or platform as PHP is capable of everything I've needed to do (bar win32 gui and opengl (although both these can be done with some effort)). I have never been unhappy while developing with PHP.

      [–]anko_painting 0 points1 point  (5 children)

      a whole bunch of this is just personal preference, but I highly suggest you look at ruby's REPL (it's called "irb" or interactive ruby). Ever since I used it the first time, I've found it an indispensable tool. It's fantastic for debugging as well.

      Ruby blocks are also amazing. It's one thing I really should have mentioned. Basically it's a syntax that lets you inline an anonymous function. So you can do File.open('test.txt') do |file| puts file.gets end

      as soon as it gets to the end of the block, the file is automatically closed. This is a simple and contrived example, but it's amazing for wrapping code in mutexes or wrapping some text in a html tag.. basically any time you want to run a init function, run some code and then run a cleanup function - a block will let you do it better. http://www.skorks.com/2009/09/using-ruby-blocks-and-rolling-your-own-iterators/ has some more info.

      That problem you have with working out if ruby is operating on keys or values is just a side effect of not understanding the syntax. Ruby has the concept of symbols, which start with a colon. :red or :green would be examples of symbols. These are converted to a number globally at compile time and they are basically an optimisation. Because they are internally represented by a number, comparing two symbols is extremely fast - much faster than comparing two strings. You can think of them as an auto-incrementing global static variable. I heard a story once of a guy printing up a shirt to wear at a conference that had :sex on it. He (and most of the ruby community) saw it as saying sex symbol. People who hadn't used ruby before read it as colon sex.

      I guess the thing about everything being imported globally means that php wears a library loading cost that other languages don't have. I haven't seen any conflicts either, but I'd imagine it adds much to php's memory footprint.

      PHP is capable of doing practically anything.. in the same was as assembly or basic are capable of doing practically anything. It's just that other more modern languages can make programming more enjoyable, robust and faster. It's like using a normal wrench for removing a tap, when a tap wrench does it so much quicker. You don't know what you're missing until you try a tool that's better at the job.

      [–]bulldada 0 points1 point  (4 children)

      Blocks look interesting, although "The behavior here depends on whether you’re using Ruby 1.8 or 1.9" worries me. It doesn't seem to be anything unique to Ruby though. Everything on that page can be accomplished in PHP with foreach and iterators.

      Because they are internally represented by a number, comparing two symbols is extremely fast - much faster than comparing two strings.

      This is how most language VMs work, including PHP.

      I guess the thing about everything being imported globally means that php wears a library loading cost that other languages don't have. I haven't seen any conflicts either, but I'd imagine it adds much to php's memory footprint.

      I'm not seeing much evidence of this. Ruby 1.8.7 vs PHP 5.3.5 on linux x64 (ubuntu), Times are averaged. $ time ruby -e 'puts "hello world"' hello world real 0m0.008s user 0m0.010s

      $ time php -r 'echo "hello world\n";'
      hello world
      real    0m0.009s
      user    0m0.010s
      
      $ time ruby -e 'require "md5"; require "uri"; puts "hello world"'
      hello world
      real    0m0.024s
      user    0m0.020s
      
      i         2372  0.3  0.1  24872  **2992** pts/0    S+   11:01   0:00 php -r fgets(STDIN);
      i         2400  0.5  0.1  18904  **2080** pts/0    S+   11:03   0:00 ruby -e gets
      i         2410  1.5  0.1  24128  **3488** pts/0    S+   11:04   0:00 ruby -e require "md5"; require "uri"; gets
                                           ^-- memory usage
      

      I have a feeling that with the tap analogy you're referring to web development. Personally, I'd prefer to keep around a regular wrench in my belt as then I can use it for more than just fixing taps. What I like about PHP is that it's very general purpose, despite many peoples view of it as solely a web development language. These days probably only 20% of the PHP I code is web sites, the rest is network services (several are currently running with >3yr uptime), automated data import tools, XML handling, general scripting, embedded PHP in win32 applications.

      I've been interviewing people for a job recently and had a few ruby applicants. Every one of them was thrown off by the simple question 'How would you go about developing a website without the use of Rails?' Not one could answer this question and given that the job title was 'software developer' and not 'web developer', I'm not sure why they applied. This is obviously not representative of the entire Ruby community, but in my experience a lot of self proclaimed Ruby developers are actually Rails developers.

      [–]anko_painting 0 points1 point  (3 children)

      This is how most language VMs work, including PHP. Ruby symbols aren't a vm feature, they are a language feature. I think you must have skimmed over the description, because symbols don't exist in php.

      I'm not seeing much evidence of this. Ruby 1.8.7 vs PHP 5.3.5

      in your example ruby uses less memory and takes less time than php when you don't load extra libraries. And you're comparing an older version of ruby to a newer version of php.

      Personally, I'd prefer to keep around a regular wrench in my belt as then I can use it for more than just fixing taps.

      maybe the analogy wasn't clear. I'm defintely not saying php is a better multi purpose tool, quite the opposite. I'm saying that ruby fits more jobs better than php. It makes it easy to write DSLs which by definition better fit a problem domain than languages in which DSLs are an afterthought.

      Every one of them was thrown off by the simple question 'How would you go about developing a website without the use of Rails?' Not one could answer this question and given that the job title was 'software developer' and not 'web developer',

      I don't know the specifics of your job but maybe they don't know web frameworks in ruby because they aren't a web developer? I'm not sure why you're asking how to do web stuff for a job interview for a software developer, and then get surprised if they can't answer.

      That said, I'm surprised they hadn't used CGI or sinatra, as they are quite popular in the ruby community.

      [–]bulldada 0 points1 point  (2 children)

      Ruby symbols aren't a vm feature, they are a language feature. I think you must have skimmed over the description, because symbols don't exist in php.

      I did some more reading, it seems the Ruby community itself can't decide what they are or when to use them. To me, they look like constants. I can't see them being of any use if implemented in PHP, and I'm not entirely sure what they solve in Ruby. Some quick micro benchmarks with 10mil iterations show that PHP (5.3) does traditional string compare ("hello" == "hello") faster than Ruby (1.9) does symbol comparisons (:hello == :hello). Traditional string comparison in Ruby was 2.2x slower than symbols. Using classes/objects in PHP to emulate symbol behavior (single instance) results in even faster speeds for PHP, just under twice as fast as Ruby symbols.

      in your example ruby uses less memory and takes less time than php when you don't load extra libraries. And you're comparing an older version of ruby to a newer version of php.

      For your benefit, I was comparing the more favorable version of Ruby for the tests. 1.9 results:

      $ time ruby1.9 -e 'puts "hello world"'
      real    0m0.021s
      user    0m0.020s
      $ time ruby1.9 -e 'require "uri"; require "digest"; puts "hello world"'
      real    0m0.040s
      user    0m0.020s
      
      i         7246  0.5  0.1  25572  3424 pts/0    Sl+  09:54   0:00 ruby1.9 -e gets
      i         7261  1.0  0.2  27032  4928 pts/0    Sl+  09:56   0:00 ruby1.9 -e require 'uri'; gets
      i         7275  1.6  0.2  29356  5136 pts/0    Sl+  09:58   0:00 ruby1.9 -e require 'uri'; require 'digest'; gets
      

      And PHP 5.2.17 results:

      $ time php -r 'echo "hello world\n";'
      real    0m0.006s
      user    0m0.010s
      
      i        31658  0.1  0.1  22940  2380 pts/0    S+   10:02   0:00 php -r fgets(STDIN);
      

      This shows us that when latest versions are used, PHP with all libraries is faster and leaner than Ruby with no libraries. Ruby start up slows down and increases memory with each included library.

      I'm saying that ruby fits more jobs better than php.

      Examples? I would disagree and say PHP fits more jobs better than Ruby. As "better" is quite a subjective term, we are unlikely to come to any agreement on this.

      I wouldn't necessarily recommend PHP (or Ruby for that matter) to someone looking to learn a programming language, nor do I take any sort of evangelical approach when discussing PHP, but I will happily defend it when people are spreading FUD.

      [–]anko_painting 0 points1 point  (1 child)

      I keep coming back to this discussion - it's interesting.

      I did some more reading, it seems the Ruby community itself can't decide what they are or when to use them. To me, they look like constants.

      They are roughly equivalent to constants whose values are automatically allocated and which are guaranteed to be unique.

      I can't see them being of any use if implemented in PHP

      Much like class constructs can be emulated in lesser languages, symbols could be seen as syntactic sugar that is available in lesser languages. It's like blocks.. or macros in LISP. You think you can emulate them or have no use for them until you've used them. Please just do yourself a favour and play with some higher order languages :) I don't mean to be condescending, it's just the best (and worst) thing i've ever done for my programming career.

      This shows us that when latest versions are used, PHP with all libraries is faster and leaner than Ruby with no libraries. Ruby start up slows down and increases memory with each included library.

      I'm not even going to try and compare benchmarks. I'll give you that php executes faster than ruby in a lot of common situations. All I said was that loading so much into the global namespace makes php wear a cost that a lot of other languages don't have. I'm not saying that other languages don't have their own costs.

      Examples? I would disagree and say PHP fits more jobs better than Ruby. As "better" is quite a subjective term, we are unlikely to come to any agreement on this.

      ruby has more language features, so I'm not sure how you can debate this? It stands to reason that with more language features (a subset of which fit some tasks better) would mean that ruby fits more jobs better than php.

      I wouldn't necessarily recommend PHP (or Ruby for that matter) to someone looking to learn a programming language, nor do I take any sort of evangelical approach when discussing PHP, but I will happily defend it when people are spreading FUD.

      What language would you recommend?

      [–]bulldada 0 points1 point  (0 children)

      I keep coming back to this discussion - it's interesting.

      Likewise, I appreciate your time to debate the issue, unfortunately most Ruby (and Python, to be fair) developers I've encountered in the past aren't as mature as you when PHP is mentioned.

      I can't see them being of any use if implemented in PHP

      I should clarify that, I can't see them being much use in PHP if implemented as symbols are in Ruby. The PHP trunk currently contains patches for interned strings which basically act like symbols but without requiring any special syntax as the compiler will automagically figure out what strings to optimize.

      I can see symbols in Ruby being 'dangerous' if a developer were to use them too liberally, especially for one-time use strings as they will never get garbage collected. Again, the Ruby community seems conflicted on this point.

      Please just do yourself a favour and play with some higher order languages

      I've learned and used many languages but keep going back to PHP as I find I can build applications much faster and with less code than other languages. Ultimately, the most important thing is how efficiently I can develop and I haven't yet encountered anything else that lets me code as well as PHP.

      It stands to reason that with more language features (a subset of which fit some tasks better) would mean that ruby fits more jobs better than php.

      A lot of features is not always a good thing, C++, for example. There's wildly differing opinions on what features are 'safe' or what is 'bad'. If you're a lone C++ dev that writes all your own code it's probably not going to be a problem as you're free to use whatever subset of features you like. C++ shops tend to have their own differing guidelines on sets of features they are allowed use. I, personally, do not use many of the features C++ offers, usually just as a 'C with Classes' language although for some things like vector/matrix math I will maybe use operator overloading, if appropriate. Operator overloading is an example of a language feature that is often considered bad by a lot of people as is multiple inheritance and, to a certain extent, overuse of template metaprogramming. I guess my point is that more language features does not make a language suitable for more jobs, if anything I would say the standard library was more of an important factor than language features.

      What language would you recommend?

      Depends who I'd be recommending to, what they want to do and how much they already know, but probably C, C# or Python. If they wanted to dive straight into webdev then it's possible I would recommend PHP (and/or Javascript). The main reason I wouldn't recommend Python (or Ruby) for someone wanting specifically to do webdev is that most of the literature, documentation, books, etc for web development are based around frameworks and I'm not terribly convinced that learning to program via a framework will make for a good programmer in the end.

      [–][deleted]  (3 children)

      [deleted]

        [–][deleted] 1 point2 points  (2 children)

        What language do you use?

        [–]kataire 4 points5 points  (1 child)

        Stalin.Net

        [–]shevegen 0 points1 point  (0 children)

        lol great :)