News for hackers. Stuff that matters.
Re:Racket is 25 by ken on Sunday May 10, 2020 @01:14PM (#23134227)
> "If functional programming is that good, why is nobody using it?"

In the past 25 years, I think we've seen quite clearly that programming language popularity depends on many different factors, and "quality of he underlying paradigm" is way down on that list -- if it's even a factor at all.

Just a quick glance at any list of most-used-languages will tell you that 50% of popularity is "is it being pushed by a big company?", and 25% is "is it the primary interface for a popular platform?"

Take away those two factors and there's maybe only about 3 languages left in the top 25 (Python, Ruby, PHP?).

Where quality shines is in being able to stay a viable niche for a long period of time. That's Scheme.

Re:Racket is 25 by hintymad on Sunday May 10, 2020 @02:03PM (#23134610)
Oh, lots of people are using functional programming. They just don't use the paradigm exclusively nor do they use a purely functional programming language. Let's see,

- Supporting higher order functions in programming languages. Check.

- Usual operations on higher-order functions like currying? Check.

- Functional reactive programming. Check. Rx was a big thing a few years ago.

- Purely functional data structures. Check. Even Java has a few reasonably popular libraries that support such data structures.

- Using referential transparency whenever we can. Check.

- Using CPS (continuation-passing style) in daily programming. Check.

- Using recursion in production. This is not functional programming per se, but given that so many people mention recursion whenever they mention functional programming, it's worth listing recursion here. And mutual recursion and tail recursion, two of the hallmarks of entry-level functional programming techniques? Check and check. For instance, RxJava implements trampoline just to support tail-recursion, as it is necessary to implement cleanly some of RxJava's operators.

- Common techniques seen in functional programming, particularly the ones that involve map, reduce, scan, left-fold and right-fold. Check.

This is just the items that are on top of my mind. I'm sure I missed plenty. The gist is that people have been adopting functional programming. They just don't necessarily move to a purely functional programming language for practical reasons: platform, support, community, ecosystems, or even marketing. Programming paradigm is just one factor among many when people choose their programming languages.

Re:Racket is 25 by zelphirkalt on Sunday May 10, 2020 @08:22PM (#23137605)
One's missing out on a lot of advantages though, if one does not apply the paradigm quite broadly in a code base. Mostly referential transparency, how do you test your code, if you cannot be sure, that something is without side effects and have to check every single procedure? It takes away a lot of the appeal. If I write a program in functional style, I want some guarantees in return, which I don't get from half baked things. Easy testability, simple parallelization, composability of functions.
Re:Racket is 25 by sweeneyrod on Sunday May 10, 2020 @03:27PM (#23135356)
Who uses CPS in daily programming? Or do you mean using a compiler that uses it?
Re:Racket is 25 by Twisol on Sunday May 10, 2020 @04:03PM (#23135670)
The Visitor pattern is not much more than a CPS-style transform that lets you represent sum types in a language without them.

A CPS transform for a computation of type `X` gives a computation of type `forall A. (X -> A) -> A`. That is, instead of evaluating to ("returning") a value of type `X`, you take a function that you deliver a valid of type `X` to, and return whatever it returns.

CPS-transforming a sum type `X + Y` gives `forall A. (X + Y -> A) -> A`, and if you distribute over the sum you get `forall A. ((X -> A) * (Y -> A)) -> A`. The visitor is the pair of functions you pass in, `(X -> A) * (Y -> A)`, and the value decides which method to call. In either event, it returns whatever the chosen visitor method returns.

(Dropping into Java syntax, this is the type of the `visit` method: `<A> A visit(Visitor<A> visitor)` -- and the Visitor is `interface Visitor<A> { A onX(X x); A onY(Y y); }`.)

Re:Racket is 25 by agumonkey on Sunday May 10, 2020 @10:20PM (#23138283)
I cannot claim it is, but async/await, at least in ES seems to be a continuation monad without the do notation.
Re:Racket is 25 by skrishnamurthi on Sunday May 10, 2020 @04:50PM (#23136044)
Callback hell in JavaScript.
Re:Racket is 25 by hintymad on Sunday May 10, 2020 @04:06PM (#23135704)
Definitely in compiler, but also in daily JavaScript as a way to avoid deeply nested callbacks.
Re:Racket is 25 by emsal on Sunday May 10, 2020 @07:53PM (#23137427)
I'm no expert but I think that the async-await pattern is quite similar to CPS.
Re:Racket is 25 by hintymad on Sunday May 10, 2020 @04:12PM (#23135749)
And I forgot to mention all kinds of monads in various languages.
Re:Racket is 25 by chubot on Sunday May 10, 2020 @02:23PM (#23134774)
I think the second reason is probably more important. What languages were pushed by a big company but weren't a primary interface to a platform?

The only ones I can think of are Java and C#, which are very big languages, but combined they're dwarfed by these languages, which follow the second rule:

C (Unix), C++ (compatible with C), JavaScript (browser), Objective C (OS X and iOS), Kotlin (Android), bash (first program to run on the Linux kernel)

Re:Racket is 25 by user5994461 on Sunday May 10, 2020 @03:08PM (#23135186)
C# is a primary interface to the Windows platform.

Java is a primary interface to the Android platform (2008). When it was originally made decades ago (1996), it was supposed to be the first language for cross platform development (compile once run anywhere), it may not be one platform per se but it is equivalent in a way.

Re:Racket is 25 by chubot on Sunday May 10, 2020 @03:17PM (#23135272)
Yeah it's true that C# gives you more access to Windows than any other language, e.g. for GUIs and such. Java became popular without Android, but Sun was very much a platform company (Solaris -- they just didn't succeed in the long term.)

So basically the point is that the first reason is a special case of the second... Marketing alone does a little bit for a language, but having the platform is more important.

People choose platforms and not languages. Big companies are the ones that own platforms (Linux being an exception).

Re:Racket is 25 by user5994461 on Sunday May 10, 2020 @03:37PM (#23135424)
Oh right almost forgot about Solaris. ^^

I don't recall Solaris ever being any significant, so must have been a good argument that Java could run on the many Unix/Linux variants besides Solaris.

Re:Racket is 25 by samatman on Sunday May 10, 2020 @07:05PM (#23137143)
Solaris was huge, in the US at least, in the 90s.

I learned Unix and C on a SparcStation, and to this day I prefer workstations to other computers.

Even if Apple is the only one still making them...

Re:Racket is 25 by wbl on Sunday May 10, 2020 @09:23PM (#23137978)
When a desktop rivals some servers for power the workstation is dead.
Re:Racket is 25 by ken on Sunday May 10, 2020 @06:42PM (#23137009)
Sure, you can swap the relative importance of those factors if you like. My point is that an expert's concept of "quality" is not indicative of market success -- in programming languages, or any other. The 25 best-selling albums of the year are probably not the 25 best musicians, either.

But I'll try to answer anyway: Go. Dart. Maybe Rust (depending on whether nonprofits count). Delphi. All of these are in the TIOBE top 25 today.

Furthermore, languages like Kotlin, Swift, and C# became a primary interface to their respective platforms, but didn't necessarily start out that way. They got popular, and then became first-class platform citizens. It may have been the plan for them to eventually become that from the start, but I would claim they would have become popular even without the platform. So I put them in the first group.

You can write Windows programs in C# today, and many developers do, but I bet even more are using it for web development. And in a popularity contest (Zipf's Law), losing even half of your fans won't change your list position much.

Re:Racket is 25 by pjmlp on Monday May 11, 2020 @02:08AM (#23139317)
Go, Dart are pushed by Google, another big company.

Delphi was pushed by Borland, the InteliJ from the 90's, everyone doing indie development on MS-DOS and Windows early days was using Borland compilers, not Microsoft's.

Most Web development with C# is done on Windows anyway.

Re:Racket is 25 by agumonkey on Sunday May 10, 2020 @10:18PM (#23138275)
Functional programming main problem was its mathy roots (too dry, too abstract, too cryptic, too culturally alien). IMO.

Nobody (hyperbole) gives a damn about math, even though they'll all end up using the very same ideas in mainstream clothing.

It might not be obvious to half the dev crowd but most thing they're talking about since 5 years is basically 80s academic FP. Destruct, patterns, lambdas, folds ..

Re:Racket is 25 by przemo_li on Tuesday May 12, 2020 @08:34AM (#23153242)
math: I found out that if your operation is XYZ then ABC nobody: hurray! ... few decades latter programmers: how the f* do we do paralle? math: ... programmers: shut up! NO! NOOOOOO!
Re:Racket is 25 by agumonkey on Tuesday May 12, 2020 @12:32PM (#23155950)
- IT: we can't compute infinite data on finite machines !

- Cantor: smh

Re:Racket is 25 by przemo_li on Tuesday May 12, 2020 @08:29AM (#23153187)
Hey.

PHP do have its great niche.

Namely it's the only programming language where whole ecosystem lives and dies by the "build and burn the whole world on each request" mantra. It have significant advantages compared to other models of computation. (Granted even PHP devs often misplace "developer friendliness" of PHP, so you are not alone ;))

Re:Racket is 25 by user5994461 on Sunday May 10, 2020 @03:00PM (#23135099)
PHP was pushed by the LAMP platform and that was pretty much the only language to make dynamic web sites in the 1990s and onto the 2000s. (The alternative would be CGI scripts if I remember well?)

Ruby only has some popularity in the silicon valley. Never heard of companies really adopting Ruby outside of there. It's open to debate whether it can qualify as one of the popular languages.

Re:Racket is 25 by tonyedgecombe on Sunday May 10, 2020 @04:31PM (#23135907)
PHP was popular before LAMP came along, if anything LAMP came about because PHP was so common.

Early on its key feature was easy hosting, there were a lot of shared host sites where using anything other than PHP or maybe a bit of Perl was difficult.

Re:Racket is 25 by alexhutcheson on Monday May 11, 2020 @10:18AM (#23142382)
You could describe PHP as the primary interface to Apache. It would be straining the the metaphor a bit, but I'd say it's still a reasonable way to explain PHP's popularity. mod_php enabled shared hosting with reasonable performance. If mod_perl had been usable in an untrusted shared environment, then PHP might never have taken off the way it did.
Re:Racket is 25 by ken on Sunday May 10, 2020 @06:20PM (#23136847)
Ruby is definitely big in Seattle -- I would say bigger than Python or PHP, but that could just be my circles. In the language popularity lists I've seen, it's typically in the #11-15 slot, which is not too shabby.

The "LAMP platform" is defined by the set of people using PHP/Perl, so I wouldn't call it "pushed" by that. It's not the native platform of Linux, Apache, MySQL, or the web, and there wasn't exactly any big company pushing it (Facebook famously uses it but it had already cemented its popularity by then).