Live data from Hacker News

Functional programming and the death of the Unix Way

newcome.wordpress.com

31–34 of 34 posts

Re: Functional programming and the death of the Unix Way

#31
post #12

The gist—as I understand it—is that Unix programs are essentially all equivalent to functions : ([String], TextStream) -> (TextStream, TextStream) which limits how one can tie them together and causes a proliferation of text-processing tools (awk, sed, grep, cut, &c &c) which is not as elegant as functional programming. There are already some Unix command-line tools that work on structured data as mentioned, e.g. jsa…

Just because data is in a text stream doesn't mean it is not structured. Awk is designed to handle structured text for example, the output of most (traditional) Unix tools is 'structured' too (eg., ls and ps). I recommend you read The Unix Programming Environment which gives many illustrations of how the Unix 'text streams' model works in practice. One of the authors of that book and other folks that created Inferno…

Traditional Unix stream processing assumes a specifically line-oriented structure, though, and is somewhat awkward in other cases. The Plan 9 people recognized that, and made some attempts to improve it, for example with Rob Pike's concept of "structural regular expressions" to describe streams that have a different "shape" than an array of lines: http://doc.cat-v.org/bell_labs/structural_regexps/

Re: Functional programming and the death of the Unix Way

#32
post #7

So basically the author is saying: The UNIX shell pipeline is really just a functional programming language whose functions can only operate on strings. Think how much more powerful, concise, readable, etc. it would be if other data types were supported. I agree. I don't even think this requires changes at the OS level. Newlisp and Racket's shell attempt might be clunky, and Clojure certainly isn't ready for quick-an…

> Think how much more powerful, concise, readable, etc. it would be if other data types were supported.

One of the reasons Unix is alive and well today is because of its simplicity. I'm not sure about the wisdom of introducing a system-wide type system.

Let's see who's using Microsoft's PowerShell 40 years from nos.

Re: Functional programming and the death of the Unix Way

#34
post #24
post #18

I had an idea to write Clojure parsers for the standard unix command line tools that translates the output into s-expressions. I got too frustrated - on the one hand, Clojure's slow start up time meant it was no fun to use in a simple pipe and on the other hand, even the simplist unix util has surprisingly complicated behavior. Like `wc` - it outputs three columns of numbers, right? Well, unless it knows filenames, w…

Not all functional languages run on the JVM or anything similar. In fact, most don't. See: Haskell, *ML, most Lisps and Schemes, ...

yeah, it's true. But I still think it's much harder to compose two functional programs running in separate processes than to write one monolithic program composing functional libraries.

Compare to perl, where piping text is so simple that chaining perl scripts with pipes is no harder than writing functions.

Post reply on HN