It’s just easier to reason about what a program will do, when the expressions more closely model an equation, no?
It’s just easier to reason about what a program will do, when the expressions more closely model an equation, no?
Minified JavaScript is not a fair comparison either. You can write scheme and lisp programs that are very readable. It annoys me when people conflate a terse and/or illegible programming style with functional programming.
We have abstractions and large languages so that humans can better understand the intent of a program. Isn't that exactly what this post is about, making a more readable lambda calculus interpreter?
Here is a less terse introduction: http://lambdaway.free.fr/workshop/?view=helloworld, using a regexp based implementation of a "dialect" of lambda-calculus.
Thanks for your interest.
The problem is, functional programming languages are almost always harder to read than other languages. Haskell is the obvious example, but Lisp is pretty bad too. It takes a bit of experience to be able to refactor in the middle of a Lisp block without messing up the balancing of the parentheses. Yes, it can be learned, and it can be learned faster than people expect. But the barrier to entry is much higher than it is for most languages.
By the way, I love both Haskell and Lisp, and I think more people should use them. But I'm not going to pretend it's easy get started working with those languages.
F# and other languages ML-style syntax are probably the easiest to read.
I think we can all agree APL is incomprehensible moon language, though /s.
Would you have any good book recommendations? Or any recommendations, really? I'm just asking in the chance that you do.
There was a gorgeous article submitted a couple of days ago:
http://www.jsoftware.com/papers/50/
That should serve as a good intro.
Software Engineering can be regarded as a discipine in which we strive for the understandability of programs which cannot possibly fit into a person's field of view all at once.
APL went all the way with this and assigned many reasonably complex operations on complex datastructures to single character symbols. Once you know those symbols the code is about as hard to understand as any other language that you've mastered. It's just that because the symbols are not used in any other language family that you are going to struggle quite a bit in the beginning. It's like trying to ready Cyrillic.
By the way, a 10x20 window: isn't that like a wasteland of wast proportions to an APL programmer?
I double-click on one parenthesis and the whole expression gets selected - I can then operate on it. How would I mess up the balancing?
The only way to mess up the balancing is editing without s-expression support. No Lisp programmer would do that.
Well, in the past they did.
BBN Lisp (later known as Xerox Interlisp) had already a structure editor in the 60s.
http://www.softwarepreservation.org/projects/LISP/bbnlisp/BB... see page 40ff.
A lot of editing support was then developed in the 70s with the various Emacs editors (TECO Emacs, Zmacs, Multics Emacs, ...) or the Interlisp editors. In the 80s various Lisp IDEs had support for editing Lisp on PCs, Macs, Unix-Workstations, Lisp Machines, ...
There are many legitimate reasons to dislike Haskell, such as being hard to parse mechanically, but being hard to read is not one of them.
> F# and other languages ML-style syntax are probably the easiest to read.
The syntax of ML's module language is pretty complicated. You cannot look at those “where type” (SML) and “with type” (OCaml) clauses and tell me with a straight face that they were meant to be easy to read. This syntax makes translucent ascription harder to read than it ought to be. It is so bad that many[0] people work around it in various ways, like using the combination of generative datatypes and transparent ascription as a poor man's translucent ascription.
As for F#, I would not call it ML-style, precisely due to the inability to express modular abstraction.
[0] Relative to the size of the ML community, of course.