Are there any statically-typed functional languages?

后端 未结 6 876
无人及你
无人及你 2021-02-05 10:48

I\'m coming from a statically-typed background and investigating functional programming, but I\'m not entirely excited about dynamic typing. I\'m curious about what kind of opti

相关标签:
6条回答
  • 2021-02-05 10:51

    There are many. Haskell, OCaml and F# come to mind. If you are a Windows developer, F# is very nice and is well supported by Microsoft (along with a very strong StackOverflow community). Lisp family languages (Common Lisp, Scheme, Clojure) are examples of dynamic functional languages.

    ActionScript 3 has optional static typing. The Haskell, OCaml and F# compilers, on the other hand, use type inference to deterministically infer types. When you first look at code written in OCaml the absence of explicit types gives it the clutter free look of a dynamically typed language with the type safety of static typing. It is my opinion that optional static typing for dynamic languages (a great idea) will eventually be replaced by type inference and that 10 years from now the static versus dynamic debate will be moot.

    0 讨论(0)
  • 2021-02-05 10:51

    The type theory was first applied to the functional programming (typed lambda calculus), long before any imperative languages.

    For the most advanced static type systems (you won't find anything comparable in the imperative world) check out Coq and Agda.

    0 讨论(0)
  • 2021-02-05 10:56

    haskell leaps to mind (although its type system is probably the most advanced out there), the ML family of languages, F# AFAIK.

    0 讨论(0)
  • 2021-02-05 10:59

    Some statically typed languages with first-class lexical closures and guaranteed tail call elimination:

    • Standard ML (1978-1997)
    • Miranda (1983-1986)
    • CAML (1985-1995)
    • OCaml (1996-present)
    • Haskell (1990-2010)
    • F# (2005-present)

    without tail call elimination:

    • C# (1999-present)
    • Scala (2008-present)
    0 讨论(0)
  • 2021-02-05 11:09

    My top recommendation for someone like you (presumably with a statically-typed, OO, imperative background) is Scala. Scala is an imperative-functional hybrid with better support for OO than Java and most other languages around. Scala compiles to JVM bytecode (.net is also supported, though used much less) and provides Java interoperability unmatched among non-Java JVM languages. I use Scala in my compiler - jgo and have found writing Scala code exceptionally fun and satisfying. The best resource for learning Scala is Programming in Scala, written by the language designer himself.

    If you don't want a hybrid language and instead prefer to jump straight into the fray of FP, I'd go with Haskell. Haskell is a purely functional language; there's no (first-class) notion of mutability or effect. My favorite Haskell resource is the witty Learn You a Haskell for Great Good!. In fact, I'd heavily recommend reading some of LYAH whether or not you intend to go with Haskell, since it's a fantastic introduction to the world of statically typed FP. I'd start reading it even before thinking about language choice.

    0 讨论(0)
  • 2021-02-05 11:13

    If you are familiar with the Java ecosystem, the very Haskell-like language Frege might be worth a look as it compiles to Java source code.

    0 讨论(0)
提交回复
热议问题