RSSAmplifier

Blog

Ostash.Dev

Recent content on Ostash.Dev

ostash.devRSS feed ↗22 posts

Latest posts

A concept of polymorphism in Clojure

Working with larger Clojure projects or libraries requires us to use some concepts that we all know from the Object Oriented Programming (OOP) world.

Data validation in Clojure

As programmers we work with data every day. It has different forms: data may come from the database, an API endpoint or from the user input.

Transient Data Structures in Clojure

Although in Clojure we strictly adhere to the idea of immutability we still have an option to work with mutable data structures.

Pre and post conditions in Clojure

Today we will discuss a topic of pre and post assertions (conditions) in Clojure. The language gives programmers an option to set certain conditions we want to constrain our function with.

Data notation in Clojure

Homoiconicity (code as a data structure) is one of the pillars of the Clojure language. It gives the extensibility and flexibility to the language.

Clojure metadata

Conceptually metadata is an ability for the symbol or the collection to have some additional information for the Clojure compiler. It is implemented as a map data structure and is often used to convey the type information to the compiler, documentation and compilation warnings.

Clojure atoms

All data structures in Clojure are immutable. Any changes we do will result in a new data structure leaving an original one untouched.

Destructuring in Clojure

Destructuring in Clojure can be confusing for someone coming from the language where this technique is not implemented. Hopefully when you are done reading this article, destructuring will make sense and you will be implementing this method in your own coding projects.

Working with ClojureScript at ease

Today we are going to talk about ClojureScript and review many useful functions and concepts you need to know when working with Clojure/JavaScript interoperability.

Better learning with Clojure

Clojure comes with many useful functions that are a great learning resource for those who are just starting to explore the language.

Clojure code comments

If we would like to comment out a line of the code we simply use a semicolon at the beginning. To comment out a block of the code we use hash underscore #_ (reader macro).

Clojure namespaces

Let’s talk about namespaces today. Below is a structure of the core.clj file that is located in /src/app/ directory. Function ns sets the namespace.

Bindings in Clojure

In Clojure we can bind a piece of the code/data to a var (variable). To declare a global var we use a def special form (similar to let keyword in JS world).

Functions in Clojure

Functions in Clojure are data structures since the language follows code as a data structure principle (homoiconicity). In Clojure those data structures are lists since it is a dialect of the LISP (LISt Processor) language, the second oldest language still in use today.

Immutability

Mutable data structure can be changed after creation immutable cannot. Paradoxically, when you need to mutate a data structure, is a time then you should use an immutable data structure because it allows a structured mutation.

About

I’m Roman Ostash, a self-taught Software Developer. I love to code and to build applications. Thinking outside of the box, problem solving skills and perseverance in achieving my goals are helping me in my personal and professional development.

A value mutability

Mutating a value. When you receive a data structure that is in its identity mutable, like an array or object, the best thing to do is to always assume that it is a read-only data structure and that you are not allowed to mutate it.

Higher order functions

What is a higher order function(HOF)? If a function receives as its input one or more functions or/and returns the function we can called it HOF.

Currying

Currying is an act of taking one function that receives more than one argument and refactoring it so it becomes HOF(a higher order function) that returns series of functions each accepting only one argument and only evaluating once we receive our final argument.

Arity

Before we explain what arity is, let’s make a clear distinction between parameters and arguments in a function. The parameter is a variable declared in the function expression.

Functional purity

What is a function? For the function to be a function it has to return something, otherwise is a procedure. Function is a semantic relationship between input and computed output.

The beginning

Like many of developers that were coding for the last few years, I was following mostly object oriented programming paradigm. Let’s not go into details on its specific implementation (hopefully the reader is familiar with it.