• +1

Who This Article Is For

Elixir
I would say that the article is mainly for people who already have an experience with some other programming languages, but they want to look around. Also, functional programming is a trending thing nowadays. So if you want to see what it actually is, welcome. If you are a complete beginner, it's still may be useful, as it's always good to know what's going on around the world of IT.

A Few Words about Elixir

A few years ago Jose Valim posted in his repository a project of the language that is built on top of Erlang VM — Elixir. In the article you’ll find extracts from the documentation and a few simple examples.

Read more →
  • +1

What I’m Going to Tell You About

In the previous article we constructed the environment needed to get familiar with the kernel. Then we took a look at loadable kernel modules and wrote a simple “Hello World!”. Finally, we wrote a simple and useless file system. Now it’s time to go on.

The main aim of this article is to teach the file system to read from disk. For now it will read the operating information only (the super block and index nodes).

Doesn’t seem like much, eh? The thing is that in this post we’ll have to define the structure of our file system – the way it will be stored on disk. Besides, we’ll also get familiar with SLAB and RCU. All of this will require some explanations – a lot of words and little code. Therefore, the post will be quite long.

Read more →
  • 0
Dear %username%,
Erlang for Beginners
Let’s continue to learn Erlang.

In the previous post we’ve reviewed the basic data types, lists and tuples. We also learnt how to use pattern matching and lists generator.
In this post we’ll move on to the next level and review modules and functions.

All functions in Erlang are defined in modules. Standard functions of the language, which we invoke as “global” (for instance, length, hd, tl), are actually inside of the module as well. They are BIFs (Built-In Functions) and belong to erlang module. This module is imported by default. Therefore, we can work with them like with regular functions (I’ll tell you more about the module importing below).

Read more →
  • +1
Dear %username%,

Erlang TutorialIt’s the first article of the series. For many of you it may seem terribly trite as I’ll review the very basis of the subject. But this tutorial is going to be really useful for Erlang beginners. I’ll also dwell on some interesting things that aren’t obvious.

In order to begin your work with Erlang, execute the following in the terminal:

$ sudo apt-get install erlang
$ erl


That will start the Erlang interpreter. You should carry out examples from the article in it. In Erlang, in contrast to most languages, we put a period at the end of expression. Comments begin with % symbol and go on till the end of the line.

So, let’s start.

Read more →
  • 0
This article is about a WebSocket server on Erlang rather than about the game itself. I’ll tell you a small prehistory. When I began playing 2048 I couldn’t stop. It was to the detriment of both my job and family. So I decided that a bot should play instead of me. But the problem was that it’s a user game, there’s no global rating and it’s not comfortable to play without a browser. That’s why I decided to create the server part so that there would be rating and my bot could play without a browser.

It’s my first project in Erlang. Many programmers are afraid of it. They suppose that it’s difficult to use it. But it’s actually not. I’ll try to highlight some things that are not obvious for Erlang beginners.

I’ve hard coded a lot of things for simplicity. But anyway, I’ll be glad to read your comments on the subject.

Read more →
  • +1
Boost
I was always scared to use C++ templates due to the absence of standard mechanisms for setting parameter limits. In other words, when a developer writes the following function:

template 
bool someFunc(T t)
{
    if (t.someCheck()) {
        t.someAction(0);
    }
}

it makes different assumptions as for the functionality of T type objects, but doesn’t have a standard facility to inform the user about them. Thus, the provided example can suppose at least the following things:

  1. T type objects are passed by value. So they should have on open copy constructor.
  2. There’s an open T::someCheck method with no parameters. It returns the value that is cast to bool type.
  3. There’s an open T::someAction method that can accept one parameter that is cast to numeric data type.

Read more →
  • 0
As I’ve already mentioned in the previous articles, the main difficulties when implementing lock-free data structures are ABA problem and memory reclamation. I will separate these two problems even though they are connected as there are algorithms that can solve only one of them.
In this article I am going to review popular methods of safe memory reclamation for lock-free containers. I’ll demonstrate the application of one or another method of the classic lock-free queue by Michael-Scott [MS98].

Read more →
  • +2
It is common practice not to like Windows. But, as a rule, phrase: “I haven't read the book but still condemn it” describes this situation well. Despite the tendency of not like Windows, there are still some things that are implemented well. I’d like to tell you about one of them.

I’ll review the embedded into OS implementation of the lock-free stack and its performance comparison with the cross-platform analogues.

The implementation of non-blocking stack on the basis of a singly linked list (Interlocked Singly Linked Lists, SList), has been available in WinAPI for quite a while. Operations on such list initializing and stack primitives over it have been implemented. Without going into details of implementing the SLists, the Microsoft just say that they use some non-blocking algorithm in order to implement atomic synchronization, increase performance and get rid of lock problems.

You can implement non-blocking singly linked lists by yourself. There are some articles written on the topic.
But there have been no 128-bit CAS operation before Windows 8. This fact caused problems when implementing such algorithms in 64-bit applications. SList helps to solve this task.

Read more →
  • +3
Haskell InterviewI guess it’s no secret for anyone that multithread applications writing is connected with many problems you wouldn’t face when developing single-thread programs. One of the problems lies in an application testing.
We can’t control the order in which operations are performed. Therefore, we also can’t control the result of the program execution. Even if we get an error, it won’t be easy to step in the same river twice. I’d like to suggest a recipe of testing a multithread application.
We’ll need the following ingredients: haskell, QuickCheck, some monads, salt/pepper to your taste.

Read more →