#52WeeksOfCode Week 5 – Ruby

Week: 5

Language: Ruby

IDE(s): Komodo Edit


“I hope to see Ruby help every programmer in the world to be productive, and to enjoy programming, and to be happy. That is the primary purpose of Ruby language.”

Yukihiro Matsumoto, the creator of Ruby, Google Tech Talk, 2008

““Anyone who has ever seen a programmer at work—any wife or husband of a programmer who has ever tried to interrupt a terminal session or a conference over a bug—knows that programming itself, if the programmer is given a chance to do it his way, is the biggest motivation in programming. ”

Excerpt From: Gerald M. Weinberg. “The Psychology of Computer Programming: Silver Anniversary eBook Edition.” iBooks. https://itun.es/us/H5erA.l

“The average person can’t see what makes code elegant or unorganized. In addition, our industry is very new. While humans have been cooking, making music, and building for thousands of years, archaeologists have yet to discover those cave paintings of Man at His Desk Typing.

So, metaphor has to become our meta-language. Not only is it how we connect the uniqueness of programming to the general public, but it’s often how we make decisions on how we approach our own software problems.”

Excerpt From: Ka Wai Cheung. “The Developer’s Code” iBooks. https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewBook?id=7687021FDF079E4460BC1CBEAA74BC02

There is a perception among non-technical folk that technical objects such as software, smartphones, computers and so forth are creations of pure logical mind, unsullied by subjective emotion, something something pure wind-swept mountains of something something intellect.


Okay, you know how when your boss says something so wrong that you feel obligated to correct them, even though this person may hold your career, your very life in their hands? How do you tell them? Rather than just straight out confront them with their wrongness, the best strategy is to simply say, “Well, that turns out not to be the case.”

Anyway, back at the pure wind-swept mountains of something something intellect….

Well, that turns out not to be the case.

Every creative person views the world as being filled with holes. When you willfully create something, you do so in order to fill one or more of those perceived holes. In short, whatever you create has to fit one of those holes and gets you one step further to completing your vision of the world according to you.

What I’m getting it is that technical innovations are as much a product of our psychology as they are of math and engineering. In fact, I would argue that many are primarily psychologically rooted in their creators, with just enough math and engineering for them to actually function out here in the real world.

Ruby is a good example. Its creator, Yukihiro Matsumoto, states:

“…there are two ways to look at a language. One way is by looking at what can be done with that language. The other is by looking at how we feel using that language—how we feel while programming…Instead of emphasizing the what, I want to emphasize the how part: how we feel while programming. That’s Ruby’s main difference from other language designs. I emphasize the feeling, in particular, how I feel using Ruby.” [Emphasis mine.]

(Venners, B. (n.d.). Retrieved from http://www.artima.com/intv/ruby.html)

Matsumoto, a.k.a. Matz, is a professional programmer and is comfortable with any number of programming languages but he saw a Ruby-shaped hole in the world.

This week’s code sample is a very simple client and server pair. The server program (Hello_World.srv.rb) opens up a network connection and waits:

macpro15:Week 5 tsinclair$ ./Hello_World_srv.rb

When the client (Hello_World_clt.rb) starts up, it connects to the server.

The server announces the connection, sends the greeting

macpro15:Week 5 tsinclair$ ./Hello_World_srv.rb
Client has connected!
Sending greeting....

and the client prints out the greeting from the server and disconnects:

macpro15:Week 5 tsinclair$ ./Hello_World_clt.rb
You are connecting from:
Hello World!
Closing the connection. Bye!

The sample code for the server is here and the code for the client is here. They are both pretty simple but as I’ve pointed out previously, the code isn’t the point of these weekly posts. However, this is the first network programming I’ve done and it’s primarily due to the ease of writing network-aware code in Ruby that I chose to do so.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s