Tag Info

Hot answers tagged

50

Major Differences: Both Scala and F# combine OO-imperative programming and functional programming into one language. Their approach towards unification of paradigms is vastly different though. Scala tries to fuse the two paradigms into one (we call it object-functional paradigm), whereas F# provides the two paradigms side by side. For example, algebraic ...


50

Is there something fundamentally different about the languages that allows F# to have the interactive console but makes it difficult to implement it for C#? Yes. F# is a a descendent of the ML programming language, which in turn was heavily influenced by languages like Lisp and Scheme. Those languages were designed from day one to have three nice ...


27

The main reason FP aims for this and C# OOP does not is that in FP the focus is on referential transparency; that is, data goes into a function and data comes out, but the original data is not changed. In C# OOP there's a concept of delegation of responsibility where you delegate an object's management to it, and therefore you want it to change its own ...


23

I have mixed feelings about F#. I have a strong functional programming background and many years of C# experience, so I can see it from both sides and I think that F# makes too many compromises to satisfy people from either group. It's worth pointing out as well that .net is fundamentally an object-oriented imperative execution environment. It's not ...


23

Search resumes for other functional languages such as Scheme, Lisp or Haskell. A lot of people learn these in school and have them on their resumes; I'm sure many of them wouldn't mind learning F#. I have Scheme in my resume even though I never used it after school and a job involving F# would probably get my attention too.


21

Mono has a C# repl: http://www.mono-project.com/CsharpRepl It even has a GUI version that allows you to directly manipulate graphics objects, or create Gtk# widgets:


20

Having spent decades writing imperative, i.e. If and While statements, and logical, i.e. PROLOG, programs and having spent the last few months learning F# I will give you some advice from my perspective. During those decades I have brushed against functional languages such as LISP, and Mercury, with enough understanding to read the code and write simple ...


19

Although it's sometimes expressed that way, functional programming¹ doesn't prevent stateful computations. What it does is force the programmer to make state explicit. For example, let's take the basic structure of some program using an imperative queue (in some pseudolanguage): q := Queue.new(); while (true) { if (Queue.is_empty(q)) { ...


19

According the Great Benchmarks Game, ATS is faster than the rest with Haskell, Scala, and one of the variants of Common Lisp in a rough tie for speed close behind that. After that Ocaml and F# are in roughly the same speed category with Racket and Clojure lagging behind... However, almost none of this means anything at all really. It's all a question of ...


16

There's nothing wrong with mixing languages in a product as long as you use each appropriately and they "play nice" together. If there is part of your project that would be best coded using a functional language then it makes sense to code it in F#. Similarly for C#. What would be pointless (at best) would be mixing languages for the sake of it.


15

Edit: To clarify from comments. I'm addressing the overlap between Haskell and F#'s type systems. The part they share is known sometimes as System F. F# by necessity provides bits and pieces of C#'s type system, but this isn't what the speaker was talking about. Both C# and Haskell/F# are statically typed, but they're two different flavors. Subtyping ...


14

I don’t use F#, but in Haskell it is considered good form to annotate (at least) top-level definitions, and sometimes local definitions, even though the language has pervasive type inference. This is for a few reasons: Reading When you want to know how to use a function, it’s incredibly useful to have the type signature available. You can simply read it, ...


13

Understanding legacy code is hard. It has almost nothing to do with functional vs. procedural. Create a map of some kind. A component diagram of the Python packages and modules. For each module, you'll need to create class diagrams. Use the Python interpreter. You should be able to import modules, create objects and exercise them interactively. ...


13

What do you mean by "viable?" "Having the most press" is not necessarily the best way to choose a language. Erlang's claim to fame is its capability of massive parallelization. That's why it's commonly used in Ericsson phone switches. Erlang is soft-realtime, so you can make certain performance guarantees about it. F# benefits from the optimization ...


13

There is inherent difference in haskell and f# semantics. In haskell function call does not perform any real calculation, but allocates heap object known as 'thunk'. It is perfectly ok for thunk to have link to itself or other thunk. However, in f# function call is an actual call, making expression like let x = 1 : 2 : x in x invalid - as it requires x to be ...


12

A few arguments for pure functional programming: It's easier to divide tasks for today's multi-core systems It's easier to prove your program is correct Functional composition can be amazing, terse, and powerful For a full treatment, see Why Functional Programming Matters and Why Why Functional Programming Matters Matters.


11

In Short: "No". On the Java side there's a similar discussion "Will Scala/Clojure (both functional languages) take over from Java? Will Jython (Java port of Python) or JRuby take over? In all of those cases the newer languages all do have some compelling features, but they're all lacking that key factor of having the existing developer base (and I'm not ...


11

You are probably best off just using Scheme. It is an easy language to learn, really. You might want to try to do some things in F# as well, but start with scheme.


11

I am having a very hard time reading imperative code. When an for-if-else-for-... nesting goes more than four levels deep, I completely lose the track of what's happening in the code. Wait...anyone completely looses track of the code with such deep nesting levels. Or as Linus Torvalds put it: If you need more than 3 levels of indentation, you're ...


11

This question has been answered on SO, and it includes some strong historic background for why "rec" is used. Here is the important quote for posterity: Functions are not recursive by default in the French CAML family of languages (including OCaml). This choice makes it easy to supercede function (and variable) definitions using let in those languages ...


10

Here's an idea: write/rewrite a program in F# as easily as possible, which may be thoroughly imperative make incremental improvements eliminate mutability look for loops that can be replaced with higher-order functions (map, filter, reduce, etc) try replacing trivial type hierarchies with discriminated unions replace conditionals, especially nested ones, ...


10

You are correct in that OOP class hierarchies are very closely related to discriminated unions in F# and that pattern matching is very closely related to dynamic type tests. In fact, this is actually how F# compiles discriminated unions to .NET! Regarding extensibility - there are two sides of the problem: OO lets you add new sub-classes, but makes it ...


9

I'm reading Real World Functional Programming and so far it's very good. It is co-authored by stackoverflow's Jon Skeet and also by Tomas Petricek.


9

Any other pitfalls I'm not considering? In practice, the main mistake I see people make is trying to force the use of F# for problems where it is the wrong tool for the job. Or anyone care to rebut the pitfalls I've mentioned? They are all obviously valid concerns to some degree but I'd question to what degree. For example, you say that everyone ...


9

F# doesn't really do anything that C# cant. They all ultimately compile down to the same CLR so there is no single technology that would be amazingly useful to you. You can even call F# from C# and vice versa. Depending on the problems your designing F# could provide simpler and more concise code. Functional languages also lend themselves very well to ...


9

A recursive let defines a significantly more complicated semantics than a normal one. Therefore, for a sake of simplicity and clean language design, there is a good reason to have both, just the same as having separate let, let* and letrec in Scheme. Simple let x = y in z is equivalent to ((fun x -> z) y). A recursive let is much more complicated and may ...


9

It should also be pointed out that you cannot measure / quantify the performance of a programming language. The best you can do is measure the performance of a specific implementation of the language on specific platforms, running specific programs. So when you ask about "the fastest functional language", what you are really asking about the best of the ...


8

When I started digging deep into Haskell (coming from a mostly Basic/C background), I already had a firm grasp of closures from thinking about them for months and months, and using them in JavaScript. Whether or not this is the biggest hurdle of learning functional programming, I'm not sure, but I'd imagine they're easier to understand when state is taken ...


8

What do you think of the F# language? I love it! I would like to learn it's positive and negative points. Pros: Productive. F# captured the essence of ML that makes it such a hugely productive programming language. Efficient. F# captured the simple mode of compilation that makes the performance of ML code so predictable and .NET 4 makes it ...


8

The fact that F# allows you to program both in a functional and in an imperative style could make your task a bit harder at the beginning because each time you have some difficulty you'll want to fall back to more familiar constructs and ways of reasoning. Have you considered a jump-into-cold-water approach, e.g. trying to learn a purely functional language ...



Only top voted, non community-wiki answers of a minimum length are eligible