4 ms·
This looks really cool and promising! I was thinking of a shell along these lines, props to you for writing it. I do take issue with one of the things you wrot
by thinkpad20 12y ago
This looks really cool and promising! I was thinking of a shell along these lines, props to you for writing it.
I do take issue with one of the things you wrote though:
> a more complex program is formed by concatenating simpler programs, hence the term "concatenative programming". Compare this to the functional approach, where constructs are nested instead of connected one after another.
There's nothing about the functional approach that necessitates writing "nested" functions, as you describe. With higher-order functions, you can structure your code in almost any arbitrary way. In particular, haskell's >>= operator has this behavior, and you can easily write an operator like
x |> f = f x
to facilitate something like
2 |> addOne |> timesTwo |> show |> reverse |> putStrLn
Or whatever one desires :)
- xiaq 12y agoI was actually shown this by another Haskeller once, and I agree that Haskell is a very expressive language allowing for a myriad ways of doing things, including the concatenative paradigm. But I have always doubted that if the language doesn't explicitly endorse a particular paradigm, you will find it pretty awkward to work with other people. Which is why less expressive languages that emphasize particular ways of doing things still make sense.
- notduncansmith 12y agoElixir supports that syntax. It's a functional language that runs on the Erlang VM. I found it pretty fun in my experiments, you should check it out: http://elixir-lang.org/ http://elixir-lang.org/
- wging 12y agoSimilarly, Clojure has in its standard library (clojure.core) constructs called 'threading macros' which let you write pipelines just as you would here: (-> 2 addOne timesTwo str reverse (apply str) println)
- pjmlp 12y agoUNIX pipes are just a basic version of what is possible when data structures and objects are combined instead. Which was possible already in Lisp and Smalltalk based OS. Combining functions raises the experience to another level. :)