r/functionalprogramming • u/Voxelman • Feb 29 '24
Question Are "mainstream" languages dead?
I want to know what new languages are currently developed in the last few years, that have the potential to become at least some importance.
Because all new languages from the last years I know of have lots of things in common:
- No "Null"
- No OOP (or at least just a tiny subset)
- Immutability by default
- Discriminated Unions (or similar concept)
- Statically typed
- Type inference
- No exceptions for error handling
All newer languages I know have at least a subset of these properties like:
Rust Gleam Roc Nim Zig
Just to name a few I have in mind
In my opinion programming languages, both mainstream and new, are moving more and more towards more declarative/functional style. Even mainstream languages like C++, C# or Java add more and more functional features (but it's ugly and not really useful). Do traditional languages have any future?
In my opinion: no. Even Rust is just an intermediate step to functional first languages.
Are there any new (serious) languages that don't follow this trend?
View all comments
Show parent comment
2
u/xenomachina Mar 01 '24
Earlier you said:
However, the
thispointer/reference itself is not mutable in Java, or any other statically typed OOP language I can think of.Now you're talking about mutating what
thispoints-at/references. It's true that being able to mutate objects is incompatible with being purely functional, but mutation doesn't have anything to do with OOP. Java, C#, and C++ are all procedural/imperative OOP programming languages. It's the procedural/imperative part that makes them "not functional", not the OOP part.thisis a complete red herring here.More modern OOP languages like Kotlin, Scala, and Swift, while still being multi-paradigm (and so still allowing imperative code) encourage a more functional style than Java. (Even Java has added more functional features, though I feel it's a bit of a lost cause.) In the Kotlin code I've worked with, most objects are immutable, and when mutation is used it's often very restricted (like using
buildListassemble a list, which is then immutable once you leave that scope).The main pillars of OOP are subtype polymorphism and encapsulation. (Often these are described as 3 or 4 pillars, but they really boil down to these two.) There's no technical reason someone couldn't make a purely functional language with subtype polymorphism and encapsulation, ie: a purely functional OOP language. It could still have a
thispointer — every object (including the one referenced bythis) must be immutable.Yes,
someValuecould have been defined at multiple possible different scopes. I think any sufficiently advanced language, functional or not, has this issue. This has nothing to do with whether the language is functional or not, and is a consequence of having nested namespaces.thisis just another scope.It also isn't necessary for OOP languages to do things this way. In method definitions,
thisis really just an implied parameter to the function. Python (in)famously does not make this parameter implicit, nor does it implicitly add it as a containing scope to methods. It's still OOP, though.