[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] which paradigms does bash support
From: |
Andy Chu |
Subject: |
Re: [Help-bash] which paradigms does bash support |
Date: |
Wed, 14 Mar 2018 14:11:32 -0700 |
I think the best way to ground this type of discussion is to show code. I
wrote a couple articles last year that show shell's relation to the broader
subject of programming paradigms, with example code:
Shell Has a Forth-like Quality
http://www.oilshell.org/blog/2017/01/13.html
Pipelines Support Vectorized, Point-Free, and Imperative Style
http://www.oilshell.org/blog/2017/01/15.html
Andy
On Wed, Mar 14, 2018 at 12:56 PM, Pádraig Brady <P@draigbrady.com> wrote:
> On 14/03/18 00:22, Pierre Gaston wrote:
> > On Mon, Jan 26, 2015 at 6:05 PM, Pádraig Brady <P@draigbrady.com> wrote:
> >
> >> On 26/01/15 13:43, Greg Wooledge wrote:
> >>> On Sun, Jan 25, 2015 at 08:11:41PM -0800, garegin16@gmail.com wrote:
> >>>> As a programming language which paradigms does bash support.
> >> Declarative, procedural, imperative?
> >>>
> >>> This belongs on help-bash@gnu.org so I'm Cc'ing that address.
> >>>
> >>> Shell scripts are procedural.
> >>
> >> It should be noted that shell programming is closely related to
> functional
> >> programming.
> >> I.E. functional programming maintains no external state and provides
> >> data flow synchronisation in the language. This maps closely to the
> >> UNIX filter idea; data flows in and out, with no side affects to the
> >> system.
> >>
> >> By trying to use filters and pipes instead of procedural shell
> statements,
> >> you get the advantage of using compiled code, and implicit multicore
> >> support etc.
> >>
> >> cheers,
> >> Pádraig.
> >>
> >
> > Though I understand what you say and maybe you can see pipes as something
> > functional(ish),
> > I believe this is a misleading statement as imo shell scripting is not
> even
> > close to be functional in any kind of way.
>
>
> Well my point was, filters and pipes are similar to functional programming.
> IMHO shell scripts are generally better when using these concepts when
> possible,
> rather than using procedural shell statements.
>
> See also http://okmij.org/ftp/Computation/monadic-shell.html
>
> cheers,
> Pádraig
>
>