Sleep sort algorithm

Some time ago I was doing some small introductions to basic algorithms I learned back in school to my colleagues at carwow (just for fun). Some of them became posts on medium.

After one of them a colleague told me about sleep sort algorithm. I think it’s ingenious and should be in a blog calling itself “weird programming”.


Implementing integer expressions in Haskell data types

Inspired by Implementing numbers in “pure” Ruby

When I started working with Elm programming language I was amazed how simple and yet powerful the type system is. It’s just shocking how far you can go with with just having some symbols and type constructors.

But how really far can we go? Well, I decided to test it out starting with implementing integers and expressions with them. I decided to use Haskell for that. Its laziness may be useful.

Ground rules

  1. Nothing from standard library is being used
  2. We can create and use data types
  3. We can have only one function called eval for evaluating our expressions.
  4. We can use pattern matching.
  5. Ground rules can be broken only for the sake of testing the code. For example, printing to the console is fine.

Functional programming, meet OOP

Originally posted on medium.com

I enjoy experimenting with programming paradigms and trying out some interesting (to me) ideas (some things become posts, like this and that). Recently I decided to see if I can write object-oriented code in a functional language.


Writing a small web service with Ruby, Rack, and functional programming

Originally posted on medium.com

I love Ruby. I also love object-oriented programming. However, nowadays functional programming is getting more and more attention. And that’s not surprising because the functional paradigm has a lot of advantages.

Ruby, being a multi-paradigm language, allows us to write programs in a functional style. Let’s see if we can write a web application this way. Maybe we even end up inventing a web framework ;)


Implementing numbers in "pure" Ruby

Originaly posted in carwow blog on medium.com

Object-Oriented Programming to me means that the system is divided into objects. An object is just an entity that has some state and some behaviour. You can make your object do something by sending it a message, hoping that it will understand you.

For practical reasons, every language has some primitives; basic data types you can use to write your program. Even though Ruby is, supposedly, a pure OO language (everything is an object), it has some primitives nevertheless.

For instance, numbers. They look like objects, they have methods and stuff. However, what are they really? 2 and 3 are different instances of the Integer class, so they are supposed to have a different state. But what is that state? Magic.

Let’s try and implement numbers on our own, without magic. Just for fun.