34

What are the most significant differences between the F# and Clojure ?

Which constructs has F# which Clojure does not have and vice versa?

Does F# have macros?

Brandon
  • 16,382
  • 12
  • 55
  • 88
nikolai
  • 349
  • 1
  • 3
  • 6

7 Answers7

61

Most of the differences will stem from the fact that F# is descended from ML while clojure is descended from lisp.

So F# has a more ML/OCaml/Haskell feel with emphasis on:

  • static typing
  • type inference
  • pattern matching

While clojure has more of a Lisp feel with emphasis on:

  • s-expressions
  • macros
  • closures

Also as Brian noted, F# is a .Net language while clojure is a JVM language so each will have access to a vast but different set of libraries.

Aaron Maenpaa
  • 119,832
  • 11
  • 95
  • 108
  • 12
    There is ClojureCLR, in Clojure/contrib, but it's alpha at the moment. – Kurt Schelfthout May 28 '09 at 08:04
  • clojure supports some lazy stuff and F# is a strict language – nickik Jul 22 '10 at 12:10
  • Also, Clojure has a great STM implementation. F#'s computation expressions (for monadic syntax) and quotations overlap with macros a bit. – J D Aug 03 '10 at 22:13
  • F# has lazy sequences more or less like Clojure's. Where I'd draw the distinction is with Clojure's built-in persistent data structures & emphasis on STM. – mshroyer Apr 24 '11 at 03:39
  • They both have sophisticated mechanisms to interact with object types. Those could be libraries or C#, Java code respectively. – Arturo Hernandez Feb 11 '13 at 16:24
11

Clojure is a lisp, actualy lisp-1 family language. F# is practicaly OCaml adopted to .net platform.

Marko
  • 30,263
  • 18
  • 74
  • 108
8

One key difference is that F# is a .NET language, whereas Clojure runs on a JVM. Thus the deployments and supported platforms will be different.

Note that F# is supported by mono, however.

As for macros, I think you're out of luck.

Community
  • 1
  • 1
Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
  • 4
    And AFAIK there exists no platform that would run .NET but wouldn't run JVM. The other way round, there are many cases. So, Clojure is more generic while F# is more or less Microsoft specific. – Joonas Pulakka May 27 '09 at 11:38
  • 4
    @mad-j Yeah well. Mono fills much of that multi-platform space for .NET. And, the vanilla JVM does not run on android, for example. So Java is more or less Sun-specific? – Kurt Schelfthout May 28 '09 at 08:10
  • 3
    Hardly. Common on Windows/Linux/Mac for instance. – Brian Agnew May 28 '09 at 11:24
  • 1
    @Joonas - iPhone and iPad run .NET via MonoTouch but do not support Java. That is a pretty big hole. – Justin Aug 02 '11 at 11:16
  • @Justin: Seems that someone is hacking Java support into iThings regardless of Apple's political decisions: http://www.jroller.com/neugens/entry/running_pure_java_applications_on – Joonas Pulakka Aug 12 '11 at 06:53
6

It looks like there's some effort being put into running Clojure on the CLR. Looks very promising.

http://github.com/richhickey/clojure-clr

Alex Beynenson
  • 803
  • 11
  • 9
3

They are both functional first programming languages, but their type systems are very different. F# is a strongly typed language and Clojure is a dynamically typed language and so

  1. Boumbles' answer to What is the Difference between Strong vs. Static Typing AND Weak vs. Dynamic Typing;
  2. haylem's answer to Dynamically vs Statically typed languages studies; or
  3. Joey Adams's question What is better for prototyping: a statically-typed language, or a dynamically-typed one?

may help answer "what are the most significant differences between the F# and Clojure?". Note however that the debate between "static typing" and "dynamic typing" is a long running one and so can appear religious.

Community
  • 1
  • 1
dumbledad
  • 16,305
  • 23
  • 120
  • 273
2

F# really corresponds to Scala on JVM. The closest thing to Clojure on .NET platform is IronScheme.

Nemanja Trifunovic
  • 24,346
  • 3
  • 50
  • 88
  • 4
    "F# really corresponds to Scala". Technically but not politically. Scala is an academic language whereas F# and Clojure are industrial languages. – J D Aug 03 '10 at 22:10
  • 1
    @Jon - not sure it is fair to describe Scala as an academic language. It has a lot of "pragmatic" features, has good Java platform interop and I've seen it being used in big enterprises (e.g. banks) more than either F# or Clojure so far. – mikera Sep 26 '12 at 14:27
  • 3
    @mikera: Well, Scala became more of an industrial language when Martin Odersky founded TypeSafe the year after I wrote that comment. Scala's UK job market share increased 10x since then. http://www.itjobswatch.co.uk/jobs/uk/scala.do – J D Sep 27 '12 at 19:55
2

If you want macros, you can use it with Boo or Nemerle.

dotneter
  • 1,689
  • 2
  • 15
  • 24