7 months ago 🏆 for day 336, 2019 with 326 words.

Functional programming

I got quite used to some basics of functional programming. I mean real basics like to functions such as map, filter or reduce. Those that help express the transformation of a piece of data — something that most computer programs are about. You take some input — let it be an array of characters like HTTP params —and transform that input, that request into a response — for example, HTML.

Often when someone says functional programming, people have flashbacks of mathematical analysis, monads and other complicated mathematics. There are sophisticated languages that make heavy use of all those characteristics, but I was never into them. I prefer programming languages that are practical at first and just after that have cool specific constructs that help model the idea.

Now an interesting thing about strongly typed languages is that it's a lot harder to express things like that. I believe those type systems may be cumbersome in some situations, and this is one of them. Of course, creators of programming languages noticed and implemented workarounds for precisely those situations. Those creators added those methods to allow creating generic functions. Not surprisingly they are called "generics".

I don't think I ever programmed in a language that didn't have generics before using Golang. Even when I started with Java, it was already on version 7, so generics were implemented. C++ has its templates system which I didn't understand that much how it can be used when I was learning about it. Later on, came ruby and since it wasn't a typed language, then generics weren't needed.

I wrote all that stuff because today I had to map an array of strings into a range of integers — trivial and popular task that can be seen quite often when reading files, for example. I had to look up how to achieve that thing in a language such as golang because allocating memory and implementing my map is not something I'm used to.


Start writing today, for free

Write Together is a safe space to blog, think, feel, and share together. Learn to write, or find a new home for your words, and join our passionate community.

Sign up Learn more
User Photo

By Bartosz Łęcki


Product engineer on a journey to actually learn how to write and get inspired by other people writing here!

Get Bartosz Łęcki's newsletter

Almost there! Check your inbox and click the link to confirm.

Subscribe to Bartosz Łęcki's latest writing to get it right in your inbox.