Thoughts on IKM Assessment

Not so long ago I had an occasion to take a test created by IKM. I’m not sure if it’s a very common way to assess programming skills but certainly the process itself looks interesting. Sadly, it seems they don’t have Erlang suite but as I developed a few things in C++ and Java before I learnt Erlang, I thought “why not?” and decided to check how much I have forgotten and how much still lingers in my skull after 2-3 years.

I have to admit – at the beginning I wasn’t sure what to expect. I was told just “IKM”, of what I’ve never heard earlier. I was wondering whether will it be problem solving, knowledge of the language core or some fancy libraries? It turned out it was the second option with a bit of the third one. I was a bit disappointed, since language is a tool (of course it is important to know your tool!) but what use is of a developer who kicks ass in C/Java/Erlang/etc. and is unable to understand the project as a whole or design a simple state machine and is just programming robot?

Anyway, probably problem solving is a difficult class of skills to be judged by computer algorithm. The tests in case of both languages consist of questions checking the understanding of language mechanisms plus some aspects from core libraries like java.io or STL. The libraries were the most difficult part for me, since I always had a problem with remembering all these BufferedFileWriterReaderShredderDiaperChanger classes (e.g. it took me a really long time to remember argument order for lists:foldl/3 :)). There were some tricky questions where I was asked for a predicted result of executing the snippet and there was just one semicolon missing or lack of int in front of function declaration. I especially liked the question aboutΒ finalize method in Java; I still remembered it is not guaranteed for it to be called ever. πŸ™‚ The frustrating one was about diamond inheritance in C++. I’ve used it once about 10 years ago when I was learning C++ and still knew the concept but even with utmost effort I couldn’t recall the correct syntax for it.

The creators of the test algorithm state that the software can adjust questions difficulty so to the assessed folk the questions will always seem challenging but not impossible. I must admit this is true. There were few questions I could answer without hesitation but I also haven’t utterly failed the rest.
I haven’t mentioned it’s a multiple choice test and bad answers lower your final score. This means sometimes it’s just better to skip the question than pick random answers (and so did I in a few cases). Answers are weighted, which means some correct ones are more obvious than others, which means less points for them. The same goes for wrong ones – completely stupid option means a considerable loss of points.

In general, both Java and C++ tests took about 1 hour each and I got about 80% in both. Perhaps for someone it would be a complete failure but given my long break and using mostly Erlang on daily basis, I’m very pleased with such results. I clearly forgot java.io, never learnt STL too well but at least my results on core language mechanisms are more than average.

… and yes, I decided to be fair and didn’t have any handbook on my desk or Google opened on laptop. Most of all, I was curious and eager to try my actual knowledge. I didn’t care about getting 100% result. I even dared to have a beer when I had only a handful of questions left. πŸ™‚

In overall, I consider it a nice experience. I understand, that for an average company it is a good way to judge if the candidate has certain skills without spending a lot of time on “manually” checking everyone. The big mistake that some probably make, is relying only on this tool or treating it as basic sieve. It’s good that final report actually divides the questions in certain classes like “memory management” or “Java IO”, so someone who understands memory management in C++, won’t be at much disadvantage because of poor skill in STL.

… but the best assessmentΒ ever will always be:

‘Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.’

(Ref.: CodingHorror and Imran on Tech)

Advertisements
Posted in Development | Tagged , | 2 Comments

Board generation for CitadErl

When playing Citadel of Blood, it seemed to be quite trivial to just pick random pieces and check if they match existing board. Maybe checking adjacent fields is easy for computer but there are certain conditions where more distant blocks can determine what kinds of corridors should the new piece have. This is a problem to be solved later, for now I decided to stick to (almost) basic pieces generation.

I thought it would be best to avoid completely random generation and checking the new field against conditions. Maybe it is quite unlikely but in theory very specific requirements could lead to very long generation. Taking conditions into consideration at the very beginning leads to a more complicated and maybe less efficient code but the generation time won’t extend significantly. Of course without proper benchmarks it is difficult to tell. πŸ™‚

What generation function needs is a list of limits. For now it is a piece type (corridor/room) and a minimal counts for: any, “wide” and “narrow” passages. Wide passages are ordinary corridors and narrow are doorways usually leading to rooms. If no min. values are specified, any passage (or none) is added in every direction. I know that I have to prevent adding wide passages to rooms. πŸ™‚ If specific passages are defined, they are inserted in random nth free spot in passages list.

Thinking about potential algorithm for limits definition, led me to a conclusion that two conditions will/could be also necessary:

  • Piece must have adjacent/opposite passages of specific/any type
  • Piece musn’t have more than X passages of specific type

Perhaps condition list will grow so much, it will eventually become more efficient to just rely on brute-force generation from certain point?

For a moment I was tempted by complete board generation when the game starts but there is one rule in Citadel of Blood that makes it impossible: “When a piece can be inserted in many ways, it is up to players to choose the rotation they want.” Maybe I described CitadErl as “inspired by Citadel of Blood”, but this is a nice feature to have and by inspiration I rather meant creating a modular server which rules can be later extended or removed at developer’s will.

So, this is some start. What will come next? Well, I intend to improve monster generation (now it’s a bit bugged and incomplete) and dungeon level modifiers. Code should also have function specs included and more comments butI wanted so badly to commit something that works, I forgot about such details this time. πŸ˜‰

I am aware that not much was done since I announced the project but lack of time is quite common in case of hobby projects. 😦

Posted in CitadErl, Erlang | Tagged , , | Leave a comment

Munctional!

I suppose many Erlang users came across this video but I just can’t resist urge to share it. For me, it’s just one of the best Monday-mood-eliminators. Even though it’s Friday, let it help us survive last hours before weekend. πŸ™‚

Posted in Erlang | Tagged , | Leave a comment

Push notifications in Erlang

Until I joined a certain project a few months ago, I wasn’t even aware of push notifications. Since that day I’ve heard phrase “push notifications” so many times, my memory instantly recalls one person who spoke with me about it most and I’m not sure if I feel comfortable seeing the same face in my mind every time I work on this subject but whatever… There are worse things like not being able to rid “Gangnam Style” out of one’s head or experiencing strange pleasure from listening to Nyan Cat for few hours straight.

From what I know, all major mobile OS providers have push notification services. From my point of view, the most significant would be:

  • iOS – Apple Push Notification System
  • Android – Cloud to Device Messaging
  • Blackberry
  • Windows Phone

Without a doubt, Erlang is tied to telecommunications since its birth. It is still true that its being used more and more frequently not only in low-level hardware, but also in e.g. chat servers for mobile applications.

Push notifications are nice invention. They compensate to certain degree two things:

  1. Unreliable mobile network connection (TCP won’t help!)
  2. Application threads frozen when app is in the background

I won’t discuss possible uses for Erlang servers with push notifications, I was rather curious are “pushes” well-supported by some libraries. I was really disappointed when I found out that apparently only a library for APNS exists. Perhaps there are some projects on GitHub but maybe my search skills are not as good as I thought.

Actually, I had an occasion to use this one library. It’s called ex_apns (click!) and is developed by creators of Cowboy server. I must admit I’m pretty happy with its API. Push messages binary formats are not very complicated but sometimes project schedule doesn’t allow experimenting with writing own solution. And of course – reinventing the wheel is good for learning or major refactoring, not for delivering new system as quickly as possible. πŸ™‚

Above statement answers a potential question “Why need libraries, since sending pushes is usually quite simple?”. Yes, it’s simple. PayPal API is also well documented and seems to be not that complicated. This doesn’t change the fact it took me a few long hours to figure out its oddities. These are hours which can be saved for developing main logic, testing, deployment – just making the customer happy.

OK, so we have library for APNS. We still need some for C2DM, Blackberry and Windows Phone. We don’t want to be worse than e.g. PHP, right?

Posted in Erlang | Tagged , | Leave a comment

New = better?

It is almost obvious that “new” not always meets expectations. Some might not agree with me and some might think it is an example discussed so many times, nobody cares already – but I just have to mention Windows Vista. Released 6 years after Windows XP, was especially loathed for its low performance and became usable after serious tweaking.

Fortunately, OTP releases are much more frequent; a few days ago R15B03 version was released. One doesn’t expect major changes from minor release but what about major versions? R13, R14 and R15?

Of course, R15 is most feature-rich, there is no doubt. It’s a shame we had to wait until R15 to get something as basic as line numbers in stacktraces. But has anything changed in terms of performance?

The case I would like to present is Erlang Jabber server. Luckily it can be compiled under R13, R14 and R15 with no changes in the code necessary. What were the results of load tests I conducted?
Well, I was quite surprised. There was no difference in memory usage but let’s say that no change is sometimes a good news. On the other hand, CPU usage was 10% higher in case of R15! I didn’t have time to inspect what could have caused such a difference, but I must admit I’m a bit afraid of R16 release. πŸ™‚

I haven’t done any tests for R13 but I’ve heard from someone else that he could observe the same difference between R13 and R14. In total it gives 20% higher CPU usage in R15 compared to R13.

I just hope this is not a pattern and we don’t get 30% score with R16. Right now, it is difficult to resist a thought, that maybe we should do development and testing (line numbers!) with R15 but deploy our systems on R14? πŸ™‚

EDIT:

Thanks to Henrik, I googled a blog post about this behaviour and also original Rickard Green explanation. It turns out the cause is schedulers working “just in case” before they go to sleep. Fortunately it can be managed with +sbwt switch for erl command.
My apologies, OTP team!

Posted in Erlang | Tagged , , , , | 2 Comments

OTP native SSL implementation performance

It’s no mystery that nobody could feel safe without SSL. Forget about on-line banking, shopping or just e-mail browsing. This technology has implementations in probably every programming language and in spite of performance differences between C, Python, Java, Erlang etc. one could expect that SSL is something so basic, it should be as fast as possible.

Not so long ago I had an occasion to load test an Erlang server which uses C bridge to OpenSSL and its experimental version completely ported to native OTP SSL implementation.
I didn’t expect it to be miraculously faster and less memory-consuming. I just wanted a cleaner version (C port is really messy in this case) with no significant performance degradation.

The reality was brutal. OTP SSL caused server to use ~20% more CPU (~64% opposed to ~46%) and ~14% more memory (~11.2GB opposed to ~12.8GB). This might not seem much but for folks who are particularly sensitive on CPU usage or every wasted GB of RAM, it is a blocker. Well, being of of these maniacs, I dare OTP team:

Can you improve SSL implementation so we can dump all crappy integration with OpenSSL?

Posted in Erlang | Tagged , , , | Leave a comment

Online gaming in Erlang

I love computer games, everyone who knows me is aware of this. Maybe I’m not a gamer with 30-year experience, but at least I do remember playing North vs. South and Mortal Kombat on Amiga with my neighbour. I don’t need to add he kicked my ass, but hey – I was 7 years old kid and he was at least 5 years older than me. I also spent hundreds of hours with my cousin and Tank 1990 in co-op. Later I found out this game running on SNES emulator can help in surviving boring lectures when I went to university.

When I was younger, it didn’t matter what genre was the game I played – NFS, adventure, FIFA (FIFA 98 is still the best one in the series because it allows playing with mouse!) or Baldur’s Gate. As of today, shelf above me is filled almost only with RPGs. One may argue if Mass Effect or Diablo is true RPG but who cares. πŸ˜‰ To be honest, I never liked multiplayer games (except for short period of meeting schoolmates in Internet cafe and spending few hours every day with Counter-Strike) – maybe it’s strange but I like predictability. Every adventure in Baldur’s Gate 2 was more and more interesting when I knew what to expect and could perfect my team + getting my Summoner to 50th lvl. πŸ™‚

Then a beautiful ginger entity appeared in my life and convinced me one day to join her in Polish MMORPG game (Margonem) and I was gone for a week. Over time we tried various other online games, current one is Settlers Online.

Some time ago I thought it would be nice to create own online game and it still exists in very early stage on GitHub and in more advanced form on paper. Now it’s “frozen”.

Maybe we’re (I mean everyone in my flat) not maniacs of board games but it’s common for us to meet in the evening in one room and play Monopoly, Scrabble or Talisman (in Polish: “Magia i Miecz”/”Magic & Sword”). Not so long ago Krzysiek found scanned version of very old game called Citadel of Blood (in Polish: “Labirynt Ε›mierci”/”Labyrinth of Death”). It seems to be simple but has quite interesting mechanics. Since it is over 30 years old, I assumed no one would really care about copyrights and I decided to create a free server (and later also client) implementing this game, which I want to write in Erlang. I don’t think anyone will ever use it for launching MMO game, it’s main purpose is to be a proof of concept and a pure fun for me. πŸ™‚ Project page is here and I hope I will find enough time to keep development going. For now what I have on my HDD is basic board pieces generation, which creates basic fields with monsters included.

And why Erlang? Simply because I work as Erlang developer and I really don’t want return to any other language. I truly believe it has feature and I’d like to combine both things I enjoy: computer games and programming in Erlang. πŸ™‚

Posted in CitadErl, Games | Leave a comment