Sunday 28 October 2018

Sequence performance





I am frequently getting getting warnings like this from Intellij Idea in kotlin projects:






And if you accept the hint, Intellij will change this into


So what Idea recommends is that if you are performing two or more computations on collections, then you should turn the collection into a sequence and do the computations on those.

But...

Is this always true?


Apparently not. When you transform one list into another list, sequence's seem to consistently under-perform the usual List operations.







When is it right?


When at the end you have to get another list, it does not seem to be a great choice But when you do not want to create another list, you just want to get a sum or avg, that is when it seems to perform always better.



And yes in this case, the transformed code does perform better.





So, having no confirmation of the performance improvement, for now I keep ignoring these hints for the most of my code-base.

Saturday 27 October 2018

Hackathon lessons

I have been on a hackathon last night, I haven't done this for over a decade. There were a few things I learned:
  1. I am a bad UI engineer, but not terribly bad. Just simply bad. I can live with this :) But also I think I could quickly improve my skills in this direction if I had some time. - meaning at the expense of my other projects
  2. Family duty is difficult to fit together with all-day all-nigh work. Ok, I kind of knew this, but now I know a lot better.

Things that now I remember a lot better (meaning I knew it):
  1. Go prepared. What can be ready ready before the start, must be ready for the start.
  2. Preparation is a team-work. All the team must be prepared. Everyone must have the tools installed on their laptops, they must be tested and working fine, all permissions need to be acquired (like github team membership)
    Also it is better to come to agreement on what tools should be used or preferred.
  3. A hackathon is not about building an application. For that it would be amazingly bad. It is about building an idea, the purpose of everything that you do on the hackathon is to demonstrate that idea.
  4. Perfection is a total enemy in this respect. Whatever works, is fine. Maybe even if it looks crappy. It will be scraped anyway.
    If we are able to demonstrate the idea, someone will have enough time to do this right.
    If we don't not only the code will go to the garbage can, but a potentially valuable idea too.
  5. Be OK with what you have achieved. If you are not, you are discrediting the idea, turning the whole team-effort into a waste.