Archive for the ‘Ruby’ Category

RubyConf Australia

October 12, 2013

RubyConf Australia 2014

RubyConf Australia 2014 will be Australia’s second Ruby conference. It will be held in Sydney in Luna Park, an amusement park. The workshops will be on February 19, and the talks will be on February 20 and 21.

About Australia

Australia has an active Ruby community, because many programmers are able to use Ruby on Rails at work. We have Ruby meetup groups in many cities in Australia.

We also hold an event every six months called “Rails Camp”. Rubyists from all around Australia go to a retreat. We have no internet access, just a wi-fi network. We do hacking, and give talks, and play games such as werewolf (Japanese link: 汝は人狼なりや?). And we drink! At the end of Rails Camp, there is a session where many people give lightning talks on what they worked on at the camp, no matter how beginner or advanced the project is. The first one was held in June 2007, and the fourteenth Rails Camp will be held in November.

Australia has an international-minded Ruby community. Many people in the Australian Ruby community are from overseas, and some Australians have moved overseas for work. We also attend overseas conferences, including Red Dot Ruby Conf and RubyKaigi. I’ve been to RubyKaigi  2011, Sapporo RubyKaigi, RubyKaigi 2013, and plan to go to RubyConf Taiwan next year.

Australia is regarded as a slightly expensive destination, but it’s possible to reduce your expenses by choosing less expensive accommodation and restaurants.

Workshops

RubyConf Australia 2013’s workshops were on the day before the talks, and the same will happen in 2014. There were five different workshops available. “Advanced Ruby” by Dave Thomas, “Code Retreat” by Corey Haines, “JRuby” by Hiro Asari and Charles Nutter, “Rails4iOS” by Lori M Olson and Tim Breitkreutz, and “Rails Girls” by Robert Postill, Kai Lemmetty, and Susan Jones. I attended the JRuby one, and found it an excellent experience. Charles and Hiro were really helpful, and I learnt a lot.

Keynote talks

There were four keynote talks given in 2013. The first was by Corey Haines, the co-founder of Code Retreat. He promoted the idea of #EmuMarch, in which you *emu*late someone you admire during the month of *March*. (His slides also had pictures of emus in them) At the end of the first day of talks, the internationally famous Aaron “Tenderlove” Patterson gave an amusing but useful keynote.

For the start of the second day of talks, the keynote was given by Australian Rubyist Mikel Lindsaar. He talked about how Ruby and Rails can and will succeed in the future and your right as an employee to deliver value. Before attending this talk, I wondered “If Ruby makes programmers happy, what language makes bosses happy?”. Because of that talk, I realized that Ruby is the language that makes bosses happy.

The closing keynote was “The Ruby Language”, by Dave Thomas. I learnt from the talk that the Himba people in Namibia have a completely different way of describing colours than English-speakers or Japanese-speakers have. Because they describe colours in a different way, they can distinguish colours that look identical to me, but can’t distinguish colours that appear completely different to me.

Other talks

The talks in 2013 were diverse and enlightening. They were given by both international and local speakers. Some of the most esoteric talks were “Sinatra in SIX lines – How to do crazy stuff with Ruby” by Konstantin Haase, and “Hacking with Gems” by Benjamin Smith, which talked about security exploits that can be put into Ruby gems. Meanwhile, Carina C. Zona’s talk “Schemas for the Real World” made us question what assumptions are made by social networking sites about people’s identities.

Less esoteric, but equally enlightening, talks were given about topics such as immutability, concurrency, and performance.

Social Activities and Touring

Social activities were held on the night after the workshop, and on each of the nights of the conference. However, on one of the nights I chose instead to have dinner with a few attendees at one of the many ethnic restaurants available near the venue.

On the day after the conference, I happened to spot a Rubyist showing other Rubyists around the city. I joined the group, and we saw various sights.

__goto__ :rubyconf_au_2014

“Egg” (pre early-bird) tickets are available until October 28. Other tickets will be available afterwards, but with less of a discount. Scholarships to attend the event are also available.

The Call For Proposals is open until October 31. Proposals will be made by Github pull requests, which was inspired by Sapporo RubyKaigi.

The official site is http://www.rubyconf.org.au/ . For updates, follow us on twitter at @rubyconf_au, or subscribe to our mailing list.

To find out more about 2013’s conference, watch the videos on Vimeo, check out Eventifier, or visit the Lanyrd site for 2013.

We hope to see you there!

Japan.binders.full?(&:women) => true

November 26, 2012

(For Japanese readers: Not familiar with “Binders full of women?” Click here)

Once upon a time, I wondered if it was inevitable that programmers were predominantly male. Visiting another country disabused me of that notion. Surprisingly enough to me, that country was Japan.

Before visiting Japan for RubyKaigi 2011, I had the perception that while Japan was a technologically advanced country, it still remained socially very conservative, and that sexism existed to a much larger extent than in western countries such as Australia, the UK and the US.

In defiance of my expectations, I found that there were many women speaking at RubyKaigi, and also involved in the organization of the event. When I dropped in on ordinary meetup groups during subsequent visits to Japan, such as Ruby Sapporo and Minami.rb, I also noticed a high proportion of female attendees.

How could I explain this?

One possibility is that my perceptions of Japan were wrong. That would be interesting in and of itself.

But there’s an even more interesting possibility. What if sexism existed in the general Japanese community, but the Japanese Ruby community decided to behave differently? That we can decide what our community is like?

I have found the Japanese Rubyist community to be diverse in other ways as well.

I’ve found the Japanese Ruby community to be diverse in what programming languages they know. For example, when I showed off the [“1”, “2”, “3”].map(&method(:Integer)) trick to a Ruby meetup group, one of the attendees remarked that there’s something like that in Haskell.

In one way, this diversity is forced upon them – many of them don’t use Ruby in their day jobs. Instead, they use Ruby in their spare time. But I doubt that they’re using Haskell in their day jobs, either.

The Japanese Ruby community is making a strong effort to interact with western countries conference-wise. Virtually every piece of information about international RubyKaigis is posted in English as well as in Japanese. Talks at RubyKaigis are translated live from Japanese into English, and vice versa.

In RubyKaigi 2011, attendees were given conversation sheets, with a list of phrases they could say in English and Japanese. There were also anti-bocchi boards, which organized lunch between strangers. I took advantage of this to have lunch with Japanese Rubyists, and was often the last to finish lunch because I was talking so much with them.

At Sapporo RubyKaigi, the organizers accepted my proposal, which was about the Japanese language. The aim of that talk was to encourage other people to learn Japanese. In the same session as my talk was Yoko Harada’s talk “Why Don’t You Go To Conferences In US?” Harada also organized try(:english), an event where Japanese Rubyists practiced English with native speakers.

To be honest, there have been challenges. Some Rubyists I’ve talked to say that they’d like to come to Australia, but that it’s too expensive. Others have laughed when I suggested that they come to RubyConf Australia – not at me, but at themselves, because they feel that their English is too bad (a lot better than my Japanese, let me tell you!).

One regret I have is that not many Japanese Rubyists go to nearby asian countries, and not many people from Japan’s neighbours come to RubyKaigi.

I’m thinking TJRCINSWAN: The Japanese Ruby Community Is Nice, So We Are Nice!

In Ruby, &method passes you!

October 3, 2011

Most Rubyists would know what the following does.

[1, 2, 3].map(&:to_s)

It takes the array of numbers, calls to_s on each item, and returns an array of the return values.

But what if you want to do the opposite? Rather than calling a method on the object, what if you want to call a method with the object as a parameter? Simple!

["1", "2", "3"].map(&method(:Integer))

Wait … what?

I’m sure you all understand how it works, because you already use map(&:to_s), and none of you would use something you don’t understand, right?

Who am I kidding?

I’ll explain how map(&:method_name) works, and then how map(&method(:method_name)) works.

When you use & (ampersand) in front of the last variable in a method call, you’re saying that what’s passed in shouldn’t be treated as an object, but treated like a piece of code – a proc.

Symbols aren’t procs, but they can be converted into them by Ruby. You can see for yourself by running to_proc and call on it with the following:
# my_proc will be something like #<Proc:0x00000001014c39c8@(irb):35>
my_proc = :reverse.to_proc
# This causes "abc".reverse to be called, which returns "cba"
my_proc.call("abc")

As Ruby calls `to_proc` if an ampersand parameter isn’t a proc, the following

def call_me_three_times(parameter_1)
  puts((yield parameter_1).inspect)
  puts((yield parameter_1).inspect)
  puts((yield parameter_1).inspect)
end

call_me_three_times("abc", &:reverse)

will print the string reversed three times.

Now that the & part is understood, let’s look at the method part.

When you call method(:method_name), you get back an object of class Method that represents the method.
# Integer(string) is a method kind of like String#to_i, but 100% more awesome.
# Look it up if you haven't done so already.
# PS: don't worry about it starting with a capital letter!
# another_proc will look like #<Method: Object(Kernel)#Integer>
another_proc = method(:Integer)
another_proc.call("42") # Returns 42

and as `Method#to_proc` exists, the `call_me_three_times` method will convert the method object into a proc and will run it without any complaints.

When you run `call_me_three_times("42", &another_proc)`, it’ll print 42 (not “42”) three times.

But wait … there’s more!

The method doesn’t even have to be from your own object – it can be something else’s. For example, if you wanted to read in a series of files, you could do

filenames = ["a.txt", "b.txt", "c.txt"]
texts = filenames.map(&File.method(:read))

File.method(:read) turns the read singleton method of the File class into an object, and then (with the help of Method#to_proc) that object gets passed to map as something that should be executed on each filename.

Downsides

Firstly, you may need to document what &method does. I’ve been programming in Ruby for over three years, and hadn’t come across this trick until I noticed it on Stack Overflow. However, it is mentioned in the Pickaxe, now that I looked it up.

Second, there may be performance penalties for this approach. If hardly anybody has used this approach, it’s unlikely to have been optimized.

Third, making code shorter isn’t always a good thing. It may make smelly code seem less smelly. If you’re doing twenty different things on one line, the answer isn’t to cram things up to make the line shorter, but to refactor that line into something more logical.

Fourth, I haven’t worked out how to abuse this trick fully. Under Ruby 1.9, if foo takes two arguments, I don’t know how to do [["a", "b"], ["c", "d"]].map(&method(:foo)) yet. That code works under 1.8, however.

(Apologies for the awful appearance of the code – I haven’t worked out how to make wordpress use Github gists without adding a plugin)