Discussion:
How to improve the readability of (any) LISP or any highlevel functional language to the level of FORTH ?
(too old to reply)
girosenth
2011-01-01 07:04:24 UTC
Permalink
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?

There are many people who have trivia complaints about parens in lisp,
but I dont.

LISP is a prefix notation.

sequence of operations would look like this on operands (ops) :

(f ops (g ops (h ops (j ops (k ops (l ops ))...))))

How do you make it readable ?
How do you home to the center or centers ?

(f (g (h (j (k (l ops)))...)))

is easy to read or

ops l k j h g f

???

Which is linear reading from L->R ? LISP or FORTH ?

AND, if I must break the nested function structure, will I not be
visiting the forbidden territory of imperative programming ?

(setq L (l ops))
(setq K (k L ))
....
....
(setq F (f G ))


If I use setq, I am using globals, atleast in elisp.

If I use let*, I have limited options as I am constrained inside the
rigid structure of let*

(let*
((L (l ops))
(K (k L ))
....
(F (f G )))

some more
)

Is there a postfix functional language that also gets rid of parens
and is not as primitive as FORTH or POSTSCRIPT ?

What are the syntax advantages of ERLANG, ML, CAML, OCAML, HASKELL,
PROLOG, RUBY over LISP ?

How does one improve readability so that the code is self-commenting ?

girosenth
Elena
2011-01-01 11:39:01 UTC
Permalink
Post by girosenth
Is there a postfix functional language that also gets rid of parens
and is not as primitive as FORTH or POSTSCRIPT ?
Factor? http://factorcode.org/
Pascal J. Bourguignon
2011-01-01 14:15:54 UTC
Permalink
Post by girosenth
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?
There are many people who have trivia complaints about parens in lisp,
but I dont.
LISP is a prefix notation.
(f ops (g ops (h ops (j ops (k ops (l ops ))...))))
How do you make it readable ?
How do you home to the center or centers ?
(f (g (h (j (k (l ops)))...)))
is easy to read or
ops l k j h g f
???
I think we can call you a troll.

Is it not obvious how you home to the center?
Loading Image...
Is it not a flagrant proof that lisp is the most easy to read?
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
Nathan
2011-01-01 16:08:06 UTC
Permalink
If you want a easy to read self-documenting functional language, look
into Ruby. I know personally that Ruby syntax was a big turn off to me
for several weeks (kind of like Lisp) but once you learn it, it
becomes the easiest to read of any programming language I've ever
experimented with. No contest.

Matz himself admitted that “...Ruby is a bad rip-off of Lisp... But it
is nicer to ordinary people.”

Though every language I've worked in, I've never been half as
productive as when I'm coding in Ruby. There are so many built in
methods to help you with common day to day tasks, and the end result
of your code will be simpler and clearer to read than you can have it
in any other language.

The downside of course is that Ruby lends itself to the efficient
production of very inefficient code. You'll be plagued with strict
evaluative breath first traversals that glut on your memory. You'll
find yourself cursing a global interpreter lock that makes Ruby's
simple method for handling threads meaningless in most situations.

In my hands, Ruby's nature seems to lend itself to the design of
inefficient code, but that can be overcome with a little attention.
Overall, I left Ruby because the community support was somewhat less
than I wanted. In particular, cross platform GUI application
development seemed poor.

If you want to develop webpages, or bang out quick one time scripts,
Ruby is hard to beat. For use at home, console applications are
probably a tolerable price to pay for the incredible development speed
and fantastic ease of maintenance Ruby will give your code.

If you give it an hour a day for two months, I guarantee you will be
head over heals in love with the Ruby language. If you're not, please
send me an email and tell me what language you prefer because I want
to try it out.

Ruby is just a blast to code in. If it had stronger GUI support, no
global interpretor lock, and either lazy evaluation or preemptive
multi-threading (with a strong preference toward the latter), I'd be
content to settle down with that for the rest of my life. But then,
this is from a guy who's learning Lisp only for the sake of mastering
a superior abstraction model. You might want to take me with a grain
of salt.
Jan Burse
2011-01-01 18:05:24 UTC
Permalink
Hi

I am responding from comp.lang.prolog.
Post by Nathan
Ruby is just a blast to code in. If it had stronger GUI support, no
global interpretor lock,
I think a global interpreter lock can be avoided by combining
the following approaches in logic programming languages:

0) Actual parameter data structures (of a thread running in the
interpreter) should be immune to concurrency problems.
1) Conversions between actual parameter data structures, and
global data structures (of the interpreter).
2) No exposure of global data structures,
only access via the interpreter.
3) When exposure of global data structures, then access via
thread safe methods.

Interestingly 0) and 1) is automatically assured by Prolog
implementations. Actual parameters are not visible between
threads, and clause instantiation can be viewed as producing
actual parameter data structures from global data structures,
whereas asserting a clause can be viewed as producting global
data structures form actual parameter data structures.

Point 2) and 3) depend on the API design for a Prolog implementation.
For point 2) it is assumend that a multi-threaded interpreter will
not have any problems accessing its global data structures, for
example in the case of Prolog clauses, concurrently. For 3) it
is assumed that corresponding access can be encapsulated in
thread safe methods.

There are a couple of Prolog system implementations around
that support multi threading. For example SWI Prolog. Or
Jekejeke Prolog. In Jekejeke Prolog mostly the approach 2)
has been followed by the API on purpose.
Post by Nathan
and either lazy evaluation or preemptive multi-threading (with a
strong preference toward the latter),
The threads deployed by multi-threading Prologs are preemptive.
They typically don't follow the cooperative model, because
coopertaive threads have only limited applications. SWI
Prolog has preemptive threads (*), Jekejeke Prolog inherits
the property from the threads of the Java VM.

Best Regards

(*)
http://hcs.science.uva.nl/projects/SWI-Prolog/articles/iclp-03.pdf
The Quiet Center
2011-01-01 23:56:05 UTC
Permalink
Post by Nathan
If you want a easy to read self-documenting functional language, look
into Ruby. I know personally that Ruby syntax was a big turn off to me
for several weeks (kind of like Lisp) but once you learn it, it
becomes the easiest to read of any programming language I've ever
experimented with. No contest.
Well, Python was chosen over Ruby for MIT's rework of their intro to
cs course because Python is multi-paradigm, whereas Ruby claims
everything is an object.

How would you code this simple list compression problem in Ruby:

1.08 (**) Eliminate consecutive duplicates of list elements.
If a list contains repeated elements they should be replaced with
a single copy of the element. The order of the elements should not be
changed.

Example:
?- compress([a,a,a,a,b,c,c,a,a,d,e,e,e,e],X).
X = [a,b,c,a,d,e]
Post by Nathan
Matz himself admitted that “...Ruby is a bad rip-off of Lisp... But it
is nicer to ordinary people.”
yeah I guess the LOOP macro is where I got stuck in doing Lisp.
Post by Nathan
Though every language I've worked in, I've never been half as
productive as when I'm coding in Ruby.
I've done Perl at corporate level for 10 years and I've heard seasoned
Perl developers say the same thing.
Post by Nathan
In particular, cross platform GUI application
development seemed poor.
yeah, wxPython is the only thing for any scripting languages that
seemed to make very professional desktop UI programs.
Post by Nathan
If you want to develop webpages, or bang out quick one time scripts,
Ruby is hard to beat. For use at home, console applications are
probably a tolerable price to pay for the incredible development speed
and fantastic ease of maintenance Ruby will give your code.
yeah sinatra.rb looks nice for web dev and ruby on rails was a runaway
hit for awhile.

By the way, here's the Prolog solution to the compression problem I
posted earlier:



% http://sites.google.com/site/prologsite/prolog-problems/1

% Problem 1.08 - compress consecutive duplicates into a single
% list element

compress([], []).
compress([X,Y], [X,Y]) :- X \= Y.
compress([X,Y], [X]) :- X = Y.

% problems writing other clauses (thanks RLa)

compress([X,Y|Z], [X|Z1]) :- X \= Y, compress([Y|Z], Z1).
compress([X,Y|Z], Z1) :- X = Y, compress([Y|Z], Z1).
Jan Burse
2011-01-02 01:10:45 UTC
Permalink
%http://sites.google.com/site/prologsite/prolog-problems/1
% Problem 1.08 - compress consecutive duplicates into a single
% list element
compress([], []).
compress([X,Y], [X,Y]) :- X \= Y.
compress([X,Y], [X]) :- X = Y.
% problems writing other clauses (thanks RLa)
compress([X,Y|Z], [X|Z1]) :- X \= Y, compress([Y|Z], Z1).
compress([X,Y|Z], Z1) :- X = Y, compress([Y|Z], Z1).
The above code does not work fully correct. Here is a
counter example (try yourself):

?- compress([a],X).
No

In a Prolog introductory course I would anyway use:

% compress(+List,-List)

compress([X,X|L],R) :- !, compress([X|L],R).
compress([X|L],[X|R]) :- compress(L,R).
compress([],[]).

No reason to use (\=)/2, which is anyway not declarative,
and no reason to avoid the cut !/0.

Bye

P.S.: On sites.google.com I find the following solution,
correct, but also avoids the cut !/0:

% 1.08 (**): Eliminate consecutive duplicates of list elements.

% compress(L1,L2) :- the list L2 is obtained from the list L1 by
% compressing repeated occurrences of elements into a single copy
% of the element.
% (list,list) (+,?)

compress([],[]).
compress([X],[X]).
compress([X,X|Xs],Zs) :- compress([X|Xs],Zs).
compress([X,Y|Ys],[X|Zs]) :- X \= Y, compress([Y|Ys],Zs).
LanX
2011-01-02 03:45:43 UTC
Permalink
Post by The Quiet Center
Post by Nathan
Matz himself admitted that “...Ruby is a bad rip-off of Lisp... But it
is nicer to ordinary people.”
Matz himself admitted in the earliest sources that Ruby is basically
Perl's semantics melted with Smalltalk's OOP syntax. All influences
from LISP come via Perl and many things criticized in Perl derive from
Larry's dedication to stay close to LISP in contrast to Guido who
breaks a lot in Python, e.g limiting lambdas to single expressions.

For sure Perl's scoping rules are much closer to eLISP's.

So in order to emulate eLISP I would rather chose a Perl or JavaScript
1.7 (with the additional "let"-command) but with the need of extra
macro functionality.

The problem are rather the datatypes which are far more static in
eLISP,
i.e.
1. no autocasting eLisp
2. hashes and arrays have only fixed length in eLisp
3. OTOH linked linked lists are not a native type in most mainstream
languages.
Post by The Quiet Center
1.08 (**) Eliminate consecutive duplicates of list elements.
    If a list contains repeated elements they should be replaced with
a single copy of the element. The order of the elements should not be
changed.
    ?- compress([a,a,a,a,b,c,c,a,a,d,e,e,e,e],X).
    X = [a,b,c,a,d,e]
in Perl:
DB<1> my $l; print grep { $l = $_ if $_ ne $l }
(a,a,a,a,b,c,c,a,a,d,e,e,e,e);
abcade

from 5.10 one can use feature "state" to avoid an extra scope to make
$l lexical.

or define an explicit compress function:

DB<2> sub compress { my $l; grep { $l = $_ if $_ ne $l } @_ }

DB<3> print compress(a,a,a,a,b,c,c,a,a,d,e,e,e,e);
abcade

(Nota bene, no explicit return needed like in LISP)

I suppose one can translate those approaches directly to Ruby, Python
or PHP. Newer JS versions call "grep" rather "filter" like in Python.
LanX
2011-01-02 04:04:27 UTC
Permalink
  DB<1>  my $l; print  grep { $l = $_  if  $_ ne $l } (a,a,a,a,b,c,c,a,a,d,e,e,e,e);
abcade
The same more explicit and less buggy

grep { if ($_ ne $l) { $l = $_ ; 1 } } LIST
Nathan
2011-01-02 05:36:37 UTC
Permalink
Well, to answer the question simply, this code will provide the
functionality you've been asking about in Ruby.

my_list = [1, 1, 1, 1, 2, 3, 3, 1, 1, 4, 5, 5, 5, 5]
print my_list.reduce([]){|x, y|
if x.empty? or x[x.length-1] != y then
x + [y]
else
x
end
}

As is typical of functional languages, this returns a value rather
than modifying the list in place. I recommended Ruby because you were
asking about a functional programming language that still reads in an
sequential manner like imperative languages, which Ruby does.

Ruby is a purely object oriented language, however there is no need
for new developers to write code in an object oriented manner. Your
code will be put into objects whether you specify those objects or not
simply for the sake of providing metadata.

I am familiar with Python, I use it more than Ruby these days. I've
found function/method names and locations to be less consistent than
in Ruby. I've found that far too many routines modify data in place -
rather than return the result- to make it a serious functional
language. That being the case, it's very usable.

It is my belief that every language possesses some piece of the light.
None are prefect; every one needs to learn from every other one.
Whether it's Ruby, Python, Java, C#, Lisp, or Perl; there are always
developers in the community that believe their language is beyond
improvement. I pity them.

Generally I consider the issue of readability to be a question of how
closely a new syntax matches what one is accustomed to reading. Many
people prefer sequential program flow over nested simply because
English, and every other spoken language I'm aware of, is sequential
in nature.

Thus, something can be considered "simple" and "intuitive" only when
it builds off what a person already knows; and since that knowledge
base changes dramatically between individuals... Simple and intuitive
are also in the eye of the beholder. In the end, what's important is
that your solution work for you.

There are many languages because there are many types of people and
there are many ways of thinking and recording thought. I believe that
greatness in thought is not about "having the prefect way of doing
things" or "finding some ultimate", to me it's about having many ways
of doing something and recognizing when to use each one.

Just like any other tool, programming languages have their strengths
and weaknesses. If one wanted, one could probably build an entire
house using nothing but a hammer. I will prefer to use a hammer only
for the nails, but that's me.
Paul Rubin
2011-01-02 06:46:08 UTC
Permalink
Post by Nathan
functionality you've been asking about in Ruby.
my_list = [1, 1, 1, 1, 2, 3, 3, 1, 1, 4, 5, 5, 5, 5]
print my_list.reduce([]){|x, y|
if x.empty? or x[x.length-1] != y then
x + [y]
else
x
end
}
That is pretty ugly; in Haskell you could write

my_list = [1, 1, 1, 1, 2, 3, 3, 1, 1, 4, 5, 5, 5, 5]
main = print [head xs | xs <- group my_list]

That uses a Python-like list comprehension since you mentioned Python,
but more idiomatic would be

my_list = [1, 1, 1, 1, 2, 3, 3, 1, 1, 4, 5, 5, 5, 5]
main = print . map head . group $ my_list

There is probably a function like "group" available in Ruby. Python has
itertools.groupby but it's a little bit brittle.
LanX
2011-01-02 15:01:54 UTC
Permalink
Post by Paul Rubin
That is pretty ugly; in Haskell you could write
my_list = [1, 1, 1, 1, 2, 3, 3, 1, 1, 4, 5, 5, 5, 5]
main = print [head xs | xs <- group my_list]
does this really produce the desired output?
Will the second 1 really be printed?

And why do you guys switch to operate on digits instead of strings?
Jerome Baum
2011-01-02 15:14:33 UTC
Permalink
In article <ce0f5c3b-bc71-4868-8d2b-5495583ccfa8
@w18g2000vbe.googlegroups.com>, ***@googlemail.com says...
Post by LanX
Post by Paul Rubin
That is pretty ugly; in Haskell you could write
my_list = [1, 1, 1, 1, 2, 3, 3, 1, 1, 4, 5, 5, 5, 5]
main = print [head xs | xs <- group my_list]
does this really produce the desired output?
Will the second 1 really be printed?
And why do you guys switch to operate on digits instead of strings?
http://codepad.org/eGFuJrHZ

import List
my_list = ["one", "one", "one", "one", "two", "three", "three", "one",
"one", "four", "five", "five", "five", "five"]
main = print [head xs | xs <- group my_list]

Output:
["one","two","three","one","four","five"]

Works fine for me...
Paul Rubin
2011-01-02 21:21:54 UTC
Permalink
Post by LanX
Post by Paul Rubin
main = print [head xs | xs <- group my_list]
does this really produce the desired output?
Will the second 1 really be printed?
Yes. "group" is a very useful function, that transforms a list into a
list-of-lists which collapses identical elements:

group [1, 1, 1, 1, 2, 3, 3, 1, 1, 4, 5, 5, 5, 5]

is

[[1,1,1,1], [2], [3,3], [1,1], [4], [5,5,5,5]]

The list comprehension

[head xs | xs <- group my_list]

simply collects the first element of each of those sub-lists.

There is also groupBy, which lets you supply your own equality
predicate. If there's not already a Lisp library similar to Python's
itertools module and Haskell's List module, it's probably worth writing
one.
w_a_x_man
2011-01-02 07:14:47 UTC
Permalink
Post by Nathan
Well, to answer the question simply, this code will provide the
functionality you've been asking about in Ruby.
my_list = [1, 1, 1, 1, 2, 3, 3, 1, 1, 4, 5, 5, 5, 5]
print my_list.reduce([]){|x, y|
  if x.empty? or x[x.length-1] != y then
Instead of x[x.size-1], use x[-1] or x.last.
Post by Nathan
    x + [y]
  else
    x
  end
}
Another way using reduce:

%w(a a a b c c a a d e e e).reduce([]){|a,x| a[-1]==x ? a : a<<x}
==>["a", "b", "c", "a", "d", "e"]

This assumes nils aren't allowed in the source array.
w_a_x_man
2011-01-02 06:59:32 UTC
Permalink
Post by The Quiet Center
Post by Nathan
If you want a easy to read self-documenting functional language, look
into Ruby. I know personally that Ruby syntax was a big turn off to me
for several weeks (kind of like Lisp) but once you learn it, it
becomes the easiest to read of any programming language I've ever
experimented with. No contest.
Well, Python was chosen over Ruby for MIT's rework of their intro to
cs course because Python is multi-paradigm, whereas Ruby claims
everything is an object.
1.08 (**) Eliminate consecutive duplicates of list elements.
    If a list contains repeated elements they should be replaced with
a single copy of the element. The order of the elements should not be
changed.
    ?- compress([a,a,a,a,b,c,c,a,a,d,e,e,e,e],X).
    X = [a,b,c,a,d,e]
"aaaabccaadeeee".squeeze
==>"abcade"

p=nil; %w(a a a b c c a a d e e e).select{|x| x!=p && p=x}
==>["a", "b", "c", "a", "d", "e"]
LanX
2011-01-03 15:22:24 UTC
Permalink
Post by w_a_x_man
p=nil; %w(a a a b c c a a d e e e).select{|x| x!=p && p=x}
    ==>["a", "b", "c", "a", "d", "e"]
and by translating my perl code you also inherited it's restrictions

p=nil; ["a","a","b",false,false,"e"].select{|x| x!=p && p=x}
=> ["a", "b", "e"]
Frank GOENNINGER
2011-01-02 14:07:02 UTC
Permalink
Post by The Quiet Center
Post by Nathan
If you want a easy to read self-documenting functional language, look
into Ruby. I know personally that Ruby syntax was a big turn off to me
for several weeks (kind of like Lisp) but once you learn it, it
becomes the easiest to read of any programming language I've ever
experimented with. No contest.
Well, Python was chosen over Ruby for MIT's rework of their intro to
cs course because Python is multi-paradigm, whereas Ruby claims
everything is an object.
1.08 (**) Eliminate consecutive duplicates of list elements.
If a list contains repeated elements they should be replaced with
a single copy of the element. The order of the elements should not be
changed.
?- compress([a,a,a,a,b,c,c,a,a,d,e,e,e,e],X).
X = [a,b,c,a,d,e]
Post by Nathan
Matz himself admitted that “...Ruby is a bad rip-off of Lisp... But it
is nicer to ordinary people.”
yeah I guess the LOOP macro is where I got stuck in doing Lisp.
Simple:

? (defun compress (list)
(let ((last-element)
(result))
(loop for element in list
when (not (equal last-element element))
do
(progn
(setq last-element element)
(push element result)))
(reverse result)))

COMPRESS

? (setq list (list 'a 'a 'a 'a 'b 'c 'c 'a 'a 'd 'e 'e 'e 'e))
(A A A A B C C A A D E E E E)

? (compress list)
(A B C A D E)

'compress can be done in much more terse way in Lisp but this is just an
example using the Loop macro.

Frank
Nicolas Neuss
2011-01-02 21:49:49 UTC
Permalink
Post by Frank GOENNINGER
? (defun compress (list)
(let ((last-element)
(result))
(loop for element in list
when (not (equal last-element element))
do
(progn
(setq last-element element)
(push element result)))
(reverse result)))
COMPRESS
? (setq list (list 'a 'a 'a 'a 'b 'c 'c 'a 'a 'd 'e 'e 'e 'e))
(A A A A B C C A A D E E E E)
? (compress list)
(A B C A D E)
'compress can be done in much more terse way in Lisp but this is just an
example using the Loop macro.
If you want to show how to use LOOP, you should use it better:

(defun compress (list)
(loop for element in list
and last-element = nil then element
unless (equal last-element element)
collect element))

Nicolas
w_a_x_man
2011-01-07 09:41:21 UTC
Permalink
Post by The Quiet Center
1.08 (**) Eliminate consecutive duplicates of list elements.
    If a list contains repeated elements they should be replaced with
a single copy of the element. The order of the elements should not be
changed.
    ?- compress([a,a,a,a,b,c,c,a,a,d,e,e,e,e],X).
    X = [a,b,c,a,d,e]
(defun compress (stuff)
(mapcon #'(lambda (x)
(if (and (> (length x) 1) (eql (car x) (cadr x)))
nil
(list (car x))))
stuff))
Didier Verna
2011-01-03 10:29:02 UTC
Permalink
Post by Nathan
Matz himself admitted that “...Ruby is a bad rip-off of Lisp... But it
is nicer to ordinary people.”
Which of course is a very sorry thing to say. Ruby is not nicer to
ordinary people. It's nicer to people having already been brainwashed by
languages full of syntax noise. At most, he could have said "to the
majority of people".

There is litterature and evidence out there that Lisp is just good
enough for ordinary people as well, when it's their first programming
experience.

This misconception that you must be exceptionally clever to learn and
use Lisp really hurts the language and the community.
--
Resistance is futile. You will be jazzimilated.

Scientific site: http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com
Tim Harig
2011-01-03 13:05:57 UTC
Permalink
Post by Didier Verna
Matz himself admitted that ???...Ruby is a bad rip-off of Lisp... But it
is nicer to ordinary people.???
This misconception that you must be exceptionally clever to learn and
use Lisp really hurts the language and the community.
What hurts the LISP community far more is the zealotry of its members,
their insistance that LISP is the *only* tool for *every* job, and their
agressiveness in trying to push it off on to everybody else -- whether
everybody else happens want it or not. Whether this is indicitive
of the entire community or simply the result of those most apparent,
I cannot say; but, it leads to the overall impression that the LISP
community is narrowminded and neophobic. Who would want to be part of
such a community?
Pascal J. Bourguignon
2011-01-03 15:51:52 UTC
Permalink
Post by Tim Harig
Post by Didier Verna
Matz himself admitted that ???...Ruby is a bad rip-off of Lisp... But it
is nicer to ordinary people.???
This misconception that you must be exceptionally clever to learn and
use Lisp really hurts the language and the community.
What hurts the LISP community far more is the zealotry of its members,
their insistance that LISP is the *only* tool for *every* job, and their
agressiveness in trying to push it off on to everybody else -- whether
everybody else happens want it or not. Whether this is indicitive
of the entire community or simply the result of those most apparent,
I cannot say; but, it leads to the overall impression that the LISP
community is narrowminded and neophobic. Who would want to be part of
such a community?
Yes, it's well known the Lisp "community" is so rich and numerous that
it can dispatch Squads of Lisp Enforcement Commandos to the cubicles all
over the world, with straps, mechanical eye openers, and sticks hitting
programmers fingers as soon as they try to type a bracket or a brace.


Or do you mean we have special Jedi mind powers and I'm just doing my
trick to force you to use Lisp?
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
rusi
2011-01-04 04:49:38 UTC
Permalink
Post by Tim Harig
Post by Didier Verna
Matz himself admitted that ???...Ruby is a bad rip-off of Lisp... But it
is nicer to ordinary people.???
This misconception that you must be exceptionally clever to learn and
use Lisp really hurts the language and the community.
What hurts the LISP community far more is the zealotry of its members,
their insistance that LISP is the *only* tool for *every* job, and their
agressiveness in trying to push it off on to everybody else -- whether
everybody else happens want it or not.  Whether this is indicitive
of the entire community or simply the result of those most apparent,
I cannot say; but, it leads to the overall impression that the LISP
community is narrowminded and neophobic.  Who would want to be part of
such a community?
There are more mundane reasons -- like unsuitability of lisp as a
distribution platform
[See http://www.newartisans.com/about-me.html where John Wiegley
explains why he switched from lisp to C++ for his program ledger ]
D Herring
2011-01-04 05:39:34 UTC
Permalink
Post by rusi
Post by Tim Harig
What hurts the LISP community far more is the zealotry of its members,
their insistance that LISP is the *only* tool for *every* job, and their
agressiveness in trying to push it off on to everybody else -- whether
everybody else happens want it or not. Whether this is indicitive
of the entire community or simply the result of those most apparent,
I cannot say; but, it leads to the overall impression that the LISP
community is narrowminded and neophobic. Who would want to be part of
such a community?
Like the dark days of apple, bsd, and linux, there can be some bizarre
fanboyism in the lisp community. Geeks are always technical but often
not personable.
Post by rusi
There are more mundane reasons -- like unsuitability of lisp as a
distribution platform
[See http://www.newartisans.com/about-me.html where John Wiegley
explains why he switched from lisp to C++ for his program ledger ]
First he says "It was originally written in C++, but lately I’ve been
porting it to Common Lisp, since I’ve realized how much simpler – and
more powerful – many of its aspects will become."

Then there's a cryptic "I found Common Lisp unsuitable as a
distribution platform."

Trying not to sound fanboyish, but there are numerous ways to
distribute lisp apps. There have been a couple notable improvements
in the last year; but several implementations have always offered to
spit out an ordinary, standalone executable.

I think many readers in the other cross posted newsgroups have seen
similar come-and-go users leave their favorite language.

- Daniel
Tim Harig
2011-01-04 08:02:35 UTC
Permalink
Post by D Herring
Post by Tim Harig
What hurts the LISP community far more is the zealotry of its members,
their insistance that LISP is the *only* tool for *every* job, and their
agressiveness in trying to push it off on to everybody else -- whether
everybody else happens want it or not. Whether this is indicitive
of the entire community or simply the result of those most apparent,
I cannot say; but, it leads to the overall impression that the LISP
community is narrowminded and neophobic. Who would want to be part of
such a community?
Like the dark days of apple, bsd, and linux, there can be some bizarre
fanboyism in the lisp community. Geeks are always technical but often
not personable.
1. You imply that the worst of the zealotry for Apple, BSD, and Linux is
over. When is it going to be over for LISP?

2. While I would agree that the listed groups have zealots among their
ranks; but, in my experience, most of them have resigned to the
fact that they often have to work with other systems. I would
suspect that most of their members are at least as knowledgable
about using Windows as most dedicated Windows users. Most of
them, when push comes to shove, will even admit that there
are things which they admire about other operating systems,
including Windows.

LISP users on the other hand, never seem to be able to let
go of LISP when the situation requires it. To be fair, most
newcomers to any given language will tend to let the idioms
from their previous language bleed into the new language.
This is an familiarity issue and most will gradually assimilate
into the mainstream as their knowledge and experience with the
language grows. Ultimately their knowledge and experience in
both langauges improves their overall abilities no matter what
language they may happen to be using. LISP users never seem
to do that. They seem to be unable, or unwilling, to learn
anything new.
Nicolas Neuss
2011-01-04 09:09:27 UTC
Permalink
Post by Tim Harig
LISP users on the other hand, never seem to be able to let
go of LISP when the situation requires it. To be fair, most
newcomers to any given language will tend to let the idioms
from their previous language bleed into the new language.
This is an familiarity issue and most will gradually assimilate
into the mainstream as their knowledge and experience with the
language grows. Ultimately their knowledge and experience in
both langauges improves their overall abilities no matter what
language they may happen to be using. LISP users never seem
to do that. They seem to be unable, or unwilling, to learn
anything new.
Could you provide a reference? Of a respected Lisp user who is
unwilling to learn anything new if the situation requires it? In my
experience people who proselytize Lisp are very often semi-newbies who
do not stay long.

Nicolas
Tim Bradshaw
2011-01-04 10:00:39 UTC
Permalink
Post by Tim Harig
LISP users on the other hand, never seem to be able to let
go of LISP when the situation requires it.
I think this probably is not the case. It may be the case that the
Lisp users *you hear from* often have this view, but I don't think
those people are necessarily very representative of Lisp users as a
whole. Of course I can't really infer much about the ones you don't
hear from other than in a sort of dark-energy way - implementors are
probably the only people who might have a chance of knowing about them
in any reliable way.

For instance, I've been berated by the users you hear from for saying I
write (and like writing) Perl and (but not like very much) Java. I
don't think that makes me an atypical Lisp user, I just think it makes
me one of the few who are in the subset of Lisp users that you hear
from and who will admit to using other langages.
Tim Harig
2011-01-04 12:21:44 UTC
Permalink
Post by Tim Bradshaw
Post by Tim Harig
LISP users on the other hand, never seem to be able to let
go of LISP when the situation requires it.
I think this probably is not the case. It may be the case that the
Lisp users *you hear from* often have this view, but I don't think
those people are necessarily very representative of Lisp users as a
whole. Of course I can't really infer much about the ones you don't
hear from other than in a sort of dark-energy way - implementors are
probably the only people who might have a chance of knowing about them
in any reliable way.
The loudest voices in the crowd tend to characterize the crowd.
Unfortunately, to my point, those vocal zealots in the LISP community
are not doing it any favors.

Perhaps I am alone in this, but I don't much appreciate being part of
communities that are too openly negative towards others. It really puts
a poor taste in my mouth. I am a right tool for the right job kind
of person and I prefer communities that are open enough to be able to
properly evaluate the role of their chosen tools compared to others.
Tim Bradshaw
2011-01-04 12:23:12 UTC
Permalink
Post by Tim Harig
The loudest voices in the crowd tend to characterize the crowd.
They characterize how it *appears*, but only that.
Tim Harig
2011-01-04 13:33:15 UTC
Permalink
Post by Tim Bradshaw
Post by Tim Harig
The loudest voices in the crowd tend to characterize the crowd.
They characterize how it *appears*, but only that.
No doubt; but, when somebody evaluates the language, their impressions
will be based far more on appearences then objective reality. My point
is, that simply offering assertions against the languages misconceptions
and/or touting the languages benefits may not be effective in generating
interest for the language -- even among those who might have strong use
cases for the LISP language.

In many instances, I think it would be more useful for the community
to appear be a little more open minded, inviting, and respectful of
other languages that a prospective LISP user might already have an
appreciation for. To do that, it needs to mitigate those negative voices
within the community that are carrying the furthest and providing the
negative contribution to the communities appearance.
Tamas K Papp
2011-01-04 12:41:43 UTC
Permalink
Post by Tim Harig
Post by Tim Bradshaw
LISP users on the other hand, never seem to be able to let go of LISP
when the situation requires it.
I think this probably is not the case. It may be the case that the
Lisp users *you hear from* often have this view, but I don't think
those people are necessarily very representative of Lisp users as a
whole. Of course I can't really infer much about the ones you don't
hear from other than in a sort of dark-energy way - implementors are
probably the only people who might have a chance of knowing about them
in any reliable way.
The loudest voices in the crowd tend to characterize the crowd.
Unfortunately, to my point, those vocal zealots in the LISP community
are not doing it any favors.
Perhaps I am alone in this, but I don't much appreciate being part of
communities that are too openly negative towards others. It really puts
a poor taste in my mouth. I am a right tool for the right job kind of
person and I prefer communities that are open enough to be able to
properly evaluate the role of their chosen tools compared to others.
It would be great if you could substantiate your points with examples
(eg links to discussions on newsgroups or mailing lists). I have been
following c.l.l for years now, but I haven't seen the kind of zealotry
that you describe. Perhaps this is because Lisp zealots go to other
forums: this is of course possible, but I would be interested in
seeing examples of lispers being "openly negative towards others"
before entertaining the idea that this is some sort of general
tendency.

I don't believe that it is possible to have a meaningful discussion
about this question unless you are a lot more specific about your
claims.

Best,

Tamas
Tim X
2011-01-04 23:32:23 UTC
Permalink
Post by Tim Harig
LISP users on the other hand, never seem to be able to let
go of LISP when the situation requires it.
I think this probably is not the case. It may be the case that the Lisp users
*you hear from* often have this view, but I don't think those people are
necessarily very representative of Lisp users as a whole. Of course I can't
really infer much about the ones you don't hear from other than in a sort of
dark-energy way - implementors are probably the only people who might have a
chance of knowing about them in any reliable way.
For instance, I've been berated by the users you hear from for saying I write
(and like writing) Perl and (but not like very much) Java. I don't think that
makes me an atypical Lisp user, I just think it makes me one of the few who are
in the subset of Lisp users that you hear from and who will admit to using
other langages.
I would add that it is a mistake to judge a community of users based on
a single forum. For example, many have complained about comp.lang.lisp
and it is often viewed as being the lisp community. In reality, it is
only a very small representation of lisp users from a single forum.
There are many other lisp forums with varying levels of acceptance,
hostility, dogma, experience, cynicism etc.

Judging the lisp community by what goes on in c.l.l is like stopping at
some remote town in the hills where everyone has the same nose and
concluding it is a national trait.

Personally, I enjoy c.l.l as I can easily recognise the threads to kill
and those which are likely to have some interesting information. Sure,
we may throw a few fists and end up rolling around in the pig shit from
time to time and sometimes one of the cousins may drink a bit much
'shine and probably should'nt pull out the shotgun, but what can you do,
its family.
--
tcross (at) rapttech dot com dot au
Tim Harig
2011-01-05 01:35:58 UTC
Permalink
Post by Tim X
Post by Tim Harig
LISP users on the other hand, never seem to be able to let
go of LISP when the situation requires it.
I would add that it is a mistake to judge a community of users based on
a single forum. For example, many have complained about comp.lang.lisp
and it is often viewed as being the lisp community. In reality, it is
I don't subscribe to c.l.l. I came across this post in c.l.f and my post
is a general statement not really directed to the topic or poster but
merely to the comment about what is detrimental to the LISP community.

Most of my experience with LISP advocates comes from bleedthrough to
other groups or aquaintences in meat-space. I would expect advocacy in a
group dedicated to the language. In groups that are language agnostic,
I would expect a more sympathetic attitude towards other languages.
I certainly wouldn't expect them to spam groups dedicated to other
languages with LISP propoganda.
Nicolas Neuss
2011-01-05 10:21:44 UTC
Permalink
Post by Tim Harig
I don't subscribe to c.l.l. I came across this post in c.l.f and my
post is a general statement not really directed to the topic or poster
but merely to the comment about what is detrimental to the LISP
community.
It is a severe reproach and should therefore be substantiated.
Post by Tim Harig
Most of my experience with LISP advocates comes from bleedthrough to
other groups or aquaintences in meat-space. I would expect advocacy
in a group dedicated to the language. In groups that are language
agnostic, I would expect a more sympathetic attitude towards other
languages. I certainly wouldn't expect them to spam groups dedicated
to other languages with LISP propoganda.
So is Xah Lee or Robert Maas your problem or is it someone else? Sorry,
but we can probably not help you there since these are unmoderated
newsgroups and we cannot stop trolls from posting and cross-posting.
Luckily, such messages can be identified easily. An interesting
possibility is to avoid any cross-posted threads.

Nicolas
Tim Harig
2011-01-05 13:24:46 UTC
Permalink
Post by Nicolas Neuss
Post by Tim Harig
I don't subscribe to c.l.l. I came across this post in c.l.f and my
post is a general statement not really directed to the topic or poster
but merely to the comment about what is detrimental to the LISP
community.
It is a severe reproach and should therefore be substantiated.
It isn't meant as a reproach. It is meant as a simple piece of advice
for those who would like to make an inviting community, which seems to
have been a goal in the post where I originally replied. If that is
not your goal, then you may safely ignore my remarks. They are merely
provided as feedback.
Post by Nicolas Neuss
Post by Tim Harig
Most of my experience with LISP advocates comes from bleedthrough to
other groups or aquaintences in meat-space. I would expect advocacy
in a group dedicated to the language. In groups that are language
agnostic, I would expect a more sympathetic attitude towards other
languages. I certainly wouldn't expect them to spam groups dedicated
to other languages with LISP propoganda.
So is Xah Lee or Robert Maas your problem or is it someone else? Sorry,
I was going to say that I wasn't targeting anybody specific; but, since
you mentioned him, I do notice that Xah Lee might have been one of
my examples. Somewhere along the line he landed in my killfile/scorefile.
Post by Nicolas Neuss
but we can probably not help you there since these are unmoderated
newsgroups and we cannot stop trolls from posting and cross-posting.
Luckily, such messages can be identified easily. An interesting
possibility is to avoid any cross-posted threads.
That is true for trolls that are not actually part of your community.
Frankly, since I don't follow c.l.l, or any other LISP specific
group, I don't know who is and who isn't a part of that community.
Other languages, however, seem to keep the appearence of being far
less interested in advocacy. I would seem that the culture of those
communities promotes an open

Note that, it isn't just a matter of my reading and ignoring LISP
advocacy. Frankly, I could care less. I just ignore it; but, then
I don't post many questions to usenet which, for better or worse, has
merely become a question and answer arena in the technical forums.

I have seen examples where questions posted in language agnostic groups
have been answered using LISP after the poster has indicated they
have no familiarity with language. The message seems to be: if you
don't share my choice of language, then you don't deserver an answer.
I can sympathize with people who have received that response. Trying to
learn a new concept is often trouble enough without having to learn a
new language to comprehend the given examples.

For my own part, when posting in language agnostic groups/forums, I
try to answer in psuedocode or as an English sequence of instructions.
That way, I am not forcing the receiver to use my language of choice
for solving the problem. If it isn't possible to answer the question
in general terms; then, I will try to answer in a language that is as
close as possible to the language the OP indicates he or she is using.
If all else fails, I try to use a language that most programmers are
probably familiar with and/or should be able to follow even if they come
from a very different language. (Javascript being a common example.)
I simply consider that to be a common courtesy and a boon to advancing
the communication of the discussion.
Nicolas Neuss
2011-01-05 13:55:20 UTC
Permalink
Post by Tim Harig
Post by Nicolas Neuss
So is Xah Lee or Robert Maas your problem or is it someone else? Sorry,
I was going to say that I wasn't targeting anybody specific; but, since
you mentioned him, I do notice that Xah Lee might have been one of
my examples. Somewhere along the line he landed in my killfile/scorefile.
Post by Nicolas Neuss
but we can probably not help you there since these are unmoderated
newsgroups and we cannot stop trolls from posting and cross-posting.
Luckily, such messages can be identified easily. An interesting
possibility is to avoid any cross-posted threads.
That is true for trolls that are not actually part of your community.
No troll is "part" of any reasonable community.
Post by Tim Harig
I have seen examples where questions posted in language agnostic
groups have been answered using LISP after the poster has indicated
they have no familiarity with language.
How can I help then at all? :-)

You know, I have even seen questions _for Common Lisp code_ answered by
Ruby, OCaml, etc code. However, I don't blame the respective
communities for this.

Nicolass
Tim Harig
2011-01-05 14:25:54 UTC
Permalink
Post by Nicolas Neuss
Post by Tim Harig
I have seen examples where questions posted in language agnostic
groups have been answered using LISP after the poster has indicated
they have no familiarity with language.
How can I help then at all? :-)
You know, I have even seen questions _for Common Lisp code_ answered by
Ruby, OCaml, etc code. However, I don't blame the respective
communities for this.
You keep assuming that I blame somebody. I don't. I have merely made
an observation. I am not even saying that is the right thing to do
because I don't know what the LISP communities goals are. Sometimes
communities degrade as they grow larger. I am merely saying, that *if*
the LISP community would like to draw more people to the LISP language,
which the poster seemed interesting in doing, it might help to improve
the appearance of the community at large.

Every group has is vocal advocates; but, some groups seem to be louder
then others. The community has no control over trolls and little over
its own members. It can however set an example and direction. If the
example that it sets is that it should be more open for the benefit
of the community, then those who truely value that community should
follow suit. No, it wouldn't stop all of the problems; but, I would
think making an effort to improve what is possible must be better then
simply doing nothing because you cannot comletely solve the problem.
Every little bit helps.
Tim Bradshaw
2011-01-05 14:02:26 UTC
Permalink
Post by Tim Harig
It isn't meant as a reproach. It is meant as a simple piece of advice
for those who would like to make an inviting community, which seems to
have been a goal in the post where I originally replied. If that is
not your goal, then you may safely ignore my remarks. They are merely
provided as feedback.
As regards CLL: it's been at least as fierce as it is now for a very
long time (at least 10 years: I don't really remember so well how
fierce it was in the 10 years before that any more, but I think it was
much the same), despite occasional discussions like this. So it's
almost certainly the case that you're wasting your time: if you want to
modify the behaviour of a Lisp community, CLL isn't the one to try.
Which I guess might lead one to wonder why you are investing all this
effort into something so obviously doomed.
Duane Rettig
2011-01-05 17:48:37 UTC
Permalink
Post by Nicolas Neuss
I don't subscribe to c.l.l.  I came across this post in c.l.f and my
post is a general statement not really directed to the topic or poster
but merely to the comment about what is detrimental to the LISP
community.
It is a severe reproach and should therefore be substantiated.
It isn't meant as a reproach.  It is meant as a simple piece of advice
for those who would like to make an inviting community, which seems to
have been a goal in the post where I originally replied.  If that is
not your goal, then you may safely ignore my remarks.  They are merely
provided as feedback.
This is ignorant advice. It assumes that the Lisp community can be
equated with c.l.l or that c.l.l has a goal. Well, a newsgroup
certainly has goals, stated in its creation, but it is the members of
the newsgroup which determines the direction it takes, and so only a
moderated newsgroup stands any chance of not being taken over by
others whose agenda don't match the goals of the newsgroup. That also
includes the agenda of a poster who has his own wisdom to impart on
the unwashed masses of that newsgroup.
Post by Nicolas Neuss
but we can probably not help you there since these are unmoderated
newsgroups and we cannot stop trolls from posting and cross-posting.
Luckily, such messages can be identified easily.  An interesting
possibility is to avoid any cross-posted threads.
That is true for trolls that are not actually part of your community.
Frankly, since I don't follow c.l.l, or any other LISP specific
group, I don't know who is and who isn't a part of that community.
Careful; you are in danger of becoming the very kind of troll you
would place in your kill-file. I had originally written you off as
what I call a "hit and run" troll: many newsgroups have people pop in
an back out saying something like "I don't read this newsgroup, but I
have this to say; don't bother replying because I won't see your
reply". Happily, I've seen that since you are answering others the
"hit and run" portion does not apply, and also since you seem to be
honestly trying to answer people's responses, I'm now considering you
not to be a troll (but only by a hair; very much more insistence on
making your single point will drive you back over the line...)
Other languages, however, seem to keep the appearence of being far
less interested in advocacy.  I would seem that the culture of those
communities promotes an open
Unfinished thought here? Or simple attention deficit?

Other languages may have their only source of advocacy in their
newsgroups. Lisp (and especially Common Lisp, since it has no
specific newsgroup) is so much bigger than c.l.l. that it needs not
beat against the wall of attempted advocacy in an unmoderated
newsgroup.
Note that, it isn't just a matter of my reading and ignoring LISP
advocacy.  Frankly, I could care less.  I just ignore it; but, then
I don't post many questions to usenet which, for better or worse, has
merely become a question and answer arena in the technical forums.
Well, there you have it. If a language had vendors who maintained
excellent mailing lists for support and such questions to be answered,
then you would indeed expect that its "newsgroup" would become less
bound up in those kinds of discussions, and thus left over would be
the kinds of conversations like the one we're having now. Who'd-a-
thunk?
I have seen examples where questions posted in language agnostic groups
have been answered using LISP after the poster has indicated they
have no familiarity with language.  The message seems to be: if you
don't share my choice of language, then you don't deserver an answer.
I can sympathize with people who have received that response.  Trying to
learn a new concept is often trouble enough without having to learn a
new language to comprehend the given examples.
Of course, any advocacy will be done in the manner in which the
advocate likes to present. Some such advocacy is effective, and other
kinds are less effective. I read comp.arch, and have in the past
posted there, including Common Lisp code. But my code almost always
includes one or more calls to disassemble, so that the readers can see
what the code is doing without ambiguity. This seems effective.
For my own part, when posting in language agnostic groups/forums, I
try to answer in psuedocode or as an English sequence of instructions.
If you are posting pseudocode, then you are advocating that
pseudocode, and the reader still has to decipher what you had meant,
because in many cases the pseudocode is not precise enough for a
discussion of the details. But many people, even those who don't
actually use Lisp, consider Lisp to be its own pseudocode, which is
one reason why you often see it in examples.
That way, I am not forcing the receiver to use my language of choice
for solving the problem.
 If it isn't possible to answer the question
in general terms; then, I will try to answer in a language that is as
close as possible to the language the OP indicates he or she is using.
In this paragraph, this statement above is the only one I agree with.
See below.
If all else fails, I try to use a language that most programmers are
probably familiar with and/or should be able to follow even if they come
from a very different language. (Javascript being a common example.)
I simply consider that to be a common courtesy and a boon to advancing
the communication of the discussion.
I don't know Javascript, so you'd better not use that as an example
around me (at least, if you want to see me understand it, or not gloss
over it as just a bit of language-specific code to ignore). Really,
you don't know what language someone knows or not, so it's a crap
shoot as to whether you're really going to connect with the reader
_unless_ you use the language of the stated forum. In c.l.l that
language is Lisp (any lisp). Go with the native language of the forum
and you will indeed reach the most readers.

Duane
Tim Harig
2011-01-05 22:51:03 UTC
Permalink
Post by Duane Rettig
Post by Tim Harig
That is true for trolls that are not actually part of your community.
Frankly, since I don't follow c.l.l, or any other LISP specific
group, I don't know who is and who isn't a part of that community.
Careful; you are in danger of becoming the very kind of troll you
would place in your kill-file. I had originally written you off as
what I call a "hit and run" troll: many newsgroups have people pop in
an back out saying something like "I don't read this newsgroup, but I
have this to say; don't bother replying because I won't see your
reply". Happily, I've seen that since you are answering others the
"hit and run" portion does not apply, and also since you seem to be
honestly trying to answer people's responses, I'm now considering you
not to be a troll (but only by a hair; very much more insistence on
making your single point will drive you back over the line...)
I wouldn't blame you for considering me a troll from this thread alone. If
you question whether or not I am a troll, you should probably look at my
posting history in an archive.

I follow far more groups then I actually post to. For instance, I follow
c.l.ada; but, I have never posted there because of the extreme negativity
that they hold towards C programmers. I do like the Ada language and I
occassionally learn from what is posted.

I don't subscribe to c.l.lisp but I do follow c.l.functional where
this was cross-posted. I am rather new to the concepts of functional
programming so I subscribed and have been monitoring this ng in the hopes
of learning functional programming idioms and techniques. I don't post
much 1. because this ng doesn't receive a lot of traffic and 2. because
my limited knowledge in this area means I wouldn't have much constructive
to say anyway even if it did.
http://groups.google.com/group/comp.lang.functional/msg/b8f6221d18f6baee?dmode=source
Post by Duane Rettig
Post by Tim Harig
Other languages, however, seem to keep the appearence of being far
less interested in advocacy.  I would seem that the culture of those
communities promotes an open
Unfinished thought here? Or simple attention deficit?
Yes, it was unfinished. Sorry. I have been running on limited sleep for
the past few days so I am a little lupy.
Post by Duane Rettig
Post by Tim Harig
For my own part, when posting in language agnostic groups/forums, I
try to answer in psuedocode or as an English sequence of instructions.
If you are posting pseudocode, then you are advocating that
pseudocode, and the reader still has to decipher what you had meant,
because in many cases the pseudocode is not precise enough for a
discussion of the details. But many people, even those who don't
actually use Lisp, consider Lisp to be its own pseudocode, which is
one reason why you often see it in examples.
I am sure that everybody considers their own language preferences to be
its own psuedocode. The truth is often far from the case.

Basic concepts such as algorithms or data structures can often be described
in language inspecific terms. A linked list works pretty equivilantly in
any language containing pointers or references even though the syntax for
accessing the next node might vary significantly.
Post by Duane Rettig
Post by Tim Harig
If all else fails, I try to use a language that most programmers are
probably familiar with and/or should be able to follow even if they come
from a very different language. (Javascript being a common example.)
I simply consider that to be a common courtesy and a boon to advancing
the communication of the discussion.
I don't know Javascript, so you'd better not use that as an example
around me (at least, if you want to see me understand it, or not gloss
over it as just a bit of language-specific code to ignore). Really,
I am not a big fan of Javascript myself; but, it is one of the most
widely known languages. I have seen reports which suggest that it
is one of the most common first programming languages because of its
association with the web. It shares a similar syntax to the so-called
and widely distributed curly brace languages so anybody with a C/Java/etc
background should be able to make heads or tails of it. It also has well
as a strong functional (but not purely functional) background so it is
possible to demonstrate functional concepts as well as imperative ones.
Implementations are also available without having to install additional
software (compilers, interpreters, etc) on almost every major network
platform; so, it is possible for the user to experiment with the
example code. I cannot think of a language that is more likely to be
recoginized and available, even if there are people like you who may
not understand it. It is simply a matter of probability. That is why I
might default to Javascript for examples.
Post by Duane Rettig
you don't know what language someone knows or not, so it's a crap
shoot as to whether you're really going to connect with the reader
_unless_ you use the language of the stated forum. In c.l.l that
What exactly is the "stated language" for forums such as comp.programming
or c.l.functional? Sometimes the poster states their language and
sometimes they provide example code to help describe their problem.
Sometimes I provide a list of the languages I know and simply ask
them which language they would prefer the example in. I generaly find
a language with enough common concepts to a language that the poster
knows to to be able to communicate -- even when we don't share a single
common language.
Duane Rettig
2011-01-06 17:45:38 UTC
Permalink
I wouldn't blame you for considering me a troll from this thread alone.  If
you question whether or not I am a troll, you should probably look at my
posting history in an archive.
I only answered you because I don't think you are s troll at this
point. That may change, but for now the conversation is on topic.
I don't subscribe to c.l.lisp but I do follow c.l.functional where
this was cross-posted.  I am rather new to the concepts of functional
programming so I subscribed and have been monitoring this ng in the hopes
of learning functional programming idioms and techniques.  I don't post
much 1. because this ng doesn't receive a lot of traffic and 2. because
my limited knowledge in this area means I wouldn't have much constructive
to say anyway even if it did.
A wise choice.
http://groups.google.com/group/comp.lang.functional/msg/b8f6221d18f6b...
Well, this is a perfect example of what is not necessary in c.l.l.
Lisp has no syntax; it's all parentheses and semantics, so there is no
need for a discussion on c.l.l about whether to add a semicolon
(unless some troll who doesn't understand that lisp has no syntax
tries to argue that he doesn't like the syntax of lisp). The whole
purpose of getting beyond the issue of syntax is so that real problems
can be discussed. That's why we seasoned lispers love the fact that
the only syntax elements are the parens, because those tend to
disappear from our cognizance so we can concentrate on the real meat
of the programming.

In the link you provided, you may have contributed to the
conversation, but I submit that the conversation itself should have
been considered useless, and people should have gotten back to
advocating for functional programming rather than discuss syntax.
Now, I don't know how that thread ended up going, because I only read
your article, but I took my clue from the subject line of the thread,
which itself had "syntax" as its discussion goal.

Threads like that in _this_ newsgroup can be immediately identified as
off-topic to lisp, and readers can kill or ignore those threads and
concentrate on the threads which actually discuss lisp concepts.
Post by Duane Rettig
Post by Tim Harig
For my own part, when posting in language agnostic groups/forums, I
try to answer in psuedocode or as an English sequence of instructions.
If you are posting pseudocode, then you are advocating that
pseudocode, and the reader still has to decipher what you had meant,
because in many cases the pseudocode is not precise enough for a
discussion of the details.  But many people, even those who don't
actually use Lisp, consider Lisp to be its own pseudocode, which is
one reason why you often see it in examples.
I am sure that everybody considers their own language preferences to be
its own psuedocode.  The truth is often far from the case.
Maybe you missed the part where I said "even those who don't actually
use Lisp".
Basic concepts such as algorithms or data structures can often be described
in language inspecific terms.  A linked list works pretty equivilantly in
any language containing pointers or references even though the syntax for
accessing the next node might vary significantly.
And how do you describe such linked-list pointers and/or
dereferences? However you describe it, you must borrow or invent some
syntax. If you invent your own syntax, you run the risk of people not
understanding it. If you borrow the syntax from a language or
language group, then your pseudocode looks like that language.
Post by Duane Rettig
you don't know what language someone knows or not, so it's a crap
shoot as to whether you're really going to connect with the reader
_unless_ you use the language of the stated forum.  In c.l.l that
What exactly is the "stated language" for forums such as comp.programming
or c.l.functional?
Just as any language which calls itself a "lisp" is acceptable for
pseudo or real code here, I would assume that any language which calls
itself "functional" would be acceptable for posting in c.l.f.

Duane
Tim Harig
2011-01-07 02:19:24 UTC
Permalink
Post by Duane Rettig
http://groups.google.com/group/comp.lang.functional/msg/b8f6221d18f6b...
Well, this is a perfect example of what is not necessary in c.l.l.
Which, besides the fact that the OP wasn't trying to re-invent LISP,
is probably why it wasn't posted to c.l.l.
Post by Duane Rettig
Lisp has no syntax; it's all parentheses and semantics, so there is no
need for a discussion on c.l.l about whether to add a semicolon
(unless some troll who doesn't understand that lisp has no syntax
tries to argue that he doesn't like the syntax of lisp). The whole
purpose of getting beyond the issue of syntax is so that real problems
can be discussed. That's why we seasoned lispers love the fact that
the only syntax elements are the parens, because those tend to
disappear from our cognizance so we can concentrate on the real meat
of the programming.
I don't doubt the power of S-expressions. If I was working on a problem
where I wanted to dynamically generate and execute code, I would no doubt
choose LISP for that project. I do not however consider that to be an
exclusive method for problem solving. Once again, I support using the
right tool for the right job. If that tool is LISP then great; if not, so
be it.
Post by Duane Rettig
Post by Duane Rettig
discussion of the details.  But many people, even those who don't
actually use Lisp, consider Lisp to be its own pseudocode, which is
one reason why you often see it in examples.
I am sure that everybody considers their own language preferences to be
its own psuedocode.  The truth is often far from the case.
Maybe you missed the part where I said "even those who don't actually
use Lisp".
I heard what you said. My point is that I don't really consider you
objective enough to make that statement.

I am sure in certain communities (ie, AI) where LISP is common, most
members probably have enough exposure with it to read it without much
trouble. I however have watched programmers without a LISP background
struggle when exposed to the language. This isn't merely a matter of
S-expressions but much more a result of cryptic standard function names
(car, cons, cdr, etc) that one needs to familiar with to understand what
is happening in a give piece of code.

I do not therefore, consider the validity of anybody telling me that their
language is equivilant to psuedocode without studies conducted on novice
programmers without experience in a similar language. I certainly wouldn't
assert that my own langauges pass for psuedocode without similar backing.
Post by Duane Rettig
Basic concepts such as algorithms or data structures can often be described
in language inspecific terms.  A linked list works pretty equivilantly in
any language containing pointers or references even though the syntax for
accessing the next node might vary significantly.
And how do you describe such linked-list pointers and/or
dereferences? However you describe it, you must borrow or invent some
syntax. If you invent your own syntax, you run the risk of people not
understanding it. If you borrow the syntax from a language or
language group, then your pseudocode looks like that language.
For something like linked lists, I would probably start off with pictures
describing the structure of a linked list. Nothing fancy, just boxes
of fields with lines showing the pointer/reference links between them.
Web forums with the ability to link images have an advantage here; but,
similar diagrams can be generated using ascii art or URLs to pictures
could be posted without explicit links.

Operations on linked lists and other algorithms can be describe as simple
English instructions:

step 1: links this to that
step 2: link that to this
stet 3: etc.

If the poster cannot figure out how to do the linking in his or her
language, then they can ask how to perform the linking in a group specific
to their language.
Post by Duane Rettig
Post by Duane Rettig
you don't know what language someone knows or not, so it's a crap
shoot as to whether you're really going to connect with the reader
_unless_ you use the language of the stated forum.  In c.l.l that
What exactly is the "stated language" for forums such as comp.programming
or c.l.functional?
Just as any language which calls itself a "lisp" is acceptable for
pseudo or real code here, I would assume that any language which calls
itself "functional" would be acceptable for posting in c.l.f.
Right; and, any programming language is theoretically acceptable for
comp.programming. These are what I call language agnostic groups since
they are about a shared rogramming topic (algorithms, data structures,
functional design, etc) irregardless of the language used to implement
them. Where such groups exist, it is reasonable to assume that not
everybody will speak the same set of languages. It is therefore important
to find non-programming language methods for communication or to find
common languages understood by both parties so as to facilitate the
communications channel. The insistance of posting in a language that
the user does not understand inhibits communication.
w_a_x_man
2011-01-07 06:39:42 UTC
Permalink
Post by Tim Harig
functional design, etc) irregardless of the language used to implement
It's "regardless" or "irrespective".
Tim Bradshaw
2011-01-07 07:48:09 UTC
Permalink
Post by Tim Harig
This isn't merely a matter of
S-expressions but much more a result of cryptic standard function names
(car, cons, cdr, etc) that one needs to familiar with to understand what
is happening in a give piece of code.
There's a school of thought among Lisp (well, CL, anyway) users that
you should never use CAR & CDR but rather FIRST & REST. I don't agree
with that - I think there's a place for them when dealing with
conses-as-pairs rather than conses-as-bits-of-linked-lists. However if
people are posting Lisp samples for non-Lisp users which are full of
CAR & CDR then that's a pretty poor example code. Even then, when
teaching Lisp, I often would start off introducing pairs by using
accessors like LEFT and RIGHT, say, and only later say that, "well,
LEFT is CAR and RIGHT is CDR (or vice-versa on little-endian machines)".

In any case, if you're seeing code that is full of car/cdr calls, or
other slightly obscure old Lisp names posted as examples in non-lisp
groups, without clear explanations of what they mean, then whoever
posted it is probably at fault I think: that's just poor code.
Tim Harig
2011-01-07 11:21:41 UTC
Permalink
Post by Tim Bradshaw
Post by Tim Harig
This isn't merely a matter of
S-expressions but much more a result of cryptic standard function names
(car, cons, cdr, etc) that one needs to familiar with to understand what
is happening in a give piece of code.
There's a school of thought among Lisp (well, CL, anyway) users that
you should never use CAR & CDR but rather FIRST & REST. I don't agree
I would certainly consider that to be a readability improvement. Using
something with a verb-subject nomenclature would be even better: get-first,
get-rest, pop-first, remove-first, etc.

Nevertheless, I wouldn't equate any programming language, which requires
basic familiarity with the language, to be equivilant to psuedocode,
visual diagrams, or basic descriptions and instructions in the user's
native spoken language.
Nicolas Neuss
2011-01-07 12:39:30 UTC
Permalink
Post by Tim Harig
Post by Tim Bradshaw
There's a school of thought among Lisp (well, CL, anyway) users that
you should never use CAR & CDR but rather FIRST & REST. I don't agree
I would certainly consider that to be a readability improvement.
get-first, get-rest, pop-first, remove-first, etc.
I would disagree here, because the verbosity introduced by "get-" does
not really help with understanding. In a functional setting, you would
expect that a function "gets" you a result. Similar with "pop-first"
and "remove-first". You should better teach people that simple lists
are constructed and accessed stack-like, i.e. only from one side (which
is from the beginning in Lisp).
Post by Tim Harig
Nevertheless, I wouldn't equate any programming language, which
requires basic familiarity with the language, to be equivilant to
psuedocode, visual diagrams, or basic descriptions and instructions in
the user's native spoken language.
They are different. Descriptions in standard language are usually
easier to understand, programs in any language are usually much more
precise. Being someone having posed a question in some newsgroup I
guess I would be grateful for both kinds of information.

Visual diagrams can be nice too, but are so much work that a questioner
should better not expect them.

Nicolas
Tim Harig
2011-01-07 13:23:21 UTC
Permalink
Post by Nicolas Neuss
Post by Tim Harig
Post by Tim Bradshaw
There's a school of thought among Lisp (well, CL, anyway) users that
you should never use CAR & CDR but rather FIRST & REST. I don't agree
I would certainly consider that to be a readability improvement.
get-first, get-rest, pop-first, remove-first, etc.
I would disagree here, because the verbosity introduced by "get-" does
not really help with understanding. In a functional setting, you would
expect that a function "gets" you a result. Similar with "pop-first"
and "remove-first". You should better teach people that simple lists
are constructed and accessed stack-like, i.e. only from one side (which
is from the beginning in Lisp).
I suggested that differentiation because it gives a clue as to what side
affects the function has on the original data. FIRST could very well act
as a pop, taking the first value out of the list and returning it to the
calling function. For purely functional languages, this wouldn't be an
issue as the source data could not be modified anyway; but, not all
dialects of LISP are purely functional. Adding the verb makes explicitly
clear exaclty what is going on.

In Erlang, and I suspect in several other functional languages, such
a function is not needed because the because the language provides a
pattern matching syntax that can be used to decompose the string:

[First | Rest] = List
Post by Nicolas Neuss
Post by Tim Harig
Nevertheless, I wouldn't equate any programming language, which
requires basic familiarity with the language, to be equivilant to
psuedocode, visual diagrams, or basic descriptions and instructions in
the user's native spoken language.
They are different. Descriptions in standard language are usually
easier to understand, programs in any language are usually much more
precise. Being someone having posed a question in some newsgroup I
guess I would be grateful for both kinds of information.
Much agreed; but, my point is that code samples are only useful if you can
make heads or tails of the language that they are written in. They don't
have to be exact. Somebody who understands C++ will likely be able
to make sense of an example written in Java. Somebody who understands
Haskell could probably manage to interpret Erlang. Giving Erlang code to
somebody who only knows Java is likely to cause quite a bit of confusion.
The same might also be true vise-versa. I feel that it is important to
at least try to make an effort to post examples in a language that the
user is comfortable with.
Post by Nicolas Neuss
Visual diagrams can be nice too, but are so much work that a questioner
should better not expect them.
Agreed.
Marco Antoniotti
2011-01-07 15:55:31 UTC
Permalink
Post by Tim Harig
Post by Nicolas Neuss
Post by Tim Harig
Post by Tim Bradshaw
There's a school of thought among Lisp (well, CL, anyway) users that
you should never use CAR & CDR but rather FIRST & REST.  I don't agree
I would certainly consider that to be a readability improvement.
get-first, get-rest, pop-first, remove-first, etc.
I would disagree here, because the verbosity introduced by "get-" does
not really help with understanding.  In a functional setting, you would
expect that a function "gets" you a result.  Similar with "pop-first"
and "remove-first".  You should better teach people that simple lists
are constructed and accessed stack-like, i.e. only from one side (which
is from the beginning in Lisp).
I suggested that differentiation because it gives a clue as to what side
affects the function has on the original data.  FIRST could very well act
as a pop, taking the first value out of the list and returning it to the
calling function.  For purely functional languages, this wouldn't be an
issue as the source data could not be modified anyway; but, not all
dialects of LISP are purely functional.  Adding the verb makes explicitly
clear exaclty what is going on.
In Erlang, and I suspect in several other functional languages, such
a function is not needed because the because the language provides a
        [First | Rest] = List
What's wrong with

(unify '(?first . ?rest) some-list)

?

(It is a shameless plug: see CL-UNIFICATION :) )

Cheers
--
Marco
Tim Harig
2011-01-07 22:19:53 UTC
Permalink
["Followup-To:" header set to comp.lang.functional.]
Post by Marco Antoniotti
Post by Tim Harig
Post by Nicolas Neuss
Post by Tim Harig
Post by Tim Bradshaw
There's a school of thought among Lisp (well, CL, anyway) users that
you should never use CAR & CDR but rather FIRST & REST.  I don't agree
I would certainly consider that to be a readability improvement.
get-first, get-rest, pop-first, remove-first, etc.
I would disagree here, because the verbosity introduced by "get-" does
not really help with understanding.  In a functional setting, you would
expect that a function "gets" you a result.  Similar with "pop-first"
and "remove-first".  You should better teach people that simple lists
are constructed and accessed stack-like, i.e. only from one side (which
is from the beginning in Lisp).
I suggested that differentiation because it gives a clue as to what side
affects the function has on the original data.  FIRST could very well act
as a pop, taking the first value out of the list and returning it to the
calling function.  For purely functional languages, this wouldn't be an
issue as the source data could not be modified anyway; but, not all
dialects of LISP are purely functional.  Adding the verb makes explicitly
clear exaclty what is going on.
In Erlang, and I suspect in several other functional languages, such
a function is not needed because the because the language provides a
        [First | Rest] = List
What's wrong with
(unify '(?first . ?rest) some-list)
1. My point in bringing up the Erlang syntax is that the sub-issue
Antoniotti brought up, which only applies to purely functional
languages where side affects cannot exist, doesn't exist for
many purely functional languages. I maintain a preference for the
verb form in LISP because:

A. it adds information for dialects where side affects are
possible and

B. it mirrors a statement in English speech which is at the very
least composed of a verb and a subject. The subject is sometimes
implied. The verb is always necessary.

This point is at best a tangent to the main issue of the thread of
conversation.

2. Back to the main issue, I didn't state that Erlang's syntax was any
clearer or equated better to psuedocode. I made no claims to its
superiority over any other syntax. I would not expect somebody
who had not seem similar constructs before, to understand or
make "heads or tails" out of it (pun intended). I can safely
exibit it here because the meaning had already been discussed
in a language that the parent understood.

3. I am sure your unify statement is perfectly readable to those familiar
with LISP; but, that hardly passes for psuedocode for those
who are not. I will give you an idea of what somebody without
experience without LISP, another symbolic manipulation language,
who as not other explanation of the statement, and who has not
followed this thread might make of your statement:

A. To unify means to join. Therefore your function must join
portions of a some-list using the DSL string to format how the
portions are joined much like how "%02d" in C's printf (1) would
specify how to interprate the remaining argument list. I am not
really sure what the period refers to in this DSL.

(1) For those who are unaware, "%02d" as the first argument of
printf(), which is used to display information on the terminal
unless it has been redirected, would indicate to printf that
it should have one other argument, that that argument should be
interpreted as an integer, and that it should be displayed with
a width of at least two characters with 0's to pad any missing
higher digits. with 0's to pad any missing higher digits. with
0's to pad any missing higher digits. with 0's to pad any missing
higher digits.

B. There must be a syntax error because the quote is unmatched.

C. The qustion marks must be sigils to indicate that these strings
are to be interpolated as variables.

D. There is only one argument, so I must assume that the resulting
join is saved to some-list and the first and last variables must be
scoped to the outside context (whatever that happens to be for
LISP).

E. Therefore, your statment, if you hadn't forgotten the closing
quote, would join two lists placing something in
between them where they are joined and saves this new list to
some-list.

Even that is taking a lot of knowledge into account that I cannot
even rid myself of. Somebody unfamiliar without LISP probably
wouldn't even know that the first item is the function or that
all of this has something to do with lists.

I reiterate my point: no programming language is intuitively obvious for
those who have no familiarity with it. Knowledge derived from familiarity
does not imply intuition. None of us are born with pre-knowledge of any
programming language.
Pascal J. Bourguignon
2011-01-08 01:19:42 UTC
Permalink
Post by Tim Harig
FIRST could very well act
as a pop, taking the first value out of the list and returning it to the
calling function.
Yes, but lispers don't like to shoot in their own feets. If an
operators pops, then it's called POP, not FIRST.
Post by Tim Harig
Post by Nicolas Neuss
Post by Tim Harig
Nevertheless, I wouldn't equate any programming language, which
requires basic familiarity with the language, to be equivilant to
psuedocode, visual diagrams, or basic descriptions and instructions in
the user's native spoken language.
They are different. Descriptions in standard language are usually
easier to understand, programs in any language are usually much more
precise. Being someone having posed a question in some newsgroup I
guess I would be grateful for both kinds of information.
Much agreed; but, my point is that code samples are only useful if you can
make heads or tails of the language that they are written in. They don't
have to be exact. Somebody who understands C++ will likely be able
to make sense of an example written in Java. Somebody who understands
Haskell could probably manage to interpret Erlang. Giving Erlang code to
somebody who only knows Java is likely to cause quite a bit of confusion.
The same might also be true vise-versa. I feel that it is important to
at least try to make an effort to post examples in a language that the
user is comfortable with.
Yes. However, lisp and scheme can be used for the same purpose, as
proved by eg. SICP.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
Tim Harig
2011-01-08 05:17:41 UTC
Permalink
Post by Pascal J. Bourguignon
Post by Tim Harig
Post by Nicolas Neuss
Post by Tim Harig
Nevertheless, I wouldn't equate any programming language, which
requires basic familiarity with the language, to be equivilant to
psuedocode, visual diagrams, or basic descriptions and instructions in
the user's native spoken language.
They are different. Descriptions in standard language are usually
easier to understand, programs in any language are usually much more
precise. Being someone having posed a question in some newsgroup I
guess I would be grateful for both kinds of information.
Much agreed; but, my point is that code samples are only useful if you can
make heads or tails of the language that they are written in. They don't
have to be exact. Somebody who understands C++ will likely be able
to make sense of an example written in Java. Somebody who understands
Haskell could probably manage to interpret Erlang. Giving Erlang code to
somebody who only knows Java is likely to cause quite a bit of confusion.
The same might also be true vise-versa. I feel that it is important to
at least try to make an effort to post examples in a language that the
user is comfortable with.
Yes. However, lisp and scheme can be used for the same purpose, as
proved by eg. SICP.
You are fighting a straw man. I never said the langauge was hard to
learn or that it could not be used for teaching. Any language can
used with a simple introduction. Even SICP feels the need teach its
readers the fundimentals of s-expressions, mathematical expressions,
assignments, conditionals, procedure definitions etc for LISP in the
very first section and chapter of the book rather then simply throwing
unexplained code at its readers. Why do you suppose that is.

Far more telling is the fact that it explains non-obvious primitive
functions before they are used. You don't see SICP using list, cons,
car, cdr, etc before being explained. The reader is never in the position
to have to guess what a piece of example code is doing.

So no, SICP doesn't expect its readers to automatically understand
the LISP language. It merely adopts a strategy of teaching them the
langauge incrementally along with basic programming concepts as it goes.
If the same level of care was being taken with posted LISP examples,
I would not have felt the need to reply to this thread in the first place.
Pascal J. Bourguignon
2011-01-08 07:10:02 UTC
Permalink
Post by Tim Harig
If the same level of care was being taken with posted LISP examples,
I would not have felt the need to reply to this thread in the first place.
Why should we include a lisp tutorial in each message to a generic
newsgroup showing lisp code, when

1- those tutorial are so easily accessible on the web,

2- the language is so simple that these tutorial mostly state the
obvious.

I mean, to take an example from sicp:

(+ (* 3
(+ (* 2 4)
(+ 3 5)))
(+ (- 10 7)
6))

if you don't understand this expression without having to read the
previous explanations, perhaps you should not consider CS and
programming. Yes, I'd tend to take that as an IQ test...
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
Tim Harig
2011-01-08 08:05:11 UTC
Permalink
Post by Pascal J. Bourguignon
Post by Tim Harig
If the same level of care was being taken with posted LISP examples,
I would not have felt the need to reply to this thread in the first place.
Why should we include a lisp tutorial in each message to a generic
newsgroup showing lisp code, when
Because you are the one insisting that somebody else needs to learn yet
another langauge just to read sample code rather then trying to find
some common ground.
Post by Pascal J. Bourguignon
1- those tutorial are so easily accessible on the web,
So are tutorials for most other languages. I therefore assume that you
thinks everybody else should learn your language that you should be just as
eager to learn everbody elses.
Post by Pascal J. Bourguignon
2- the language is so simple that these tutorial mostly state the
obvious.
You assume that because it is obvious to you, who is already familiar
with the language, that it is obvious to everbody else. I could make
the same statement of any of the languages that I use. I could claim
that Engish is more intuitive the Arabic. Most native English speakers
would probably agree with me; but, I am sure people from the middle east
would probably disagree.

If LISP is so obvious, then why do I have a LISP book that requires 600
pages to explain it? Why does SICP, your own example, need to teach
the language throughout the book? Perhaps you would like to explain
why somebody who has never encountered CDR should immediately understand
its purpose?

The only difference between me with my language and you with your's is
that I am objective enough to realize that people weren't born speaking
my programming language; or any other.
Post by Pascal J. Bourguignon
(+ (* 3
(+ (* 2 4)
(+ 3 5)))
(+ (- 10 7)
6))
So is:

((3 * ((2 * 4) + (3 + 5))) + ((10 - 7) + 6))

That at least has the advantage to what most of us learned in elementry
math class. The RPN version is only slightly less familiar to most of us.
Both of them can be entered into commonly available calculators. Where do
I buy a $20 LISP entry calculator?

But then, this is a contrived and overly simplified example. All languages
look pretty simple when all you are doing is simple arithmetic. All of
them get harder to follow when you add more functionality. My LISP book
lists 129 primatives. I don't know about you, but I had to learn all of
them *after* I was born.
Post by Pascal J. Bourguignon
if you don't understand this expression without having to read the
previous explanations, perhaps you should not consider CS and
programming. Yes, I'd tend to take that as an IQ test...
No, it is a knowledge test. Somebody who has a IQ of 120 wouldn't have a
clue about the meaning of those symbolic representations had they not been
taught Arabic numerals and/or mathematics using "+-*" operators/functions.
Or should I think you have a low IQ because you cannot solve equations
written in Mayan? IQ is evident in how well you use them after you have
learned their meaning.
Pascal J. Bourguignon
2011-01-08 08:22:15 UTC
Permalink
Post by Tim Harig
Post by Pascal J. Bourguignon
Post by Tim Harig
If the same level of care was being taken with posted LISP examples,
I would not have felt the need to reply to this thread in the first place.
Why should we include a lisp tutorial in each message to a generic
newsgroup showing lisp code, when
Because you are the one insisting that somebody else needs to learn yet
another langauge just to read sample code rather then trying to find
some common ground.
Post by Pascal J. Bourguignon
1- those tutorial are so easily accessible on the web,
So are tutorials for most other languages. I therefore assume that you
thinks everybody else should learn your language that you should be just as
eager to learn everbody elses.
Why should *I* learn python or ruby or whatever to read your examples?
Post by Tim Harig
Post by Pascal J. Bourguignon
2- the language is so simple that these tutorial mostly state the
obvious.
You assume that because it is obvious to you, who is already familiar
with the language, that it is obvious to everbody else. I could make
the same statement of any of the languages that I use.
Mostly, yes. A normal programmer should be able to understand an
algorithm whatever the programming language used, even if he doesn't
understand the fine details of the syntax.

Or said otherwise, if you write an algorithm in a programming language
for human consuption, you should make it clear, and avoid any
obfuscation.
Post by Tim Harig
If LISP is so obvious, then why do I have a LISP book that requires 600
pages to explain it? Why does SICP, your own example, need to teach
the language throughout the book? Perhaps you would like to explain
why somebody who has never encountered CDR should immediately understand
its purpose?
My point is that any programmer should have encountered CDR as well as
BEGIN/END. After all, both are operators that are as old as computer
programming.
Post by Tim Harig
The only difference between me with my language and you with your's is
that I am objective enough to realize that people weren't born speaking
my programming language; or any other.
We're not talking about babies, we're talking about computer
programmers.
Post by Tim Harig
Post by Pascal J. Bourguignon
(+ (* 3
(+ (* 2 4)
(+ 3 5)))
(+ (- 10 7)
6))
((3 * ((2 * 4) + (3 + 5))) + ((10 - 7) + 6))
That at least has the advantage to what most of us learned in elementry
math class. The RPN version is only slightly less familiar to most of us.
Both of them can be entered into commonly available calculators. Where do
I buy a $20 LISP entry calculator?
Where do you buy a $20 calculator? It's been at least 20 years I've
seen a calculator...
Post by Tim Harig
But then, this is a contrived and overly simplified example. All languages
look pretty simple when all you are doing is simple arithmetic. All of
them get harder to follow when you add more functionality. My LISP book
lists 129 primatives. I don't know about you, but I had to learn all of
them *after* I was born.
But not after you became a programmer.
Post by Tim Harig
Post by Pascal J. Bourguignon
if you don't understand this expression without having to read the
previous explanations, perhaps you should not consider CS and
programming. Yes, I'd tend to take that as an IQ test...
No, it is a knowledge test. Somebody who has a IQ of 120 wouldn't have a
clue about the meaning of those symbolic representations had they not been
taught Arabic numerals and/or mathematics using "+-*" operators/functions.
Or should I think you have a low IQ because you cannot solve equations
written in Mayan? IQ is evident in how well you use them after you have
learned their meaning.
No, IQ is how well you are able to guess or infer their meaning.

Babies don't have to read a grammar and a dictionnary to learn how to
speak. Most programmers don't read language reference manuals either to
learn a new programming language.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
Tim Harig
2011-01-08 08:54:24 UTC
Permalink
Post by Pascal J. Bourguignon
Post by Tim Harig
Post by Pascal J. Bourguignon
Post by Tim Harig
If the same level of care was being taken with posted LISP examples,
I would not have felt the need to reply to this thread in the first place.
Why should we include a lisp tutorial in each message to a generic
newsgroup showing lisp code, when
Because you are the one insisting that somebody else needs to learn yet
another langauge just to read sample code rather then trying to find
some common ground.
Post by Pascal J. Bourguignon
1- those tutorial are so easily accessible on the web,
So are tutorials for most other languages. I therefore assume that you
thinks everybody else should learn your language that you should be just as
eager to learn everbody elses.
Why should *I* learn python or ruby or whatever to read your examples?
Which pretty much demonstrates my point. Why should anybody learn LISP to
read yours? We have better things to do with our time and more advanced
langauges to learn. With that, this conversation is basically finished.
Post by Pascal J. Bourguignon
Post by Tim Harig
If LISP is so obvious, then why do I have a LISP book that requires 600
pages to explain it? Why does SICP, your own example, need to teach
the language throughout the book? Perhaps you would like to explain
why somebody who has never encountered CDR should immediately understand
its purpose?
My point is that any programmer should have encountered CDR as well as
BEGIN/END. After all, both are operators that are as old as computer
programming.
So is the massively overloaded anachronism that is JCL's DD. I don't
expect modern programmers outside of MVS to know how to use it either.
Post by Pascal J. Bourguignon
Post by Tim Harig
That at least has the advantage to what most of us learned in elementry
math class. The RPN version is only slightly less familiar to most of us.
Both of them can be entered into commonly available calculators. Where do
I buy a $20 LISP entry calculator?
Where do you buy a $20 calculator? It's been at least 20 years I've
seen a calculator...
I would suggest looking at your local office supply store.
Pascal J. Bourguignon
2011-01-08 11:23:32 UTC
Permalink
Post by Tim Harig
Post by Pascal J. Bourguignon
Post by Tim Harig
Post by Pascal J. Bourguignon
Post by Tim Harig
If the same level of care was being taken with posted LISP examples,
I would not have felt the need to reply to this thread in the first place.
Why should we include a lisp tutorial in each message to a generic
newsgroup showing lisp code, when
Because you are the one insisting that somebody else needs to learn yet
another langauge just to read sample code rather then trying to find
some common ground.
Post by Pascal J. Bourguignon
1- those tutorial are so easily accessible on the web,
So are tutorials for most other languages. I therefore assume that you
thinks everybody else should learn your language that you should be just as
eager to learn everbody elses.
Why should *I* learn python or ruby or whatever to read your examples?
Which pretty much demonstrates my point. Why should anybody learn LISP to
read yours? We have better things to do with our time and more advanced
langauges to learn. With that, this conversation is basically finished.
Now, please explain why I can read algorithms written in python, PL/1 or
Algol even while I never learned these programming languages?

(Granted, I'd have more difficulties with APL and perl, but Lisp is not
like these language, it doesn't rely on syntax to convey meaning).
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
Nicolas Neuss
2011-01-08 12:06:36 UTC
Permalink
Post by Tim Harig
Post by Pascal J. Bourguignon
Post by Tim Harig
If the same level of care was being taken with posted LISP examples,
I would not have felt the need to reply to this thread in the first place.
Why should we include a lisp tutorial in each message to a generic
newsgroup showing lisp code, when
Because you are the one insisting that somebody else needs to learn
yet another langauge just to read sample code rather then trying to
find some common ground.
IIRC, we were starting from someone posing a programming question in a
newsgroup. Assume that this person indeed got an answer with code in a
programming language that (s)he does know. In my opinion, reasonable
patterns of behaviour of this person could be:

- Wait for a better answer in another language (the chances are probably
not bad if the newsgroup is language-agnostic and the previous answer
used a "rare" language).

- Try to understand the code (maybe even by reading a tutorial on the
unknown language). If necessary, ask about details. This would be
the way of choice for a programmer with a little time and some
self-respect.

What is not a reasonable pattern of behaviour (IMO) is to complain
loudly about the impertinence of that answer. Remember that asking in
newsgroups is not the same as paying for consulting.

Nicolas
Nicolas Neuss
2011-01-08 12:10:34 UTC
Permalink
[...] newsgroup. Assume that this person indeed got an answer with code in a
programming language that (s)he does know. [...]
^
not

Pascal J. Bourguignon
2011-01-08 00:49:26 UTC
Permalink
Post by Tim Harig
Post by Tim Bradshaw
Post by Tim Harig
This isn't merely a matter of
S-expressions but much more a result of cryptic standard function names
(car, cons, cdr, etc) that one needs to familiar with to understand what
is happening in a give piece of code.
There's a school of thought among Lisp (well, CL, anyway) users that
you should never use CAR & CDR but rather FIRST & REST. I don't agree
I would certainly consider that to be a readability improvement. Using
something with a verb-subject nomenclature would be even better: get-first,
get-rest, pop-first, remove-first, etc.
I'm just happy mathematicians don't name their functions get-sinus-of,
get-cotangeant-of, etc.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
Tim Bradshaw
2011-01-05 09:52:46 UTC
Permalink
Post by Tim X
I would add that it is a mistake to judge a community of users based on
a single forum. For example, many have complained about comp.lang.lisp
and it is often viewed as being the lisp community. In reality, it is
only a very small representation of lisp users from a single forum.
There are many other lisp forums with varying levels of acceptance,
hostility, dogma, experience, cynicism etc.
I think it's almost universally a mistake to judge anything by usenet
news, not just CLL. Newsgroups have always been odd and fierce places,
and (without evidence) I think usenet must be close to dead as a
discussion forum (as opposed to a media distribution mechanism where
it seems to be thriving).
Pascal J. Bourguignon
2011-01-04 06:24:13 UTC
Permalink
Post by rusi
Post by Tim Harig
Post by Didier Verna
Matz himself admitted that ???...Ruby is a bad rip-off of Lisp... But it
is nicer to ordinary people.???
This misconception that you must be exceptionally clever to learn and
use Lisp really hurts the language and the community.
What hurts the LISP community far more is the zealotry of its members,
their insistance that LISP is the *only* tool for *every* job, and their
agressiveness in trying to push it off on to everybody else -- whether
everybody else happens want it or not.  Whether this is indicitive
of the entire community or simply the result of those most apparent,
I cannot say; but, it leads to the overall impression that the LISP
community is narrowminded and neophobic.  Who would want to be part of
such a community?
There are more mundane reasons -- like unsuitability of lisp as a
distribution platform
[See http://www.newartisans.com/about-me.html where John Wiegley
explains why he switched from lisp to C++ for his program ledger ]
I saw no explanation, only the statements that he "found Common Lisp
unsuitable as a distribution platform."

Perhaps it was just him being unable to find an implementation of Common
Lisp suitable as distribution platform. I've got the impression a lot
of people are able to find such implementations of Common Lisp, to
distribute and deploy their applications, be it free software
implementations or commercial implementation.



In anycase, he gives no justification.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
Raffael Cavallaro
2011-01-04 15:43:37 UTC
Permalink
Post by Pascal J. Bourguignon
I saw no explanation, only the statements that he "found Common Lisp
unsuitable as a distribution platform."
He also says he likes Mac OS X so maybe he was looking for a native Mac
OS X distribution option. Unless he was writing about a very recent
experience, the best free option, Clozure CL64/32, was not yet mature
enough that many would want to use it to distribute an application
(imho it is now).

The other option for native Mac apps has been available for years -
LispWorks - but it is not free. Never underestimate people's ability to
allow the desire for a no-cost solution to override better judgement.
Clearly, he thinks lisp is superior; he thinks Mac OS X is superior;
until recently, you had to pay to distribute this combination in a
native app using a mature implementation and IDE.

warmest regards,

Ralph
--
Raffael Cavallaro
Didier Verna
2011-01-04 10:18:51 UTC
Permalink
Post by Tim Harig
What hurts the LISP community far more is the zealotry of its members,
their insistance that LISP is the *only* tool for *every* job, and
their agressiveness in trying to push it off on to everybody else --
whether everybody else happens want it or not. Whether this is
indicitive of the entire community or simply the result of those most
apparent, I cannot say; but, it leads to the overall impression that
the LISP community is narrowminded and neophobic. Who would want to be
part of such a community?
Not sure which lispers you've been talking to. I don't see any more
zealotry in the Lisp community than in any other one. I see, however,
things like Racket in which Lispers put a lot of efforts learning about
the cool stuff that comes from other languages and incorporating them
into their Lisp dialect (static typing, contracts, to name a few). Is
that narrowminded? Is it wrong to try to improve your preferred language
instead of switching to another one? These are the Lispers you should
talk to.

About the "*only* tool for *every* job" thing, there is often a
confusion between Lisp -- The Idea, and Lisp -- The Language(s). Lispers
usually like Lisp for its extreme customizability, something that is
closely related to Lisp -- The Idea (code is data, structural
reflexivity, the Lisp macros etc.). However, no programming language is
perfect, not even Lisp -- The Language(s). Common Lisp is far from
perfect, it's not perfect to have a gazillion Scheme dialects, let alone
Emacs Lisp.

The other thing that puzzles me is why you would be annoyed by people
trying to "push it off" on you. Maybe (just maybe ;-) I would try to
push off Lisp -- The Idea on you, but I wouldn't dare to try to push off
*any* language on you, because I don't know your background, your needs,
your interests etc. If somebody does that on me, I just ignore them.
--
Resistance is futile. You will be jazzimilated.

Scientific site: http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com
girosenth
2011-01-01 22:50:52 UTC
Permalink
Post by Pascal J. Bourguignon
Post by girosenth
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?
There are many people who have trivia complaints about parens in lisp,
but I dont.
LISP is a prefix notation.
(f ops (g ops (h ops (j ops (k ops (l ops ))...))))
How do you make it readable ?
How do you home to the center or centers ?
(f (g (h (j (k (l ops)))...)))
is easy to read or
ops l k j h g f
???
I think we can call you a troll.
Factually, such a level of prejudice is not good for health, intellect
or discussion.
Post by Pascal J. Bourguignon
Is it not obvious how you home to the center?http://www.informatimago.com/~pjb/bulleye.png
Is it not a flagrant proof that lisp is the most easy to read?
There are things that I was hoping experienced programmers would fill
in that I forgot to state.

In a one liner which is an accurately represented by the subsets your
image displays, it is infact true that the center(s) are immediately
obvious. But if each of the f,g,h,...k,l are huge functions (in the
definitions) then they may occupy parts of a screen and the whole may
occupy several screens, or several tens of screens. Note also that I
have ops only before , but they can be everywhere. Function
(definition) enclosures have a 1-1 correspondence with trees as any
hierarchical objects and may look like a herringbone tree.

Sphagetti code which was promoted by a goto was brought under control
by "structured" programming which had only 3 forms (thus removing the
need for a flow chart) ie sequence, selection and iteration.
Functional language adds another useful form which is recursion and
(as a side comment) recursion is not representable by a flowchart.

The sequence, which is the simplest of the construct is essentially
imperative in nature. Sequence of state changes.

A purely functional program would have a single huge nested function.

One could say that a huge function can be broken into simpler
functions. Logic could always be chased LINE BY LINE by a determined
reader with unlimited time, but for most of us, programming efficiency
is an issue. However, to break a several screen or even a smaller set
of computation, I am faced with how to break it into parts due to
coupling in its parts. I was doing it inside let* to avoid setq
(fair ?) but I have a function that must return a number or a string
depending on if a regex was found and its index or a message that it
was not found.

(string-match REGEXP STRING &optional START)

inside a (cond) I return a string or the number

I am constrained to write like this because I wrote a quick and dirty
working and structurally (in the sense of structured) readable code
but WITHOUT taking care of failures or errors. Now I am trying to
modify it to take care of errors.

I must test it as soon as string match what type of regexp was not
found.

As I started modifying it, I lost track of its structure. I could
understand it at the write time but I know that after forgetting, at
the read time I will not understand it in the linear sense of the size
increase.

Even as I explained to a friend, I realized that I need to home in to
the center and reading was not linear as FORTH promises and any
postfix language with action words (functions) reads. The reading is
not linear.

I realized that you can read infix notation or standard function
notation f(x) of (f x) only because they are simpler functions, not
the recursive type functions of McCarthy. Those functions have if then
else logic embedded that is not apparent as you start reading it.

Our math functions are very simple, and most often single letters.
That is why algebraic notation is easy for them.

In comparison to prefix, postfix seems in the order of the action.
Certainly, it starts with the center object moved to the left most.

One gentleman has advocated ruby. The thread will be enriched by
perspectives from other functional languages. Suppose, I want to stick
to elisp and then move to CL (since almost everyone who has not taken
a course in lisp or scheme and who starts with linux comes to emacs
and elisp first) instead of ruby, then it appears to me that macros
which are being discussed without any examples in elisp or even CL
might be an answer to take care of sphagetti code or highly coupled
code. I was considering making a huge MIMO function that takes in many
bits and makes an output to be used by others. Atleast, the main
program would be readable. Such a function would have no analogy to
the real world object or operation and thus built on fictional lines
and unstable in construction and likely to be challenged by then next
exception that I would encounter in my build-fix method and thus beg
for recoding and re-reading again. Readability then is an issue.

I read your post somewhere with your example of flatten. I was
honestly not impressed with readability. All that you did was to
compress cond and also to use push/pop which would be indicated by a
text comment as clearly. Admitted that the code took smaller part of
the screen.

In modern IDE's there is a feature which allows code to be collapsed.
I am using older version of emacs I dont know if RMS and his team has
copied such features from eclipse and other IDEs into emacs and
debugged them or a bold adventurer would be on their mercy.

In the hygenic macro thread currently in progress, I want to ask them
to show me how macros can be written to prove their claims assuming
that I have good grasp of basics like quote, backquote, unquote and
splice.

I know some of these might sound unpleasant to commercial entities
with so much invested in it but for us, honest discussion and support
of claims by demonstration example is what really counts.

girosenth
Post by Pascal J. Bourguignon
--
__Pascal Bourguignon__                    http://www.informatimago.com/
A bad day in () is better than a good day in {}.- Hide quoted text -
- Show quoted text -
José A. Romero L.
2011-01-03 16:21:42 UTC
Permalink
On 1 Jan, 23:50, girosenth <***@india.com> wrote:
(...)
Post by girosenth
of computation, I am faced with how to break it into parts due to
coupling in its parts. I was doing it inside let* to avoid setq
(fair ?) but I have a function that must return a number or a string
(...)

Can't you simply use setq inside let?:

(setq blah 1)
(let ((blah))
(setq blah 2) ;; <-- This is not blah! ;)
(message "blah is %s" blah))

Cheers,
--
José A. Romero L.
escherdragon at gmail
"We who cut mere stones must always be envisioning cathedrals."
(Quarry worker's creed)
jacko
2011-01-03 18:03:05 UTC
Permalink
Not sure about present languages, I like Tcl for fast script hacks.

I'm developing a language called pHone which is just starting to be
formalized.

Try

http://sites.google.com/site/jackokring/phone-language/looking-in-2011

For a look at the core definition, before symbol processing and
numerics have been added.

Cheers Jacko
Chip Eastham
2011-01-02 23:45:59 UTC
Permalink
On Jan 1, 9:15 am, "Pascal J. Bourguignon" <***@informatimago.com>
wrote:

[snip]
Post by Pascal J. Bourguignon
A bad day in () is better than a good day in {}.
Ah, at last the meaning of your .sig dawns on me!

regards, chip
Pascal Costanza
2011-01-01 23:56:58 UTC
Permalink
Post by girosenth
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?
I'm rather wondering how we can improve the readability of (any) English
to the level of German.


Pascal
--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
D Herring
2011-01-02 05:39:26 UTC
Permalink
Post by Pascal Costanza
Post by girosenth
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?
I'm rather wondering how we can improve the readability of (any)
English to the level of German.
The classic response:
http://www.users.globalnet.co.uk/~choh/german.htm

I haven't a clue where this originated.

- Daniel
Frank GOENNINGER
2011-01-02 14:17:11 UTC
Permalink
Post by D Herring
Post by Pascal Costanza
Post by girosenth
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?
I'm rather wondering how we can improve the readability of (any)
English to the level of German.
http://www.users.globalnet.co.uk/~choh/german.htm
I haven't a clue where this originated.
Must be the proposal of Mr Oettinger, the German politican now being EU
Commisioner for Energy. Hearing him speaking English very closely
assemble the "Modern English" as outlined on that page ...



No, I'm not proud of that ...

Frank
Jerome Baum
2011-01-02 14:53:44 UTC
Permalink
Post by Frank GOENNINGER
Must be the proposal of Mr Oettinger, the German politican now being EU
Commisioner for Energy. Hearing him speaking English very closely
assemble the "Modern English" as outlined on that page ...
http://youtu.be/icOO7Ut1P4Y
No, I'm not proud of that ...
Frank
You just have to love the comment:

"I understand only train station"

(To put it into context, that's the text on an ad run by some English
training business over here in Germany.)
LanX
2011-01-02 14:58:11 UTC
Permalink
Post by Jerome Baum
Post by Frank GOENNINGER
No, I'm not proud of that ...
Frank
"I understand only train station"
come on guys, he speaks better English than more than 90% of all Anglo-
Saxon politicians speak any other foreign language...
Bernd Paysan
2011-01-02 17:55:22 UTC
Permalink
Post by D Herring
Post by Pascal Costanza
Post by girosenth
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?
I'm rather wondering how we can improve the readability of (any)
English to the level of German.
http://www.users.globalnet.co.uk/~choh/german.htm
I haven't a clue where this originated.
The version I know stated at the end that the Germans zot zis vas a
viktory, and zey achived zeir original goal.
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://www.jwdt.com/~paysan/
jacko
2011-01-03 18:07:33 UTC
Permalink
Post by Pascal Costanza
Post by girosenth
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?
I'm rather wondering how we can improve the readability of (any) English
to the level of German.
Pascal
--
My website:http://p-cos.net
Common Lisp Document Repository:http://cdr.eurolisp.org
Closer to MOP & ContextL:http://common-lisp.net/project/closer/
That's a worthy endeavour, but how would you translate chauser?
Doug Hoffman
2011-01-02 12:59:27 UTC
Permalink
Post by girosenth
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?
There are many people who have trivia complaints about parens in lisp,
but I dont.
LISP is a prefix notation.
(f ops (g ops (h ops (j ops (k ops (l ops ))...))))
How do you make it readable ?
How do you home to the center or centers ?
(f (g (h (j (k (l ops)))...)))
is easy to read or
ops l k j h g f
[snip]
Post by girosenth
Is there a postfix functional language that also gets rid of parens
and is not as primitive as FORTH or POSTSCRIPT ?
Forth remains only as primitive as you want it to be.

Consider the list compression example later in this thread:

Example:
?- compress([a,a,a,a,b,c,c,a,a,d,e,e,e,e],X).
X = [a,b,c,a,d,e]

To solve this using Forth I took an existing dynamic string library
class and added one method as follows:

\ Create a subclass of string with a compress method
:class string++ <super string+
\ compress: will return a new string object
:m compress: ( -- newStr )
self heap: ( newStr) 0 self at: { newStr lastChar }
0 0 newStr new:
lastChar newStr +:
self size: 1
?DO i self at: dup lastChar <>
IF dup newStr +: THEN
to lastChar
LOOP newStr ;m
;class

string++ s \ declare a string object named s

\ 1st copy&paste the input list from the Example
\ and place it into s
s" a,a,a,a,b,c,c,a,a,d,e,e,e,e" s new:

\ 2nd, remove all commas
s" ," 0 0 s replall:

\ 3rd, do the compression and save the output object in x
s compress: value x

\ We are done:
x p:
abcade \ Q.E.D


\ Or, if one insists on pretty printing
: e ( idx -- ) x at: emit ;
: print ( obj -- )
[char] [ emit 0 e
size: 1 DO [char] , emit i e LOOP
[char] ] emit ;

x print
[a,b,c,a,d,e] \ Q.E.D

\ return heap memory
s free:
x free:

If I find the compress method to be repeatedly useful in various
problems I would keep it as part of my class library. I may code a
compress method that is more general and perhaps also for ordered
collections. I am confident that there are (many) other solutions to
the above using more "primitive" Forth techniques.

We also have some extensive postfix arithmetic routines that prove
useful when translating, for example, Fortran equations. But I won't
get into that here.

-Doug
w_a_x_man
2011-01-02 19:14:16 UTC
Permalink
Post by Doug Hoffman
Post by girosenth
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?
There are many people who have trivia complaints about parens in lisp,
but I dont.
LISP is a prefix notation.
(f ops (g ops (h ops (j ops (k ops (l ops ))...))))
How do you make it readable ?
How do you home to the center or centers ?
(f (g (h (j (k (l ops)))...)))
is easy to read or
ops l k j h g f
[snip]
Post by girosenth
Is there a postfix functional language that also gets rid of parens
and is not as primitive as FORTH or POSTSCRIPT ?
Forth remains only as primitive as you want it to be.
That is equally true of assembly language.

Forth is a low-level language used primarily for programming embedded
applications such as controlling the flushing of a toilet.

"Forth, the toilet-flusher!"
Elizabeth D Rather
2011-01-03 05:20:59 UTC
Permalink
...
Post by w_a_x_man
Post by Doug Hoffman
Forth remains only as primitive as you want it to be.
That is equally true of assembly language.
Forth is a low-level language used primarily for programming embedded
applications such as controlling the flushing of a toilet.
"Forth, the toilet-flusher!"
I actually know of no toilet-control applications of Forth. But I do
know some applications controlling satellite tracking antennas,
large-scale electric power-distribution systems, satellite
instrumentation, scientific instruments, and quite a few other pretty
non-trivial applications.

Cheers,
Elizabeth
--
==================================================
Elizabeth D. Rather (US & Canada) 800-55-FORTH
FORTH Inc. +1 310.999.6784
5959 West Century Blvd. Suite 700
Los Angeles, CA 90045
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==================================================
MarkWills
2011-01-03 10:48:39 UTC
Permalink
Post by w_a_x_man
Post by Doug Hoffman
Post by girosenth
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?
There are many people who have trivia complaints about parens in lisp,
but I dont.
LISP is a prefix notation.
(f ops (g ops (h ops (j ops (k ops (l ops ))...))))
How do you make it readable ?
How do you home to the center or centers ?
(f (g (h (j (k (l ops)))...)))
is easy to read or
ops l k j h g f
[snip]
Post by girosenth
Is there a postfix functional language that also gets rid of parens
and is not as primitive as FORTH or POSTSCRIPT ?
Forth remains only as primitive as you want it to be.
That is equally true of assembly language.
Forth is a low-level language used primarily for programming embedded
applications such as controlling the flushing of a toilet.
"Forth, the toilet-flusher!"
Er, no.

Forth has been/is used for:

* Controlling radio telescopes
* Performing the data acquisition on radio telescopes
* Cargo bay loading system on space shuttle
* Controlling CNC machines in metal finishing
* Controlling DC rectifiers in metal finishing
* Dosing controllers in metal finishing
* Anodising controllers in metal finishing
* Distributed control system in factories
* Airport management
* Rain gauge data acquisition in environmental applications
* Flow meter monitoring (data acquisition) and reporting in water/
sewage applications
* Subsea data acquisition and control (in progress)
* Real-time telemetry in Formula 1 cars (still ongoing)
* Initialising PC mother boards all over the world
* OLPC laptop

Note that, contrary to your bizarre assertion, I personally know of no
instance where a Forth system has been used to flush a toilet. It
would be a bit over the top, since a 555 timer and a relay would do
the job quite nicely, as we used to do in the 80's with that exact
application, and similarly with industrial washer detergent dosing
systems.

I know you're a troll and I shouldn't 'feed you' but Forth is still
used, and is still a valuable programming language.
LanX
2011-01-03 15:13:07 UTC
Permalink
Post by MarkWills
Post by w_a_x_man
"Forth, the toilet-flusher!"
I know you're a troll and I shouldn't 'feed you' but Forth is still
used, and is still a valuable programming language.
indeed!
jacko
2011-01-03 18:20:58 UTC
Permalink
Post by w_a_x_man
Post by Doug Hoffman
Post by girosenth
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?
There are many people who have trivia complaints about parens in lisp,
but I dont.
LISP is a prefix notation.
(f ops (g ops (h ops (j ops (k ops (l ops ))...))))
How do you make it readable ?
How do you home to the center or centers ?
(f (g (h (j (k (l ops)))...)))
is easy to read or
ops l k j h g f
[snip]
Post by girosenth
Is there a postfix functional language that also gets rid of parens
and is not as primitive as FORTH or POSTSCRIPT ?
Forth remains only as primitive as you want it to be.
That is equally true of assembly language.
Forth is a low-level language used primarily for programming embedded
applications such as controlling the flushing of a toilet.
"Forth, the toilet-flusher!"
C the toilet contents...
jacko
2011-01-03 18:22:16 UTC
Permalink
Post by w_a_x_man
Post by Doug Hoffman
Post by girosenth
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?
There are many people who have trivia complaints about parens in lisp,
but I dont.
LISP is a prefix notation.
(f ops (g ops (h ops (j ops (k ops (l ops ))...))))
How do you make it readable ?
How do you home to the center or centers ?
(f (g (h (j (k (l ops)))...)))
is easy to read or
ops l k j h g f
[snip]
Post by girosenth
Is there a postfix functional language that also gets rid of parens
and is not as primitive as FORTH or POSTSCRIPT ?
Forth remains only as primitive as you want it to be.
That is equally true of assembly language.
Forth is a low-level language used primarily for programming embedded
applications such as controlling the flushing of a toilet.
"Forth, the toilet-flusher!"
C the toilet contents...
Didier Verna
2011-01-03 10:18:20 UTC
Permalink
Post by girosenth
AND, if I must break the nested function structure, will I not be
visiting the forbidden territory of imperative programming ?
Why do you think imperative programming is forbidden in Lisp ?
--
Resistance is futile. You will be jazzimilated.

Scientific site: http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com
pineapple
2011-01-04 06:47:31 UTC
Permalink
Post by girosenth
Is there a postfix functional language that also gets rid of parens
and is not as primitive as FORTH or POSTSCRIPT ?
Joy.

http://en.wikipedia.org/wiki/Joy_(programming_language)
P.M.Lawrence
2011-01-04 14:14:49 UTC
Permalink
Post by pineapple
Post by girosenth
Is there a postfix functional language that also gets rid of parens
and is not as primitive as FORTH or POSTSCRIPT ?
Joy.
http://en.wikipedia.org/wiki/Joy_(programming_language)
Not quite; that does use bracketing around chunks of code, as much as
anything for quoting purposes to allow lazy evaluation.

The problem with a completely postfix notation for a functional
language is that parameters are evaluated as they turn up, without
regard to the operation that needs them (as, without lookahead that
would destroy the gains from postfix notation, it isn't yet known what
will be needed). That appears to enforce strict evaluation, unless the
postfix notation is loosened with some quoting system.

However, I did some work on this myself for my Furphy project (see
http://users.beagle.com.au/peterl/furphy.html - but so far it's only a
prototype/testbed, and still quite "primitive"). I found an
indirection mechanism that gave lazy evaluation without a quoting
system, which I implemented with the complementary keywords FREEZE and
THAW. Even so, a quoting system is so convenient that I added one back
in - only, now it is a layer of syntactic sugar rather than an
alternative treatment of the source. I wanted to avoid that
alternative treatment so that inconsistencies wouldn't develop from
going in and out of postfix notation - I was even able to make keyword
naming postfix. P.M.Lawrence.
Xah Lee
2011-01-05 14:58:39 UTC
Permalink
Post by girosenth
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?
There are many people who have trivia complaints about parens in lisp,
but I dont.
LISP is a prefix notation.
Note that calling lisp syntax as “prefix” is misleading.

When you say “prefix” or “postfix” notation, implied in the word is
use of operators and their general ordering characteristics.

lisp syntax does not use operators, or rather, it primarily relies on
one single match-fix operator the parenthesis. And as a match-fix
operator, the word “pre-fix” doesn't make much sense because that word
is primarly for operators used in a linear (none nested) way.

for detail, see:

〈The Concepts and Confusions of Prefix, Infix, Postfix and Fully
Nested Notations〉
http://xahlee.org/UnixResource_dir/writ/notations.html
Post by girosenth
(f ops (g ops (h ops (j ops (k ops (l ops ))...))))
How do you make it readable ?
How do you home to the center or centers ?
(f (g (h (j (k (l ops)))...)))
is easy to read or
ops l k j h g f
???
Which is linear reading from L->R ? LISP or FORTH ?
AND, if I must break the nested function structure, will I not be
visiting the forbidden territory of imperative programming ?
(setq L (l ops))
(setq K (k L  ))
....
....
(setq F (f G  ))
If I use setq, I am using globals, atleast in elisp.
If I use let*, I have limited options as I am constrained inside the
rigid structure of let*
(let*
  ((L (l ops))
   (K (k L  ))
   ....
   (F (f G  )))
some more
)
Is there a postfix functional language that also gets rid of parens
and is not as primitive as FORTH or POSTSCRIPT ?
you might get some tips about this from this article:

〈What's Point-free Programing? (point-free function syntax)〉
http://xahlee.org/comp/point-free_programing.html

i've thought about a syntax that does not use any match-fix operators
(nesting of symbols) whatsoever. But my current conclusion is that

• strictly no nesting whatsoever is not a desired property.
• when done to a large extend yet not 100% (e.g. APL and derivatives),
you sacrifice several advantages in syntax and also some semantic
possibilty in the lang.

also note, reduction or elimination of match-fix operators in so-
called stack
based lang such as Forth, does not really qualify as a syntactical
solution. It
rids of match-fix by a semantic solution. (i.e. there's implicit
hiding of
arguments, they went into a “stack”). Another way to view this is
that, when we
look at Forth (which am not familiar) or HP-28s calculator's language
(which i'm
familiar), or if we look at so-called “reverse polish notation” RPN,
the RPN is
not a complete syntx system on its own right, but relies on a language
system... (not sure if anyone see what i mean here... i need to do a
lot more
thinking to express this in some “formal” way, so as to clearly
indicate the
properties differences)
Post by girosenth
What are the syntax advantages of ERLANG, ML, CAML, OCAML, HASKELL,
PROLOG, RUBY over LISP ?
that's a loaded question of course.

but my own pet peeves is that there is to-date no major general
purpose comp lang that actually have a lexical grammar. The awareness
of the concept of a grammar for syntax is little known among
programers. Each lang basically create a bunch of ad hoc syntax, that
are not consistent nor well defined. In fact, no major general purpose
languages even have a lexical grammar per se. (what we have are just
tools that helps define and parse)

The only close exception is XML, but of course it is just a markup
lang.

for some detail, see:

• 〈Math Notations, Computer Languages, and the “Form” in Formalism〉
http://xahlee.org/cmaci/notation/lang_notation_formalism.html

• 〈Pattern Matching vs Lexical Grammar Specification〉
http://xahlee.org/cmaci/notation/pattern_matching_vs_pattern_spec.html
Post by girosenth
How does one improve readability so that the code is self-commenting ?
it's a common myth among programers that certain lang's syntax is so
clear that it is “self-documenting”. For example, lisp coders said it
in 1970s or earlier when sexp and the idea of a lang that reflex math
directly is new. Mathematica literature said it in 1990s because
pattern matching is a good fit for symbolic manipulation. Haskeller
has said it because they think Haskell code is so much a direct mirror
of traditional math notation (and this is quite laughable when
compared to Mathematica). And Ruby coder said it because they feel how
the syntax mirror programing algorithms so clearly and concisely.

Perl mongers to various degree also thinks of that of their lang,
because how the perl idioms allow ommision of many syntactical details
and quite flexible and they think it reflect the way human uses
natural lang (e.g. english).

so, sometimes in discussion, someone show you a line of code without
any comment or explanation. To you, you are perplexed at what the code
does. When you ask, you find out that they are honestly surprised
because they think that the code's meaning is so plain and obvious
that any additional explanation actually complicate it.

part of all these feelings is due to the fact that when you are
familiar with a lang, it becomes part of your thinking, a written
language to express your thoughts. Especially so if you don't know
much of other langs. You are too familiar with the lang to realize the
fact that different languages have always been a barrior to
communication. The more expert you are with a lang, and the less the
number of other langs you actually work with in depth, the more likely
you forgot that different langs are just different. What's obvious to
you, even just a short line, is really just a string of gibberish
symbols mixed together in weird ways to another who are not familiar
with your lang.

So, your question «How does one improve readability so that the code
is self-commenting ?» has many answers depending what you really want.
Comp lang syntax readability is a subject in the context psychology
and linguistics. Among comp lang forums among programers, they knew
nothing of it, and what you read there usually is utter garbage. But
to take a general programer practioners's point of view, for example,
Python is considered very readable, and the primary reason for sayig
so is actually just code formatting (i.e. short lines, and all neatly
indented), and the reason python code are well formatted because the
formatting is worked into the language's syntax.

take a complete different perspective, there's Mathematica. For
example, what do you think if comp lang source code are like
traditional math notation that's so-call 2-dimentional notation? e.g.
you have 「x^3」 with the 3 raised, you have 1/2 with 1 on top of a bar
and 2 below the bar, etc. And when the expression gets complex, e.g.

-b + Sqrt[b^2-4 a c]/(2 a)

it becomes much easier to read when in traditional math notation. In
Mathematica, its syntax system is such that, it can display the source
code in 2-dimentional notation automatically, if you want. you can see
some example here, also in PDF format

〈Math Typesetting, Mathematica, MathML〉 http://xahlee.org/math/typesetting_Mathematica_mathML.html

The same expression in lisp style you get this

/(+(-(b) √(+(^(b 2) -(*(4 a c))))) *(2 a))

is it readable? Many lispers insist that its the most readable syntax.

See also:
• 〈What's Function, What's Operator?〉 http://xahlee.org/math/function_and_operators.html

Xah ∑ http://xahlee.org/ ☄
Andrew Haley
2011-01-05 16:21:13 UTC
Permalink
Post by Xah Lee
lisp syntax does not use operators, or rather, it primarily relies on
one single match-fix operator the parenthesis. And as a match-fix
operator, the word ?pre-fix? doesn't make much sense because that word
is primarly for operators used in a linear (none nested) way.
?The Concepts and Confusions of Prefix, Infix, Postfix and Fully
Nested Notations?
http://xahlee.org/UnixResource_dir/writ/notations.html
Given that the article even manages to confuse Polish notation and
Reverse Polish notation, I strongly recommend that everyone avoid it.

Andrew.
Pascal J. Bourguignon
2011-01-05 21:29:50 UTC
Permalink
Post by Andrew Haley
Post by Xah Lee
lisp syntax does not use operators, or rather, it primarily relies on
one single match-fix operator the parenthesis. And as a match-fix
operator, the word ?pre-fix? doesn't make much sense because that word
is primarly for operators used in a linear (none nested) way.
?The Concepts and Confusions of Prefix, Infix, Postfix and Fully
Nested Notations?
http://xahlee.org/UnixResource_dir/writ/notations.html
Given that the article even manages to confuse Polish notation and
Reverse Polish notation, I strongly recommend that everyone avoid it.
As most of what he writes...
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
Xah Lee
2011-01-07 05:36:22 UTC
Permalink
Post by Andrew Haley
Given that the article even manages to confuse Polish notation and
Reverse Polish notation, I strongly recommend that everyone avoid it.
Hi man,

if you are not familiar with RPN, please see:

http://xahlee.org/prog/hp28s/hp28s.html

there are several free progs writting in RPN language. Among which, is
a music chord generating prog, could be fun to play with.

if you in college, you could show it to your friends and be
impressive.

Also, you might want to pickup emacs. In it, you can type 【Alt+x】,
Enter, then type “calc”, then you can play with RPN. My own pet peeve
about emacs calc is about its doc... due to that, i never actually
done much with it in the past decade of emacs-using other than simple
arithemitcs with Reals. Though, am aware of the fact that it can very
much do vector and matrix — even solving equations — arithemitcs, as
well as complex.

Xah
Andrew Haley
2011-01-07 13:28:31 UTC
Permalink
Post by Xah Lee
Post by Andrew Haley
Given that the article even manages to confuse Polish notation and
Reverse Polish notation, I strongly recommend that everyone avoid it.
Hi man,
http://xahlee.org/prog/hp28s/hp28s.html
Thank you, Xah. If I ever forget about RPN, I'll be sure to come
straight to you for a refresher. In the meantime, I suggest you fix
that article.

Andrew.
Xah Lee
2011-01-07 16:19:27 UTC
Permalink
Post by Xah Lee
Post by Andrew Haley
Given that the article even manages to confuse Polish notation and
Reverse Polish notation, I strongly recommend that everyone avoid it.
Hi man,
http://xahlee.org/prog/hp28s/hp28s.html
Thank you, Xah.  If I ever forget about RPN, I'll be sure to come
straight to you for a refresher.  In the meantime, I suggest you fix
that article.
thanks. corrected, with credit.

Xah
Elena
2011-01-05 17:59:10 UTC
Permalink
Post by Xah Lee
The same expression in lisp style you get this
/(+(-(b) √(+(^(b 2) -(*(4 a c))))) *(2 a))
is it readable? Many lispers insist that its the most readable syntax.
And here is why: http://blo.udoidio.info/2008/09/lisp-syntax-is-great.html
Xah Lee
2011-01-05 20:13:26 UTC
Permalink
Post by Elena
Post by Xah Lee
The same expression in lisp style you get this
/(+(-(b) √(+(^(b 2) -(*(4 a c))))) *(2 a))
is it readable? Many lispers insist that its the most readable syntax.
And here is why: http://blo.udoidio.info/2008/09/lisp-syntax-is-great.html
oops, a typo. Copied the wrong line. The correct form is

(/ (+ (- b) (√ (+ (^ b 2) (- (* 4 a c))))) (* 2 a))

article on my blog now
http://xahlee.blogspot.com/2011/01/whats-most-readable-computer-language.html

Xah
Pascal J. Bourguignon
2011-01-05 21:42:35 UTC
Permalink
Post by Elena
Post by Xah Lee
The same expression in lisp style you get this
/(+(-(b) √(+(^(b 2) -(*(4 a c))))) *(2 a))
is it readable? Many lispers insist that its the most readable syntax.
And here is why: http://blo.udoidio.info/2008/09/lisp-syntax-is-great.html
He's wrong, the most readable is:

(divide (minus (square-root (minus (square b) (* 4 a c)))
b)
2 a)

or, for wanbees:

(/ (- (sqrt (- (square b) (* 4 a c))) b)
2 a)
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
Doug Hoffman
2011-01-06 13:38:59 UTC
Permalink
Post by Pascal J. Bourguignon
Post by Elena
Post by Xah Lee
The same expression in lisp style you get this
/(+(-(b) √(+(^(b 2) -(*(4 a c))))) *(2 a))
is it readable? Many lispers insist that its the most readable syntax.
And here is why: http://blo.udoidio.info/2008/09/lisp-syntax-is-great.html
(divide (minus (square-root (minus (square b) (* 4 a c)))
b)
2 a)
(/ (- (sqrt (- (square b) (* 4 a c))) b)
2 a)
Without getting into the issues of the proper way to handle the
quadratic (this has been thoroughly hashed thru on comp.lang.forth) and
sticking with just the simple equation as presented (I'll ignore the
issue of taking the square root of negative numbers) I would make the
following observations:

1)
Post by Pascal J. Bourguignon
(divide (minus (square-root (minus (square b) (* 4 a c))) b) 2 a)
This may be very readable for Lispers. For others not so much.

2) The following is one way (of many) to approach this in standard Forth:

: quad f{ a b c -- root }
b FNEGATE b FDUP F* 4e a c F* F* F- FSQRT F+ 2e a F* F/
;

-2e 7e 15e quad f.
-1.500000

Is it readable? Unless you're a Forther I would say no. But notice the
complete lack of parentheses and operator precedences to resolve. Any
competent Forther could quickly see exactly what is going on.

3) We have available in Forth a FORmula TRANslator utility (it is not
part of the official ANS Forth standard). It could be applied in this
situation as follows:

: quad2 f{ a b c -- root }
f' (-b + sqrt(b^2 - 4*a*c))/(2*a)'
;

-2e 7e 15e quad2 f.
-1.500000

Is it readable? I would say yes. Note that it compiles *exactly* the
same Forth code as quad in 2).

4) I am able to do a copy/paste of
=(-b + sqrt(b^2 - 4*a*c))/(2*a)
into an Excel spreadsheet and with the variables a, b, and c defined
the spreadsheet gives the expected results.

-Doug
Pascal J. Bourguignon
2011-01-06 19:20:50 UTC
Permalink
Post by Doug Hoffman
: quad f{ a b c -- root }
b FNEGATE b FDUP F* 4e a c F* F* F- FSQRT F+ 2e a F* F/
;
-2e 7e 15e quad f.
-1.500000
Is it readable? Unless you're a Forther I would say no. But notice
the complete lack of parentheses and operator precedences to resolve.
Any competent Forther could quickly see exactly what is going on.
Now, as a Forth programmer, ask yourself what you would have to do, to
call an operator with a variable arity?

In Postscript, there is a mark operator, to push a mark on the stack, so
that a next operator of variable arity may collect a variable number of
arguments, up to that mark.

Then, as a Forth programmer, ask yourself what you would need to be able
to parse a Forth expression containing unknown operators, ie. operators
of unknown (possibly fixed, but also variable) arity?]

If you consider a separate table giving the arity of the operators, then
it is not unknown anymore. The only solution I know, is to use mark
systematically:


MARK MARK MARK MARK MARK b FNEGATE FDUP F* MARK 4e a c F* F- FSQRT F+
MARK 2e a F* F/

Then, we may add some syntactic sugar, replacing call the MARK operator
'(', and adding gratuituous balanced ')' after each operator:

(((((((b -) FDUP) f*) (4e a c F*) F-) FSQRT) F+) (2e a F*) F/)

Finally, we may apply mechanically a recursive reverse:

(defun rrev (x)
(if (listp x)
(mapcar 'rrev (reverse x))
x))

(rrev
'(((((((b -) FDUP) f*) (4e a c F*) F-) FSQRT) F+) (2e a F*) F/))

(F/ (F* a 2e)
(F+ (FSQRT (F- (F* c a 4e)
(F* (FDUP (- b)))))))

so it becomes readable again and you can see there's a bug in the Forth
expression. Since the syntax become suddenly much simplier, we don't
need to prefix operators with 'F' anymore. So we can write merely:


(/ (* a 2)
(+ (sqrt (- (* c a 4)
(* (dup (- b)))))))

Anyways, the great thing now, is that we have homoiconicity
(notice how I used the parenthesised source expression as data passed
to rrev), and we can process expressions without knowing the arity of
the operators (the operators may even not be defined before we process
expressions using them!). For example, we could now write:

(derivate '(/ (* a 2)
(+ (sqrt (- (* c a 4)
(* (dup (- b)))))))
'a)
and get:

--> (- (/ 2 (sqrt (- (* 4 a c) (* b b))))
(/ (* 4 a c) (expt (sqrt (- (* 4 a c) (* b b))) 3/2)))

and since this is one of the first applications of Lisp, you can see now
the reasons and advantages why lisp has these parentheses. Of course,
that doesn't preclude writing in lisp symbolic mathematic programs like
maxima, providing the mathematical user with a more usual infix input
and 2D output:

Loading Image...
Post by Doug Hoffman
3) We have available in Forth a FORmula TRANslator utility (it is not
part of the official ANS Forth standard). It could be applied in this
: quad2 f{ a b c -- root }
f' (-b + sqrt(b^2 - 4*a*c))/(2*a)'
;
There are also infix-to-lisp utilities to embed infix expressions in
lisp program. If you had to implement a program with a lot of
mathematical formula to copy from a book, I guess these utility would
come handy.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
w_a_x_man
2011-01-07 00:09:01 UTC
Permalink
Post by Pascal J. Bourguignon
so it becomes readable again and you can see there's a bug in the Forth
expression.    Since the syntax become suddenly much simplier, we don't
need to prefix operators with 'F' anymore.
Since Forth is a low-level language, operators aren't overloaded.

"F+" adds two floats, "+" adds two integers.
Doug Hoffman
2011-01-07 12:04:17 UTC
Permalink
Post by Pascal J. Bourguignon
Post by Doug Hoffman
: quad f{ a b c -- root }
b FNEGATE b FDUP F* 4e a c F* F* F- FSQRT F+ 2e a F* F/
;
-2e 7e 15e quad f.
-1.500000
Is it readable? Unless you're a Forther I would say no. But notice
the complete lack of parentheses and operator precedences to resolve.
Any competent Forther could quickly see exactly what is going on.
Now, as a Forth programmer, ask yourself what you would have to do, to
call an operator with a variable arity?
One way to handle a variable number of input parameters is to precede
them with a count. There is at least one ANS Forth word that does this.
I've seen the technique used a lot elsewhere in Forth code. Supplying
a "mark" is also something I've seen.

If I am going to apply a single operator to a list of many items, in
Forth I would likely put the items in a list, perhaps a list of objects
depending on the nature of the items, and then iterate over the list.


Just to be clear, so we don't get sidetracked on a Lisp vs Forth
tangent: I commented that I believed the Lisp example is somewhat
readable to someone unfamiliar with Lisp, Forth is not readable to
someone unfamiliar with Forth. The standard "Fortran/spreadsheet"
syntax version is the most readable for this example regardless of
language familiarity, again in my opinion.

[snip]
Post by Pascal J. Bourguignon
(F/ (F* a 2e)
(F+ (FSQRT (F- (F* c a 4e)
(F* (FDUP (- b)))))))
so it becomes readable again and you can see there's a bug in the Forth
expression.
No, I can't see any bug in the Forth example. Could you point it out
more clearly?

-Doug
Xah Lee
2011-01-06 22:59:21 UTC
Permalink
Post by girosenth
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?
some basics that might be helpful.

〈What's Function, What's Operator?〉
http://xahlee.org/math/function_and_operators.html

--------------------------------------------------
What's Function, What's Operator?

Xah Lee, 2010-12-14, 2011-01-06

Typically, we understand what “function” and “operator” mean, but
programer may have a hard time explaining them, and mathematician may
never thought about it. Here, we clarify a bit on the meaning of the
word “function” and “operator”, their context, their relation.

--------------------------------
Function is a Mathematical Concept

Function you probably understand. A function takes a input, and output
a value for a given input. The inputs are called “parameters”. A
specific set of input is called “arguments”. The number of parameters
of a function is called the function's “arity”. So, for example, the
function “sin” has arity 1. A constant, such as 35, π, can be
considered as functions of no parameter, so they are functions of
arity 0. A function of 2 parameters, such as f(x,y) := x+y has arity
2.

Function is a mathematical concept. Viewed in another way, it's a map
from one space (aka set) to another.

--------------------------------
Operator is About Notation

A operator, is less of a mathematical concept, but more of a concept
of notation. Or, in computer language contexts, a element of syntax. A
“operator” is a symbol (or symbols) that are written to indicate
operations. For example, we write 1+2, the “+” is a operator, and the
“1” and “2” are its “operands”. Mathematically, operator is a function
that acts on its operands. The operands are the arguments of the
function.

--------------------------------
Binary Operators

Typically, operators takes 2 arguments, the left and right of the
symbol. e.g. 2×3, 3/4, 2^3, union {3,4}∪{2,4,1}, etc.

--------------------------------
Unary Operators

But there are also 1-argument operators. For example the minus sign
-3, and the logical not ¬ sign, the factorial 3!, square root √3.

--------------------------------
Multi-symbol Operators

Operators can also involve other forms with more symbols. For example,
the absolute sign |-3|, floor ⌊3.8⌋ uses a bracket, summation ∑ takes
4 arguments, a expression, a variable, and start and end values. The
anti-derivative (aka indefinite integral) ∫ takes 2 arguments, a
expression and a symbol. In traditional notation, the integration
operator involves 2 symbols, ∫ and ⅆ. For example, we write ∫ sin(x)
ⅆx .

--------------------------------
Implicit Operators

Operator can be a bit complicated. For example -3 can be interpreted
in several ways. We can think of the minus sign as unary operator
acting on the argument 3. So, mathematically, it is a function of 1
arity that returns the addictive inverse of the element 3. Or, we can
interprete it as one single entity, a element of Reals denoted -3.
When we write 3-2, the ways to interprete it gets a bit more complex.
One way to think of it as a notation shorthand for 3 + (-2). The -2
part can be thought of as before. Another way is to think of - as a
binary operator on 3 and 2, but this seemingly simple interpretation
is a bit complex. Because, what is math definition of the minus binary
function? I'm not sure how it can be defined in terms of algebra
without ultimately thinking of it as additon of 2 elements, one being
a addictive inverse. The other way is to think of it as a real line,
moving the first argument to the left by a distance of the second
argument. Of course ultimately these are equivalent, but i can't think
of a simple, direct, interpretation that can serve as a math
foundation. Also, this is directly related to how does one interprete
division, such as 3/2.

The multiplication operator also gets complicated. For example, when
we write 3 x, it usually means 3*x. The space acts as implicit
multiplication sign. But when we write 3 +2, the space there has no
significance. When we write 3x, even there is no space nor any
operator, but we mean 3*x. As a computer language syntax based on
traditional notation, the parsing rule is not trivial.
Operator Stickiness

There's also the concept of “operator stickiness” (aka “operator
precendence”) at work that makes expressions with operators more
concise. When we write3△4▲5, how do you know it's (3△4)▲5 or 3△(4▲5)?
The concept of operator stickiness is needed to resolve that.
Otherwise, you'll need to always write 3+(4*5) instead of the simpler
3+4*5. But this again, also introduced more complexity. When you have
a expression of tens of different operators, it becomes a problem of
remembering the stickiness grammar for each operator. (in practice,
when you are not sure about the procedence, you usually just use
explicit priority indicator by parens. This often happens in
programing with logic operators (e.g. and &&, or ||, not !.)
Forgetting Operator Precedence is a common error in programing. In
written math for human communication, it is prone to
miscommunication.)

--------------------------------
Operator is tied to Notation

Because the concept of “operator” more has to do with syntax and
notation, and when considering traditional math notation of writing in
“2-dimensions”, also the fact that traditional math notation has a lot
ambiguities, it gets a bit complicated and not as imprecise as we
like. (See: The Problems of Traditional Math Notation)

Mathematically, operator and function are the same thing.

Math function in traditional notation has the form e.g. sin(x),
f(x,y), where the things inside the paren are its parameter/arguments,
and function name is placed to the left.

Operators are useful because writing everything out in full function
notation gets very cumbersome and hard to read. For example, we write
3+4*5 instead of plus(3,times(4,5)) or +(3,*(4,5)).

Here's a example of traditional notation using operators:

-b+√(b^2-4 a c)/(2 a)

If you don't allow space as implicit multiplication sign, then you
have to write:

-b+√((b^2)-4*a*c)/(2*a)

If you don't allow the the concept of operator precedence, then you
have to write:

(-b)+(√((b^2)-((4*a)*c))/(2*a))

If you prefer the structural clarity of the traditional function
notation f(x), you have to write:

/(+(-(b),√(+(^(b,2),-(*(4,a,c))))),*(2,a))

If you prefer words than symbols, as traditionally practiced when
writing out functions, you have to write:

divide(add(minus(b),sqrt(add(power(b,
2),minus(times(4,a,c))))),times(2,a))

The notation using operators is much concise, readable, but at the
cost of relatively complex lexical grammar. The full functional
notation is precise, grammatically simple, but difficult to read.

In math context, it's best to think of functions instead of operator,
and sometimes also use a uniform function notation, where all
arguments are explicitly indicated in one uniform way.

Here's what Wikipedia has to say about operators: Operation
(mathematics). Quote:

An operation ω is a function of the form ω : X1 × … × Xk → Y. The
sets Xj are called the domains of the operation, the set Y is called
the codomain of the operation, and the fixed non-negative integer k
(the number of arguments) is called the type or arity of the
operation.

Note that it doesn't really speaks of “operators”, but speaks of
“operations”, and flatly defines operation as a function.

--------------------------------
Traditional Function Notation sin(x) Isn't Perfect

Note that, even the functional notation such as sin(x), isn't perfect.
Problem of Functions Returning Functions

Normally, with full function notation, you'd expect that execution
order of operations clearly corresponds to the nesting structure. For
example, in our example before:

divide(add(minus(b),sqrt(add(power(b,
2),minus(times(4,a,c))))),times(2,a))

The inner-most parts are evaluated first.

But there's a problem when a function returns a function. For example,
the derivative takes a function and returns a function. We might
write:

derivative(f)

Now, if we want to evaluate the result at 3, then we might write:

derivative(f)(3)

You can see that the notation no longer nests. The operator precedence
issue is back. Now, you need to have a slightly more complex notion of
precedence to work out the notation.

One solution to this is the lisp language's syntax. In lisp syntax,
everything is written inside a paren. The first element is the
function name, the rest is its arguments. So, sin(x) would be written
as (sin,x). (comma is used for separator) Our derivative example would
then be:

((derivative,f),3)

In this way, the syntax remains a pure nested form, and provides the
utmost precision.

Our formula example in fully nested syntax be:

(/,(+,(-,b),(√,(+,(^,b,2),(-,(*,4,a,c))))),(*,2,a))

We could change the comma separator to space. So, it would look like
this:

(/ (+ (- b) (√ (+ (^ b 2) (- (* 4 a c))))) (* 2 a))

(Note: actual lisp language's syntax is not 100% regular. Many of its
syntax does not have the form (a b c ...). See: Fundamental Problems
of Lisp.)

--------------------------------
Syntax Design for Computer Languages
Mixing Operator Syntax with Full Function Notation Syntax

In most computer language, they allow both the operator and full
function syntax. For example, you can write (sin(x))^2+3. (almost all
languages do this; e.g. C, C++, C#, Java, Pascal, Perl, Python, Ruby,
Bash, PowerShell, Haskell, OCaml. The only exception is lisps.)

(Though, almost all computer languages does not have a regular syntax,
in fact, non of any major computer lang has a syntax specification.
The closest one that has a somewhat regular and simple syntax grammar
is Mathematica. See: The Concepts and Confusions of Prefix, Infix,
Postfix and Fully Nested Notations ◇ Math Notations, Computer
Languages, and the “Form” in Formalism.)

Mixed form is normal, and most flexible. Because, not all functions
have a associated operator symbol. And, writing everything in nested
brackets is not readible and hard to write too. The question is, is it
possible to design a syntax, that is fully regular with a very simple
lexical grammar, and easy to read and write?

Xah ∑ http://xahlee.org/ ☄
Jan Burse
2011-01-07 11:47:05 UTC
Permalink
Hi

This is quite funny to write a tractate about operator definitions
to comp.lang.prolog. Prolog has already for some time operator
definitions. But some other programming language do have also.

Best Regards

See also:
http://cs.union.edu/~striegnk/learn-prolog-now/html/node82.html#sec.l9.operators
from http://www.learnprolognow.org/
Post by Xah Lee
Post by girosenth
How to improve the readability of (any) LISP or any highlevel
functional language to the level of FORTH ?
some basics that might be helpful.
〈What's Function, What's Operator?〉
http://xahlee.org/math/function_and_operators.html
--------------------------------------------------
What's Function, What's Operator?
Xah Lee, 2010-12-14, 2011-01-06
Typically, we understand what “function” and “operator” mean, but
programer may have a hard time explaining them, and mathematician may
never thought about it. Here, we clarify a bit on the meaning of the
word “function” and “operator”, their context, their relation.
--------------------------------
Function is a Mathematical Concept
Function you probably understand. A function takes a input, and output
a value for a given input. The inputs are called “parameters”. A
specific set of input is called “arguments”. The number of parameters
of a function is called the function's “arity”. So, for example, the
function “sin” has arity 1. A constant, such as 35, π, can be
considered as functions of no parameter, so they are functions of
arity 0. A function of 2 parameters, such as f(x,y) := x+y has arity
2.
Function is a mathematical concept. Viewed in another way, it's a map
from one space (aka set) to another.
--------------------------------
Operator is About Notation
A operator, is less of a mathematical concept, but more of a concept
of notation. Or, in computer language contexts, a element of syntax. A
“operator” is a symbol (or symbols) that are written to indicate
operations. For example, we write 1+2, the “+” is a operator, and the
“1” and “2” are its “operands”. Mathematically, operator is a function
that acts on its operands. The operands are the arguments of the
function.
--------------------------------
Binary Operators
Typically, operators takes 2 arguments, the left and right of the
symbol. e.g. 2×3, 3/4, 2^3, union {3,4}∪{2,4,1}, etc.
--------------------------------
Unary Operators
But there are also 1-argument operators. For example the minus sign
-3, and the logical not ¬ sign, the factorial 3!, square root √3.
--------------------------------
Multi-symbol Operators
Operators can also involve other forms with more symbols. For example,
the absolute sign |-3|, floor ⌊3.8⌋ uses a bracket, summation ∑ takes
4 arguments, a expression, a variable, and start and end values. The
anti-derivative (aka indefinite integral) ∫ takes 2 arguments, a
expression and a symbol. In traditional notation, the integration
operator involves 2 symbols, ∫ and ⅆ. For example, we write ∫ sin(x)
ⅆx .
--------------------------------
Implicit Operators
Operator can be a bit complicated. For example -3 can be interpreted
in several ways. We can think of the minus sign as unary operator
acting on the argument 3. So, mathematically, it is a function of 1
arity that returns the addictive inverse of the element 3. Or, we can
interprete it as one single entity, a element of Reals denoted -3.
When we write 3-2, the ways to interprete it gets a bit more complex.
One way to think of it as a notation shorthand for 3 + (-2). The -2
part can be thought of as before. Another way is to think of - as a
binary operator on 3 and 2, but this seemingly simple interpretation
is a bit complex. Because, what is math definition of the minus binary
function? I'm not sure how it can be defined in terms of algebra
without ultimately thinking of it as additon of 2 elements, one being
a addictive inverse. The other way is to think of it as a real line,
moving the first argument to the left by a distance of the second
argument. Of course ultimately these are equivalent, but i can't think
of a simple, direct, interpretation that can serve as a math
foundation. Also, this is directly related to how does one interprete
division, such as 3/2.
The multiplication operator also gets complicated. For example, when
we write 3 x, it usually means 3*x. The space acts as implicit
multiplication sign. But when we write 3 +2, the space there has no
significance. When we write 3x, even there is no space nor any
operator, but we mean 3*x. As a computer language syntax based on
traditional notation, the parsing rule is not trivial.
Operator Stickiness
There's also the concept of “operator stickiness” (aka “operator
precendence”) at work that makes expressions with operators more
concise. When we write3△4▲5, how do you know it's (3△4)▲5 or 3△(4▲5)?
The concept of operator stickiness is needed to resolve that.
Otherwise, you'll need to always write 3+(4*5) instead of the simpler
3+4*5. But this again, also introduced more complexity. When you have
a expression of tens of different operators, it becomes a problem of
remembering the stickiness grammar for each operator. (in practice,
when you are not sure about the procedence, you usually just use
explicit priority indicator by parens. This often happens in
programing with logic operators (e.g. and&&, or ||, not !.)
Forgetting Operator Precedence is a common error in programing. In
written math for human communication, it is prone to
miscommunication.)
--------------------------------
Operator is tied to Notation
Because the concept of “operator” more has to do with syntax and
notation, and when considering traditional math notation of writing in
“2-dimensions”, also the fact that traditional math notation has a lot
ambiguities, it gets a bit complicated and not as imprecise as we
like. (See: The Problems of Traditional Math Notation)
Mathematically, operator and function are the same thing.
Math function in traditional notation has the form e.g. sin(x),
f(x,y), where the things inside the paren are its parameter/arguments,
and function name is placed to the left.
Operators are useful because writing everything out in full function
notation gets very cumbersome and hard to read. For example, we write
3+4*5 instead of plus(3,times(4,5)) or +(3,*(4,5)).
-b+√(b^2-4 a c)/(2 a)
If you don't allow space as implicit multiplication sign, then you
-b+√((b^2)-4*a*c)/(2*a)
If you don't allow the the concept of operator precedence, then you
(-b)+(√((b^2)-((4*a)*c))/(2*a))
If you prefer the structural clarity of the traditional function
/(+(-(b),√(+(^(b,2),-(*(4,a,c))))),*(2,a))
If you prefer words than symbols, as traditionally practiced when
divide(add(minus(b),sqrt(add(power(b,
2),minus(times(4,a,c))))),times(2,a))
The notation using operators is much concise, readable, but at the
cost of relatively complex lexical grammar. The full functional
notation is precise, grammatically simple, but difficult to read.
In math context, it's best to think of functions instead of operator,
and sometimes also use a uniform function notation, where all
arguments are explicitly indicated in one uniform way.
Here's what Wikipedia has to say about operators: Operation
An operation ω is a function of the form ω : X1 × … × Xk → Y. The
sets Xj are called the domains of the operation, the set Y is called
the codomain of the operation, and the fixed non-negative integer k
(the number of arguments) is called the type or arity of the
operation.
Note that it doesn't really speaks of “operators”, but speaks of
“operations”, and flatly defines operation as a function.
--------------------------------
Traditional Function Notation sin(x) Isn't Perfect
Note that, even the functional notation such as sin(x), isn't perfect.
Problem of Functions Returning Functions
Normally, with full function notation, you'd expect that execution
order of operations clearly corresponds to the nesting structure. For
divide(add(minus(b),sqrt(add(power(b,
2),minus(times(4,a,c))))),times(2,a))
The inner-most parts are evaluated first.
But there's a problem when a function returns a function. For example,
the derivative takes a function and returns a function. We might
derivative(f)
derivative(f)(3)
You can see that the notation no longer nests. The operator precedence
issue is back. Now, you need to have a slightly more complex notion of
precedence to work out the notation.
One solution to this is the lisp language's syntax. In lisp syntax,
everything is written inside a paren. The first element is the
function name, the rest is its arguments. So, sin(x) would be written
as (sin,x). (comma is used for separator) Our derivative example would
((derivative,f),3)
In this way, the syntax remains a pure nested form, and provides the
utmost precision.
(/,(+,(-,b),(√,(+,(^,b,2),(-,(*,4,a,c))))),(*,2,a))
We could change the comma separator to space. So, it would look like
(/ (+ (- b) (√ (+ (^ b 2) (- (* 4 a c))))) (* 2 a))
(Note: actual lisp language's syntax is not 100% regular. Many of its
syntax does not have the form (a b c ...). See: Fundamental Problems
of Lisp.)
--------------------------------
Syntax Design for Computer Languages
Mixing Operator Syntax with Full Function Notation Syntax
In most computer language, they allow both the operator and full
function syntax. For example, you can write (sin(x))^2+3. (almost all
languages do this; e.g. C, C++, C#, Java, Pascal, Perl, Python, Ruby,
Bash, PowerShell, Haskell, OCaml. The only exception is lisps.)
(Though, almost all computer languages does not have a regular syntax,
in fact, non of any major computer lang has a syntax specification.
The closest one that has a somewhat regular and simple syntax grammar
is Mathematica. See: The Concepts and Confusions of Prefix, Infix,
Postfix and Fully Nested Notations ◇ Math Notations, Computer
Languages, and the “Form” in Formalism.)
Mixed form is normal, and most flexible. Because, not all functions
have a associated operator symbol. And, writing everything in nested
brackets is not readible and hard to write too. The question is, is it
possible to design a syntax, that is fully regular with a very simple
lexical grammar, and easy to read and write?
Xah ∑ http://xahlee.org/ ☄
Loading...