Dear Habrakollegi!
I want to offer you the opportunity to join one more programming language: F #. The idea to write such notes arose from life - by the nature of my work I have to talk about F #, and when people ask me where I can read more about this language, I have to refer to English-language resources. Therefore, I decided to quietly tell about F # in my blog , and now also in Habré, when I saw a wonderful start-up programmer community. Since F # is a very beautiful language that will not leave anyone indifferent - I decided to headline the cycle of articles “ fall in love with F # ”, and call each of the articles “ dose ”: after using them, you will have to hook on F #, and I will painfully exploit your patience, taking forced (due to lack of time) breaks between doses.
It was recently announced that the standard delivery of Visual Studio 2010 will feature, in addition to Visual Basic and C #, another programming language: F # . This, as you might guess from the title, is a language of primarily functional programming , originating in OCaml , ML, etc. Although someone could mistakenly guess that this is the implementation of Fortran for .NET :)
Why “predominantly functional”? Because it is also an object-oriented language, perfectly integrating with the .NET platform, and slightly imperative. You can consider F # as a full-fledged functional programming coming to the .NET platform (in the sense of its industrial availability), or it can be just another .NET-language with many “quirks” and a strange, but very compact syntax. Judge for yourself, here’s how Hoar’s quick sort is recorded on F # (for comparison, see how the algorithms written in C or Pascal look like by reference ):
let rec quicksort = function [] -> [] | h::t -> quicksort ([ for x in t when x<=h -> x]) @ [h] @ quicksort ([ for x in t when x>h -> x]);;
Why did Microsoft begin to invest in a functional language in the past few years, and even put it on par with the “main” languages ​​of the .NET platform? After all, it is known that functional programming is not used too much in industrial programming!
For good reason. In the latest issue of Dr.Dobb's Journal there is a whole article dedicated to this issue. One of the main reasons is that functional programming makes it easier to write multi-threaded applications for multi-core processors. Why this is so - we will look at the next lesson, where we will talk about what functional programming is. In addition, functional programs do not allow or minimize side effects, which increases the reliability of programs and simplifies debugging. In general, we can say that functional programming allows us to write several times less code, but it makes us think more . If you like to work with your head, and not with your fingers, pay attention to F # and functional programming. And I will try to help you to do this without serious consequences, in Russian.
If you start to consider F # on the other hand, without going into its functional essence, then you can see that it is a compact language, which includes automatic type inference (we almost never have to describe data types for objects) with static typing, resulting in code like a dynamic language, but with type checking and more efficient byte-code generated.
Microsoft in the Visual Studio implementation positions F # as a language convenient for solving various data processing tasks. At the same time, it is not supposed (although it is possible) that F # will be widely used for building user interfaces, so no support for F # from visual designers is promised.
All of the above causes considerable interest in the F # language from students, teachers and the academic community as a whole. At the same time, there is no literature on this language in Russian yet. I will try in the following posts to tell about F # in more detail so that you can get acquainted with the language and begin to use it for educational and research purposes. I will also tell you where to download and how to install F #, incl. on platforms other than Windows. But - next time.
Now I’m happy to answer your questions and accept suggestions about which aspects of the F # language you would like to hear first. All this is in the comments below, or in the VKontakte group . Also share, do you use functional programming languages in your work? Have you been taught functional programming in high school? I will be interested to hear how familiar my readership is with functional programming!
Source: https://habr.com/ru/post/50967/
All Articles