Category Archives: random thoughts

One year with Scala

This is gonna be rambling personal experience. You have been warned.

A year ago I took a break from my work at Inviqa to learn Scala and functional programming. This has been a great decision, a most successful endeavour, and an amazing learning experience.

I’ve been stuck with PHP for a long time. Mind, at Inviqa we were doing as good PHP as one can. I learned lots about software engineering from a multitude of conference speakers and industry leaders. This was further helped by a very active learning & development department and a generous conference/learning budget. Still, it was PHP. The language sucks.

Learning Scala as a “better Java” kind of language was easy. Case classes, options, lots of easy wins. Learning functional programming… well, I’ve been reading the awesome Functional Programming in Scala book, and I’m still reading it one year later. Despite its hands-on approach and lots of hand-holding, it’s not easy for me to digest. Functional programming is hard.

I used to really like Python. I wrote about 50 lines of Python recently, and just couldn’t believe how difficult it was. One needs to explicitly write return to return values. When just trying things out, you don’t get quick feedback from the compiler. Either write tests or run your code – the former seemed like overdoing it for such a short program, the latter was tedious. Working with the collections was a pain.

Let’s have a look at an example. What we want to do: split a string on commas, then strip whitespace from each element.

In Python:

map(lambda i: i.strip(), re.split(',', string))

In Scala:

string.split(",").map(_.trim)

The relative conciseness of Scala is nice, sure, but the Scala code basically follows the instructions: take a string, split on a comma, trim whitespace. Python is completely cryptic in comparison.

The main drawback of Scala is not the language but the ecosystem. SBT (Scala Build Tool) is powerful but often times incomprehensible. The compilation can be slow at times. Scala’s Play Framework is not nearly as polished as PHP’s Symfony. Replacing any piece of Symfony is just a dependency injection away. Replacing a component of Play is bordering on impossible, everything depends on everything and is mostly hardcoded. I wanted to do a really simple one-line change in Play Framework routing but had to give up.

Inviqa didn’t have as much interest in Scala as I hoped, so regrettably, I stopped working for them. Now I’m part of KwiqJobs (soon to be Swarms Technologies), an amazing startup. We turn people’s waiting time into a new resource for companies. Our tech team works remotely and we meet about once a month for a week. It’s lots of fun! Also we’re hiring! :)

How I didn’t stop eating food

I’ve recently read How I Stopped Eating Food and think the author is nuts. Rob claims his wonder-potion helped him clear his to-do list and got him rid of his coffee addiction. While his approach is questionable, I’ve long shared many of his goals, such as a healthy and balanced diet, while not wasting time preparing food.

Here are some dishes I’ve been cooking lately:

  • First my absolute favorite: fast, clean and super-healthy. Take broccoli/cauliflower/spinach/green beans/other vegetable. Wash, cut up in a couple of pieces, put in a plastic box, add a bit of water, and microwave between one and three minutes. Steamed vegetables retain both their taste and vitamins. Meanwhile, grate some cheese to sprinkle on top and wash side-dish tomatoes/paprika/carrots/other vegetables. Add a bit of pepper and pour olive oil over it all. Voila, that took about 7 minutes, dirty dishes amount to one plastic box and the grater.
  • Preheat oven. Wrap fish in aluminium foil and put it in the oven. Go read a book for 10 minutes. Wash side-dish vegetables and perhaps cut a slice of bread. No dirty dishes.
  • Scrambled eggs are pushing it, preparation takes like 15 minutes and there’s the dirty pan left afterwards. But sometimes I still enjoy them.

I eat tomatoes and paprika with almost every meal. For meals without much protein, I add few slices of dead animals. If the dish doesn’t have enough fat, I add generous amount of olives and snack nuts afterwards. Oh and I’ve just discovered avocados!

Breakfast is my guilty pleasure, oats (+ banana and nuts) with yogurt, often times of Greek variety, with 15 grams of saturated fat per half-a-cup, instantly getting to 75% of maximum recommended daily saturated fat intake. Oh well.

Chairs

I’ve been undergoing torture all my life. These devices of the devil bend my body 90° at the waist, and then again 90° at the knees. Halfway between bent and straight. I can hardly imagine anything less comfortable.

I’d be happy if the chair-angles were either bigger or smaller. Kneeling chairs are nice, as the body/thighs angle is about 110°, which “reduces lower back strain by promoting proper spinal alignment”. Zafu is cool, because you can sit on it in many different ways, according to your current mood. Bean bags are comfortable, they adjust their shape to your shape. Sitting on the floor leaning against a wall with legs stretched out and a small pillow under your back is almost as good as sitting on a bed of leaves leaning against an oak.

But Aeron? No thank you.

Déjà vu explained

So, Wikipedia says:

The psychologist Edward B. Titchener in his book A Textbook of Psychology (1928), wrote that déjà vu is caused by a person getting a brief glimpse of an object or situation prior to full conscious perception, resulting in a false sense of familiarity. The explanation that has mostly been accepted of déjà vu is not that it is an act of “precognition” or “prophecy”, but rather that it is an anomaly of memory, giving the false impression that an experience is “being recalled”.

What a load of bollocks. Here’s the real deal:

When you experience a déjà vu, it had already happened to you. Your experiences are fully controlled by your mind — you do not perceive some objective reality but your subjective one.

Subjective reality means you can experience different situations in a very similar way, when they put you in the same emotional state. More scientifically, the same partial chain of neurons in your brain fires in the same sequence. That’s why you remember it, that’s why you sense a déjà vu — it had already happened to you.

From the half-assed-guesses-I-am-absolutely-convinced-about department.

One week in Sheffield

  • Almost got run over dozen of times. Surprisingly, on a bike it’s easier to keep left.
  • Stores are open (convenient; I’ve lived in a country where stores are closed).
  • In Sainsbury’s, everything is either discounted or 3 for the price of 2. You think people would see right through that, but I still get excited when whatever I want to buy turns out to be discounted.
  • Show me a white person in Sheffield and I’ll show you two Asians.
  • Local “pale ale” is actually very tasty.
  • Female cashiers twice your age call you “my love”.
  • Yesterday at a concert I met a guy from South England who couldn’t understand the Sheffield accent either.
  • Cheddar.
  • Hot girls are usually Asian. Or Spanish exchange students.
  • Full English breakfast is not bad. Though the beans take time getting used to.
  • Sheffield is hilly. Even though five speeds are all I need on my bike, sometimes I can’t help but secretly wish for a lower speed.
  • Ordered spicy pork noodle soup in an Asian place. It was the spicy-in, spicy-out kind.
  • There’s no light in my hotel bathroom but the pub downstairs is way cool.
  • Museums and galleries are plentiful and free.
  • Had to pack and move all my things three times in one week. Bought a pull-up bar and a bicycle to make the process more challenging.
  • Got called up on stage at a local theater play. Scared me so much that when asked where I was from, answered Argentina.
  • Peak district is awesome.

Future of employment

There’s been a lot of uproar about unemployment rates. US unemployment recently climbed up to 10%, Spain has soared up to 23%, et cetera. But we ain’t seen nothing yet.

During the industrial revolution at the end of 19th century, machines have taken significant portion of low-skilled jobs and forced millions of workers into unemployment. And they’ll do it again.

I’ve recently taken an online introduction to AI course. It was a lot of fun, and reminded me how fast and in how different areas have computers – or smart programs, rather – been taking over humans in their abilities. In chess, computers won against humans in 1997. You may have noticed there haven’t been many publicized chess matches between computers and humans recently – I’ll leave it up to you to guess why.

Drivers will be among the first to go. It started with driverless trains, and will shortly continue with self-driving cars. The computer never falls asleep behind the wheel, is able and willing to work 24 hours a day, and is overall far more reliable than your average lorry driver. Truck drivers, wave bye-bye to your jobs.

Next in line are the translators. Have you noticed how much google translate has improved lately? I remember it being near unusable just a couple years ago. These days, not only has it started following grammar rules and increased its accuracy, it can also translate between almost any two languages. Human translators are expensive, make mistakes, and their translations are terribly inconsistent. Translators of prose and poetry should stay unaffected, but legal, technical, and computer game translators will either end up assisting the computer, or will have to find a new line of work.

In related news, armies of expensive lawyers are replaced by cheaper software.

If your job consists mainly of talking to people, you’re pretty safe. Does your job require significant creativity? You should be mostly safe for the time being – computers are notoriously bad at creativity despite repeated attempts by very smart people. However, if your job looks like something that could be potentially replaced by a computer some time in the future, it will be replaced within 20 years – please take a thorough look and reconsider your career path.

For the time being, as long as human civilization thrives, I feel reasonably safe about my job prospects: there will always be need for people who can talk to computers. But I’d also like to capitalize on my conviction that the employment crisis is nowhere near its end. How can I do that?

Daylight Saving Time

The European one. It’s wrong.

Central European Summer Time starts on last Sunday of March and ends on last Sunday of October. I never paid much attention to it, but always assumed that the start and end of daylight saving time is somehow related to equinox.

Now I found out the longest night of the year happens two months after switching to winter time and three months before switching back to summer time. Why?

To correct the assymetry, I demand for CEST to start one month earlier, on last Sunday of February. I’d been planning to visit Brussels anyway.

PS: Infographics are cool. This post was an excuse to try creating one myself.

Exposure bracketing

I have an old Canon 20D. I’m pretty happy with it, the large pixels behave well in low light conditions and it’s got reasonably comfortable handling. There’s just one thing that’s been really bothering me, and as far as I know, all the other cameras suck just as much as mine.

Exposure bracketing was implemented by someone who hates HDR, photographers, and humanity altogether.

I use continuous shooting mode (hold the button down and the camera keeps shooting as fast as it can until it chokes). First, I have to press the button and hold it for exactly the right amount of time to get three pictures. In the beginning, it used to give me a headache, but after some time I got used to it. It’s stil an inconvenience, but a rather minor issue.

There’s something I don’t get at all: Why do I even have to shoot more pictures to get more dynamic range?

If the wonderful RAW format had for example 32bit depth instead of 12 or 14, we wouldn’t need bracketing at all! You would just take the longest of the exposures, and the camera could record all the data without overblowing the highlights. Or, if that is too much hassle, it could make 3 “virtual” RAW files — by simply taking a snapshot of the sensor’s state at three different times during the single exposure.

Given the amazing feedback I’ve been getting here lately, I don’t expect an answer. But I do wonder — is there anything in the way? Or are camera manufacturers incompetent?

PS: Yes, HDR is an instrument of the devil. If you look at my recent pictures, you might see that I realized that aready. But sometimes, sometimes I like to go to the dark side…

Double elimination tournaments

Let me start by saying that I really like the concept of a double elimination tournament. So I might be biased in my analysis.

Second, this post deals specifically with potential use of double elimination tournaments in settings of EGC/LSG side event.

What is wrong with the current approach

Current approach has two separate parts — qualification and finals. Qualification consists of several groups playing round robin system (8 groups of 6 people). First two of each group get to the finals, which is a simple single elimination (16 players in our study case). The total number of rounds is 5 + 4.

There are several related problems which stem from this concept. First, not all games are important. Some people leave halfway during the eliminations or just decide to resign the remaining games, as they have no chance of advancing to the finals anymore. This can influence who advances to the finals and has a negative impact on the tournament atmosphere. Second, the final only determines the winner reliably. Plus it just sucks that by blundering once, you get eliminated.

Why double elimination

Double elimination eliminates the unnecessary games. Every game matters. If someone decides not to participate anymore, his opponent gets a free win, but it doesn’t harm anyone but the one who quit.

You are free to lose any single game and can still win the tournament.

Double elimination is also much more accurate in determining the second to fourth places, which are available without any extra playoffs, with single playoff necessary to determine fifth and sixth place.

So where’s the catch?

Perhaps the biggest disadvantage is that double elimination of (up to) 64 players takes 12 rounds. That is considerably more than 9, and so the necessary extra time needs to be reserved. The reward is elimination of redundant games and much fairer results.

Another disadvantage might be that quarter of the participants only get to play two games. On the other hand, they can go to the beach and have fun instead of having to play.

Conclusion

Double elimination is particularly suitable for faster tournaments, where you can finish a round in under half an hour (and the whole 64-player tournament under 6 hours). The slightly asynchronous nature of double elimination allows for certain brackets to develop faster. On the other hand, there can appear bottlenecks when someone doesn’t show up. This can be taken care of by giving a default win to bottlenecker’s opponent, hence speeding up the tournament even more.

I would like to try double elimination for 9×9, 13×13, and blitz tournaments at LSG 2010. I’m all ears for your opinions on this idea.

By the way, have you already registered for LSG 2010?

On decisions

We have freedom and can make a lot of decisions — isn’ it great? On the other hand, we often have to make decisions. I generally don’t like making decisions. Making a decision means that I will most probably regret it sooner or later.

I use a regret-based approach to making decisions. I try to estimate the probability that I’ll regret the decision. Sometimes, that probability is 100% for one option, so the other option wins by default.

About a year ago, in early 2009, I decided to quit my work and explore Poland. I reached that decision by realising that if I don’t do it, I will regret it for sure. My vacation time ended up being almost three times as long as I expected, mostly due to unplanned trip to Korea, which was great. I didn’t really have enough money to go there, but I knew I would definitely regret not going. 2009 has definitely been the best year of my life so far.

I wish I could apply this approach to making decisions more broadly, as it rarely fails. There are decisions for which I am fully aware of the right choice, yet can’t follow through and end up choosing the bad one.