3 ms·
Is there a reason it's always functional languages? Despite being HNs favourite paradigm, functional languages really are an obscure to most people. As soon a
by Gunax 6y ago
Is there a reason it's always functional languages?
Despite being HNs favourite paradigm, functional languages really are an obscure to most people.
As soon as there is a (convenient, useful) REPL for Java or c#, it will get picked up.
I know Java added a repl a few versions ago, so maybe we will start to see this in the Java world.
- Jtsummers 6y agoIt's not just functional languages. It's dynamic languages that tend to have a better REPL experience, because nearly the entire language can be used within the REPL, and nearly everything written in the REPL can be placed into conventional source files and used there without alteration. Additionally, both languages you listed (Java and C#) are batch-oriented. They assume you're compiling large units of code (at least a whole source file, which in Java means the entire class and all its methods and constructors). Translating that to a REPL is challenging. You now have to leave class definitions open (which is not the normal Java behavior, a class cannot be altered without jumping through hoops outside its initial definition). So you make those hoops available via special REPL-only constructs, your REPL is no longer a Java REPL, it's a partial-Java REPL with additional things. My primary REPL experiences have been with these languages: Python, Common Lisp, Erlang, Matlab. 2 of those are functional (as a primary part of their design, Common Lisp is multi-paradigm). Python has some functional elements, but is an OO/imperative language. And Matlab (at least when I used it) was definitely an imperative language. But the thing they all have in common is that nearly every line of code could be moved between the REPL and a source file without alteration (Erlang is deficient here in that you can't define functions in the same way in the REPL as in the source code, and I think Matlab had the same issue but it's been 15 years). Another thing that languages with a good REPL tend to have is a general trend towards being expression-oriented rather than statement oriented. What's the return value of an if statement in Java or C#? It doesn't have one, how would you interact with that in a REPL, then? In Common Lisp, if expressions return a value (the result of evaluating either the true or the false branch).
- The_rationalist 6y agoKotlin has a first class REPL and even has scripting mode.
- aidenn0 6y agoThe two ur-examples of Smalltalk and Lisp aren't particularly functional