Programming ≈ Fun

Why Reddit Is Not Worth It?

This article will sum up my experiences with reddit and why I think it is not worth it to bother with. It all started this summer. Somebody has putted me on a HN and I went front page.

7k visitors was more that my tender brain could comprehend :)
I didn’t know it right away but in hindsight that put a “link-aggregate” bug in my brain. I am a long time occasional reddit reader. I know you are not exactly supposed to put you own stuff up there, but hey it’s not like it is really spamming. There is down vote button on the article so if it’s a dumb one it will get buried in 5 minutes. No harm done. Right?

It’s easy to say ‘don’t put your own stuff’. BUT when you have zero readers (like me) it’s easier said than done.

Ruby Oddities

Over the course of time I’ve noticed three peculiar Ruby behaviours. I am not saying these things are good or bad. They are a bit odd/unexpected, mostly neat and always good to know.

I Would Love to See This in Ruby

| Comments

I like small methods. Small methods make comments unnecessary and allow me to describe algorithms in a way I will understand in couple of months when bug strikes. They allow me to develop domain and talk about domain in the code. There is just one thing bothering me:

The excessive presence of end keyword.
This is particularly bothersome for small methods.

Refactoring Exercise

I’ve just read an excellent article about refactoring rcat in Rubies in the Rough. If you are not subscribed you should be… I couldn’t resist to take a swing at it and refactor Display class since thats where most of the action is happening. In one line rcat is supposed to behave as Unix cat command for some basic cases.

Geek…No More!

Majority of people I know of that are great with computers tend to be not so great at sports. In tender years of their youth they are usually picked up the last for all sorts of sports activities. I believe this actually helps their computer skills as they get to spend more time with computer. After all everybody likes doing what he is good at. I’ve noticed couple of distinct phases.

Grokking the Ruby Blocks in 10 Minutes

I am assuming you are intrigued about Ruby blocks. My assumption is that you are aware that they exist but unsure of what they are or how to use them. From my experience main obstacle in understanding them is introduction of multiple concepts all at once. You need to understand closures and procs to understand blocks. Also Ruby mix-up with lambda vs. proc debate is not helpful either. There are some great posts about the subject. For example Understanding Ruby Blocks Procs and Lambdas.

Nightmare at 20,000 Feet
Nightmare at 20,000 Feet via Wikipedia

I am going to bluntly ignore the details and just give the 20,000 feet look at it.

Block in Ruby is just another type of variable.

Memorize the Concepts Not the APIs

| Comments

I was always ashamed of not being able to bang out code without looking at the documentation. One example was file opening/handling in .NET 1.1. I remember not being able to do it even if my life would depend on it. Later on I’ve read that Microsoft made the study about APIs usability. One of the APIs that missed the mark was the IO.

The main complaint was that you need way too many lines of code for basic scenarios.
The other complaint was that you need the knowledge of rather abstract (from the usage point of view) inheritance tree. That was a bit of relief. I stopped feeling as such an imposter that was getting payed for doing nothing. Still I regarded this as my flaw and was always irritated when unable to do simple stuff because I forgot API details.

Similarly, after finding out about Ruby I was amazed that alpha geeks figured it out five years before me. When I think about it more carefully, it would not be logical any other way. I speculate that they were able to position Ruby as a Smalltalk derivate that has some Perl syntax sugar and some Lisp functional goodness. That enabled them to label/recognize the whole technology relatively fast and easy.

Breaking the Rules

| Comments

Yesterday I’ve subscribed to Rubies in the Rough from James Edward Gray II and read his article “Doing it Wrong”.

In his article he questions (along with some other rules) the rule of never using regular expression for xml parsing.

As it turned out it was a fortunate move since six dollars and one day latter I came across .xml that needed to be parsed.

I have a confession to make: I’ve always hated xml parsers. This particular .xml did not even use xml strengths; data inside was all messed up:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Exchage rates list</title>
<link>http://*******</link><description>Excange rates list 12/13/2011</description><item>
      <guid isPermaLink="false">code: 978</guid>
      <title>EMU (EUR)</title>
      <description>
          Unit: 1<br />
          Buying: 1.95583  <br />
          Medium: 1.95583  <br />
          Selling: 1.95583 <br />
      </description>

  </item>   <item>
      <guid isPermaLink="false">code: 36</guid>
      <title>Australia (AUD)</title>
      <description>
          Unit: 1<br />
          Buying: 1.488813<br />
      ...

Small Sample of Ruby Elegance

| Comments

If you don’t know Ruby please take a few moments and look at code below. You may like it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
w = %w[a c d b e] # same as w = ["a", "c", "d", "b", "e"]
w.sort #=> ["a", "b", "c", "d", "e"]
w.sort.reverse #=> ["e", "d", "c", "b", "a"]
w.sort { |a,b| b<=>a } #=> ["e", "d", "c", "b", "a"]

w.reduce(:+) #=> "acdbe"
w.map(&:upcase) #=> ["A", "C", "D", "B", "E"]

w.include? "a" #=> true

(1..8).select(&:even?) #=> [2, 4, 6, 8]
(1..8).reject(&:even?) #=> [1, 3, 5, 7]

langs = %w[ruby python perl] # same as langs = ["ruby", "python", "perl"]

langs.group_by(&:chr) #=> {"r"=>["ruby"], "p"=>["python", "perl"]}
langs.map(&:capitalize) #=> ["Ruby", "Python", "Perl"]

As they say:

The beauty of Ruby is found in its balance between simplicity and power.

If after this your mouth is watering, you can try Ruby online.

Quality Is Overrated

| Comments

I’ve been a TDD zealot for the last 7-8 years. I take pride in my code being well tested, my solutions being user friendly and my design being test driven.

When I test I know my system works. I sleep like a baby. I have a balls of brass. I can embrace change and laugh at how easy it is to add new requirements.

The thing is, in my life I’ve seen a fair amount of big systems that are terrible. They all have one thing in common. Everybody hates them. Programmers, users… but they do work, sort of. They are slow and buggy but nevertheless they deliver some value to the users.

Enterprise is euphemism for lame systems that barely work for 300 users?

Oddly, in many of those terrible systems funny thing happened. After a while guess what? People involved (users and programmers) made those terrible systems work (just enough) and all of a sudden you have a winner. Bigger the system, bigger the win. Bigger the mess, bigger the ecosystem of additional companies making it all work.

Think Windows & antivirus for example.

I wonder how smug IBM felt when developing OS/2 with all the cool stuff…and than a big nothing happened. Right now you might be thinking that I’ve lost it. You are ready to click away… but let see some examples: