Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is Lisp related to F#, and is learning Lisp a useful leg up to F#?

This is the situation : I mostly program C# and have written types in it I don't want to lose. At the same time I would like to learn functional programming. The obvious answer of course is F#.

But for everything apart from C# I use emacs as an editor, and I really would like to learn Lisp too. (Learn your editors/IDE's language you know, that's why I know a bit VB to write my VS-macro's in it) And it's not just emacs, Lisp is something I really want to learn.

As for F#, I could mingle it with C# without any interop problem, have a great GUI (WPF) and a lot of other .NET goodies. But it is, of course, not as mature as Lisp.

If I am realistic I know if I want to smuggle a functional language into my professional life it has to be F#. Since learning two whole languages seems a bit much, I was hoping that Lisp would be a great way to learn functional programming, and if I start out F# later, It would be very easy....

Is this true? Or are the two languages not comparable at all?

like image 475
Peter Avatar asked Jun 23 '09 16:06

Peter


People also ask

Why is Lisp a functional language?

Lisp is a functional programming language with imperative features. By functional we mean that the overall style of the language is organized primarily around expressions and functions rather than statements and subroutines. Every Lisp expression returns some value.

Is F# a Lisp?

LISP is dynamically typed whereas F# is statically typed. LISP has macro's built in. F# does not.

Are all lisps functional?

Every Lisp procedure is a function, and when called, it returns a data object as its value. It is also commonly referred to as “functions” even though they may have side effects.

What is F language used for?

F# is an open-source, cross-platform programming language that makes it easy to write succinct, performant, robust, and practical code. It's a general-purpose language that enables you to create many different types of applications like Web API, Desktop, IoT, Gaming and more.


2 Answers

Lisp is a large family of languages and implementations. Scheme for example is a Lisp dialect with probably more than one hundred implementations (about ten of them mildly popular). Common Lisp is another dialect with about ten currently maintained implementations. Scheme and Common Lisp both have written standards that implementations try to implement.

F# is both a language and implementation. From Microsoft. It was mostly derived from OCAML and belongs to the family of ML languages.

Lisp was a very early language supporting functional programming (Lisp 1.5 in the 60s). Lots of the early experiments with functional programming was done in Lisp. In the 70s in the Lisp community there was a movement to the roots of functional programming and the result was Scheme. Then especially in the 80s and 90s of the last century new functional languages appeared (ML, Miranda, FP, SML, Haskell, Clean, ...) that were/are quite different from the usual Lisp dialects. There is still some heritage, but mostly they developed in different directions (static typing, type inference, module systems, batch languages, algebraic data types, lazy evaluation, purity, and more). The Scheme community still has lots of contacts to the FP community. But that's mostly it.

There are some basic FP ideas that can be learned independent from a particular FP language, but generally F# is very different from most Lisp dialects. The other feature, that F# supports the .net ecosystem (especially since it is a Microsoft creation) is not that well supported by Lisp dialects.

I would also not expect much benefit from knowing a restricted Lisp dialect like Emacs Lisp for learning F#.

like image 87
Rainer Joswig Avatar answered Sep 20 '22 03:09

Rainer Joswig


I think there is only a small 'overlap' for what'd you'd learn via Common Lisp versus F#. The commonality is I think roughly

  • Programming with 'cons-lists' as a common fundamental data type, sometimes writing recursive (especially tail-recursive) functions rather than loops
  • Some basic uses of common higher-order functions (e.g. 'map' - apply a function to every value in a list)

Apart from some of that very core functional-programming stuff, I think Common Lisp and F# are about as far apart from each other as two mainstream 'functional' (non-Haskell) languages can be. Common Lisp is dynamic; F# is statically-typed. The syntactic forms are completely different. The runtimes are completely different. The libraries are very different. The object systems are completely different.

Regardless of which order you learn them, I think after learning one there will still be quite a bit more to learn in the other (modulo the small overlap I described above).

like image 32
Brian Avatar answered Sep 22 '22 03:09

Brian