What is the case against F#? (2009)
stackoverflow.com
stackoverflow.com
It should be relatively obvious at this point that the outright merits of a language have little or nothing to do with its popularity, at least when compared to things like the corporate backing and will behind a language (see: Objective-C / Swift), and other factors such as positioning and luck (e.g. Javascript). So, you cannot start from "this language is _clearly_ better, so it will certainly become more popular".
And this is the problem for most people / dev shops choosing a language. Popularity brings a huge amount of good things, such as good quality training materials, job security, easy hiring, good quality libraries, etc (and a few negative things), so it is kind of a big deal.
I also suspect that the relationship between how many people are successfully using a language, and how often you hear about it on the Internet, is non-linear. And most the popular rankings (TIOBE, SO developer survey, etc) are really measuring how often you hear about it on the Internet.
For me, the real killer feature that every language must have is an escape hatch. This is every bit as true of AAA languages as it is of up-and-coming ones. Give me a way to expose a C ABI or a COM interface, and I'll feel more confident I won't get trapped. (Though I still cry myself to sleep at night knowing POSIX doesn't have a great answer to COM or WinRT.) For one project I'm working on, I'm currently feeling very trapped in Java, of all things. Because, while Java has decent enough facilities for calling out, it's much more difficult/expensive/both to call into Java from other platforms.
But for companies, it's pretty hard to put together 3-4 teams of developers in some esoteric language. And to find developers for it many years down the line for maintenance. So, they understandably stick to mainstream stuff, even if there are significant inherent advantages to something off the beaten bush.
Even if a new developer is a complete novice at a language, I would still expect that to be less effort than learning the business domain, getting to know the codebase, and socially integrating oneself with the team.
I beg to differ. People had 25 years to abandon Java but since then, the usage has only grown. I remember when Groovy and Ruby had their hyped periods sometime in the 00s, but what happened to that wave in the end? Grails and Rails became history, FAANG nowadays runs on Spring, the same for the rest of the world. Every practical feature that a JVM language had at a moment in time was later adopted by Java in some way. (maybe with the exception of Clojure which is the only language that didn't try to be a better Java).
You described the network effect of large companies converging on one language.
Well... it's complicated. I would say that for a new language to succeed now, it has to be clearly better at something - some niche, or some programming paradigm, or some such. It also has to meet the minimum bar of having libraries that cover much of the normal stuff that we expect libraries to cover. (That's where corporate backing comes in - it pays for building all the libraries that people have come to expect.)
But if the language isn't clearly better at something, then it's clearly worse, because I can hire people for a mainstream language, or I can have trouble hiring people for the offbeat language. If the offbeat language isn't enough better to make that a worthwhile trade-off, then why not use the mainstream one?
programming language maintainers need to think about UX.
I’ve started building a web server library[1] in F# to address this. Other libraries took for granted that I had no knowledge of .Net and required lots of .Net boilerplate.
[1]: https://wiz.run
Noticed one typo in https://wiz.run/api/#api-run — the second `setHost` should be `setPort` but also probably you don't need either of those in that `run` example
Introduction to the 'Why use F#' series (2012) (HN): https://news.ycombinator.com/item?id=26142662
... in case anyone thinks I am against using F#. Important to know the pros-and-cons.
0: https://docs.microsoft.com/en-us/dotnet/core/install/linux-d...
It's like, if you're sitting in a hardware store having a hard time choosing between buying a Ryobi brand miter saw and a Ryobi brand power drill for your current project, maybe it's time to take a step back to better define what you're planning to do, and then come back to the store. Sure, since they're both Ryobis they do have a lot of things in common, but that doesn't mean you'd ever substitute one for the other.
I won't list every difference, because there's a lot, but, to an approximation, the intersection of their two feature lists looks more-or-less like SML's feature list.
Java and .NET frameworks use threads, rationale being threads perform better. I won't go into that discussion, even if I do have an opinion. Right now, I'm just pointing to what others say.
It might be the only functional language developed “in house” at a major corporation, but it's not the only one supported by a big corporation, as Microsoft (under the GitHub name) is a leading sponsor of the new Haskell Foundation.
Jane Street and OCaml would be another good example of deep corporate involvement in an ML family language.
After playing around with it and porting some of my python work to F#....they may be right.
https://devblogs.microsoft.com/dotnet/announcing-f-5/#packag...
I am starting to use this to port some of python data munging scripts. Especially those that have to call external apis because Fsharp data providers are voodoo magic.
https://fsprojects.github.io/FSharp.Data/library/JsonProvide...
Really excited to see what ya'll have planned for 2021
I say that as someone who, prior to getting into the data space, was a fanatical partisan of static typing.
For actually implementing the core bits of analytics and ML tooling, I have a hard time seeing past languages that can match the performance of Fortran/C/etc and are able to expose a C ABI. Because those languages let you write one central, highly-optimized implementation that everyone can access from their favorite higher-level language.
i hope 11 years later we have a different attitude
The idea of keeping functions pure, when you can without making a mess of things, has pretty wide agreement.
The use of Option types instead of Null is getting to the point of being widespread (C# 9 sorta does it, Zig kinda does it, people love it in Rust and F#)
But other things like, passing partially applied functions to other functions, that to me is still really hard to reason about, especially with type inference on those function signatures. Immutable data structures, while nice to reason about sometimes have huge performance downsides. And computers aren't really getting faster in ways that help that much anymore.
It's a self-inflicted criticism. It's non-fpers saying that fp is too hard, not fpers.
Programmers in 2020: "Yeah some of the people on the team know how to use flatMap."
There is a whole series on C# to F#: https://fsharpforfunandprofit.com/posts/porting-to-csharp-in...
Syntax is fairly different but the concepts are broadly similar. Rust has many of the same nice things as F# does, like "if" as an expression rather than a statement, algebraic data types, mutability declared as a keyword, etc. In fact Rust is much stricter with the "declared mutability" thing, because in F# you can use an immutable reference to a mutable object to mutate the object.
The really big paradigm difference I found as an F# person when starting to learn Rust was the lack of guaranteed tail-call optimisation, meaning that Rust kind of wants you to avoid recursive functions. I also find it much more annoying to write sequences ("Iterators") in Rust than in F# (where the `seq` computation expression makes everything ludicrously easy at the cost of some oddly bad performance sometimes). F#'s anonymous interface implementations are also really handy, but Rust's situation there is at least no worse than C#.
Maybe I'm missing something. Under what use-cases would someone be choosing between OCaml/F# and Rust?
I think key to proper functional adoption is wide range entry level adoption (and not only university).
I simply don’t use any such languages.
But C#, F#, Go, Swift, Dart, etc.? They are initially populated by developers from a specific company, and will, from the start, have that company’s culture and goals implicitly ingrained. No outside developer will be able to climb the ladder and gain any appreciable mindshare to significantly affect this; the direction is set from the start and cannot be altered as long as the original developers (or their successors from the same company) are mostly still there. To get back to my example, Unix only really started to thrive once it was taken over by the BSD developers.
(I have written about this before on here. First six years ago (https://news.ycombinator.com/item?id=8733705) and again about two years ago (https://news.ycombinator.com/item?id=18370067).)
The list goes on.
So, yes, even though I don’t like Javascript as a programming language, I would not shy away from it merely because of its corporate roots.
I just mentioned 3 very popular and effectively best in class technologies that started at a corporation and now have robust open communities supporting them.
- Chez Scheme (Cisco)
- Erlang (Ericsson)
- Rust (Mozilla)
- Java (Sun Microsystems, Oracle)
The above examples show languages that outgrew the companies that developed them.
Typescript might follow a similar path in the future.
Edit: others on SO already pointed this out.
Also, IMO imperative programming generally maps better to the way business requirements are- First do this, then that, unless you see Y then do that. It’s harder to walk a BA or non technical manager through functional code and stand a chance of them tracking what’s going on.
Yes, modelling code around receiving requests and returning responses was a good idea.
> It’s harder to walk a BA or non technical manager through functional code and stand a chance of them tracking what’s going on.
Jane Street adopted OCaml as its main programming language early on because the language's functional programming style and clear expressiveness made it possible for code reviews to be performed by traders who were not programmers, to verify that high-performance code would do what it was intended to do.
Not really. Check out fsharp code and you use domain words to actually model the business case.
This is really old code, but it communicates Fsharp's effectiveness quite well. https://github.com/swlaschin/NDC_London_2013/blob/master/ddd...
Has the need to use functional programming languages become obvious yet? Has C/C++ et al. fallen by the wayside, yet?
Also, I seriously hope they won't. The whole point of C in this day and age is extreme simplicity and portability. The latest standard, C17, has only corrections. C11 has really all that's needed for "modern" applications, aka a threading library which is not pthreads and decent unicode support.
Lambda's: great! But real null-safety, strong type safety, proper sum types, pattern matching/ type destructuring, are now my requirements.
I'd say Kotlin is the language with the most adoption that ticks the boxes. And it is (not surprisingly) an OO lang.
How? Kotlin is decisively an object oriented language.
You can also check out C# since it fits your requirements. It has pattern matching, but sum types are still in the works.
https://www.reddit.com/r/csharp/comments/7b8mvn/have_sum_typ...
Most new languages I can think of have a concept of immutability and sum types. (Kotlin, Swift, Rust)
Many languages are in fact converging on what seems like a local optimum, with a blend of functional and non-functional idioms.
The line has become a lot blurrier, which makes the question hard to answer.
As much as a generation of Java programmers (like myself) grew up thinking that C++ was old hat and Java was its natural successor, C++ has been quietly ahead of Java with regard to lambdas, generics, type-level trickery. Not to mention performance and backward-compatibility [1].
But reading C++ makes my eyes bleed. I much prefer FP for business logic and web-app development. Haskell is fast but it's no C++, and that's OK. I wouldn't want Haskell to take C/C++ market-share. I want it to compete against other languages that don't give me performance, safety or terseness.
[1] C++17 on the Commodore 64: https://www.youtube.com/watch?v=zBkNBP00wJE
What does hero-code mean?
Allowing hero-coding in any language makes it harder to work as a team, so using language that leverages hero output only makes it worse. I wouldn't say that the power of the language is the thing that should be blamed.
I can certainly see that using constructs that the team as a whole isn't ready to adopt being a problem that also comes up in adoption of Scala.
As an anecdote, I see it come up with clojure a lot. Some of the clojure devs in my company can spin up a lot of interesting applications and fast. However, trying to read any of there code can be nearly impossible. Why? Usually because of a generous helping of their own metaprogramming constructs that they've built up over time. I've watched them program and it's both interesting and really hard to follow.
The big problem we've ran into is these clojure projects have been really hard for teams to get into. As a result, the worst thing has happened, many of them are being scrapped and rewritten in java because they are too hard to maintain otherwise.
The next question is whether this is from lack of common constructs/conventions by those new to F# or if it would always pervade as seems to be the case with Lisps. e.g. Clojure was specifically made to cover more in its library and syntax to promote standard styles.
Rather than thinking F# didn't/doesn't work, what were the reasons and what could be changed so it did work well?
Maybe some workflow changes like more design discussions before putting up a PR for review, or pair programming with rotating pairs so that conventions emerge. Also over time the codebase itself if it has benefited from convergence would show repeating patterns of adopted conventions.
I see the language itself as unapproachable only by reputation/lineage. In practice it can be on about the level of Elixir which is gaining traction and success stories.
In F# that would be an even bigger challenge. You could do it, but it would but way ugly. F# is my go-to language for side projects, but for anything server-side that I'm getting paid to work on, I'd be reluctant to suggest F# as a starting point, as much as I'd like to.
[1] - https://www.bing.com/version
[2] - https://devblogs.microsoft.com/dotnet/azure-active-directory...
[3] - https://www.microsoft.com/en-us/research/project/trill/
I think it's likely most of the serious problems there could have been fixed by smarter in memory caching: a few big objects instead of millions of small ones. However the whole experience left a sour taste in my mouth for overly allocation-happy code styles.
C# and F# also got compile-time analysis for working with spans, span-like, byrefs, etc. as of 2018 so that you can write some of this code yourself and have a reasonable assurance the the compiler will keep your code from allocating. Coding like this isn't easy either, but it's far simpler than it used to be because of the underlying types an compiler analysis that can help you.
IDK if any of it ever went anywhere though, as I left the team shortly thereafter.
The choice in that situation is to risk spending a few days debugging (50% at best success rate) or spend 20 minutes and use a ThreadPoolExecutor and you're done.
Java was the first programming language specced out by adults, and early to get a correct memory model and correct concurency primitives. 'correct' is a much better attribute than 'new' or 'shiny'.
For most developers, it's probably not using another language so you can "wait faster" most of the time. The performance sensitive code can be scrutinised and properly optimised on a case-by-case basis.
Maybe that function is waiting for a signal from Mars or a DNS lookup, or a 3GB file download, or for an O(N^2) algorithm to finish (e.g. does your "no code" tool know when to say "no"?,) but it hangs up everything else.
Web browsers are huge programs written in C++ by the greatest software development organizations and they block the render thread as little as possible, Javascript inherits this property as embedded in the browser and that is why it is so dominant on the front end.
Perhaps some more radical idea like breaking the application up into tasks that are killed in (say) 50ms and can be individually crashed (like Erlang) but going from that idea to conception is a lot of work -- one thing to do for a very simple mobile app, another to do write a framework you could write an IDE like VS Code in.
And that is what I find so irksome about the hand-wringing behind "Why isn't language X so popular?" is that if you really want to be doing something harder than what most people are doing you will need to thread a path from beginning to end and you're going to do that first through mastery of computer science (general) and second doing it through mastering your tools (specific).
There is so much path-dependence everywhere. I have gotten into the Arduino hobby lately. A 1970s computer scientist would think it was insane that it uses C instead of something more like Pascal or PL/I, that it should have a language that respects the Harvard architecture, etc.
They'd be right. C's a terrible language to use for that purpose, except that (1) the developers of Arduino could get a good C compiler and toolset off the shelf, (2) many people know how to program C, (3) you aren't wasting your time learning C, and (4) C isn't that bad, and (5) you can't write that big of a program for an Arduino anyway so you can only get into so much trouble with a "buffer overflows included" language.
F# first appeared in 2005. I think it is safe to say it is not 'new or shiny' anymore.
wait? synchronized? notify? notifyall? Fat threads and CompletableFutures that won't cancel? No thank you!
I'll take green threads and transactions over them any day!