[GRASS-dev] Re: 'g.gui wxpython' won't work in wingrass as wxgui is a shell scrip

On Mar 19, 2008, at 7:11 PM, grass-dev-request@lists.osgeo.org wrote:

Date: Wed, 19 Mar 2008 23:10:29 +0600
From: Ivan Shmakov <ivan@theory.asu.ru>
Subject: [GRASS-dev] Re: 'g.gui wxpython' won't work in wingrass as
  wxgui is a shell script
To: grass-dev@lists.osgeo.org
Cc: Ivan Shmakov <oneingray@gmail.com>
Message-ID: <m2lk4efxmi.fsf@cherry.siamics.int>
Content-Type: text/plain; charset=us-ascii

Michael Barton <michael.barton@asu.edu> writes:

Not really. Simple tasks can be done with just the GUI.

One certainly won't go far only doing simple tasks.

First a context statement that may seem a bit odd given my comments below. I strongly encourage social and natural scientists to be able to think about processes in algorithmic terms -- "computational thinking" in current NSF jargon -- and I have several large projects in the works to develope ways to encourage this broadly in the sciences. I also program, although completely self taught with all of its pitfalls, and encourage my students to learn programming skills as needed.

Actually you can do some pretty complex stuff with the GUI. Try it.

  Actually I've meant the ``... but it might take you a LOT
  longer...'' cases specifically here.

  Nowadays, it seems that even computer programmers, let alone
  users, have very little experience with programming [1].

Agreed. In many cases it is simply unnecessary. I think that it is a good idea to know how an automobile works and be able to do some level of repairs or maintenance on it. BUT for many people, this is a waste of very precious time and unnecessary in order to drive the car from point A to point B. When I was a graduate student, one had to learn to program to get any use out of a computer. Now you can do an enormous amount of useful work without knowing a bit of programming. I think this is great. Nothing wrong with programming. But why MUST one learn it when it is not necessary to use the computer as a tool?

  Consequently, even a simple ``show me a MODIS Total Totals index
  on a map'' task becomes unsolvable by adding a ``... for every
  day of july, 2007'' bit to it.

Yes, this is a task that programming would help with. But it is a task that the great majority of computer users never need to do.

[1] http://www.stsc.hill.af.mil/CrossTalk/2008/01/0801DewarSchonberg.html

  Perhaps, my perception is influenced quite heavily by my
  experience with remote sensing (and to have 100 rasters per day
  for a monthly interval is hardly an untypical situation.) But I
  really believe that an ``average computer user'' is expected to
  know at least a couple of programming languages.

This doesn't match with your statement above. In fact, I'd wager that the average computer today user knows absolutely NO computer language at all. People have a lot to do in limited time. Learning and using programming languages requires a significant investment of time. Why should they learn 2 or more computer languages when it is of no use to getting their work done? Why would any employer want their employee to do so when it is unnecessary to use a computer?

  Unfortunately, typical GUI cannot be easily programmed and thus
  (as it seems to me) discourages programming way too often.
  (Though the GRASS GUI seems to be on the right way to overcome
  this problem.)

So we should make applications more difficult to use so that users are forced to get the character-building experience of learning to program? That doesn't seem to be a good way to make analytical tools available to users who need them. That seems a way to make sure that only a very limited group of specialists can use computational tools. Is that what we want?

People should learn programming if it helps them solve problems. There is no reason except the history of computation why computational devices should be controlled by typing English words on a screen in a particular syntax. Furthermore, typing words is not the not a particularly "normal" way for humans to manipulate representations of spatial relationships. We are much more accustomed to represent spatial relationships through gestures, for example.

More complex tasks really deserve a proper programming language. The
range inbetween, where bash is a reasonable solution, is actually
quite narrow.

The only thing that I have to say in the defense of Bash is that
the little languages always have a narrow, but not a negligible
niche.

The thing that bash allows you to do is to chain together the same
commands that you get in the GUI. That is, you can do the same stuff
in the GUI that you can do by scripting, but it might take you a LOT
longer to accomplish it.

  Well, yes, but would one's actions be accurate after doing the
  same for 10 times? or 100 times? or 1000?

  Apart from the obvious unreliability of a tired user, any real
  life task has its time constraints.

I agree absolutely. This is the advantage of being able to script GRASS if you need and want to do it. A GUI has its place and so does combining operations to automate a series of repetitive, error-prone tasks. This is why GRASS definitely needs to remain completely scriptable. But this is not an either or with GUI use. One should not be forced or encouraged to use either method to access commands.

In fact, I'd love to see the addition of other ways to manipulate the tools that make up GRASS. For example, a year ago, I saw a demo of a great visual environment for creating GIS models by combining commands. Some command objects could be nested inside other command objects or linked to command objects through graphic representations. OSSIM does something along this line.

I personally might prefer to type some stuff--because I'm used to it--but this could be a very powerful way to apply algorithmic thinking to the creation of multi-process, interative geospatial models.

Any scripting language that can interact with GRASS commands (i.e.,
most of them) can serve this same purpose. You can do it with Python,
PERL, Java, TclTk, etc. Bash is handy because it comes preinstalled
on Linux and Mac systems (and sh on earlier Unix systems) and was
consistently available even when other scripting languages were not.
It is only for this historical reason that it has become a standard
for scripting in GRASS.

  Yes.

IMHO, it's a pretty primitive and opaque programming language (e.g.,
you have to use another scripting language like awk to do floating
point math).

  That's quite a frequent practice (consider, e. g., `expr' in
  Tcl, or Cpp for C.) I don't think it should be afraid of.

expr does not call another language in TclTk, it simply signals to evaluate an expression--any experession.

You can do a lot with it, but it is not easy to do or to deconstruct
(or debug) what others have done. I say this in spite of having made
a number of the existing GRASS Bash scripts, including some pretty
complex ones (e.g., d.vect.thematic).

  Real programmers can write Shell in any language, I guess.

  To put it serious, it seems to me that the potential of the
  Shell wasn't fully exploited. (After all, where's that library
  of the Shell functions deemed useful for a GRASS programmer?)

With GRASS 7 and opening up of GRASS for Windows, we have an
opportunity to modernize scripting on GRASS (Note I am not a Windows
user). There will always be people who script in Bash. It's great
that one can do so.

  Yes, it certainly makes sense to support many different
  languages available for GRASS scripting.

However, I think that it would benefit the community settle on a new
scripting "standard" that is truly cross- platform and an easier,
more up-to-date, powerful, and easier to use language. There are
several good candidates for this, but Python has a number of
pragmatic advantages in the current context.

  Indeed, it may be a reasonable decision. (Though it'd be
  interesting for me to know what are the particular problems with
  Tcl, which is both portable and was used in GRASS for quite some
  time?)

TclTk is a nice GUI platform, but there are some limitations especially with the creation of graphic canvases. We went through them in detail a couple years back. It's on the WIKI I think. If not, I think I've got copies of the discussions and can send them to you. It also turns out that TclTk for Mac has problems, which is why GRASS for Mac is distributed with X11 TclTk instead of the aqua version--though maybe these are getting fixed with 8.5 and above.

However, beyond a platform for GUI development, Python (i.e., not wxPython) is more full-featured as a general purpose programming language. It is also a lot easier to use than bash. And this will hopefully will encourage more people to try their hands at programming tasks in GRASS. I don't want to make programming a requirement, but I DO want to make it easier for users to create programs to solve problems with GRASS when they need to do so. And I DO want to encourage social and natural scientists to conceptualize system dynamics in algorithmic ways. This is easier done if people have some programming experience.

What this means is that we need to have Python people volunteer to
begin to rewrite existing Bash scripts in Python and begin writing
any new scripts in that platform so that we can have the critical
mass to encourage others to learn it and write in it. A couple people
have started on this.

  I'm afraid that an attempt to rewrite /all/ the Shell scripts in
  Python will both take time and bring some mess along. Would
  you, e. g., consider an untested 100-lines Python substitute for
  a 50-lines Shell script (that's known to be working for years)
  to encourage anyone to write in Python?

Actually, from my limited experience, I'd suspect that it would be the other way around--50 lines of code or less in Python to replace 100 lines of bash shell script, and be easier to read.

The shell scripts distributed with GRASS are an integral part of the distribution package. To the average user, they are functionally equivalent to the modules programmed in C. We need to replace shell scripts with the same functions in a portable cross-platform language if we want GRASS to work well on non-POSIX systems (primarily Windows). IMHO, it would be (and is) problematic to continue to release GRASS with a significant number of critical modules that fail on a very common OS. There really aren't all that many that would need to be replaced. Some of them might well even work better if re-written.

  If there're particular strong points of Python, they're to be
  exploited first (is wxPython among the others?)

Python is the general purpose object-oriented programming language. wxPython is a Python port of the wxWidgets GUI interface development platform. You can do all scripting of GRASS in Python without employing wxPython at all. However, Python is needed in order to use wxPython for GUI development.

Michael

Michael Barton <michael.barton@asu.edu> writes:

>>>>> Not really. Simple tasks can be done with just the GUI.

>>>> One certainly won't go far only doing simple tasks.

> First a context statement that may seem a bit odd given my comments
> below. I strongly encourage social and natural scientists to be able
> to think about processes in algorithmic terms -- "computational
> thinking" in current NSF jargon -- and I have several large projects
> in the works to develope ways to encourage this broadly in the
> sciences. I also program, although completely self taught with all of
> its pitfalls, and encourage my students to learn programming skills
> as needed.

  I'll try to keep the above in mind while replying.

  I should also note that I'm primarily concerned with the
  programming expertise (or rather, the lack of) of natural
  scientists, too. So I believe we aren't contradicting each
  other that much.

>>> Actually you can do some pretty complex stuff with the GUI. Try it.

>> Actually I've meant the ``... but it might take you a LOT
>> longer...'' cases specifically here.

>> Nowadays, it seems that even computer programmers, let alone users,
>> have very little experience with programming [1].

> Agreed. In many cases it is simply unnecessary.

  It is unnecessary for computer programmers to have experience
  with programming? That sounds strange, at least.

> I think that it is a good idea to know how an automobile works and be
> able to do some level of repairs or maintenance on it. BUT for many
> people, this is a waste of very precious time and unnecessary in
> order to drive the car from point A to point B. When I was a graduate
> student, one had to learn to program to get any use out of a
> computer. Now you can do an enormous amount of useful work without
> knowing a bit of programming. I think this is great. Nothing wrong
> with programming. But why MUST one learn it when it is not necessary
> to use the computer as a tool?

  It depends on where we'd draw a demarcation line.

  Given the number of devices which do contain certain electronic
  circuitry within them, and that that circuitry is often based on
  MCUs, which are, technically, almost finished computers, it
  seems to be obvious that it isn't necessary to learn programming
  in order to use an MCU-powered flat iron, or a car.

  On the other hand, a desktop computer is not a flat iron.

>> Consequently, even a simple ``show me a MODIS Total Totals index on
>> a map'' task becomes unsolvable by adding a ``... for every day of
>> july, 2007'' bit to it.

> Yes, this is a task that programming would help with. But it is a
> task that the great majority of computer users never need to do.

  It's rather a task the great majority of computer users never
  heard nor thought of. And how could one decide whether he needs
  something, if he's unaware of its presence beforehand?

>> [1] http://www.stsc.hill.af.mil/CrossTalk/
>> 2008/01/0801DewarSchonberg.html

>> Perhaps, my perception is influenced quite heavily by my experience
>> with remote sensing (and to have 100 rasters per day for a monthly
>> interval is hardly an untypical situation.) But I really believe
>> that an ``average computer user'' is expected to know at least a
>> couple of programming languages.

> This doesn't match with your statement above.

  Unfortunately, yes. There's a certain mismatch between the
  present state of affairs (as I view it) and my expectations.
  That contributes a share to my motivation to work in the field.

> In fact, I'd wager that the average computer today user knows
> absolutely NO computer language at all. People have a lot to do in
> limited time. Learning and using programming languages requires a
> significant investment of time.

  Yes, so every opportunity has to be exploited to shorten this
  time, unless the quality of the learning will degrade as a
  consequence.

> Why should they learn 2 or more computer languages when it is of no
> use to getting their work done?

  Could you please name a field of human activity which doesn't
  rely on one doing repetitive tasks and where the use of
  computers would be appropriate at the same time?

> Why would any employer want their employee to do so when it is
> unnecessary to use a computer?

  The concerns I've expressed were solely about the computer
  users.

>> Unfortunately, typical GUI cannot be easily programmed and thus (as
>> it seems to me) discourages programming way too often. (Though the
>> GRASS GUI seems to be on the right way to overcome this problem.)

> So we should make applications more difficult to use so that users
> are forced to get the character-building experience of learning to
> program?

  So we should ensure that GRASS continues ``to remain completely
  scriptable.''

> That doesn't seem to be a good way to make analytical tools available
> to users who need them. That seems a way to make sure that only a
> very limited group of specialists can use computational tools. Is
> that what we want?

  Do we want for the programming tools to be accessible to a very
  limited group of specialists instead? And it's what we're going
  to go by assuring the ``average users'' that the present day's
  use of computers doesn't require one to program anymore.

> People should learn programming if it helps them solve problems.

  People should learn the basics of programming to be able to
  decide whether it will help them solve problems.

  One's perception, and one's decisions, are heavily influenced by
  the prior experience and knowledge. There's no way for you to
  decide the applicability of a tool, or a certain knowledge,
  without knowing a bit of it first. And my personal experience
  shows that the majority of computer users just don't know what
  the programming is for, nor what they could achieve by writing
  programs. And once this matter is clarified at least a bit,
  some of them become quite eager at getting in it.

  To clarify it is the hardest part, though.

> There is no reason except the history of computation why
> computational devices should be controlled by typing English words on
> a screen in a particular syntax. Furthermore, typing words is not the
> not a particularly "normal" way for humans to manipulate
> representations of spatial relationships. We are much more accustomed
> to represent spatial relationships through gestures, for example.

  However, you should note that speech is the most developed form
  of human communication. It's probably the most robust as well.
  It exists in a variety of forms -- oral, written, braille. How
  would you transmit a gesture by phone? Would gestures help you
  to communicate with a visually impaired person?

  You may consider comparing the popularity of the Picto and
  Esperanto languages. While Esperanto is actively used, Picto
  seems to be mostly forgotten. I relate this to the fact that
  Picto wasn't based on a conventional writing system.

  I don't know whether to use letters or symbols (and isn't
  `printf' a symbol?) is a ``natural'' or ``normal'' way for
  humans to communicate, but I'm quite certain that this way was
  used broadly throughout the history of mankind. So, yes, it was
  the history why the computational devices are controlled by
  typing words. But it's not just the history of computation.

  As to the use of English, it became the international language
  for the computer-related matters. And yes, it's not
  unreasonable for a computer user to learn English in order to
  use computers as well. Having said that, I do /not/ think that
  the i18n and l10n efforts are a waste of time.

>>>>> More complex tasks really deserve a proper programming language.
>>>>> The range inbetween, where bash is a reasonable solution, is
>>>>> actually quite narrow.

>>>> The only thing that I have to say in the defense of Bash is that
>>>> the little languages always have a narrow, but not a negligible
>>>> niche.

>>> The thing that bash allows you to do is to chain together the same
>>> commands that you get in the GUI. That is, you can do the same
>>> stuff in the GUI that you can do by scripting, but it might take
>>> you a LOT longer to accomplish it.

>> Well, yes, but would one's actions be accurate after doing the same
>> for 10 times? or 100 times? or 1000?

>> Apart from the obvious unreliability of a tired user, any real life
>> task has its time constraints.

> I agree absolutely. This is the advantage of being able to script
> GRASS if you need and want to do it. A GUI has its place and so does
> combining operations to automate a series of repetitive, error-prone
> tasks. This is why GRASS definitely needs to remain completely
> scriptable.

  I agree with the above.

> But this is not an either or with GUI use. One should not be forced
> or encouraged to use either method to access commands.

  There's no need to force anyone to use either method.

> In fact, I'd love to see the addition of other ways to manipulate the
> tools that make up GRASS.

  So would I.

> For example, a year ago, I saw a demo of a great visual environment
> for creating GIS models by combining commands. Some command objects
> could be nested inside other command objects or linked to command
> objects through graphic representations. OSSIM does something along
> this line.

  Either way, it'd be a symbolic notation for writing programs.
  It hardly matters, whether it'd be a word (`mov'), a
  pseudographical symbol (`:=', `<-'), or a graphical arrow, to
  represent an assignment, for example.

  But certainly, a rich set of tools to manipulate ASCII files is
  available, and if the program isn't stored in such a file, it
  may become troublesome to handle it in automagical ways.

> I personally might prefer to type some stuff--because I'm used to
> it-- but this could be a very powerful way to apply algorithmic
> thinking to the creation of multi-process, interative geospatial
> models.

  For the reasons I hope I've explained above, I doubt that that'd
  be an effective mean of programming. However, I have no intent
  to prevent, or discourage, anyone from experimenting in this
  field. It may be quite an enlightening experience, after all.

[...]

>>> Bash is handy because it comes preinstalled on Linux and Mac
>>> systems (and sh on earlier Unix systems) and was consistently
>>> available even when other scripting languages were not. It is only
>>> for this historical reason that it has become a standard for
>>> scripting in GRASS.

>> Yes.

>>> IMHO, it's a pretty primitive and opaque programming language
>>> (e.g., you have to use another scripting language like awk to do
>>> floating point math).

>> That's quite a frequent practice (consider, e. g., `expr' in Tcl, or
>> Cpp for C.) I don't think it should be afraid of.

> expr does not call another language in TclTk, it simply signals to
> evaluate an expression--any experession.

  It depends on what you do mean by ``calling'', and how it's
  different from ``signalling''. IIRC, there were a lot of Tclers
  to consider the `expr' syntax separate from the Tcl's own one.

  As for a little language that is (or was?) available for Tcl as
  a separate package, you may consider Tcl-nap:

http://tcl-nap.sourceforge.net/

  On the other hand, per POSIX, AIUI, C preprocessor is a part of
  C, and `expr' is a part of the Shell language.

[...]

>>> However, I think that it would benefit the community settle on a
>>> new scripting "standard" that is truly cross- platform and an
>>> easier, more up-to-date, powerful, and easier to use
>>> language. There are several good candidates for this, but Python
>>> has a number of pragmatic advantages in the current context.

>> Indeed, it may be a reasonable decision. (Though it'd be
>> interesting for me to know what are the particular problems with
>> Tcl, which is both portable and was used in GRASS for quite some
>> time?)

> TclTk is a nice GUI platform, but there are some limitations
> especially with the creation of graphic canvases. We went through
> them in detail a couple years back. It's on the WIKI I think. If not,
> I think I've got copies of the discussions and can send them to you.
> It also turns out that TclTk for Mac has problems, which is why GRASS
> for Mac is distributed with X11 TclTk instead of the aqua version--
> though maybe these are getting fixed with 8.5 and above.

> However, beyond a platform for GUI development, Python (i.e., not
> wxPython) is more full-featured as a general purpose programming
> language.

  Could you outline a few of advantages of Python over Tcl (i. e.,
  without Tk)?

> It is also a lot easier to use than bash.

  I guess that depends on a task.

  Is Python suitable for use as an interactive Shell for GRASS,
  for instance?

> And this will hopefully will encourage more people to try their hands
> at programming tasks in GRASS.

  I hope so.

> I don't want to make programming a requirement, but I DO want to make
> it easier for users to create programs to solve problems with GRASS
> when they need to do so.

  However, given that with the transition to Python a POSIX Shell
  will become optional, some of the GRASS/W32 users may become
  inclined to use cmd.exe with GRASS. And it doesn't seem to be a
  particularly good way to encourage GRASS users to try GRASS
  scripting.

> And I DO want to encourage social and natural scientists to
> conceptualize system dynamics in algorithmic ways. This is easier
> done if people have some programming experience.

>>> What this means is that we need to have Python people volunteer to
>>> begin to rewrite existing Bash scripts in Python and begin writing
>>> any new scripts in that platform so that we can have the critical
>>> mass to encourage others to learn it and write in it. A couple
>>> people have started on this.

>> I'm afraid that an attempt to rewrite /all/ the Shell scripts in
>> Python will both take time and bring some mess along. Would you,
>> e. g., consider an untested 100-lines Python substitute for a
>> 50-lines Shell script (that's known to be working for years) to
>> encourage anyone to write in Python?

> Actually, from my limited experience, I'd suspect that it would be
> the other way around--50 lines of code or less in Python to replace
> 100 lines of bash shell script, and be easier to read.

  If it would, then go for it.

  But I doubt it would unless a considerable time is put into the
  creation of an adequate library of wrappers.

[...]

Ivan Shmakov wrote:

>> Nowadays, it seems that even computer programmers, let alone users,
>> have very little experience with programming [1].

> Agreed. In many cases it is simply unnecessary.

  It is unnecessary for computer programmers to have experience
  with programming? That sounds strange, at least.

I would agree that it's at least useful (even if not absolutely
necessary) for *programmers* to have programming experience.

However, the demand for programming skills is growing faster than
those skills can be acquired. Consequently, the average level of
experience is decreasing.

Nowadays, there are a lot of programmers whose only experience is the
PHP/JavaScript web application for which they learnt programming in
the first place.

If you're thinking of programmers in terms of people with Computer
Science (or Software Engineering etc) degrees, or people who taught
themselves back in the days of the 8-/16-bit home micros, they're a
small minority. There are many more people who started off as web
designers and have learnt just enough PHP/Perl/Java/JavaScript to get
the job done. Or who learnt VB/VBScript for writing MS-Office macros.

>> Unfortunately, typical GUI cannot be easily programmed and thus (as
>> it seems to me) discourages programming way too often. (Though the
>> GRASS GUI seems to be on the right way to overcome this problem.)

> So we should make applications more difficult to use so that users
> are forced to get the character-building experience of learning to
> program?

  So we should ensure that GRASS continues ``to remain completely
  scriptable.''

There is a never-ending tension between simplicity and capability.

This tension tends to manifest itself as an argument between those
believe that simplicity is the ultimate goal, and those who also want
capability.

Unfortunately, the simplicity camp tends to grant zero weight to
capability issues, and often tries to paint those who also want
capability as simply being fundamentally oppsed to simplicity.

> expr does not call another language in TclTk, it simply signals to
> evaluate an expression--any experession.

  It depends on what you do mean by ``calling'', and how it's
  different from ``signalling''. IIRC, there were a lot of Tclers
  to consider the `expr' syntax separate from the Tcl's own one.

  As for a little language that is (or was?) available for Tcl as
  a separate package, you may consider Tcl-nap:

I would agree that "expr" is not part of the Tcl language. It's a
standard function, not a language construct. In most languages,
arithmetic is a language construct (except functional languages, where
almost everything is a standard function, but there, each arithmetic
operator is a separate function).

This is relevant insofar as e.g. the C expression:

  foo(a+b, c+d);

looks like:

  foo [expr $a + $b] [expr $c + $d]

in Tcl. The Tcl syntax is rather ugly if you do a lot of arithmetic.

  On the other hand, per POSIX, AIUI, C preprocessor is a part of
  C, and `expr' is a part of the Shell language.

On the last point, "expr" *may* be a shell built-in, but it may also
be an external command.

So far as POSIX is concerned "may be a shell built-in" simply means
that you can't assume that you can invoke it directly via e.g.
execl(), as it might not exist as a separate program. If you're
writing a shell script, it doesn't matter whether something is a
built-in.

> However, beyond a platform for GUI development, Python (i.e., not
> wxPython) is more full-featured as a general purpose programming
> language.

  Could you outline a few of advantages of Python over Tcl (i. e.,
  without Tk)?

Tcl has many of the same defects as the Bourne shell.

Languages which are based primarily upon textual substitution are
simple to implement, and it's simple to describe the (relatively few)
rules which define the language, but they're a nuisance to program in.

Such languages tend to encourage over-use of "eval", which produces
messy code, and can cause problems when data values contain language
metacharacters (Lisp's "eval" doesn't have the latter problem, as it
doesn't involve parsing).

Another problem is the "everything is a string" model. This creates
problems with different representations of the same value. E.g. are
"12", "12.0" and "012" all equal? There are also problems with
constructing structured values (e.g. lists) using string operations,
e.g.:

  set x "$a $b $c"
versus:
  set x [list $a $b $c]

The former does the wrong thing when a variable contains spaces.

If you want more evidence of the problems with the use of textual
substitution in programming, search the archives of BugTraq and other
security-related lists for "SQL injection" and "shell injection".
Manipulating structured data by manipulating its string representation
will always be error-prone.

> It is also a lot easier to use than bash.

  I guess that depends on a task.

  Is Python suitable for use as an interactive Shell for GRASS,
  for instance?

Not at all. For similar reasons, interactive shells aren't
particularly suitable for use as programming languages.

The Bourne shell is a good interactive shell because it was designed
for use as an interactive shell. It isn't a good programming language
because it was designed for use as an interactive shell, not as a
programming language.

cmd.exe isn't a particularly good interactive shell, but it's good
enough for most usage. Although bash has far more features, most of
them are primarily for use in scripts rather than interactive use.

> I don't want to make programming a requirement, but I DO want to make
> it easier for users to create programs to solve problems with GRASS
> when they need to do so.

  However, given that with the transition to Python a POSIX Shell
  will become optional, some of the GRASS/W32 users may become
  inclined to use cmd.exe with GRASS. And it doesn't seem to be a
  particularly good way to encourage GRASS users to try GRASS
  scripting.

For how long are you going to keep trying to conflate command-line use
with scripting?

Right now, we include Bourne-shell scripts and a Bourne shell. When
the scripts are written in Python, we'll include (or at least require)
Python.

Neither of those will be familiar to the average Windows user, so if
they want to write scripts, they need to learn one. They would be a
lot better off learning Python.

--
Glynn Clements <glynn@gclements.plus.com>

Glynn Clements <glynn@gclements.plus.com> writes:

>>>> Nowadays, it seems that even computer programmers, let alone
>>>> users, have very little experience with programming [1].

>>> Agreed. In many cases it is simply unnecessary.

>> It is unnecessary for computer programmers to have experience with
>> programming? That sounds strange, at least.

> I would agree that it's at least useful (even if not absolutely
> necessary) for *programmers* to have programming experience.

> However, the demand for programming skills is growing faster than
> those skills can be acquired. Consequently, the average level of
> experience is decreasing.

> Nowadays, there are a lot of programmers whose only experience is the
> PHP/JavaScript web application for which they learnt programming in
> the first place.

> If you're thinking of programmers in terms of people with Computer
> Science (or Software Engineering etc) degrees, or people who taught
> themselves back in the days of the 8-/16-bit home micros, they're a
> small minority. There are many more people who started off as web
> designers and have learnt just enough PHP/Perl/Java/JavaScript to get
> the job done. Or who learnt VB/VBScript for writing MS-Office macros.

  It's unfortunate that this minority is ought to satisfy the
  evergrowing demands of the other part of the users. It both
  makes the programmers strained by their work, and makes the
  users unsatisfied with the results.

  There's a certain line one has to cross in order to get into the
  programming. And the current computer system marketers' motto
  ``you don't have to learn to use it'' just makes it harder for
  an average user to do so.

[...]

>>> expr does not call another language in TclTk, it simply signals to
>>> evaluate an expression--any experession.

>> It depends on what you do mean by ``calling'', and how it's
>> different from ``signalling''. IIRC, there were a lot of Tclers to
>> consider the `expr' syntax separate from the Tcl's own one.

>> As for a little language that is (or was?) available for Tcl as a
>> separate package, you may consider Tcl-nap:

> I would agree that "expr" is not part of the Tcl language. It's a
> standard function, not a language construct. In most languages,
> arithmetic is a language construct (except functional languages,
> where almost everything is a standard function, but there, each
> arithmetic operator is a separate function).

  Well, you seem to be talking about the language syntax, and the
  programming language as a whole isn't only the syntax -- it's
  the standard library, too. And thus the syntax used by its
  facilities belongs to the language.

  Thus, `expr' is, indeed, a part of the Tcl language, as well as
  its syntax.

  I don't think that it matters much, though.

> This is relevant insofar as e.g. the C expression:

> foo(a+b, c+d);

> looks like:

> foo [expr $a + $b] [expr $c + $d]

  Or, avoiding the textual substitution:

foo [expr {$a + $b}] [expr {$c + $d}]

> in Tcl. The Tcl syntax is rather ugly if you do a lot of arithmetic.

  Yes. The aforementioned Tcl-nap package seems to help a lot by
  allowing, e. g.:

nap { a = { 1 .. 5 } }
nap { b = 2 * $a + 1 }

  A number of GNU R-like constructs is available as well, and even
  some ability to operate on georeferenced data (or is it?)

  Unfortunately, it has (had?) some problems with the build system
  (the use of M4 for C preprocessing C files contributed to it, I
  guess), some rather fundamental deficiences of the syntax, and
  it doesn't seem to be actively maintained nowadays.

>> On the other hand, per POSIX, AIUI, C preprocessor is a part of C,
>> and `expr' is a part of the Shell language.

> On the last point, "expr" *may* be a shell built-in, but it may also
> be an external command.

> So far as POSIX is concerned "may be a shell built-in" simply means
> that you can't assume that you can invoke it directly via e.g.
> execl(), as it might not exist as a separate program. If you're
> writing a shell script, it doesn't matter whether something is a
> built-in.

  Yes. That was the idea I wished to express when starting this
  discussion.

[...]

>> Could you outline a few of advantages of Python over Tcl (i. e.,
>> without Tk)?

> Tcl has many of the same defects as the Bourne shell.

> Languages which are based primarily upon textual substitution are
> simple to implement, and it's simple to describe the (relatively few)
> rules which define the language, but they're a nuisance to program
> in.

> Such languages tend to encourage over-use of "eval", which produces
> messy code, and can cause problems when data values contain language
> metacharacters (Lisp's "eval" doesn't have the latter problem, as it
> doesn't involve parsing).

  Actually, Tcl's `eval' doesn't necessarily involve parsing.
  Rather, `eval' expects its arguments to be proper lists which
  are merged (`concat'enated) to produce a list to be evaluated.

  If the arguments to `eval' are strings, they're implicitly
  converted (parsed) into the respective lists as per the basic
  rule of the language.

> Another problem is the "everything is a string" model. This creates
> problems with different representations of the same value. E.g. are
> "12", "12.0" and "012" all equal?

  There're both ``string equality'' and ``number equality'' tests
  in Tcl:

% set a 12
12
% set b 12.0
12.0
% string equal $a $b
0
% expr { $a == $b }
1
%

  You may compare it, e. g., to the presence of `equal?', `=',
  `string=?' and `char=?' in Scheme.

> There are also problems with constructing structured values
> (e.g. lists) using string operations, e.g.:

> set x "$a $b $c"
> versus:
> set x [list $a $b $c]

> The former does the wrong thing when a variable contains spaces.

  Yes. The allowance to construct structured values by
  constructing their respective string representations has it's
  benefits (and it's natural given the overall design of the
  language), but may quite easily lead one to write incorrect
  code, e. g.:

eval "$a $b $c"

  Instead of the proper:

eval [ list $a $b $c ]

> If you want more evidence of the problems with the use of textual
> substitution in programming, search the archives of BugTraq and other
> security-related lists for "SQL injection" and "shell injection".
> Manipulating structured data by manipulating its string
> representation will always be error-prone.

  Yes, but there's at least the list representation and (starting
  with Tcl 8.5) the ``dict'' representation for the structured
  data.

  On the other hand, there's no way to make a foolproof
  programming language. You may search the archives for ``buffer
  overflow'' for the ``evidence of deficiency'' of C pointers, for
  example.

>>> It is also a lot easier to use than bash.

>> I guess that depends on a task.

>> Is Python suitable for use as an interactive Shell for GRASS, for
>> instance?

> Not at all. For similar reasons, interactive shells aren't
> particularly suitable for use as programming languages.

> The Bourne shell is a good interactive shell because it was designed
> for use as an interactive shell. It isn't a good programming language
> because it was designed for use as an interactive shell, not as a
> programming language.

> cmd.exe isn't a particularly good interactive shell, but it's good
> enough for most usage. Although bash has far more features, most of
> them are primarily for use in scripts rather than interactive use.

[...]

>> However, given that with the transition to Python a POSIX Shell will
>> become optional, some of the GRASS/W32 users may become inclined to
>> use cmd.exe with GRASS. And it doesn't seem to be a particularly
>> good way to encourage GRASS users to try GRASS scripting.

> For how long are you going to keep trying to conflate command-line
> use with scripting?

  For as long as no clear dividing line between command-line use
  and scripting was shown to me.

> Right now, we include Bourne-shell scripts and a Bourne shell. When
> the scripts are written in Python, we'll include (or at least
> require) Python.

> Neither of those will be familiar to the average Windows user, so if
> they want to write scripts, they need to learn one.

  Agreed completely.

> They would be a lot better off learning Python.

  I hope I'd be able to respond to this later.