Implementing OOP in FP

Some years back I wrote the essay “Functional programming, meet OOP”. A few months ago I gave a talk loosely based on it but with some major improvements. It didn’t feel right to update the original post so instead I decided to rewrite it to go a little bit more in detail of the higher level concepts and to make it less Clojure-specific.


Microservices aren't the problem. Incompetent people are

Have you read the awesome essay “Death by a thousand microservices”? I agree with everything said in it. However, I’d like to emphasise that microservices aren’t a problem in itself. Also, I don’t think monoliths are necessarily a better fit most of the time even for smaller products. In fact, personally, I prefer services (intentionally avoiding the “micro”) to a huge monolith in the work setting.

The real problem, I think, is the lack of engineering competence and the lack of “giving a shit” in companies. That’s what creates complex systems nobody can efficiently work on.


Coding alone vs coding in a team

Recently I’ve been working on a personal project (a Tinder bot integrated with ChatGPT and using Telegram Bot API as UI). I started out with a small prototype in Ruby (like 40 lines script) however then I switched to Common Lisp.

The reason for it was that I wanted to use the language for a while but couldn’t bring myself to (because I hate LISP-2 and I also thought and still do that CL is a language equivalent of a dumpster).

My opinion of the language hasn’t changed but I did love the experience. And now I’m gonna try to explain why.


Yet another validation DSL

I’ve been reading my old essays and found this one written in Russian back in 2019.

Essentially, it describes a Ruby gem (library) I had written that allows you to create your own validation DSL as a bunch of functions and data. It emphises simplicity and flexibility. I thought it had a really interesting idea behind it so I’m going to rehash it here.

The below can be applied to any language (admittedly, it’ll be less convenient in some). I wrote examples in Ruby and Clojure.


ruby -run

This is a loose translation of my post from 2017

Recently, I was looking for a one-liner to start a web-server in the current directory. Stack Overflow gave me this command:

ruby -run -e httpd -- -p 9090 [DIR]

So what is this mysterious -run option an why is it not in the ruby manual?


ruby -e for better console experience

This is a loose translation of my post from 2017.

Ruby was influenced by Perl and can substitute it in its niche of “practical extraction and reporting”. In this small post, I’ll talk about using ruby for simple text processing in the terminal.


I hate Ruby constants

This is a loose translation of my post from 2018.

Ruby is a very complex programming language. It’s incredibly beautiful and expressive. However, it also has lots of traits and implementation details that even some of the experienced Ruby programmers may not know. One of these is constant lookup.

I’m not gonna try to explain the lookup algorithm works. I just want to raise some awareness of the topic. Mostly, it’s just a rant.


How I use git

This is a loose translation of my post from 2017 + minor edits.


Getting rid of OOP in Javascript with lodash/fp

One of the things I dislike about JavaScript is how it intertwines object-oriented paradigm with functional programming. Ironically, that’s also the thing that I do like about JS. I like that I have a choice and JS actually does allow you to write functional code that looks natural (as opposed to Ruby that doesn’t even have actual functions per se).

However, the standard library in JavaScript is written in a OOP manner, meaning that you need to call methods on objects instead of using functions. This creates inconsistency when you write in functional style because you end up with code that uses both functions end methods: getUsers(ids).map(userToJson).

I’d much rather prefer to have a consistent function-oriented code. Lodash, defining a lot of commonly-used functions, basically provides functional alternative to JS methods from standard library.


Programming only with classes

In my post Implementing numbers in “pure” Ruby I established some ground rules that allowed us to use some basic ruby stuff like equality operator, booleans, nil, blocks and so on.

But what if we had absolutely nothing, even basic operators like if and while? Get ready for some pure OOP-madness.


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 my blog.


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.


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.