Falling in love with F #: Dose 0: Why do we need another programming language?

    Dear Habrakollegi!



    I want to offer you the opportunity to join another programming language: F #. The idea to write such notes arose from life - by the nature of my activity I have to talk about F #, and when they ask me where to read more about this language in more detail - I have to refer to English-language resources. Therefore, I decided to slowly talk about F # on my blog , and now also on the hub, seeing a wonderful community of startup programmers. Since F # is a very beautiful language that will not leave anyone indifferent - I decided to head the series of articles “ fall in love with F # ” and call each of the articles a “ dose": at the end of their use, you will have to get hooked on F #, and I will painfully exploit your patience by making forced (due to lack of time) breaks between doses.



    Recently it was announced that in addition to Visual Basic and C #, another programming language will appear in the standard package of Visual Studio 2010: F # . This, as you might guess from the name, is a language primarily of functional programming , originating in OCaml , ML, etc. Although someone might have mistakenly guessed that this is a Fortran implementation for .NET :)



    Why “predominantly functional”? Because it is also an object-oriented language that integrates perfectly with the .NET platform and is slightly imperative. You can consider F # as a full-fledged advent of functional programming on the .NET platform (in the sense of its industrial availability), or you can also consider it as yet another .NET language with many “quirks” and with a strange but very compact syntax. Judge for yourselves, this is how fast Hoare sorting is written in F # (for comparison, look at the algorithms written in C or Pascal 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 a 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!



    There are reasons for that. The latest issue of Dr. Dobb's Journal has an entire article on this subject. One of the main reasons - functional programming makes it easier to write multi-threaded applications for multi-core processors. Why this is so - we will consider in 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, not your fingers, pay attention to F # and functional programming. And I will try to help you do it painlessly, in Russian.



    If you start to consider F # on the other hand, without going into its functional essence, you can notice that this is a compact language, in which there is, including automatic type inference (we almost never have to describe data types for objects) with static typing, resulting in code like in a dynamic language, but with type checking and a more efficient generated bytecode.



    Microsoft in the implementation of Visual Studio positions F # as a language convenient for solving various data processing tasks. At the same time, it is not assumed (although it is possible) that F # will be widely used to build user interfaces, therefore, support for F # by visual designers is not 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 to tell you more about F # in the following posts, so that you can get acquainted with the language and start using it for educational and research purposes. I will also tell you where to download and how to install F #, incl. to platforms other than Windows. But - next time.



    Now I will be happy to answer your questions and accept suggestions about what aspects of the F # language you would like to hear first of all. All this - in the comments below, or in the VKontakte group . Also share if you use functional programming languages in your work? Have you been taught functional programming at the university? I will be interested to hear how familiar my readers are with functional programming!



    Also popular now: