What happens when a successful OO language cross-pollinates with FP ideas?

There are programming languages, and there are the ways we use them. Sometimes the two line up, and sometimes our expectations and conventions obscure the full range of possibilities.

For example, many programmers who’ve never touched a line of C++ think of it as an object-oriented version of the ancient C language. And they’re not entirely wrong (after all, C++ is a direct evolution of an experiment called C with classes). And yet, any modern-day developer who actually uses C++ knows that it’s a wide-open multiparadigm language that can go in plenty of different directions.

C## is a different story — or is it? It started out as a streamlined, Java-influenced, thoroughly object-oriented language. (For a brief time, it was even codenamed Cool, for “C-like Object Oriented Language.”) But recently, the ground has been shifting. Among the many improvements in C## 9 — the version we’ll see released this year with .NET 5 — are some features that have the distinct flavor of functional programming.

Mads Torgersen, the lead C## language designer has been clear about his interest in functional programming. When asked what he would do if he had the chance to redesign C## from scratch, he said:

“C## started out very object-oriented, and has been adopting functional features over time. Starting over, I would probably try to strike a balance between the two from the get-go.”

(Side note: if you were expecting us to talk about Anders Hejlsberg, the creator of C#, let us update you. Hejlsberg is still active at Microsoft, but now spends most of his days heading up development on the TypeScript language.)

Clearly, the ideas of functional programming are exerting an influence at Microsoft. But is functional programming in C## a promising direction or a mere flash in the pan? Let’s take a look at the two most notable examples in C## 9.

#functional-programming #programming #csharp #oop

C# 9 Creeps Closer to Functional Programming
7.35 GEEK