📜 ⬆️ ⬇️

Opinion: Why you should learn and use Clojure

image

Developers from the American company Gaslight wrote an interesting material about why the organization, known for its love of Ruby and Ruby on Rails, decided to invest in the development of new technologies - for example, Clojure. We at Later develop billing for operators Hydra and also work with this programming language, so we decided to highlight the main points of the Gaslight team into a separate material.

So why study Clojure and use it in real projects?
')

Not just Ruby and RoR


According to Jeff Lane, who wrote a post on the Gaslight blog, with the help of Clojure, his team manages to solve tasks that are beyond the reach of Ruby. He illustrates this thesis with the words of Gaslight co-founder Doug Alcorn:

“I’m sure you can’t hold on to one programming language forever. The time will come when Ruby will give way to a new language. Because the environment itself will change. I only hope that the one who occupies this throne will be better and more merciful. ”

Lane says the company is still anxious about Ruby. Rails is still considered the best solution for writing web applications. But, like any tool, it has its limitations:


Functional programming as an alternative


In turn, functional programming is a completely different way of thinking. Take a look at Wikipedia :

"Functional programming is a section of discrete mathematics and a programming paradigm in which the computation process is interpreted as calculating the values ​​of functions in the mathematical understanding of the latter."

Functional languages, unlike object-oriented Ruby and JavaScript, offer a completely different approach to solving problems. The study of this approach allows you to acquire new knowledge that will not be available if you are constantly in the comfort of already familiar programming languages, Lane is convinced.

Clojure runs on server
Take the description of the work of the language from the site Clojure.org :

“Clojure achieves its goals by clearly following industry standards and using the open source JVM platform. This is a redesign of the familiar Lisp. It provides functional programming with stable and robust data structures. Provides built-in support for multi-threaded programming using software for transactional memory and asynchronous agents. Clojure is fast and reliable solutions to your problems. ”

So, Clojure works on a Java virtual machine (JVM), which means it has the undoubted advantages that this tool offers:


Clojure can be used wherever modern, efficient, stable data structures are needed. It also introduces a new multi-threaded programming model with core.async. And then, many other useful libraries are now being developed for logic programming, pattern matching, option-types, and much more, which would be useful to practice.

Clojure works in a browser
Another quote. Here is how the advantages of the ClojureScript Wiki language are described:

“Development platform with good portability, wide coverage and multi-vendor support. A sophisticated toolkit for creating better and more reliable applications that is compatible with all new devices. ”

ClojureScript is easily compiled into JavaScript and runs in a browser. All this provides a completely new approach to creating client applications. For many reasons, the JavaScript developer community doesn’t like it. Clojure can also be called a completely independent son of Lisp, a convenient, concise language with excellent asynchronous support, writes Lane. It can interact with other JavaScript libraries. This allows you to use the same language for the client and server parts, avoiding unnecessary sacrifices and loss of time.

Ensuring the full preservation of the current state (statefullness) in applications for clients is not an easy thing. And while the JavaScript frameworks (for example, React or Ember) are just getting closer to this problem, you should ask yourself - is it possible to change the approach itself drastically? Perhaps there is a language to pair with one of these frameworks that can teach us how to better manage with such difficulties.

Of course, there is no universal tool that would be suitable for solving all types of tasks. However, the fact that Clojure can be used “on both sides of the barricades” of client-server interaction is its undoubted advantage.

Game ahead of the curve


Lane also quotes great hockey player Wayne Gretzky:

"How do I do it?" I just always try to be where the puck will be in the next moment, and not where she has already been. ”

Clojure allows you to fill in some of the gaps in the process of creating specific types of applications. Those of them that need high speed processing of large volumes of information. The era of multi-core processors has long begun, but most traditional programming languages ​​are still not adapted to such an architecture, Lane is convinced. Functional programming can solve this problem when writing software. Clojure has all the necessary tools to enable programmers to work efficiently with large data sets. In fact, you can streamline and convert data in real time.

No extra innovation


In the world of technology, sometimes there are things so advanced and new that the benefits of them are not obvious - at least sometime in the future and can be significant - and the application carries great risks. To designate such technologies, a special term was invented - “bleeding edge”. Work with them comfortably only lovers of everything new.

Clojure can not be attributed to the leading edge technology, the stability of which is in question. The release of the language took place more than 5 years ago, and the new tool received quite benevolent reviews in the developer community. Therefore, it's time to get to know him better, without fear of exposing yourself to the risks of pioneers, Lane said.

Clojure Foundation is a well-known technology, for example, the same JVM, which has been under development for more than 15 years. Therefore, working with Clojure, you can use all the high-quality Java libraries that exist at the moment.

Curiosity - the engine of progress


Well, the very last argument for studying Clojure is curiosity and a desire to learn something new. There is always a desire to be at the forefront, to own and be able to handle the best technologies on the market. Clojure is ideal for this purpose. It is always interesting to set new goals. And finding solutions for them is an incomparable pleasure.

Now in Latera, we are using Clojure to execute equipment management commands. The specificity of the task lies in the requirements for simultaneity in the execution of commands and flexible constraints. On the one hand, it is impossible to “fill up” one device with commands, on the other hand, to execute all commands sequentially inefficiently, because they can be executed in parallel on different equipment. This task is easily solved by the core.async library, which adds support for go-blocks and channels familiar from the Go language, where they use interacting sequential processes (a term better known as CSP ).

At the same time, Slojure is a general-purpose language; it is easy to find its use. Since it is based on the JVM, there is actually a huge choice of libraries for it, so when using it you do not need to write everything anew, which greatly reduces the entry threshold.

Even if you don’t tolerate Lisp, you should become familiar with the concepts that are inherent in the language, many of them make you take a fresh look at programming.

Source: https://habr.com/ru/post/280734/


All Articles