Ruby, Rails, Web2.0 » Uncategorized https://rubyrailways.com Experiences with Ruby and Rails, Web2.0 and other development technologies Tue, 26 May 2009 07:57:08 +0000 en-US hourly 1 http://wordpress.org/?v=3.5.2 RailsBridge is Born https://rubyrailways.com/?p=430 https://rubyrailways.com/?p=430#comments Mon, 04 May 2009 10:14:12 +0000 peter https://rubyrailways.com/?p=430 Continue reading ]]> rails_bridge.pngI surely don’t have to introduce last week’s Ruby/Rails earthquake to anyone by now – it has been covered by a boatload of blogs (including this one), analyzed, argued over, rebutted, reddited, dugg and whatnot – suffice to say, it’s time to move on. It was a rather unpleasant drama piece, but fortunately it shed light on some problems the Ruby/Rails communities are facing, and (besides the ensuing trollfest and pointless arguing) it had a pleasant side-effect: a handful of people started to discuss how things could be made better, creating a small (and growing) but determined community: RailsBridge!

Say Hello to RailsBridge!

RailsBridge’s mission is “To create an inclusive and friendly Ruby on Rails community” (check out details on the homepage). Everyone is welcome to participate – with ideas, suggestions, design, code, new project proposals or just about anything that would make Rails a more open and accepted technology and community.

It’s very important to understand that we are not trying to form yet another oh-my-god-we-are-so-awesome Rails group of uber-hackers which looks down on everyone not in it’s ranks – for two reasons, at the very least:

  • RailsBridge is open to anyone! – you don’t have to be a Rails core commiter, coder with 20 years of experience or a renowned Rails blogger – it’s enough if you’d like to make the Ruby/Rails scene more welcoming in any way
  • We are trying to promote the exact opposite philosophy – we acknowledge that Rails’s image is somewhat tarnished because of the “rock star” attitude and we’d like to show by our actions that we are working on this and will eventually turn Ruby and Rails into a very welcoming and enjoyable community

Surely, this is quite a venture – our mission statement sounds great, but everyone can do the talking on just about whichever Gordian Knot out there, be it world hunger, world peace or friendly Rails. We’ll have to demonstrate that we mean serious business, and that’s why we need you – everyone’s ideas, insights and help matters! Check out the RailsBridge homepage to learn more about what are we up to and how to get involved.

]]>
https://rubyrailways.com/?feed=rss2&p=430 32
FOWA Dublin videos (including DHH talk) https://rubyrailways.com/?p=405 https://rubyrailways.com/?p=405#comments Tue, 31 Mar 2009 10:43:59 +0000 peter https://rubyrailways.com/?p=405 Continue reading ]]> dhh-ftrw.png As promised, here’s a quick post about the FOWA Dublin videos which have been uploaded recently – including the most anticipated Doing a Start Up in the Real World (a.k.a. ‘Fuck the real world’) talk by David Heinemeier Hansson. If you watch only one video, make sure it’s this one :-) .

I just got back from a wonderful Scotland on Rails 2009 so will post my experience later today (or whenever I’ll be able to catch up with all my chores – spent almost 1.5 week in England + Scotland so my TODO list is huge :-)

]]>
https://rubyrailways.com/?feed=rss2&p=405 6
Twitter Unveils New Premium Accounts? I hope not!!! https://rubyrailways.com/?p=395 https://rubyrailways.com/?p=395#comments Thu, 19 Mar 2009 10:18:19 +0000 peter https://rubyrailways.com/?p=395 Continue reading ]]> twitter_post.png
Update: I definitely jumped the gun with this one :-) It *is* meant to be a joke. Thanks god.

I hope this is a joke. A bit sounds like it, but it might be still true. I am really hoping it’s not!

The news (“Twitter Unveils New Premium Accounts“) is spreading like wildfire on twitter right now, making it impossible to even guess who retweeted who, but that doesn’t really matter anyway. What matters is that everyone in twitterverse is talking about it right now. I really do hope it’s just a scam, because I don’t like the idea at all… here’s why:

  • Raising the character limit – (this is the part that makes me think/hope it’s a scam) I believe twitter’s success is partly because of the ‘do less’ scheme. If you look at jaiku, plurk, pownce and a ton of other failed (or let’s put it like this: not as successful as twitter by a wide margin) microblogging services, who hoped to differentiate themselves from twitter (also) by adding a ton of other features twitter doesn’t have, didn’t succeed. I (and I believe I am talking for the most of the twitter users out there) love the service exactly because it’s a no-brainer: you have to squeeze some interesting information into 140 chars. That’s it. The story ends here.

    There are plenty of third party apps (several hundreds when I last checked) that add this or that on top of twitter, some of them actually very good. That’s a win for everyone: you can choose which service to use (often multiple sites are competing for the same type of service – competition is always a good thing!). Modularity is a good thing – not to mention that great services (like search, a.k.a. summize) are integrated into twitter later anyway.
  • Messing it up – you get random followers?!?! Why is that? I am already annoyed by the ‘quest for numbers’ “feature” of twitter – totally unrelated people following each other just to bump their follower count. This is kind of understandable, as the follower count is viewed as an universal number of influence/power on twitter, but still, why should you push information to people (or consume the information they are pouring onto you) if you are not in the same niche/field/market? This sounds really crazy.

    Anyway, how will those 20/100/1000 random followers be chosen? Will they accept that they have to follow someone? Bullshit meter +1. This really smells like hoax.
  • Elitism – the same concerns as with Kevin Rose’s latest brainchild, wefollow.com – the rich get richer, the poor get poorer. Invisible (and possibly otherwise great) people will remain undiscovered Good Will Huntings for good, while users already boasting thousands (or much more than that) followers will climb to even more higher places. How is this good for a community as a whole??!
  • Price – this is basically the B variant of “Elititsm”. Open source enthusiasts, students, researchers, a big part of developers (the group I am personally interested in) and a lot of others (you surely have a similar group with other interests) won’t be willing (and able to in some cases) to pay the $15/$50/$100 monthly fee – it’s just too much. $5 is OK for everyone, but that doesn’t buy you nearly anything. The other premium levels are just too much for most of people, again just pushing the elite to higher places.

I have a ton of other points, but the more and more I think about it, I seriously think this is a SCAM. I really love twitter and hope they’ll have a solid business model and will make a ton of money sooner or later, but please not this way. I am not even against premium accounts, or just paying a sensible monthly fee – would surely do that – but please stay with the roots and don’t promote elitism. Khtxbai!

]]>
https://rubyrailways.com/?feed=rss2&p=395 6
DHH: Fuck the Real World https://rubyrailways.com/?p=389 https://rubyrailways.com/?p=389#comments Tue, 10 Mar 2009 10:32:59 +0000 peter https://rubyrailways.com/?p=389 Continue reading ]]> dhh-ftrw.png
I planned to do a writeup on the talks @ FOWA Dublin, but Dave Concannon did such a great job that I could not add too much without re-iterating what he said, so I’d like to concentrate on just one talk instead, which totally blew me away: Creating Software in the Real World by David Heinmeier Hansson.

Let me start with a bit of background – as a Rails developer for almost 3 years now, this was obviously not the first time I heard about David, 37signals, their Getting Real principles, business practices etc. – however, this was the first time I have seen him live, delivering a great talk. And it made a huge difference.

If you happen to know me, you probably know that I am not a guy who gets ecstatic because someone is an alleged rock star, ninja, pirate or zen master, even if he happens to be author of something as significant as Ruby on Rails which I think is the greatest piece of software since Prince of Persia. I had my own reservations wrt David (a slew of blog posts about him suggest that he is kind of a controversial character to say the least: the potty-mouth Dane, the F-bomb terrorist who always has a curse or two up his sleeve for good measure, brings on the vitriol first and ask questions later etc. etc.) After seeing him perform live, I am quite sure that most of these negative comments are either taken out of context, coming from the sour grape camp or are just plain wrong. Sure, David is not a grail knight when it comes to defending his stance – that’s one of the reasons why he keeps building kick-ass stuff like Rails or Basecamp. He totally pwn3d the stage from the very beginning, and even if I wanted to be very critical, I just could not see that he is the douchebag suggested by his critics.

It also became clear to me that DHH != (only) Rails. While he is often primarily described as the author of the Rails framework, that’s a gross oversimplification of the big picture. I think Rails is “just” the side effect of David’s passion to create web apps in a getting real way. Above everything else, he is a guy with a vision who gets things done, no matter what does it cost – e.g. writing a web framework in Ruby (the language he found the most “getting real” style when he needed to implement Basecamp).

OK enough rambling – here is the summary of the talk (I certainly could not get everything, but I am trying my best)

* “We don’t have 200k RSS subscribers because of my deliciously swirly hair” – a central question (asked also during the Q/A session): how on the earth did Basecamp and other 37signals products become so popular? All of a sudden, they emerged from nowhere! As David points out, it was not that ‘out of the blue’ as it looks like. When they started with Basecamp, they already had 2000 subscribers on their blog, Signal vs Noise, so they built a channel which through they could advertise themselves.
This advice meshes with one of my favorite points from Getting Real which goes something like “Just start doing something”. Really. Start blogging. Creating/contributing to open source software. Get on twitter. Let your voice be heard! You probably won’t have thousands of listeners right away, that’s OK – it takes time. But you can start today!

* “Fuck the real world” – probably the tagline this speech will be remembered for. Taken out of context, DHH critics have yet another flickr snapshot where they can demonstrate arrogant F-bomb usage, good for nothing. Bullshit. It was designed and “dropped” perfectly, kicking off the whole talk! David’s advice is to stop listening to “advice” which goes like “yeah, this is a great idea/concept/whatever, but it will not survive in the real world”. Sure, Rails didn’t look like a great idea when Java and PHP have been the bee’s knees. Today no one (except the hard-core sour-grape Java/PHP/COBOL fanboys) would argue that it made a big impact on how web software is developed (call it web2.0 if you like). David said that none of their current apps passed the “real world” (in the sarcastic sense) test – and look where they arrived.

* “I didn’t start coding when I was 6, but 21, and Jason (Fried) started business school later too” – David de-bunked the myth that you have to be a “natural” to accomplish great things. True, quite a few of the IT related success stories start with “I got my first Sinclair ZX Spectrum/Commodore/Atari/Amiga when I was 4, started coding in xyzBasic at the age of 5, roocked fooBasic at 7 etc. While this is all great, and certainly a big help if one happens to become a professional coder later, it’s certainly not the only path to victory. There is no such thing as “starting out too late”. Just make sure you start today.

* “Forget the _advice_ that you shouldn’t build too simple software” – “Good bye to bloat”, “Simple, focused software that does just what you need and nothing you don’t” are rules 37signals are living by, not just pretending. If you check out their award-winning software, used by over a million people today, you’ll notice that despite of their age (several years) they are still simple pieces of focused apps. That’s one of the secret sauces of 37signals: if it works for them, why shouldn’t it work for you? The point is to create something usable, not bloated.

* “Would I pay for this app?” – a great reality check they are asking themselves all the time. If you wouldn’t pay for such a product, why would anyone else?

* “Running your own business = the power to say no – You should be able to say “no” and stick to your vision rather than trying to add all the bells and whistles required by the customers. Note that this does not mean you should refuse / reject all the requests – some of them are really great, but eventually *you* have to decide which ones to keep and which ones to boot (because they just don’t fit into your vision).

* “startup is a category I hate – you have to build a business” – another great point. It’s so trendy to found start-ups today, it almost sounds like a game for grown-ups. (It’s not, I founded two of them myself and it was the hardest part of my professional life so far. Compared to a startup, regular freelancing / contracting feels like a walk in the park :-) ). You have to plan for long term, have real goals, start making money as soon as possible (vs. wait for google or another Silicon Valley dude with a lot of money), get real. It’s not a game, it’s a business.

* “You don’t need rock stars, but a rock star environment. Your employees are not stupid” – argues that the environment your company is in matters more than the individuals. With a great company culture where you respect and trust your employees (e.g. 37signal employees get a company credit card, with one policy – use it reasonably! wow) your team will live up to their full potential. By creating and nurturing an atmosphere of growth, you won’t have to micromanage everybody and everything – don’t treat your employees as idiots, because they are not.

* “An idea is so small part of a business that it’s almost a rounding error” – So true. I have so many ideas right now, that it would take months to prototype them – but that would eventually become an endless process, because during prototyping I would get new ideas, etc. Ideas are cheap, everyone has them. The question is whether you have the skills and perseverance to make them happen.

* “you have to build massive popularity slowly” – Probably my most favorite point of the talk. As a small business owner, startup founder and entrepreneur I found out on my own skin several times that it’s relatively easy to start something – be it a startup, a blog, an open source project, a client assignment, a relationship/marriage/organization/company/habbit/just about anything. The trick is to keep pushing with the initial vigor (at least) once you reach the plateau – for a long time, until the breakthrough comes (you finish your project, your blog gets picked up, your startup is featured on techcrunch, etc.) That’s one of the main things that sets successful ventures apart from non-succesful ones. Everybody has ideas. Everybody can start. A few of them can finish because it takes time and perseverance. You have to believe in yourself and your idea to make it through, as long as it takes.

Unfortunately this summary can’t capture the atmosphere of the talk – as far as I can tell, the room was on fire, everybody was charged up and motivated by this speech (I can’t imagine who wouldn’t be). For me it was worth the price of the conference alone. Massive thanks to David!

]]>
https://rubyrailways.com/?feed=rss2&p=389 66
FOWA Dublin – a Mixed Blessing https://rubyrailways.com/?p=380 https://rubyrailways.com/?p=380#comments Sun, 08 Mar 2009 23:45:28 +0000 peter https://rubyrailways.com/?p=380 Continue reading ]]> fowa.png
I am sitting on the plane flying home from Dublin, trying to summarize my thoughts about the Future of Web Apps conference. While I think that overall, FOWA Dublin was worth attending (because of the speakers, especially David Heinemeier Hansson, who surpassed all my (high) expectations – will post about it later), in my opinion it did not live up to its full potential. The most annoying thing is that just with a tiny bit of more effort it could have been an 5-star conference in every sense of the word – however it missed to deliver this additional plus, leaving a bad taste in my mouth.

I have seen blog posts/tweets raving about the conference – in a paradoxical way (given what I just wrote in the above paragraph) I can mostly agree with those posts too. The trick is whether you are judging the conference solely based on the content (in which case I can agree with the above blog posts) – or as a whole, including venue, wifi, organization, socialization, before and after parties, freebies, extras, all the bells and whistles. Using the latter method (and I see no reason why one should not) the conference was mediocre IMHO – a few thoughts why:

* (almost) no wifi – After all, a conference centered around the web full of nerds with iPhones, notebooks and other wifi-hungry devices needs no wifi right? Wrong. (OK, the reality was more complex than that: there _was_ some kind of “home wifi” but in practice that meant constant hunting for the signal which broke randomly after a few minutes)

* crowd – A huge crowd (or too little space, if you put it like that) right from the very beginning; Arrived 30 minutes before the actual start, to experience an episode from the life of herrings in the lobby on my own skin, without the slightest idea of why couldn’t we enter the auditorium or what are we supposed to do (other than brewing in our own sweat and looking around to see more puzzled herrings)

* the way the uni sessions were delivered – no microphone; very noisy from outside; people running around all the time, causing constant distraction;

* no announcements of talks – (like someone running out to the foyer and shouting ‘hey guys we are starting in 5 minutes!’) – half of the people still in the foyer, resulting in slow, continuous trickling into the auditorium, again causing a lot of distraction (probably less distracting the closer you sit to the stage, but at the upper end it was really annoying). The doors were open for some reason, so constant murmuring from the foyer.

* No freebies – for this price, at least a coffee or two (and maybe I am not too demanding to add something like snacks/muffins/mineral water?) would have been nice. Ridiculous prices at the bar (well, quite normal compared to Dublin – 2-3 EUR for a tea, 4-5 EUR for a coffee, 5-6 EURs for a pint of Guiness, you get the idea)

* seats – people standing around; though there were theoretically enough seats, de facto about a dozen or more people have been standing around all the time, which felt weird to me, even though I managed to get a seat somehow during the whole conference.

* no sockets – If you were lucky enough to sit close to one of the few (ok, make it a dozen – for 400 ppl!) sockets in the wall, you could recharge your laptop. Otherwise, you have been out of luck.

* a huge rush – I had the feeling that the organizers wanted to pack as much action into one day as possible, which theoretically sounds great, but IMHO it didn’t work out that well in the practice; I missed the beginning of two talks and one full talk after the lunch break because the breaks were barely enough to accomplish anything, be it buying snacks/coffee, use the toilet (1 working toilet for hundreds of guys – great idea) or to grab a proper lunch at a restaurant.

* it was overpriced for what we got – (or we got too little for an OK price) – c’mon, 400 people at an average price of 150 EUR, is 60,000 EURos, + sponsors like Sun and Microsoft, and not even a fucking cup of cofee? We organized EuRuKo in Prague last year for 20EUR / dude, had Matz, the creator of Ruby as well as a roster of other Ruby celebrities, conference t-shirts and a slew of other conference souvenirs, industrial strength wifi, catering (several tea/coffe/snack breaks, hot food for lunch) for 2 full days, free coffee and beverages, and even some free beers (cheers for Brightbox) all this in the heart of Prague. I repeat it again – for EUR 20!

* Little room for socialization (both in physical and abstract sense) – no before-event party (e.g. compare it with Scotland on Rails – three weeks to go, but I know about almost all the attendees, when and where are we going for a whisky (pre-, during- and post-conference), who is staying where, arriving when, going for a sightseeing tour with an option to join them etc. All the organizers did to make this happen was they set up a google groups mailing list and a twitter account, updated with great info every now and then, enabling the attendees to augment it with their own stuff (e.g. when are we going to have a boatload of whisky))
OK, this is not entirely an organizational problem, but still, all the conferences I went to so far addressed socialization in some way.

* after-party – Some of the guys were raving about the after-party – well, I think it was poorly organized too. I went there on time, and had no idea where the FOWA-party “crowd” is – I have seen random micro-bunches of probably-FOWA attendees scattered around the huge (otherwise excellent) Dandelion bar. Asked a few of them about the party, they were just as clueless as myself. Ok, so I left to grab something to eat to the nearby TGIF, but the situation got even worse when I came back. The dispersion of probably-FOWA-micro-bunches-or-lone-rangers went up significantly, so after a few minutes of strolling around I left. Maybe I was just unlucky and popped up at times when everybody was at toilet / had a quick smoke outside or whatever, but some more info (an A4 sheet of paper with ‘we are here’ perhaps) wouldn’t hurt.

Wow – re reading what I just wrote makes FOWA Dublin look really bad – but unfortunately I don’t know what should I remove from the above. These little (or sometimes not so little) things really added up, and fscked up the whole atmosphere. A little more organization and polishing would have solved 80% of the problems.

I am going to summarize a few of the talks I enjoyed in a follow-up post – now I am too tired for that – spent 6 extremely exhausting days in Dublin so need to get some sleep first!

]]>
https://rubyrailways.com/?feed=rss2&p=380 13
“I guess Ruby is over: it Was Fun While it Lasted.” https://rubyrailways.com/?p=366 https://rubyrailways.com/?p=366#comments Thu, 05 Mar 2009 00:15:48 +0000 peter https://rubyrailways.com/?p=366 Continue reading ]]> ruby_sad.gifUpdate: As several guys pointed out in the comments, Tim’s remark which basically pulled the trigger was sarcastic – I guess have to re-calibrate my sarcasm meter. So you need to replace “Tim” and whatever he said with a different guy and his random quote. There are plenty of them out there these days, so the choice should be easy :-) .

This rant was in the works for quite some time – I ditched it at least two times already, convincing myself that there is no use to get into language wars and similar nonsense… but people didn’t let the issue go (i.e. that Ruby jumped the shark / it started to suck for some reason etc – most recent example being a tweet by @timbray) so get ready for some grandiose rantbling!

Tim Bray: “I guess Ruby is over…”

Srsly? By what measure? Actually when did it start? Why exactly then? Again, by what measure? What does ‘over’ mean at all? Says who?

I am currently reading “The Black Swan: The Impact of the Highly Improbable” from Nassim Taleb. There is a section describing Tim’s logic perfectly:

“By a mental mechanism I call naive empiricism, we have a natural tendency to look for instances to confirm our story … – these instances are always easy to find. You take past instances that corroborate your theories and treat them as evidence… I can find confirmation for just about anything, the way a skilled London cabbie can find traffic to increase the fare, even on a holiday”

… or the way Tim can find a bogus evidence for Ruby’s alleged decline, whatever that means. I am wondering where have the current “ruby jumped the shark” guys been 3 quarters ago when Ruby books have been on a roller coaster riding up with the speed of light?!?!

Naive empiricism is everywhere

Guess what, I am guilty of naive empiricism too: I wrote an article stating the opposite of Tim’s tweet, based on similar, but opposite O’Reilly data (i.e. Ruby book sales on the rise). Why? Because I have been a Ruby/Rails zealot back then already, that’s why! And I *wanted* to see Ruby on the rise, and did not really care whether my claims were objective (I *wanted* to see that they were objective – meta-naive empiricism FTW!)

Another great example of naive empiricism is the ‘CDBaby: from Rails to PHP‘ vs ‘MuxTape: from PHP to Rails‘ 2-part saga: the funny thing is that both Derek and Luke argue very convincingly and charismatically about the exact different side of the same coin: why the move from framework X to Y has been the best idea since sliced bread, how it saved their ass, pushed productivity to the ends of the earth… arriving at a total opposite conclusion using the same reasoning.

Another bogus reasoning I hear a lot: Python is used in google so it’s > Ruby! Unfortunately enough for the guys treating this fact as a royal flush , Ruby is used in NASA, by some of the smartest folks in Ruby-land. So what?! Does this mean Ruby > Python (or at least is equal to gogle <=> NASA)? Not at all (In my opinion Ruby > Python actually, but 1) this is a personal preference thing 2) it has nothing to do with google vs NASA 3) is a topic of a different rant, which possibly won’t be written as I grew tired of lang wars fought with flame throwers).

Or take github: currently 31% of the code living there is Ruby (and you can’t really argue that by now, github matters – it’s not just a hobby project of 2 guys tired with their original startup any more). So according to this measure, everyone start learning Ruby!

but Tim argues instead:

“…Everyone start learning C#”

This is the second part of @timbray’s rather questionable tweet… and here is why:

Comparing the need for Ruby workforce to the C# one is like comparing the need for planes to that of cars. No correlation.

C# is usually used…

  • for enterprisey stuff
  • to write big, monolithic apps
  • by big teams for long-term projects
  • by BigCO running on a large budget
  • in M$ shops

Ruby/Rails is the total opposite… it’s usually used…

  • for coding quick web apps / internal DSLs / domain specific stuff
  • to craft lean, focused apps, interoperating with each other
  • by small, agile, flexible teams, sometimes lone rangers
  • Usually smaller budget (direct consequence of the first point)
  • in shops with totally different culture compared to that of M$

Both lists could grow unbounded if I cared to come up with more points.

So Tim is essentially saying ‘no need for agile teams cranking out top notch (usually web-based) software fast – everybody jump on the Titanic (the safe 9-5 world of enterprise apps in one of the cubicles of BigCO).
Sorry, but this is utter BS. There will be always a need for lean, agile, quick teams. Following this logic, you should abandon the Python/Django ship too. And btw guess what – the Titanic sunk in the end, no matter how safe it originally was.

So where’s Rails?

It’s not clear to me where is Rails (and a slew of other widely used frameworks/software produced in Ruby) in Tim’s picture. The thing is that Ruby is tied to Rails just like the US economy is tied to just about everyone else’s economy around the world. If Rails prospers, so does Ruby – a kick-ass r41lz h4xx0r is a kick-ass Ruby h4xx0r with knowledge of Rails after all.

However, it looks like there is need for Rails coders: Tom Mornini, one of the founders of Engine Yard, the leading Ruby/Rails hosting states that good Rails developers are very scarce. And while Rails developers will be a scarce commodity, Ruby developers will be too.

Ruby isn’t Fun anymore… wtf?

This is the original part of the rant, from the time when more “ruby/rails sucks” articles popped up in a quick succession, followed by a grandiose trollfest on various social sites, and eventually meta-ranting (my personal favorite).

Apples and Oranges Strike Again

I am a bit confused after reading all this outburst: I seriously think ‘fun’ vs ‘mainstream’, ‘imperfect’ (or even ‘buggy’), ‘slow’ etc. are orthogonal problems. Why should be Ruby less fun than it ever was because now it has more acceptance / users / enterprise penetration and/or it’s slow / 1.9 is not a big deal / it leaks memory (fill in the other pain points from the rants)??! This just doesn’t make any sense. Ruby is fun _and_ it has some problems to address. These two are not contradictory statements at all. It’s immense fun to be with my 2-year old daughter, though she is sometimes hard to handle – so I should say it’s no fun anymore?!?

“Ruby isn’t fun any more *for me*” is a totally different claim from “Ruby isn’t fun any more” (in general). I don’t give a shit if Ruby isn’t fun any more for *you*, but please, don’t describe it as community- or language-wide phenomenon. kthx.

Conclusion

You like python? Great! Putting bread on the table coding in Java? Cool. You’d like to play around with bleeding edge stuff (clojure/scala/erlang etc.)? All the better.

Ruby is slow? The syntax is obscucre? You don’t like Rails/DHH/fanboys/TextMate/Ruby/arrogant douchebags/whatever? Ruby is not fun for you (any more?)
Too bad, so sad – however, this doesn’t alter the fact that Ruby *is* immense fun for me, and a whole community of people, and no ranting will change that, no matter how hard you are trying.

I am not even arguing that Ruby is better than X – I am far beyond that point already (after having my share with some Java vs Ruby flamewars). I am just arguing that people should stop tweeting / blogging about nonsense underpinned with ‘evidence’ just because they want to see the world that way.

]]>
https://rubyrailways.com/?feed=rss2&p=366 11
Advanced Twitter Queries with the Twitter Gem https://rubyrailways.com/?p=360 https://rubyrailways.com/?p=360#comments Thu, 26 Feb 2009 00:56:32 +0000 peter https://rubyrailways.com/?p=360 Continue reading ]]> twitter_post.pngI wanted a reliable way to find out a few things about my twitter account (for example which of the users I am following are not following me back) – unfortunately the third party apps out there are not always very reliable, do not exactly do what I want/as I want so I decided to check out how easy it is to hack up a more advanced query using a Ruby twitter API wrapper. It turned out that it couldn’t be easier!

There are several gems wrapping the Twitter API out there – I started to use the ‘twitter’ gem from John Nunemaker and I am perfectly happy with it so far. John did a great job supporting all the features offered by the API – it’s a different question that the API, like twitter itself, is quite minimalistic. For example I have not found a way to get all my followers/friends easily (drop me a comment if I am missing something) so I monkey-patched this into the module in a generic way:

module Twitter
  class Base
    def all_entries(method, options = {})
      all_entries = []  
      next_100 = self.send method, {:page => (current_page = 1)}.merge(options)
      while (next_100.size != 0) do
        all_entries << next_100
        next_100 = self.send method, {:page => (current_page += 1)}.merge(options)
      end  
      all_entries.flatten
    end
  end
end

for example you can call connection.all\_entries(:friends) to get all of your friends, given that you set up a connection to your account (I found only a method which returns your first 100 friends – didn’t spend too much time with the documentation though – agin, drop me a message if I overlooked something).

I have added a bit of syntactic sugar to be able to call connection.all\_friends instead of connection.all\_entries(:friends):

module Twitter
  class Base
    alias_method :throw_method_missing, :method_missing
    
    def method_missing(method_name, *args, &bloke)
      if (method_name.to_s =~ /^all_.+/)
        all_entries(method_name.to_s[/all_(.+)/,1], args[0] || {})
      else
        throw_method_missing(method_name, *args, &bloke)
      end
    end
  end
end

Here we ensure that only method calls that start with all\_ are handled by all\_entries, the rest is throwing a method\_missing since we are not interested in handling those messages.

Now it could not be easier to implement the function I originally intended to build: list of users who are not following back.

class Array
  def names
    self.map{|u| u.screen_name}
  end
end

module Twitter
  class Base
    def not_following_back
      all_friends.names - all_followers.names
    end
  end
end	

That’s all there’s to it (I am not a big fan of monkey patching core classes btw ; but in this case, adding the names() method to the Array class just made the method I intended to originally implement much cleaner so I rolled with it).
Note that since subtraction is a non-commutative operation, all\_friends.names – all\_followers.names is not necessarily the same as all_followers.names – all_friends.names.
This is how the final code looks like:

require 'rubygems'
require 'twitter'

connection =  Twitter::Base.new('yourname', 'yourpass')

class Array
  def names
    self.map{|u| u.screen_name}
  end
end

module Twitter
  class Base
    alias_method :throw_method_missing, :method_missing
    
    def method_missing(method_name, *args, &bloke)
      if (method_name.to_s =~ /^all_.+/)
        all_entries(method_name.to_s[/all_(.+)/,1], args[0] || {})
      else
        throw_method_missing(method_name, *args, &bloke)
      end
    end
    
    def all_entries(method, options = {})
      all_entries = []  
      next_100 = self.send method, {:page => (current_page = 1)}.merge(options)
      while (next_100.size != 0) do
        all_entries << next_100
        next_100 = self.send method, {:page => (current_page += 1)}.merge(options)
      end  
      all_entries.flatten
    end
    
    def not_following_back
      all_friends.names - all_followers.names
    end
    
  end  
end  

p connection.not_following_back

You can download/check out the code here – do not try to copy & paste it from the text as it will be b0rk3d.

In part 2 I’d like to set up a small Sinatra app showing the above users in a list – displaying their avatar, screen name and real name, plus a link to remove them if you decide so.

]]>
https://rubyrailways.com/?feed=rss2&p=360 26
Ruby’s Most Underused Keyword https://rubyrailways.com/?p=343 https://rubyrailways.com/?p=343#comments Fri, 06 Feb 2009 17:25:00 +0000 peter https://rubyrailways.com/?p=343 Continue reading ]]> redo.pngI spent the first 2+ years in Ruby-land without even knowing about the probably most underused (and underrated) keyword of the language: redo. Even after I came across the first example and liked it immensely, I could not come up with another use for it, so I threw it to the bottom of my toolbox. Then I found another example, and another one – so I came to the conclusion that redo might be a valuable keyword in your Ruby arsenal after all – it is one of those things which you rarely need, but if you need it, it’s a perfect solution which would be cumbersome to replace with other constructs.

Break vs Next vs Redo

I am sure everyone is familiar with redo’s cousins: next and break. While next and break allow you to skip an iteration, resp. skip the rest of the remaining iterations altogether, redo does not skip anything – it ‘restarts’ the same iteration. In other words, while next transfers control to the end of the iteration block, redo ‘jumps’ to the beginning of the block. Let’s see an example, where redo is used to recover from an input error (code from “The Ruby Programming Language”):

puts "Please enter the first word you can think of"
words =%w(apple banana cherry)
response = words.collect do |word|
  print word + "> "
  response = gets.chop
  if response.size == 0
    word.upcase!
    redo
  end
  response
end

The trick is that whenever the user enters an empty string, the block is restarted with redo, asking the same ‘question’ until the user enters something that makes sense to the system.

A Real Example – Tail Recursion

As of now, Ruby does not support tail recursion optimization, so you either have to write the function in a non-recursive (i.e. iterative) way yourself, or suffer the consequences of a full stack… or use redo!

I recently came across Magnus Holm’s article on this problem. Magnus provides an elegant solution using redo:

define_method(:acc) do |i, n, result|
  if i == -1
    result
  else
    i, n, result = i - 1, n + result, n
    redo
  end
end

def fib(i)
  acc(i, 1, 0)
end

Magnus even worked around a redo perk: “The redo statement restarts the current iteration of a loop or iterator”. That means he couldn’t define a method with “def”, since that neither involves a loop nor an iterator. Maybe a less esoteric way relying on the same fact would be to use a lambda:

def fib(i)
  acc = lambda do |i, n, result|
    if i == -1
      result
    else
      i, n, result = i - 1, n + result, n
      redo
    end
  end.call(i, 1, 0)
end

Golf Time

Here is a Ruby golf riddle, which I have no idea how could be made this short (42 characters) without redo (via coderrr):

"Generate a random string of length 4 or more consisting of only the following 
set of characters: a-z, A-Z, 0-9"

Here is the winner, Magnus Holm‘s solution (The name sounds familiar? Right, the previous example was from him too – he understands the power of redo for sure :-) ).

(0..9).map{rand(?z).chr[/[^_\W]/]||redo}*""

The above solution might not be instantly crystal clear – so let’s break it down a bit:

  1. rand(?z) is equivalent to rand(122) (but shaves off a character!)
  2. rand(?z).chr turns the random number into a string (equivalent to its ASCII code, i.e. 65.chr == “A” etc)
  3. the regexp /[^_\W]/ means the negation of ‘everything but underscore or non-word character (digits and numbers). To put it another way, accept word characters but not an underscore. (\w includes underscore, so we need to get rid of that)
  4. rand(?z).chr[/[^_\W]/] acts as an identity function for letters and digits, but returns nil for everything else. So “a”[/[^_\W]/] == “a” but “@”[/[^_\W]/] == nil. “_”[/[^_\W]/] also returns nil.
  5. And now comes the redo trick: rand(?z).chr[/[^_\W]/] || redo will restart the block until a random character/letter is not found! w00t!

While one might argue that golfing examples are contrived by definition, I don’t always agree: the [/[^_\W]/] is a neat trick to get numbers/letters from a string only, as well as the use of redo is valid and non-contrived.

Conclusion

As demonstrated above, redo can be used in a variety of situations to produce an elegant solution that would look much more cumbersome without it. Of course all the usual stuff applies: don’t overuse, abuse etc. etc.

If you have any other interesting cases for redo, leave a comment – I’d love to see some more :-)

]]>
https://rubyrailways.com/?feed=rss2&p=343 44
Ruby Quiz: Gathering Ruby Quiz 2 Data https://rubyrailways.com/?p=337 https://rubyrailways.com/?p=337#comments Sun, 01 Feb 2009 00:08:05 +0000 peter https://rubyrailways.com/?p=337 Continue reading ]]> ruby_quiz.png After running the Ruby Quiz show for almost a year, Mathew Moss, the second Ruby Quiz master had just retired (as a quiz master :-) – great work Matt!), passing the ball to Daniel Moore, who just kicked off the third season with the following problem:

I'm building the new Ruby Quiz website and I need your help...

This week's quiz involves gathering the existing Ruby Quiz 2 data from
the Ruby Quiz website: 

Each quiz entry contains the following information:

 * id
 * title
 * description
 * summary

There are also many quiz solutions that belong to each quiz. The quiz
solutions have the following:

 * quiz_id
 * author
 * ruby_talk_reference
 * text 

For some reason, no one (except me) participated this time – so for the first time in history, I am pretty sure my solution is the best of all! w00t!

Daniel did a really great writeup of my solution (which utilized scRUBYt! and Nokogiri) – check it out here (view the code here), so I am not going to do my own writeup this time.

]]>
https://rubyrailways.com/?feed=rss2&p=337 0
The Top 30 Most Helpful People on #rubyonrails https://rubyrailways.com/?p=334 https://rubyrailways.com/?p=334#comments Wed, 21 Jan 2009 22:58:02 +0000 peter https://rubyrailways.com/?p=334 Continue reading ]]> Just about 2 weeks ago I have been bitching about the #rubyonrails channel (no need to look it up as this article will negate that anyways). Fortunately (for everyone I guess :-) some prominent rails guys came after me, gently kicked my ass and challenged me to check out #rubyonrails again (after leaving a bit pissed off about 2 years ago), claiming that the atmosphere has changed drastically.

So, I took their advice, joined the channel, and was indeed pleasantly surprised. During my 2+ weeks of stay, I can’t remember any incident (ok, except the constant trolling on TextMate vs Vim, Mac vs Linunx, Shoulda vs rSpec, jQuery ftw, how RJS sucks, how Java sucks (well, initiated by me ;-) ) and found most of the people very friendly and helpful. Also made a few friends and had some great fun.

I also discovered some great #rubyonrails stats by @radarlistener and persuaded him to add a little feature to it: display then number of thanks per all messages. It’s not a huge feature, but we can find out some interesting stuff with it – for example, the signal to noise ratio off different guys: which of them are helping out the most on average (we could probably dig out the reverse info too – a.k.a. help vampires, but that’s outside of the scope of this post).

So, without further ado, here is a top 30 list (the number behind the nick denotes “lines per thanks”, i.e. how much lines the given person had to enter to receive a “thank you”):

  1. pet3r: 69
  2. stympy: 70
  3. octopod: 83
  4. mikeg1a: 90
  5. mf_irc: 97
  6. koppen: 105
  7. noodl: 120
  8. eljo: 120
  9. topfunky: 126
  10. leeo: 128
  11. fcheung: 129
  12. chippy: 137
  13. rainmkr: 138
  14. gerhardlazu: 139
  15. blj: 142
  16. madrobby: 142
  17. darix: 154
  18. toretore: 158
  19. minam: 162
  20. thread: 162
  21. donomo: 166
  22. halorgium: 168
  23. sonofslim: 169
  24. don-o: 170
  25. claudio: 176
  26. melvinram: 180
  27. bitsweat: 180
  28. ddfreyne: 181
  29. archetypo: 183
  30. jacobat: 185

Hey where’s lifo and rsl? Wtf?!!11!1! My script must be buggy… need to spend more time on #rubyonrails to learn this Ruby thingy properly.

Thanks to @radarlistener for his great work on the stats, as well as other great #rubyonrails bots.

]]>
https://rubyrailways.com/?feed=rss2&p=334 4