Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Valentine Bingo - Comments?

74 views
Skip to first unread message

Steve Graham

unread,
Jan 26, 2012, 4:24:58 PM1/26/12
to
Thanks to all who posted comments to the earlier Word Array posting.

Here is the finished (for now) program which prints out 1 or more
Valentine Bingo Cards. I'd be interested in any comments on style, etc.

Thanks, Steve

---

\
\ Valentine Bingo
\

create wordarr
," Be Mine"
," Love"
," It's Love"
," All Mine"
," Kiss Me"
," You & Me"
," Awesome"
," My Baby"
," Love Me"
," All Star"
," My Way"
," Love You"
," For You"
," Cool"
," I Hope"
," Love Life"
," Angel"
," Sweet Talk"
," True Love"
," Be Good"
," How Nice"
," Let's Kiss"
," #1 Fan"
," Be True"
," Love Her"
0 ,

\ number of phrases
25 constant #wordarr

\ which numbers chosen
create chosen-bingo-numbers #wordarr allot

\ chosen numbers in order
create ordered-bingo-numbers #wordarr allot

\ jump from one phrase to the next
: jumper \ addr -- addr'
count + aligned
;

\ get nth phrase
: nth$ \ n base -- addr
swap 0 ?do jumper loop
;

\ print phrases
: .tab \ base --
begin
dup @
while
dup count cr type jumper
repeat
drop
;

\ print first part of webpage
: .html-1 \ --
cr
." <HTML>" cr
." <BODY>" cr
." <TABLE border=1 height=500 width=500>" cr
." <TR style='color:red;'>" cr
." <TH width='20%'>B</TH>" cr
." <TH width='20%'>I</TH>" cr
." <TH width='20%'>N</TH>" cr
." <TH width='20%'>G</TH>" cr
." <TH width='20%'>O</TH></TR>" cr
;

\ print last part of webpage
: .html-2 \ --
cr ." </TABLE>"
cr ." </BODY>"
cr ." </HTML>"
cr
;

\ get 24 random non-repeating numbers in order
: get-bingo-numbers \ --
#wordarr chosen-bingo-numbers over erase
ordered-bingo-numbers over erase
24 0 do
dup choose
begin
dup chosen-bingo-numbers + c@ 0 >
while
drop dup choose
repeat
chosen-bingo-numbers over + 1 swap c!
ordered-bingo-numbers i + c!
loop
drop
;

\ print nth square's phrase given proper number
: (.square) \ n --
ordered-bingo-numbers + c@
wordarr nth$ count type
;

\ print nth square's phrase given any number
: .square \ n --
dup 12 <
if (.square)
else dup 12 =
if drop ." Free Square"
else 1- (.square)
then
then
;

\ print rows of bingo card
: .rows \ --
5 0 do
cr ." <TR align='center' >"
5 0 do
cr ." <TD>"
j 5 * i +
.square
cr ." </TD>"
loop
cr ." </TR>"
loop
;

\ print n bingo cards
: .cards \ n --
0 do
get-bingo-numbers
.html-1
.rows
.html-2
loop
;

---

1 .cards
<HTML>
<BODY>
<TABLE border=1 height=500 width=500>
<TR style='color:red;'>
<TH width='20%'>B</TH>
<TH width='20%'>I</TH>
<TH width='20%'>N</TH>
<TH width='20%'>G</TH>
<TH width='20%'>O</TH></TR>

<TR align='center' >
<TD>True Love
</TD>
<TD>I Hope
</TD>
<TD>You & Me
</TD>
<TD>Be Good
</TD>
<TD>For You
</TD>
</TR>
<TR align='center' >
<TD>Love
</TD>
<TD>Sweet Talk
</TD>
<TD>All Mine
</TD>
<TD>How Nice
</TD>
<TD>Angel
</TD>
</TR>
<TR align='center' >
<TD>Cool
</TD>
<TD>Be Mine
</TD>
<TD>Free Square
</TD>
<TD>All Star
</TD>
<TD>Let's Kiss
</TD>
</TR>
<TR align='center' >
<TD>Love Me
</TD>
<TD>Kiss Me
</TD>
<TD>#1 Fan
</TD>
<TD>My Way
</TD>
<TD>Love Her
</TD>
</TR>
<TR align='center' >
<TD>My Baby
</TD>
<TD>It's Love
</TD>
<TD>Love You
</TD>
<TD>Love Life
</TD>
<TD>Awesome
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
ok

Hugh Aguilar

unread,
Feb 2, 2012, 2:12:06 AM2/2/12
to
On Jan 26, 2:24 pm, Steve Graham <jsgraha...@yahoo.com> wrote:
> Thanks to all who posted comments to the earlier Word Array posting.
>
> Here is the finished (for now) program which prints out 1 or more
> Valentine Bingo Cards.  I'd be interested in any comments on style, etc.
>
> Thanks, Steve

Good job on writing a program, Steve! I have a great deal of respect
for anybody who writes a Forth program (as compared to just claiming
to be the world's expert on Forth without every writing any Forth code
at all).

I rewrote the program to use my novice package (http://www.forth.org/
novice.html). In regard to style, I don't like all of those nested
control-structures and stair-step indentation. I largely avoided that
in my version.

My program is totally ANS-Forth compatible. I would be interested in
seeing any of the comp.lang.forth crowd write a version of their own.
Maybe you could all work together on it!

I removed all of the comments from my program so that they wouldn't
get word-wrapped in this post. The fully commented program is
available by email if anybody wants to see it. Here is the version
without comments:


\ We need NOVICE.4TH already loaded.
\ We need LIST.4TH already loaded.

marker bingo.4th

5 constant squares

squares 2/ constant middle

squares dup * 1- constant min-phrases

variable phrases
variable #phrases

squares squares w 2array card

variable html


: append-html ( head -- )
html @ swap link
html ! ;

: fill-phrases ( -- )
c" phrases.txt" read-seq dup phrases !
length #phrases !
#phrases @ min-phrases < abort" *** PHRASES.TXT file needs at
least enough phrases to fill bingo card ***"
squares 1 and 0= abort" *** SQUARES needs to be an odd
number so there is a middle square ***" ;

: <fill-card> ( element -- )
phrases @ #phrases @ rnd nth
phrases @ swap remove
rot !
phrases ! -1 #phrases +! ;

: fill-card ( -- )
card-zero
c" FREE " new-seq middle middle card !
lim-card ^card do
I @ 0= if I <fill-card> then
w +loop ;

: <fill-html> { element -- }
<cstr
c" <TD> " +cstr
element @ .line @ +cstr
c" </TD>" +cstr
cstr> new-seq append-html ;

: fill-html ( -- )
c" prologue.html" read-seq html !
squares 0 do
c" <TR align='center' >" new-seq append-html
squares 0 do I J card <fill-html> loop
c" </TR>" new-seq append-html
loop
c" epilogue.html" read-seq append-html ;

: generate-html { filename -- }
init-seed
fill-phrases
fill-card
fill-html
html @ filename write-seq
lim-card ^card do I @ <kill-seq> w +loop
html @ kill-seq
phrases @ kill-seq ;


You also need the PROLOGUE.HTML file:

<HTML>
<BODY>
<TABLE border=1 height=500 width=500>
<TR style='color:red;'>
<TH width='20%'>B</TH>
<TH width='20%'>I</TH>
<TH width='20%'>N</TH>
<TH width='20%'>G</TH>
<TH width='20%'>O</TH></TR>


You also need the EPILOGUE.HTML file:

</TABLE>
</BODY>
</HTML>


And finally, you need a PHRASES.TXT file (this can contain as many
phrases as you want):

Be Mine
Love
It's Love
All Mine
Kiss Me
You & Me
Awesome
My Baby
Love Me
All Star
My Way
Love You
For You
Cool
I Hope
Love Life
Angel
Sweet Talk
True Love
Be Good
How Nice
Let's Kiss
#1 Fan
Be True
Love Her


This is an example result:

<HTML>
<BODY>
<TABLE border=1 height=500 width=500>
<TR style='color:red;'>
<TH width='20%'>B</TH>
<TH width='20%'>I</TH>
<TH width='20%'>N</TH>
<TH width='20%'>G</TH>
<TH width='20%'>O</TH></TR>
<TR align='center' >
<TD> Love You </TD>
<TD> How Nice </TD>
<TD> Be Good </TD>
<TD> #1 Fan </TD>
<TD> You & Me </TD>
</TR>
<TR align='center' >
<TD> For You </TD>
<TD> Angel </TD>
<TD> Awesome </TD>
<TD> Cool </TD>
<TD> My Way </TD>
</TR>
<TR align='center' >
<TD> It's Love </TD>
<TD> All Mine </TD>
<TD> FREE </TD>
<TD> Be Mine </TD>
<TD> Love </TD>
</TR>
<TR align='center' >
<TD> Kiss Me </TD>
<TD> Let's Kiss </TD>
<TD> Love Me </TD>
<TD> I Hope </TD>
<TD> True Love </TD>
</TR>
<TR align='center' >
<TD> All Star </TD>
<TD> My Baby </TD>
<TD> Sweet Talk </TD>
<TD> Love Life </TD>
<TD> Love Her </TD>
</TR>
</TABLE>
</BODY>
</HTML>

crc

unread,
Feb 3, 2012, 2:35:19 PM2/3/12
to
This seemed interesting enough that I was curious as to how it'd work
in my non-standard dialect of Forth.

needs array'

[ "Be Mine"
"Love"
"It's Love"
"All Mine"
"Kiss Me"
"You & Me"
"Awesome"
"My Baby"
"Love Me"
"All Star"
"My Way"
"Love You"
"For You"
"Cool"
"I Hope"
"Love Life"
"Angel"
"Sweet Talk"
"True Love"
"Be Good"
"How Nice"
"Let's Kiss"
"#1 Fan"
"Be True"
"Love Her" ] ^array'fromQuote constant WORDS

WORDS ^array'length constant #WORDS

create CARD
#WORDS dup , allot

: nth ( na-$ ) 1+ + @ ;
: rnd ( -n ) random #WORDS mod ;

: obtain ( -$ )
0 [ drop rnd WORDS nth dup CARD ^array'stringIn? ] while ;

: populate ( - )
CARD 1+ #WORDS [ obtain swap !+ ] times drop "Free Square" CARD 13
+ ! ;


( This should probably be split into smaller functions... )
: card ( - )
populate CARD 1+
5 [ "<tr align='center'>" puts 5 [ @+ "<td>%s</td>" puts cr ] times
"</td>" puts ] times cr ;

( HTML boilerplate )
: header ( - )
"\n<html>\n" puts
"<body>\n" puts
"<table border=1 height=500 width=500>\n" puts
"<tr style='color: red'>\n" puts
"<th width='20\%'>B</th>\n" puts
"<th width='20\%'>I</th>\n" puts
"<th width='20\%'>N</th>\n" puts
"<th width='20\%'>G</th>\n" puts
"<th width='20\%'>O</th>\n" puts
"</tr>\n" puts ;

: footer ( - )
"</table>\n" puts
"</body>\n" puts
"</html>\n" puts ;

: bingo ( - )
header card footer ;

( Since it generates HTML, we may as well make it a trivial web app )
( Running at http://rx-core.org/dev/bingo )

needs casket'
with casket'
: /bingo ( - )
Content-type: text/html
bingo ;

[ ( -$ ) "/home/crc/apps/bingo/" ] is casket:root
[ ( -$ ) "http://rx-core.org/dev/bingo" ] is casket:url
&/bingo is /
&dispatch is boot
save bye

Paul Rubin

unread,
Feb 5, 2012, 12:15:18 AM2/5/12
to
Steve Graham <jsgra...@yahoo.com> writes:
> Here is the finished (for now) program which prints out 1 or more
> Valentine Bingo Cards. I'd be interested in any comments on style,
> etc.

I'm no Forth wizard either, but generally code in any language should
follow the DRY (Don't Repeat Yourself) principle. Seeing the same set
of strings in two places in the program is a "code smell". I also
felt that the weird packed c-addr format and the linear jumping
through it on each output square was a bit clumsy, though it's an
artifact of how ," works. ," is present in gforth by the way, but
undocumented, so I had to spend a while figuring out what it did.

As an exercise for myself I wrote my own version, partly adapted
from yours. This works in gforth 0.7. Gforth doesn't have
the "choose" function or any other built-in random number generator
as far as I can tell, so I had to write a simple one. I used
gforth's "utime" function (current time in microseconds) to
seed it -- I don't know if VFX has that, but there is probably
something similar.

================================================================

create packed-messages
create pvec 24 cells allot \ array of c-addrs that point to messages
variable pnext \ pointer to next slot in pvec

\ simple random number generator. utime is a gforth word that
\ gets the number of microseconds since some epoch, as 2 words
\ on the stack, used to initialize the RNG seed.
variable rand-seed utime drop rand-seed !
: get-rand ( -- n )
rand-seed @ 1103515245 * 12345 + dup rand-seed ! ;


: n-get ( n -- n ) \ get word at location n from array
cells pvec + @ ;
: n-set ( n v -- ) \ set word at location n in array to v
swap cells pvec + ! ;

\ create a randomly addressible array of the c-addrs by
\ jumping through the packed vector
: init-pvec ( -- )
packed-messages
24 0 do i over n-set dup c@ + 1+ aligned loop
pvec pnext !
drop ;

: dump-pvec \ for debugging
cr 24 0 do i . i n-get count type cr loop ;

\ these 2 words are for randomly shuffling the array
: exch ( n1 n2 -- ) \ swap locations n1 and n2 in array
2dup n-get >r n-get n-set r> n-set ;
: shuffle ( -- )
24 0 do get-rand 24 mod i exch loop
pvec pnext ! ;

: next-msg ( -- addr u ) \ get next message from the array
pnext @ dup 1 cells + pnext ! @ count ;

: tr ( -- ) \ start a row
." <tr>" cr ;
: /tr ( -- ) \ end a row
." </tr>" cr ;
: td/ ( addr u -- )
." <td>" type ." </td>" cr ;

\ print first part of webpage
: p-header ( -- )
cr
." <HTML>" cr
." <BODY>" cr
." <TABLE border=1 height=500 width=500>" cr
." <TR style='color:red;'>" cr
." <TH width='20%'>B</TH>" cr
." <TH width='20%'>I</TH>" cr
." <TH width='20%'>N</TH>" cr
." <TH width='20%'>G</TH>" cr
." <TH width='20%'>O</TH></TR>" cr ;

\ print last part of webpage
: p-footer ( -- )
cr ." </TABLE>"
cr ." </BODY>"
cr ." </HTML>"
cr ;

: dprint ( -- ) \ get next message and print it
next-msg td/ ;

: x-row ( -- ) \ print regular row
tr dprint dprint dprint dprint dprint /tr ;

: centerprint s" Free Square" td/ ;
: center-row ( -- ) \ print center row
tr dprint dprint centerprint dprint dprint /tr ;

: make-card ( -- )
shuffle
p-header
x-row x-row center-row x-row x-row
p-footer ;

: .cards ( n -- ) \ print n cards
init-pvec
0 do make-card loop ;

1 .cards
bye

Steve Graham

unread,
Feb 7, 2012, 9:39:57 AM2/7/12
to
Hugh/Paul:

Thank you for your interest and comments. Always there is more than 1
way to code a solution to problems, including this one. Below is my
final solution. I ended up using some of Stephen Pelc's code, because
it was better/shorter/more succinct than my own. Also, I made the final
output such that there were 2 cards per page. Earlier I had been
outputting this from Chrome, but with this final change I used Firefox
instead. Finally I included a heart for the free square in the middle:
It was for Valentine's Day.
: .top-html \ --
cr
cr ." <HTML>"
cr ." <BODY>"
cr ." <TABLE>"
;

\ print last part of webpage
: .bottom-html \ --
cr ." </TABLE>"
cr ." <BR>"
drop ." <img src='heart.png' alt='Heart' height='70' width='70'/>"
else 1- (.square)
then
then
;

\ print card
: .card \ --
get-bingo-numbers
cr ." <TABLE border=1 height=673 width=446>"
cr ." <TR height='20%' style='color:red;'>"
cr ." <TH style='font-size:200%' width='20%'>B</TH>"
cr ." <TH style='font-size:200%' width='20%'>I</TH>"
cr ." <TH style='font-size:200%' width='20%'>N</TH>"
cr ." <TH style='font-size:200%' width='20%'>G</TH>"
cr ." <TH style='font-size:200%' width='20%'>O</TH>"
cr ." </TR>"
5 0 do
cr ." <TR align='center' height='16%'>"
5 0 do
cr ." <TD>"
j 5 * i +
.square
." </TD>"
loop
cr ." </TR>"
loop
cr ." </TABLE>"
;

\ print n bingo cards
: .cards \ n --
.top-html
0 do
i dup 2 mod 0=
if
cr ." <TR>"
then
cr ." <TD>"
.card
cr ." </TD>"
2 mod
if
cr ." </TR>"
then
loop
.bottom-html
;

Hugh Aguilar

unread,
Feb 7, 2012, 8:59:11 PM2/7/12
to
On Feb 4, 10:15 pm, Paul Rubin <no.em...@nospam.invalid> wrote:
You do make a good point that Steve's packed counted-string array was
clumsy.

Your Valentine program is not robust though, because it has the array
size (25) hard-coded into the program (and the phrases also hard-
coded). If you had used lists, your program would have been more
robust in that the number of phrases could be easily changed (just
edit the PHRASES.TXT file) without having to modify or recompile the
program itself. This would have actually improved your Valentine
program significantly. If you are restricted to 25 phrases and your
cards have 24 squares (not counting the middle square), your bingo
games are going to last about 5 minutes because every player will mark
a square for every phrase that is called out --- you really need more
phrases to make the game at all interesting (at least as interesting
as bingo can be). If every card has every phrase on it, then there are
going to be cases in which multiple players call out bingo
simultaneously. Who will get the prize? You could resolve this
conflict by having the children fight each other with their fists, and
the last one standing gets the valentine. On the other hand, if you
had more phrases as I recommended, the conflict would be less likely
to arise in the first place. It is also possible to write the program
in such a way that the conflict is guaranteed to never occur.

For the most part, I aim for robustness first, and don't worry about
speed too much. In general, lists are more robust than arrays in that
you can do more with them (like dynamically resize) --- I pretty much
use lists for everything, unless there is some compelling reason to
use a different data-structure --- that is why my novice package has
so much support for lists. With modern computers, speed is not
generally an issue --- my slide-rule program has several lists of over
15000 elements, and it is pretty fast --- now that I have LLRB trees,
I could rewrite the program to use them (the data has to be kept
sorted, so trees are a good choice), but I doubt that there would be
much if any speed boost.

Also, you really ought to stick with ANS-Forth. What is the point of
having a standard if even simple programs such as this are compiler-
specific?

If you want to shuffle an array (which is theoretically more
efficient), you are still better off to read the phrases into a list
(with READ-SEQ) so that your program doesn't have to know ahead of
time how many phrases there are, and then convert the list into an
array (with LIST>ARRAY). Use the novice package --- it will make your
programs a lot shorter and simpler. This Valentine application is very
easy, and yet your program is quite long and difficult to follow ---
imagine what kind of complexity explosion you are going to have if you
use this same style in a bigger program. You once described my slide-
rule program as being a lot of tedious work that most programmers
would not have bothered with. Actually, if you had written it the same
way that you wrote this program, you would still be debugging it
months later --- my novice package really does simplify big programs a
lot.

Steve Graham

unread,
Feb 8, 2012, 9:53:46 AM2/8/12
to
> ," You& Me"
Paul,

You said:

Seeing the same set of strings in two places in the program is a "code
smell".

To which section of my code are you referring?

I could have padded each phrase with spaces, making them the same length
and been able to calculate the address of the nth space. Better on
time, worse on space, perhaps easier to code the calculation, adding
code to erase the trailing spaces (-spaces ?)

VFX Forth includes CHOOSE for generating a random number. Not sure why
the ANSI standard does not.

I like the way you made words for td and tr. Perhaps that is what you
meant by the smell test.

Thanks, Steve

Paul Rubin

unread,
Feb 8, 2012, 1:59:00 PM2/8/12
to
Steve Graham <jsgra...@yahoo.com> writes:
> Seeing the same set of strings in two places in the program is a "code
> smell".
>
> To which section of my code are you referring?

Whoops, when I first looked at your post, I saw all the phrases
repeated, but didn't notice that the second occurrence was the output of
the program. I thought it was some kind of HTML template or something.
I didn't figure it out til after looking more closely while coding my
own version, and at that point I forgot to edit that part of the post I
was writing. Sorry.

The code I posted has its own problems, of course. It occurred to me
afterwards that it might have been nicer to write a parsing word that
copied a string's caddr to the pvec array instead of making those
contiguous packed strings. So the message list would look something
like:
<" Be Mine> <" Love> <" It's Love>
etc. and each of those would allot some space and copy the parsed
string to it. But those parsing words are themselves pretty messy
to write.

> I could have padded each phrase with spaces, making them the same
> length and been able to calculate the address of the nth space.

Nah, the computer should do that, not a person.

> VFX Forth includes CHOOSE for generating a random number. Not sure
> why the ANSI standard does not.

Yeah, I coded a simple RNG, but my shuffling routine is slightly
mathematically wrong (doesn't generate all permutations with equal
probability). I didn't carefully check yours.

> I like the way you made words for td and tr. Perhaps that is what you
> meant by the smell test.

I didn't have that in mind but it's a slight issue.

WJ

unread,
Mar 3, 2012, 12:32:10 AM3/3/12
to
This is a good example of the extreme primitiveness of ANS
Forth. An array of strings is created, but the language is
too brain-dead to be able to count the number of items in
the array.

So the programmer has to tell ANS Forth how many strings
there are. (After all, we can't expect ANS Forth to be
able to do something as taxing as counting to 25.) Later,
when the programmer adds to the string list, he has
to change the constant #wordarr. It's as
bad as or worse than assembly language.

ANS Forth is designed only to be used for very low-level
tasks such as programming an embedded controller that
flushes a toilet.

For the bingo job, it would be wise to use a higher-level
language such as Ruby.


phrases =
"Be Mine
Love
It's Love
All Mine
Kiss Me
You & Me
Awesome
My Baby
Love Me
All Star
My Way
Love You
For You
Cool
I Hope
Love Life
Angel
Sweet Talk
True Love
Be Good
How Nice
Let's Kiss
#1 Fan
Be True
Love Her".split( /\s*\n\s*/ )

sorted = phrases.sort_by{ rand }

our_phrases = sorted[0,12] + ["Free Square"] + sorted[-12,12]

puts "
<HTML>
<BODY>
<TABLE border=1 height=500 width=500>
<TR style='color:red;'>
<TH width='20%'>B</TH>
<TH width='20%'>I</TH>
<TH width='20%'>N</TH>
<TH width='20%'>G</TH>
<TH width='20%'>O</TH></TR>"

5.times{
puts " <TR align='center'>"
puts " <td>" +
our_phrases.pop(5).join( "</td>\n <td>" ) + "</td>"
puts " </TR>"
}

puts "
</TABLE>
</BODY>
</HTML>"


===== output =====

<HTML>
<BODY>
<TABLE border=1 height=500 width=500>
<TR style='color:red;'>
<TH width='20%'>B</TH>
<TH width='20%'>I</TH>
<TH width='20%'>N</TH>
<TH width='20%'>G</TH>
<TH width='20%'>O</TH></TR>
<TR align='center'>
<td>Be Mine</td>
<td>Sweet Talk</td>
<td>True Love</td>
<td>Love Life</td>
<td>Love Me</td>
</TR>
<TR align='center'>
<td>Awesome</td>
<td>#1 Fan</td>
<td>Love You</td>
<td>Cool</td>
<td>Be Good</td>
</TR>
<TR align='center'>
<td>I Hope</td>
<td>Be True</td>
<td>Free Square</td>
<td>My Way</td>
<td>You & Me</td>
</TR>
<TR align='center'>
<td>My Baby</td>
<td>For You</td>
<td>Love Her</td>
<td>How Nice</td>
<td>It's Love</td>
</TR>
<TR align='center'>
<td>Angel</td>
<td>Love</td>
<td>Let's Kiss</td>
<td>Kiss Me</td>
<td>All Star</td>
</TR>

</TABLE>
</BODY>
</HTML>

Elizabeth D. Rather

unread,
Mar 3, 2012, 2:00:35 AM3/3/12
to
On 3/2/12 7:32 PM, WJ wrote:
> Steve Graham wrote:
>
>>
>> create wordarr
>> ," Be Mine"
>> ," Love"
>> ," It's Love"
>> ," All Mine"
>> ," Kiss Me"
>> ," You& Me"
If you need to count, it's trivially easy to do:

Variable #strings
: ," ( n -- n+1 ) 1+ ," ; / Counting version

create wordarr 0
," Be Mine"
," Love"
," It's Love"
/ etc.

#strings !


> So the programmer has to tell ANS Forth how many strings
> there are. (After all, we can't expect ANS Forth to be
> able to do something as taxing as counting to 25.) Later,
> when the programmer adds to the string list, he has
> to change the constant #wordarr. It's as
> bad as or worse than assembly language.

Forth is an application-oriented language. It's incredibly easy to
modify it to do what your app needs, and doesn't burden you with a lot
of complexity you don't need. If you tend to do the same sorts of apps
over and over, you develop your own library of application-specific things.

I have never heard a professional programmer complain about this sort of
adaptation being hard or burdensome. On the contrary, the professional
Forthers I worked with for 30 years were vastly more productive than
their peers using other languages. It's mostly the newbies who get
culture-shock.

> ANS Forth is designed only to be used for very low-level
> tasks such as programming an embedded controller that
> flushes a toilet.

Hilarious. If only you knew...

> For the bingo job, it would be wise to use a higher-level
> language such as Ruby.

Sure. In fact, as John Passaniti frequently points out, every language
has a particular target set of applications for which it is best suited.
Valentine Bingo isn't really the kind of app that Forth is aimed at,
though it's a cool example of how to do some stuff. I would agree that
Forth is mainly aimed at embedded systems. But to assume they're all
idiot simple is plain ignorance. Most of the electric power grid in
North America is managed by Forth, to give just one example.

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."
==================================================

WJ

unread,
Mar 3, 2012, 4:21:32 AM3/3/12
to
WJ wrote:

> 5.times{
> puts " <TR align='center'>"
> puts " <td>" +
> our_phrases.pop(5).join( "</td>\n <td>" ) + "</td>"
> puts " </TR>"
> }

Better:


5.times{
puts " <TR align='center'>"
puts our_phrases.pop(5).map{|s| " <td>#{ s }</td>" }
puts " </TR>"
}

Paul Rubin

unread,
Mar 3, 2012, 4:26:53 AM3/3/12
to
"WJ" <w_a_...@yahoo.com> writes:
> Better:
> 5.times{ ...

Really, the Ruby newsgroup is that way ------> comp.lang.ruby
Those who want Ruby know where to find it.

Josh Grams

unread,
Mar 3, 2012, 7:52:33 AM3/3/12
to
Paul Rubin wrote: <7xd38uq...@ruckus.brouhaha.com>
Heh. Good luck with that. He has been coming around here and doing
this periodically for most of the time that Ruby has existed. Just
ignore him -- he will get bored shortly and move on if he doesn't get a
rise out of anybody.

--Josh

Rugxulo

unread,
Mar 3, 2012, 2:35:12 PM3/3/12
to
Hi,

On Mar 2, 11:32 pm, "WJ" <w_a_x_...@yahoo.com> wrote:
>
> This is a good example of the extreme primitiveness of ANS
> Forth. An array of strings is created, but the language is
> too brain-dead to be able to count the number of items in
> the array.

(semi-joking) Isn't it Turing complete? Isn't that enough.

Well, you can't please everyone, no language supports everything "out
of the box". Remember: "a poor carpenter blames his tools".

> So the programmer has to tell ANS Forth how many strings
> there are. (After all, we can't expect ANS Forth to be
> able to do something as taxing as counting to 25.)  Later,
> when the programmer adds to the string list, he has
> to change the constant #wordarr.  It's as
> bad as or worse than assembly language.

Sometimes assembly is needed as no general purpose (portable) language
can emulate everything. But I don't know of an (easy, obvious) way to
use assembly under Ruby.

> ANS Forth is designed only to be used for very low-level
> tasks such as programming an embedded controller that
> flushes a toilet.
>
> For the bingo job, it would be wise to use a higher-level
> language such as Ruby.

(snip)

Big credit to you for posting actual code, it gives legitimacy to your
claims. I'm not saying Ruby is bad, it's not. "Use the right tool for
the job", etc.

But Ruby (esp. 1.9 series) is far less portable than Forth and has no
standard. At least Matz's interpreter (IIRC) assumes long == void* and
has never (IIRC) run on less than 32-bit platforms. It's also written
in C with POSIX libs. I guess you know that C is considered "too low-
level", yet tons of people still use it for everyday tasks, hence why
it's (far) above Ruby in the rankings, funnily enough.

John Passaniti

unread,
Mar 3, 2012, 5:08:47 PM3/3/12
to
On Mar 3, 7:52 am, Josh Grams <j...@qualdan.com> wrote:
> Heh.  Good luck with that.  He has been coming around here
> and doing this periodically for most of the time that Ruby
> has existed.  Just ignore him -- he will get bored shortly
> and move on if he doesn't get a rise out of anybody.

I think the guy is silly and I don't understand his motivation for
posting here.

But it would be a mistake to ignore him. Yes, this is a Forth
newsgroup. But I see nothing wrong with pointing out areas of Forth
that some consider weak and expressing that perspective. I don't
think there is any danger of Forth turning into Ruby. But gosh, maybe
some of the folks here who think Forth walks on water might be
intrigued by the brevity and expressiveness of Ruby and other
languages, and think how the experience of other programmers in other
languages might help Forth evolve.

One of the most annoying things about comp.lang.forth to me is that
people here tend to be pretty binary in their thinking. It's like
there is no middle ground. Ruby-guy comes in here and the knee-jerk
reaction is to say that Ruby isn't appropriate for all problems, much
less the problems one typically uses Forth for. Well, duh. Wouldn't
it be more interesting to not look at other languages (like Ruby) as
some monolithic whole and instead look at specific features it offers
and think how they might be useful in Forth? Wouldn't it be a great
demonstration of the flexibility of Forth that you could take
essential features in a high-level object-oriented language like Ruby
and not just recreate the functionality, but the brevity and
expressiveness?

I see one other value of Ruby-guy's posts. Many times when people use
the phrase "other languages" here, they don't really mean that. Far
more often than not, when the phrase "other languages" is used, it's a
placeholder for C. And sure, that makes some sense historically, at
least in the embedded systems world. But a funny thing happened in
the past THIRTY FREAKIN' YEARS. There is much more than just C out
there. And in fact, many of the languages that are in common use
today have many of the same capabilities that Forth programmers
value. It's very easy to point out that C isn't interactive and
extensible. But Ruby and a bunch of other languages are. It's very
easy to point out that C has no concept of compilation at run-time.
But plenty of languages these days do.

Over the years, I've gotten increasingly bored with many in the
comp.lang.forth community who think the year is still 1980. Value the
past, learn from it, but don't live there.

Paul Rubin

unread,
Mar 3, 2012, 5:41:28 PM3/3/12
to
John Passaniti <john.pa...@gmail.com> writes:
> more often than not, when the phrase "other languages" is used, it's a
> placeholder for C. And sure, that makes some sense historically, at
> least in the embedded systems world. But a funny thing happened in
> the past THIRTY FREAKIN' YEARS. There is much more than just C out
> there.

Heh, 30 years ago was the 1980's, the heyday of Lisp, and Lispers were
saying the same things about C back then, that the Ruby guy says about
Forth now. As far as I can tell, Ruby is (like Python and Javascript,
to be fair) a somewhat lobotomized Lisp with some creature comforts
added. So I don't think the Ruby guy is really bringing much in
language technology that hasn't been around for longer than Forth.
Chuck has said more than once that Forth was inspired partly by Lisp.

I'd conclude that Forth users either aren't terribly interested in
language technlogy for its own sake (e.g. because their real profession
is hardware engineering or something like that, and Forth does what they
need), or else they're programming under constraints were Lisp or Ruby
wouldn't work (I'd like to see the Ruby guy port Ruby to an 8 bit
micro), or else they're perfectly aware of Ruby's ilk but have their own
reasons for being interested in Forth.

John Passaniti

unread,
Mar 3, 2012, 8:39:37 PM3/3/12
to
On Mar 3, 5:41 pm, Paul Rubin <no.em...@nospam.invalid> wrote:
> Heh, 30 years ago was the 1980's, the heyday of Lisp, and Lispers
> were saying the same things about C back then, that the Ruby guy
> says about Forth now.  As far as I can tell, Ruby is (like Python
> and Javascript, to be fair) a somewhat lobotomized Lisp with some
> creature comforts added.  So I don't think the Ruby guy is really
> bringing much in language technology that hasn't been around for
> longer than Forth. Chuck has said more than once that Forth was
> inspired partly by Lisp.

Ruby is far more like Smalltalk than it is like Lisp. Python has some
limited functional aspects, but that never got top billing. Both are
firmly in the camp of object-oriented dynamically typed languages.
Their functional aspects aren't significant, either to their history
or to their predominate use.

Forth may have been "inspired" by Lisp, but there is very little left
of that in it. Lists were replaced with arrays, recursion was
replaced with iteration, treating programs as data was only ever
possible with carnal knowledge, and homoiconicity is completely
ignored.

> I'd conclude that Forth users either aren't terribly interested
> in language technlogy for its own sake (e.g. because their real
> profession is hardware engineering or something like that, and
> Forth does what they need), or else they're programming under
> constraints were Lisp or Ruby wouldn't work (I'd like to see
> the Ruby guy port Ruby to an 8 bit micro), or else they're
> perfectly aware of Ruby's ilk but have their own reasons for
> being interested in Forth.

I'm not suggesting that people should be interested in programming
languages technology "for its own sake." Instead, I would hope people
would show a bit of intellectual curiosity when viewing other
languages and their features. The mere existence of other programming
languages isn't significant, but the features they provide and the
differences in the way they direct programmers to solutions can be
quite valuable.

I'm firmly in the embedded systems camp. It's what I'm paid to do,
and it's what I'm best at. But that doesn't stop me from seeing
what's up in other fields and seeing how I can apply what others are
working on. For example, I enjoy watching the presentations over on
infoq.com, even though I'm not writing "enterprise" applications.
Why? I'm not writing financial trade applications in Java, but I have
found some of the techniques used to maintain high-throughput have
direct application to the network processing in my embedded systems.
I have yet to use a "no-SQL" distributed document-centered database
for anything, but the discussions about some of the underlying
technologies introduced me to vector clocks, which have direct
application to versioning of data in our distributed systems.

Often some of the technologies introduced don't have any direct
application. But given that these days, an "embedded system" might be
a $6 ARM SoC running Linux with loads of resources, it starts to bring
into question past assumptions. For example, in an upcoming system,
we need to create a desktop user interface. We're going to target web
browsers because they are ubiquitous. And in doing that, we're
reviewing the wealth of both server-side and client-side languages,
tools, and libraries available. Thankfully, we don't have to start
from scratch. The enterprise computing community has been there for
some time, and they've already been through various fads and silver
bullets. Paying attention to what they've experienced isn't
technology for technology's sake. It's building off their experience
and not making the same mistakes they've made.

The lines between "embedded" and other problem domains is growing
increasingly fuzzy. I think that's a good thing.

Paul Rubin

unread,
Mar 3, 2012, 10:18:40 PM3/3/12
to
John Passaniti <john.pa...@gmail.com> writes:
> Ruby is far more like Smalltalk than it is like Lisp. Python has some
> limited functional aspects, but that never got top billing. Both are
> firmly in the camp of object-oriented dynamically typed languages.

Lisp also is OO (as in CLOS and its predecessors).

> Their functional aspects aren't significant, either to their history
> or to their predominate use.

I don't know about Ruby. With Python, it's a matter of programming
style and the predominance of "functional" aspects depends on who's
writing the code.

> Forth may have been "inspired" by Lisp, but there is very little left
> of that in it.

Sure. It just shows that Lisp wasn't some weird alien development that
came along later.

> The lines between "embedded" and other problem domains is growing
> increasingly fuzzy. I think that's a good thing.

Yes, though the examples you mentioned don't involve much direct
hardware control.

Elizabeth D. Rather

unread,
Mar 3, 2012, 10:51:43 PM3/3/12
to
On 3/3/12 12:08 PM, John Passaniti wrote:
> On Mar 3, 7:52 am, Josh Grams<j...@qualdan.com> wrote:
>> Heh. Good luck with that. He has been coming around here
>> and doing this periodically for most of the time that Ruby
>> has existed. Just ignore him -- he will get bored shortly
>> and move on if he doesn't get a rise out of anybody.
>
> I think the guy is silly and I don't understand his motivation for
> posting here.
>
> But it would be a mistake to ignore him. Yes, this is a Forth
> newsgroup. But I see nothing wrong with pointing out areas of Forth
> that some consider weak and expressing that perspective.

Of course, in principle that's quite true, but this is more of a "drive
by egg throwing", not someone who's taken some time to look at Forth and
offer a considered opinion. I think we're pretty good at discussing
thoughtful criticisms.

...
>
> One of the most annoying things about comp.lang.forth to me is that
> people here tend to be pretty binary in their thinking. It's like
> there is no middle ground. Ruby-guy comes in here and the knee-jerk
> reaction is to say that Ruby isn't appropriate for all problems, much
> less the problems one typically uses Forth for. Well, duh. Wouldn't
> it be more interesting to not look at other languages (like Ruby) as
> some monolithic whole and instead look at specific features it offers
> and think how they might be useful in Forth? Wouldn't it be a great
> demonstration of the flexibility of Forth that you could take
> essential features in a high-level object-oriented language like Ruby
> and not just recreate the functionality, but the brevity and
> expressiveness?

In fact, I didn't hear a knee-jerk response except to recognize that
this guy has been here with almost the same word-for-word troll, to wit,
"ANS Forth is designed only to be used for very low-level tasks such as
programming an embedded controller that flushes a toilet." Had he
*asked* how one might count strings in that example, he'd have gotten a
lot more respect. As it is, I tried to answer the question he didn't
ask, in case someone else might be interested.

> I see one other value of Ruby-guy's posts. Many times when people use
> the phrase "other languages" here, they don't really mean that. Far
> more often than not, when the phrase "other languages" is used, it's a
> placeholder for C. And sure, that makes some sense historically, at
> least in the embedded systems world. But a funny thing happened in
> the past THIRTY FREAKIN' YEARS. There is much more than just C out
> there. And in fact, many of the languages that are in common use
> today have many of the same capabilities that Forth programmers
> value. It's very easy to point out that C isn't interactive and
> extensible. But Ruby and a bunch of other languages are. It's very
> easy to point out that C has no concept of compilation at run-time.
> But plenty of languages these days do.
>
> Over the years, I've gotten increasingly bored with many in the
> comp.lang.forth community who think the year is still 1980. Value the
> past, learn from it, but don't live there.

I really don't think most of us are that ignorant. Those of us who are
happy using Forth for the work we do may not make the investment in
learning some of the newer languages, particularly those designed for
other application domains, but I'm pretty sure most folks here know they
exist.

Josh Grams

unread,
Mar 4, 2012, 7:29:09 AM3/4/12
to
John Passaniti wrote:
> On Mar 3, 7:52 am, Josh Grams <j...@qualdan.com> wrote:
>> Heh. Good luck with that. He has been coming around here
>> and doing this periodically for most of the time that Ruby
>> has existed. Just ignore him -- he will get bored shortly
>> and move on if he doesn't get a rise out of anybody.
>
> I think the guy is silly and I don't understand his motivation for
> posting here.
>
> But it would be a mistake to ignore him. Yes, this is a Forth
> newsgroup. But I see nothing wrong with pointing out areas of Forth
> that some consider weak and expressing that perspective.

Yeah, but I think the history shows pretty clearly that he's not
interested in a real dialogue either. He just comes by and periodically
and posts Ruby code with an inflammatory paragraph or two.

> One of the most annoying things about comp.lang.forth to me is that
> people here tend to be pretty binary in their thinking. It's like
> there is no middle ground. Ruby-guy comes in here and the knee-jerk
> reaction is to say that Ruby isn't appropriate for all problems, much
> less the problems one typically uses Forth for.

Yes, and I'm not endorsing that. I'm familiar with Ruby and have used
it for several small projects. My only issue is that it seems to be
very slow. :( Every time I try to use it on any volume of data it is
slower than I feel like waiting for and I wind up going back to Perl. I
suppose I should try it again -- it has been a year or two and maybe
they have made improvements. Python was horribly slow for *years* and
they eventually fixed that...

At any rate, I don't have a problem with Ruby-guy posting here; I just
think it's probably a waste of time to expect him to engage in any
meaningful debate.

--Josh

Doug Hoffman

unread,
Mar 4, 2012, 10:07:39 AM3/4/12
to
On 3/3/12 12:32 AM, WJ wrote:

> This is a good example of the extreme primitiveness of ANS
> Forth. An array of strings is created, but the language is
> too brain-dead to be able to count the number of items in
> the array.

Wrong. It just depends on how ANS Forth is used.

object-list w

: p" [char] " parse
['] string+ w add:
( addr len ) w obj: !: ;

p" Be Mine"
p" Love"
p" It's Love"

0 w at: p: => Be Mine

> So the programmer has to tell ANS Forth how many strings
> there are.

Of course not.
w size: . => 3

> Later,
> when the programmer adds to the string list, he has
> to change the constant #wordarr.

Wrong again.
p" All Mine"
w size: . => 4

... and so on.

\ library code source
http://soton.mpeforth.com/flag/fms/index.html

All of the above was posted a short while ago. If you are going to drop
in on a newsgroup and make sweeping statements you should first follow
the discussions a bit and also understand what library code is readily
available.

-Doug Hoffman

Rugxulo

unread,
Mar 4, 2012, 10:53:06 AM3/4/12
to
Hi,

On Mar 4, 6:29 am, Josh Grams <j...@qualdan.com> wrote:
> John Passaniti wrote:
>
> > But it would be a mistake to ignore him.  Yes, this is a Forth
> > newsgroup.  But I see nothing wrong with pointing out areas of Forth
> > that some consider weak and expressing that perspective.
>
> Yeah, but I think the history shows pretty clearly that he's not
> interested in a real dialogue either.  He just comes by and periodically
> and posts Ruby code with an inflammatory paragraph or two.

It might be (mostly) off-topic, but at least he's posting actual code.
If all he was saying was, "Go flush yourselves, Forthers!", that might
be more annoying. ;-)

> > One of the most annoying things about comp.lang.forth to me is that
> > people here tend to be pretty binary in their thinking.  It's like
> > there is no middle ground.  Ruby-guy comes in here and the knee-jerk
> > reaction is to say that Ruby isn't appropriate for all problems, much
> > less the problems one typically uses Forth for.
>
> Yes, and I'm not endorsing that.  I'm familiar with Ruby and have used
> it for several small projects.  My only issue is that it seems to be
> very slow. :(  Every time I try to use it on any volume of data it is
> slower than I feel like waiting for and I wind up going back to Perl.  I
> suppose I should try it again -- it has been a year or two and maybe
> they have made improvements.  Python was horribly slow for *years* and
> they eventually fixed that...

Ruby 1.8.7 is the last of that line and is basically done and
finished. It will only have very minimal fixes done for a short while,
then it will be completely abandoned. It's already suggested to use
the 1.9 series full-time, and latest seems to be (EDIT: bump) 1.9.3.
Yes, it's supposed to be much faster (though I've not tried it):
native threads, Unicode, YARV, etc. But, like I alluded to before,
Ruby is just not as portable as Forth, and 1.9 is worse. :-( Yeah,
I know, cry me a river, but it just seems odd to have so many
questionable assumptions in a so-called general purpose language. So,
at least for portability and standardization, Forth easily wins over
Ruby (which BTW is more inspired by Perl than Smalltalk or Lisp, hence
the name).

EDIT: You say Python "fixed that", how so? I only heard about Unladen
Swallow, but even that was eventually basically abandoned (and only
partially completed and only for slightly older version, right?). I
don't know why these languages aren't speedy enough, I sometimes
wonder if being written in C (or maybe using GCC) is the real
bottleneck. I might get flamed for saying that, but seriously,
sometimes I honestly wonder. Despite all the proclaiming that
"algorithms matter more than micro-optimizations", I can't help but
feel that sometimes you have to worry about opcode selection too
(although it's an almost pointless task, too hard to do well IMHO, at
least across various x86 versions).

> At any rate, I don't have a problem with Ruby-guy posting here; I just
> think it's probably a waste of time to expect him to engage in any
> meaningful debate.

Well, it's no worse than browsing Rosetta Code out of curiosity. At
least real code is better than empty arguing.

Rugxulo

unread,
Mar 4, 2012, 11:16:10 AM3/4/12
to
Hi,

On Mar 3, 4:08 pm, John Passaniti <john.passan...@gmail.com> wrote:
>
> I think the guy is silly and I don't understand his motivation for
> posting here.

Presumably just boredom or comparison. It's too easy to assume the
worst, and I doubt he has an axe to grind.

> But it would be a mistake to ignore him.  Yes, this is a Forth
> newsgroup.  But I see nothing wrong with pointing out areas of Forth
> that some consider weak and expressing that perspective.  I don't
> think there is any danger of Forth turning into Ruby.

Perhaps he should write a simple subset of Ruby in Forth? I know, not
an easy task, but if he likes it so much ....

> But gosh, maybe
> some of the folks here who think Forth walks on water might be
> intrigued by the brevity and expressiveness of Ruby and other
> languages, and think how the experience of other programmers in other
> languages might help Forth evolve.

"help Forth evolve" ... ugh. I'm not one of those who wants to add
everything and the kitchen sink to a language until it's
unrecognizable. I'm not implying you are either, just saying,
sometimes it's frustrating when things change too much or too many
dialects persist. Sometimes it feels like people are raving on and on
about their favorite thing, only to completely change it in the
process. Well, then what did you like about it in the first place?? It
always reminds me of that play, "I love you, you're perfect, now
change." Just silly.

> One of the most annoying things about comp.lang.forth to me is that
> people here tend to be pretty binary in their thinking.  It's like
> there is no middle ground.  Ruby-guy comes in here and the knee-jerk
> reaction is to say that Ruby isn't appropriate for all problems, much
> less the problems one typically uses Forth for.  Well, duh.  Wouldn't
> it be more interesting to not look at other languages (like Ruby) as
> some monolithic whole and instead look at specific features it offers
> and think how they might be useful in Forth?

Such as what? OOP? Regex? Generators? Threading? Unicode?

> Wouldn't it be a great
> demonstration of the flexibility of Forth that you could take
> essential features in a high-level object-oriented language like Ruby
> and not just recreate the functionality, but the brevity and
> expressiveness?

I don't think you'll win anybody over, but sure, go ahead and try.

> I see one other value of Ruby-guy's posts.  Many times when people use
> the phrase "other languages" here, they don't really mean that.  Far
> more often than not, when the phrase "other languages" is used, it's a
> placeholder for C.  And sure, that makes some sense historically, at
> least in the embedded systems world.  But a funny thing happened in
> the past THIRTY FREAKIN' YEARS.  There is much more than just C out
> there.

C is still used very widely, maybe not exclusively, but it's still in
the top three. ( http://lang-index.sourceforge.net/ ) And that may be
due to the fact that other languages (Perl, Python, Ruby, Lua) are
written in it. Or maybe because tons of legacy code exists. Or maybe
because of heavy use by GNU, BSD and other POSIX places. Or maybe due
to popular "successors" like C++ or Objective C.

But let's not pretend that C hasn't evolved either. 1978 was when K&R1
was published, 1989 was the ANSI standard, 1994 was normative
amendment (or whatever), C99 was the updated standard, and now we even
have (finalized) C11 coming our way. So yeah, that's a lot of changes,
even for "standard" C.

> And in fact, many of the languages that are in common use
> today have many of the same capabilities that Forth programmers
> value.  It's very easy to point out that C isn't interactive and
> extensible.

Not directly, no, but if Linux and GForth are written in C, does the
criticism still apply?

> But Ruby and a bunch of other languages are.  It's very
> easy to point out that C has no concept of compilation at run-time.
> But plenty of languages these days do.
>
> Over the years, I've gotten increasingly bored with many in the
> comp.lang.forth community who think the year is still 1980.  Value the
> past, learn from it, but don't live there.

1980 ... ah, a very good year. The year of the debut of Lilith
(Modula-2 machine). Also the (in)famous 8086 had just been invented
but not widely deployed yet. And I was less than a year old too. Heh,
so I can't pretend that things haven't changed. But I'm probably one
of the worse offenders to you as I still use DOS. ;-) I'm most
conservative because I just don't understand all these new-fangled
things. Also, I refuse to believe you need a 64-bit SMP machine just
to open/read/write/close a file.

It's true, things are evolving, whether we like it or not. I don't
think Forth is dead, and I don't think ANS '94 killed it (hi, Hugh). A
new standard will probably indeed happen eventually. I'd be surprised
if threading and Unicode weren't standardized (hopefully as an
optional appendices) in the next few years as "everybody else" seems
to assume them, even C11. Times are definitely different than they
were, even compared to 2007. But if things change too fast, nobody can
keep up, and who wants that? So you have to tread lightly.

Bernd Paysan

unread,
Mar 4, 2012, 11:39:04 AM3/4/12
to
Rugxulo wrote:

> t's true, things are evolving, whether we like it or not. I don't
> think Forth is dead, and I don't think ANS '94 killed it (hi, Hugh). A
> new standard will probably indeed happen eventually. I'd be surprised
> if threading and Unicode weren't standardized (hopefully as an
> optional appendices) in the next few years as "everybody else" seems
> to assume them, even C11.

Well, the first release candidate of Forth-2011 is out, so it's nothing
you need to speculate about.

http://www.forth200x.org/documents/forth11-1.pdf

And yes, it supports Unicode (with UTF-8 encoding) through the optional
Xchar wordset.

--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/

Bernd Paysan

unread,
Mar 4, 2012, 11:42:12 AM3/4/12
to
Bernd Paysan wrote:

> Rugxulo wrote:
>
>> t's true, things are evolving, whether we like it or not. I don't
>> think Forth is dead, and I don't think ANS '94 killed it (hi, Hugh).
>> A new standard will probably indeed happen eventually. I'd be
>> surprised if threading and Unicode weren't standardized (hopefully as
>> an optional appendices) in the next few years as "everybody else"
>> seems to assume them, even C11.
>
> Well, the first release candidate of Forth-2011 is out, so it's
> nothing you need to speculate about.
>
> http://www.forth200x.org/documents/forth11-1.pdf

Oops, cut&paste error, it is:

http://www.forth200x.org/documents/forth-rc0.pdf

Marcel Hendrix

unread,
Mar 4, 2012, 10:42:26 AM3/4/12
to
Doug Hoffman <glid...@gmail.com> Re: Valentine Bingo - Comments?

> On 3/3/12 12:32 AM, WJ wrote:

>> This is a good example of the extreme primitiveness of ANS
>> Forth. An array of strings is created, but the language is
>> too brain-dead to be able to count the number of items in
>> the array.

> Wrong. It just depends on how ANS Forth is used.

Arguments in CLF always follow this path:

Some outsider:
"You can't do foo in Forth, bar functionality is missing.
Forth is only good for flushing toilets."

Then someone shows how to do foo or add bar , exactly solving
the problem (and probably nothing more than that).

Statler and Waldorf:
"That is not standard Forth code."

Given how long it takes to standardize even trivial words, and
given that most functionality will be in library form, which is
in itself not standardized in Forth, the rate of advance is
glacially slow.

Strangely enough, nowadays progress comes from the vendors.
It used to be users that dragged the language forward, and
vendors that pulled the brakes.

-marcel


Josh Grams

unread,
Mar 4, 2012, 12:24:39 PM3/4/12
to
Rugxulo wrote:
> On Mar 4, 6:29 am, Josh Grams <j...@qualdan.com> wrote:

> But, like I alluded to before, Ruby is just not as portable as Forth,
> and 1.9 is worse. :-(

Oh? I missed that, where was it?

>> Python was horribly slow for *years* and they eventually fixed
>> that...
>
> You say Python "fixed that", how so?

Just a general observation. It was mainly startup speed (including
compilation and loading) that bothered me. The runtime speed seemed
pretty decent -- slower than Perl, but not tremendously so. This was
back on a dual-G4 533MHz PowerMac running Linux, and the startup time
was a good solid third of a second, and loading any code tended to push
it up around a half-second. Which is fine for some purposes, but makes
it (for me) totally unbearable for command-line tools. I remember
trying the bzr distributed version control system and having it take
about .7 seconds to display the command-line help. That's a lot longer
than I'm willing to wait.

Then a couple of years later I was complaining about it to someone who
said that wasn't the case, and I went back to that box and installed the
latest version of Python, and sure enough it started up and loaded code
fast enough to be acceptable. I don't know what they did to make that
happen.

--Josh

Rugxulo

unread,
Mar 4, 2012, 2:41:23 PM3/4/12
to
Hi,

On Mar 4, 11:24 am, Josh Grams <j...@qualdan.com> wrote:
> Rugxulo wrote:
> > On Mar 4, 6:29 am, Josh Grams <j...@qualdan.com> wrote:
> > But, like I alluded to before, Ruby is just not as portable as Forth,
> > and 1.9 is worse. :-(
>
> Oh? I missed that, where was it?

What exactly? (confused) :-/

Well, I guess I have to post a bunch of off-topic links now just to be
exhaustive. ;-) And I'm far far FAR from a Ruby pro.

1993 - Ruby "conceived"
1995 - Ruby 0.9.5
1996 - Ruby 1.0
2003 - Ruby 1.8.0
2007 - Ruby 1.9.0
2008 - Ruby 1.8.7pl0
2010 - draft standard (Japan)
2011 - final Ruby 1.8.7 patchlevel 352
2012 - Ruby 1.9.3

http://en.wikipedia.org/wiki/Ruby_(programming_language)
http://www.ruby-lang.org/en/news/2003/08/04/ruby-180-released/
http://www.ruby-lang.org/en/news/2007/12/25/ruby-1-9-0-released/
http://www.ruby-lang.org/en/news/2011/07/02/ruby-1-8-7-p352-released/
http://www.ruby-lang.org/en/news/2012/02/16/ruby-1-9-3-p125-is-released/
http://www.rubyinside.com/ruby-1-9-0-3-and-drops-support-for-9-platforms-970.html
http://www.ruby-lang.org/en/news/2011/10/06/plans-for-1-8-7/
http://www.ipa.go.jp/osc/english/ruby/index.html

1.8.7 bugfixes only until June 2012, security fixes until June 2013.
Then it's frozen in time ("dead"?). Wouldn't be a huge deal except 1.9
dropped a lot of platforms, and IIRC, you can't (easily) build 1.9
without some of the more expensive features. (Even Java dropped green
threads eventually, so why am I surprised?) Also, the proposed
standard (2010 draft, so far not finalized) was based upon 1.8.7. Oh,
and for licensing geeks, the 1.9 series is dually licensed with BSD
this time (instead of formerly GPL).

So yeah, it's weird. (And I'm literally the worst Ruby advocate, not
even! But still very vaguely interested, heh.) Hmmm, better get on-
topic: I still like Forth better. ;-)

ken...@cix.compulink.co.uk

unread,
Mar 5, 2012, 5:09:10 AM3/5/12
to
In article
<72fc94cd-74b5-4aee...@32g2000yqn.googlegroups.com>,
rug...@gmail.com (Rugxulo) wrote:

> Or maybe because tons of legacy code exists.

Or maybe because Unix, Linux and Windows are written in it. to use any
of the system calls in those that do not have wrappers provided involves
understanding C calling procedure at the least. While Delphi and Visual
Basic support the Windows 32 interface they do not directly support the
Windows NT functions left over from NT which some programmers still use.

> 1980 ... ah, a very good year.

The year I bought my first home computer. 16K of memory and Basic in
ROM. The alternative languages available were assembler and tiny Pascal.
There was probably a Forth available but I never came across it. My
second machine was an ST and I got HiSoft Object Forth for that. My
current machine has Delphi and WinForth on it. IIRC HiSoft supplied
Basic, C , Fortran and Pascal compilers as well.


Ken Young

van...@vsta.org

unread,
Mar 5, 2012, 12:27:50 PM3/5/12
to
Paul Rubin <no.e...@nospam.invalid> wrote:
> Lisp also is OO (as in CLOS and its predecessors).

That's like saying C is Forth, because I can implement a stack and word list
in C. Bolting on something to a language is rarely compelling, although it
might find favor with those who are already committed to that language. So
Python bolts on lambda, which is no selling point to the Lisp crowd (although
it's heavily used by Python coders). And I've never heard of a Smalltalk'er
who jumped to Lisp because of CLOS.

--
Andy Valencia
Home page: http://www.vsta.org/andy/
To contact me: http://www.vsta.org/contact/andy.html

hwf...@gmail.com

unread,
Mar 6, 2012, 11:38:16 PM3/6/12
to
On Sunday, March 4, 2012 8:42:26 AM UTC-7, Marcel Hendrix wrote:
> Strangely enough, nowadays progress comes from the vendors.
> It used to be users that dragged the language forward, and
> vendors that pulled the brakes.

Because vendors are the leading-edge users. Do you think they make their money selling Forths?

-Brad

Hugh Aguilar

unread,
Mar 8, 2012, 1:10:06 AM3/8/12
to
>   \ library code sourcehttp://soton.mpeforth.com/flag/fms/index.html
>
> All of the above was posted a short while ago.  If you are going to drop
> in on a newsgroup and make sweeping statements you should first follow
> the discussions a bit and also understand what library code is readily
> available.
>
> -Doug Hoffman

I'm not familiar with the code that Doug is referring to (because I
don't use other people's code), but it looks trivial to implement.
Also, as I pointed out, my novice package has all of this capability
already. It is possible to read the strings out of a file into a list,
obtain the length, and then convert the list into an array (or just
leave it as a list as I did in my program) --- you get the benefit of
being able to modify your file of strings without having to recompile
your Forth program. This kind of stuff is trivial --- it is not really
worthwhile to spend a lot of time pondering something like this
Valentine program --- the only reason why I got involved at all was to
help out our novice Steve, but now he has been forgotten and the
thread has devolved into a my-language-can-beat-up-your-language
debate, which is not useful to Steve in any way (I doubt that he wrote
his Forth program because he was hoping that somebody would convince
him to become a Ruby programmer).

As for Ruby, I've heard good things about it. Over on comp.lang.lisp
it is referred to as "Matz-Lisp" --- the general idea being that it
provides *most* of the power of Lisp, but with a friendlier syntax
(for people with a background in infix languages) --- the Lispers are
not intimidated by Ruby, and generally consider it to be a stepping-
stone into Lisp. Whatever... None of this matters to me, as nobody is
really making any money at either Ruby or Lisp. There are a few people
making money at Ruby-on-Rails, but that is effectively a language in
itself, which has little to do with writing Ruby scripts (such as this
Valentine program). For the most part desktop-computer software is
given away for free. It is a good idea to know a desktop-computer
scripting language, as this is useful for many people including micro-
controller programmers, but I don't think that it is wise to focus
entirely on scripting as there is no money in it. The only way to make
money is by selling hardware.

When I release Straight Forth, which is for micro-controller
programming, I will most likely declare a "sister language" that will
be used for related desktop scripting. There is no point in using a
wide variety of languages, as there really isn't much difference
between them --- it is not as if particular scripts have to be in one
language and other scripts have to be in another language --- they can
all be written in the same language for pretty much the same result. I
am leaning toward making Racket my sister-language, but Ruby or Python
or Factor are also reasonable choices. I haven't given much thought to
the question as I don't really have much interest in the subject. My
criteria is mostly that the language should be easy to learn ---
because many of my users will be electrical engineers, and they aren't
usually very good at programming --- besides that, I have to learn the
language too, and I'm not very good at learning new things either.

WJ

unread,
Apr 12, 2013, 2:29:23 PM4/12/13
to
Steve Graham wrote:

> Thanks to all who posted comments to the earlier Word Array posting.
>
> Here is the finished (for now) program which prints out 1 or more Valentine Bingo Cards. I'd be interested in any comments on style, etc.
>
> Thanks, Steve
>
> ---
>
> \
> \ Valentine Bingo
> \
>
> create wordarr
> ," Be Mine"
> ," Love"
> ," It's Love"
> ," All Mine"
> ," Kiss Me"
> ," You & Me"
> ," Awesome"
> ," My Baby"
> ," Love Me"
> ," All Star"
> ," My Way"
> ," Love You"
> ," For You"
> ," Cool"
> ," I Hope"
> ," Love Life"
> ," Angel"
> ," Sweet Talk"
> ," True Love"
> ," Be Good"
> ," How Nice"
> ," Let's Kiss"
> ," #1 Fan"
> ," Be True"
> ," Love Her"
> 0 ,
>
> \ number of phrases
> 25 constant #wordarr
>
> \ which numbers chosen
> create chosen-bingo-numbers #wordarr allot
>
> \ chosen numbers in order
> create ordered-bingo-numbers #wordarr allot
>
> \ jump from one phrase to the next
> : jumper \ addr -- addr'
> count + aligned
> ;
>
> \ get nth phrase
> : nth$ \ n base -- addr
> swap 0 ?do jumper loop
> ;
>
> \ print phrases
> : .tab \ base --
> begin
> dup @
> while
> dup count cr type jumper
> repeat
> drop
> ;
>
> \ print first part of webpage
> : .html-1 \ --
> cr
> ." <HTML>" cr
> ." <BODY>" cr
> ." <TABLE border=1 height=500 width=500>" cr
> ." <TR style='color:red;'>" cr
> ." <TH width='20%'>B</TH>" cr
> ." <TH width='20%'>I</TH>" cr
> ." <TH width='20%'>N</TH>" cr
> ." <TH width='20%'>G</TH>" cr
> ." <TH width='20%'>O</TH></TR>" cr
> ;
>
> \ print last part of webpage
> : .html-2 \ --
> cr ." </TABLE>"
> cr ." </BODY>"
> cr ." </HTML>"
> cr
> ;
>
> \ get 24 random non-repeating numbers in order
> : get-bingo-numbers \ --
> #wordarr chosen-bingo-numbers over erase
> ordered-bingo-numbers over erase
> 24 0 do
> dup choose
> begin
> dup chosen-bingo-numbers + c@ 0 >
> while
> drop dup choose
> repeat
> chosen-bingo-numbers over + 1 swap c!
> ordered-bingo-numbers i + c!
> loop
> drop
> ;
>
> \ print nth square's phrase given proper number
> : (.square) \ n --
> ordered-bingo-numbers + c@
> wordarr nth$ count type
> ;
>
> \ print nth square's phrase given any number
> : .square \ n --
> dup 12 <
> if (.square)
> else dup 12 =
> if drop ." Free Square"
> else 1- (.square)
> then
> then
> ;
>
> \ print rows of bingo card
> : .rows \ --
> 5 0 do
> cr ." <TR align='center' >"
> 5 0 do
> cr ." <TD>"
> j 5 * i +
> .square
> cr ." </TD>"
> loop
> cr ." </TR>"
> loop
> ;
>
> \ print n bingo cards
> : .cards \ n --
> 0 do
> get-bingo-numbers
> .html-1
> .rows
> .html-2
> loop
> ;
>
> ---
>
> 1 .cards
> <HTML>
> <BODY>
> <TABLE border=1 height=500 width=500>
> <TR style='color:red;'>
> <TH width='20%'>B</TH>
> <TH width='20%'>I</TH>
> <TH width='20%'>N</TH>
> <TH width='20%'>G</TH>
> <TH width='20%'>O</TH></TR>
>
> <TR align='center' >
> <TD>True Love
> </TD>
> <TD>I Hope
> </TD>
> <TD>You & Me
> </TD>
> <TD>Be Good
> </TD>
> <TD>For You
> </TD>
> </TR>
> <TR align='center' >
> <TD>Love
> </TD>
> <TD>Sweet Talk
> </TD>
> <TD>All Mine
> </TD>
> <TD>How Nice
> </TD>
> <TD>Angel
> </TD>
> </TR>
> <TR align='center' >
> <TD>Cool
> </TD>
> <TD>Be Mine
> </TD>
> <TD>Free Square
> </TD>
> <TD>All Star
> </TD>
> <TD>Let's Kiss
> </TD>
> </TR>
> <TR align='center' >
> <TD>Love Me
> </TD>
> <TD>Kiss Me
> </TD>
> <TD>#1 Fan
> </TD>
> <TD>My Way
> </TD>
> <TD>Love Her
> </TD>
> </TR>
> <TR align='center' >
> <TD>My Baby
> </TD>
> <TD>It's Love
> </TD>
> <TD>Love You
> </TD>
> <TD>Love Life
> </TD>
> <TD>Awesome
> </TD>
> </TR>
> </TABLE>
> </BODY>
> </HTML>
> ok

Factor:

USING: vectors random ;

CONSTANT: phrases {
phrases randomize >vector "shuffled" set

"<HTML>
<BODY>
<TABLE border=1 height=500 width=500>
<TR style='color:red;'>
<TH width='20%'>B</TH>
<TH width='20%'>I</TH>
<TH width='20%'>N</TH>
<TH width='20%'>G</TH>
<TH width='20%'>O</TH></TR>" print

5 [ " <TR align='center'>" print
5 [ " <td>" write "shuffled" get pop write "</td>" print ]
times
" </TR>" print ]
times

" </TABLE>
</BODY>
</HTML>" print


===== output =====

<HTML>
<BODY>
<TABLE border=1 height=500 width=500>
<TR style='color:red;'>
<TH width='20%'>B</TH>
<TH width='20%'>I</TH>
<TH width='20%'>N</TH>
<TH width='20%'>G</TH>
<TH width='20%'>O</TH></TR>
<TR align='center'>
<td>Love</td>
<td>Sweet Talk</td>
<td>My Way</td>
<td>All Star</td>
<td>Cool</td>
</TR>
<TR align='center'>
<td>It's Love</td>
<td>Love You</td>
<td>Be Good</td>
<td>All Mine</td>
<td>Love Me</td>
</TR>
<TR align='center'>
<td>I Hope</td>
<td>#1 Fan</td>
<td>Let's Kiss</td>
<td>Be Mine</td>
<td>How Nice</td>
</TR>
<TR align='center'>
<td>Be True</td>
<td>For You</td>
<td>Kiss Me</td>
<td>Awesome</td>
<td>Love Her</td>
</TR>
<TR align='center'>
<td>Angel</td>
<td>True Love</td>
<td>My Baby</td>
<td>You & Me</td>
<td>Love Life</td>
</TR>
</TABLE>
</BODY>
</HTML>
0 new messages