Groups | Search | Server Info | Login | Register


Groups > comp.lang.forth > #23666

Re: jonesforth: taking up the challenge

From Bernd Paysan <bernd.paysan@gmx.de>
Newsgroups comp.lang.forth
Subject Re: jonesforth: taking up the challenge
Date 2013-06-16 00:33 +0200
Organization 1&1 Internet AG
Message-ID <kpiq34$oa0$1@online.de> (permalink)
References (5 earlier) <7xehc83xx2.fsf@ruckus.brouhaha.com> <2013Jun12.171604@mips.complang.tuwien.ac.at> <7xppvn880t.fsf@ruckus.brouhaha.com> <kpil1f$k51$1@online.de> <7x4nczghro.fsf@ruckus.brouhaha.com>

Show all headers | View raw


Paul Rubin wrote:

> Bernd Paysan <bernd.paysan@gmx.de> writes:
>> So if you write a Forth in Ruby, you either make it simple, and then
>> you will get something considerably different (RPL or so), or you try
>> hard to implement Forth, and it will look messy.
> 
> I guess JSForth is messy, though maybe it could be cleaned up some, and
> maybe Ruby could be less messy than JS, I don't know.

Both JavaScript and Ruby are essentially Lisps with a different syntax, so 
the semantics is similar for both.  Writing RPL in JavaScript or Ruby is 
*much* easier, because you just define the stacks, and then push normal 
JavaScript or Ruby things on that.  Which aren't the same as Forth things.

JSForth maybe could use asm.js as fundation to implement Forth in a least-
messy way, asm.js is using JavaScript as portable assembler (and that maps 
to real assembler code, by the use of a Forth program inside the JavaScript 
engine - at least in Firefox, where asm.js comes from ;-).

>> No, but you ditched the dictionary entry entirely, by saying that "it
>> does a CREATE".  Then the magic Anton mentions just goes to CREATE.
> 
> Then maybe there's something to CREATE that I don't understand, but I
> thought it just reads the next input token, makes a dictionary entry (a
> straightforward data structure) and adjusts a few variables.

Yes, the data structure is actually not that complicated.

>>> You mean like functions?  Of course that seems useful.
>> Maybe if you program in Haskell.  Functions are not that common in
>> programs, as most subroutine have side-effects.
> 
> I think the concept of purity in functions doesn't really occur to most
> programmers unless they've been exposed to something like Haskell.
> Functions in programming conceptually start out as things like "square
> root", but since they're code, they can have print statements and
> whatnot, and nobody notices that this is impure.

IMHO that is the essence of the programmer's mind: A computer is really a 
state machine.  The fact that "impure" procedures modify the state is the 
real nature of a computer.

>> A friend of mine tried learning Haskell, and his "proof of the
>> pudding" is writing a word count program.  After he was 1/3 through
>> the Haskell book, he still couldn't.  Because the I/O was still
>> missing, and Haskell's file I/O isn't done right.
> 
> http://www.haskell.org/haskellwiki/Simple_unix_tools

I know, the problem was that IO Monads were explained at the end of the 
book.  This means you pretty much can't do anything real before you reach 
the end of the book.  The wiki above is much more pragmatic.

>> IMHO, Haskell should treat the file system as a index -> value table.
> 
> This might make sense for a read-only file system, where you don't care
> about large files.

Large files: mmap.  Ok, on a 32 bit system, not always practical ;-), but 
for 64 bit systems, mmap works quite well.

If you use the table metaphor, you can create new index -> value pairs, or 
replace existing pairs, just like you do on a hash table, so it is read-
write.

What this approach doesn't do is operate on bytes or lines.  I really don't 
like that approach much; we use slurp in Gforth a lot (and there's a 
counter-part, spit, which creates a file from a string).  Especially with 
the Haskell way of thinking, IMHO the "treat the file data as a whole, and 
not as a stream of bytes" is the right way.

> Haskell's "lazy i/o" stuff (shown above) works pretty well for many
> things and is fairly easy to understand for simple use cases, and it
> should be fine for a word count program, or even for something like TeX.
> It turns out to be impure in a way that bites you if you're writing
> stuff like network servers and you find your program leaking file
> descriptors, but this is mostly an issue if you're opening 1000's of
> them.  The "pure" way to do it that avoids these leaks is unfortunately
> rather complicated.  Various ways to bring clarity to it are still being
> developed.

Yes, and my suggestion was to use something like slurp/spit.  Even a 
network works quite well that way: You define how your network stream is 
packeted (e.g. a HTML request ends with an empty line).  And then, you just 
slurp in a packet, and respond with spitting another packet out.  My web-
server (in Forth) pretty much works that way.  It might be a bit more 
difficult to handle keep-alive connections, but if a HTTP connection isn't 
kept alive, it is a pretty pure function: Request maps to response, 
stateless.

>> It was about *implementation*, not about the language as such.
>> Forth's implementation is no way untypical, a lot of languages have
>> VMs which, under the hood, don't look that much different.
> 
> That's just the address interpreter.  The text interpreter and compiler
> is almost shocking ;-).  The language and its programming practices
> revolve around that one-pass transliteration into the dictionary.

Yes, and no.  It revolves about simplicity, and doing just what needs to be 
done, no more.

>> Oh, yes, Forth is about solving the problem at hand, not something
>> general.  How would that wholemeal approach e.g. solve the Triceps
>> playing Go stuff?. ..  Forth approach: Take the OpenGL texture the
>> webcam renders its preview into, and draw it with perspectivic
> 
> Probably kind of similar except you'd have a series of transforms that
> were composed with each other without a lot of explicit coordinates in
> between.

Not sure, the Forth program has just three transforms:  The OpenGL 
perspectivic correction (draws a rectangle rotated in 3D space), the pixel 
binning, and the majority decision.

If you solve the general problem, it's IMHO image recognition.

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

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-04 18:14 +0000
  Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-04 11:28 -0700
  Re: jonesforth: taking up the challenge Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-06-06 15:37 -0500
    Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-06 13:49 -0700
      Re: jonesforth: taking up the challenge "Ed" <invalid@invalid.com> - 2013-06-07 12:32 +1000
    Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-07 14:36 +0000
      Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-07 08:39 -0700
        Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-07 17:04 +0000
          Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-07 11:19 -0700
          Re: jonesforth: taking up the challenge "Rod Pemberton" <do_not_have@notemailnotq.cpm> - 2013-06-07 17:24 -0400
            Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-07 23:04 +0000
        Re: jonesforth: taking up the challenge anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-06-11 14:59 +0000
          Re: jonesforth: taking up the challenge Bill Richards <billrich@gmx.com> - 2013-06-11 16:09 +0000
            Re: jonesforth: taking up the challenge Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-06-12 08:08 -0500
              Re: jonesforth: taking up the challenge Bill Richards <billrich@gmx.com> - 2013-06-12 13:52 +0000
                Re: jonesforth: taking up the challenge Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-06-12 14:17 -0500
                Re: jonesforth: taking up the challenge anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-06-13 08:24 +0000
              Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-12 14:18 +0000
                Re: jonesforth: taking up the challenge Bill Richards <billrich@gmx.com> - 2013-06-12 15:05 +0000
                Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-13 01:40 +0000
                Re: jonesforth: taking up the challenge Lars Brinkhoff <lars.spam@nocrew.org> - 2013-06-13 08:55 +0200
                Re: jonesforth: taking up the challenge "Elizabeth D. Rather" <erather@forth.com> - 2013-06-12 21:05 -1000
                Re: jonesforth: taking up the challenge Lars Brinkhoff <lars.spam@nocrew.org> - 2013-06-13 10:49 +0200
                Re: jonesforth: taking up the challenge anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-06-13 08:55 +0000
                Re: jonesforth: taking up the challenge Bernd Paysan <bernd.paysan@gmx.de> - 2013-06-13 14:33 +0200
                Re: jonesforth: taking up the challenge anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-06-13 13:14 +0000
                Re: jonesforth: taking up the challenge Bill Richards <billrich@gmx.com> - 2013-06-13 18:33 +0000
                Re: jonesforth: taking up the challenge Mark Wills <markrobertwills@yahoo.co.uk> - 2013-06-14 01:25 -0700
                Re: jonesforth: taking up the challenge rickman <gnuarm@gmail.com> - 2013-06-15 12:00 -0400
                Re: jonesforth: taking up the challenge Mark Wills <markrobertwills@yahoo.co.uk> - 2013-06-15 14:35 -0700
                Re: jonesforth: taking up the challenge rickman <gnuarm@gmail.com> - 2013-06-15 19:29 -0400
                Re: jonesforth: taking up the challenge Mark Wills <markrobertwills@yahoo.co.uk> - 2013-06-17 03:31 -0700
                Re: jonesforth: taking up the challenge rickman <gnuarm@gmail.com> - 2013-06-17 19:16 -0400
                Re: jonesforth: taking up the challenge rickman <gnuarm@gmail.com> - 2013-06-15 11:58 -0400
          Re: jonesforth: taking up the challenge Bernd Paysan <bernd.paysan@gmx.de> - 2013-06-11 18:32 +0200
            Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-11 10:33 -0700
              Re: jonesforth: taking up the challenge Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2013-06-11 20:42 +0100
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-12 00:20 -0700
              Re: jonesforth: taking up the challenge Mark Wills <markrobertwills@yahoo.co.uk> - 2013-06-12 01:29 -0700
              Re: jonesforth: taking up the challenge Bernd Paysan <bernd.paysan@gmx.de> - 2013-06-12 19:52 +0200
                Re: jonesforth: taking up the challenge Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-06-12 14:19 -0500
                Re: jonesforth: taking up the challenge anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-06-13 08:47 +0000
                Re: jonesforth: taking up the challenge Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-06-13 07:45 -0500
                Re: jonesforth: taking up the challenge anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-06-13 13:04 +0000
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-14 21:32 -0700
                Re: jonesforth: taking up the challenge anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-06-17 17:15 +0000
                Re: jonesforth: taking up the challenge Lars Brinkhoff <lars.spam@nocrew.org> - 2013-06-20 09:42 +0200
                Re: jonesforth: taking up the challenge "Elizabeth D. Rather" <erather@forth.com> - 2013-06-19 21:52 -1000
                Re: jonesforth: taking up the challenge Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-06-16 10:01 -0500
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-16 14:14 -0700
                Re: jonesforth: taking up the challenge Bernd Paysan <bernd.paysan@gmx.de> - 2013-06-16 23:58 +0200
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-16 23:17 -0700
                Re: jonesforth: taking up the challenge anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-06-17 16:00 +0000
                Re: jonesforth: taking up the challenge Elizabeth D Rather <erather@forth.com> - 2013-06-17 08:05 -1000
                Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-17 19:33 +0000
                Re: jonesforth: taking up the challenge Gerry Jackson <spam@qlikz.org> - 2013-06-17 21:23 +0100
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-12 22:58 -0700
                Re: jonesforth: taking up the challenge "Elizabeth D. Rather" <erather@forth.com> - 2013-06-12 20:48 -1000
              Re: jonesforth: taking up the challenge rickman <gnuarm@gmail.com> - 2013-06-15 12:05 -0400
            Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-13 10:39 +0000
          Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-11 18:44 -0700
            Re: jonesforth: taking up the challenge anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-06-12 15:16 +0000
              Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-15 12:54 -0700
                Re: jonesforth: taking up the challenge "Elizabeth D. Rather" <erather@forth.com> - 2013-06-15 11:05 -1000
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-15 14:21 -0700
                Re: jonesforth: taking up the challenge Bernd Paysan <bernd.paysan@gmx.de> - 2013-06-15 23:06 +0200
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-15 14:56 -0700
                Re: jonesforth: taking up the challenge Bernd Paysan <bernd.paysan@gmx.de> - 2013-06-16 00:33 +0200
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-15 16:47 -0700
                Re: jonesforth: taking up the challenge Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-06-16 09:45 -0500
                Re: jonesforth: taking up the challenge anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-06-17 16:19 +0000
                Re: jonesforth: taking up the challenge Alex McDonald <blog@rivadpm.com> - 2013-06-17 11:51 -0700
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-18 00:31 -0700
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-18 00:33 -0700
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-18 00:46 -0700
                Re: jonesforth: taking up the challenge Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-06-18 04:11 -0500
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-18 23:51 -0700
                Re: jonesforth: taking up the challenge Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-06-19 04:32 -0500
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-19 02:42 -0700
                Re: jonesforth: taking up the challenge Lars Brinkhoff <lars.spam@nocrew.org> - 2013-06-19 12:08 +0200
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-19 09:25 -0700
                Re: jonesforth: taking up the challenge Lars Brinkhoff <lars.spam@nocrew.org> - 2013-06-19 19:10 +0200
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-20 17:08 -0700
                Re: jonesforth: taking up the challenge Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-06-19 09:04 -0500
                Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-19 09:26 -0700
      Re: jonesforth: taking up the challenge Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-06-07 16:45 -0500
  Re: jonesforth: taking up the challenge "Rod Pemberton" <do_not_have@notemailnotq.cpm> - 2013-06-06 23:29 -0400
    Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-07 14:41 +0000
      Re: jonesforth: taking up the challenge "Rod Pemberton" <do_not_have@notemailnotq.cpm> - 2013-06-07 17:24 -0400
        Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-07 23:07 +0000
          Re: jonesforth: taking up the challenge Bernd Paysan <bernd.paysan@gmx.de> - 2013-06-08 01:26 +0200
            Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-07 17:54 -0700
              Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-19 10:01 +0000
            Re: jonesforth: taking up the challenge Lars Brinkhoff <lars.spam@nocrew.org> - 2013-06-08 07:29 +0200
              Re: jonesforth: taking up the challenge mhx@iae.nl - 2013-06-07 23:17 -0700
                Re: jonesforth: taking up the challenge mhx@iae.nl - 2013-06-08 01:30 -0700
              Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-07 23:41 -0700
                Re: jonesforth: taking up the challenge Lars Brinkhoff <lars.spam@nocrew.org> - 2013-06-08 09:35 +0200
                Re: jonesforth: taking up the challenge anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-06-08 14:28 +0000
                Re: jonesforth: taking up the challenge Lars Brinkhoff <lars.spam@nocrew.org> - 2013-06-08 21:22 +0200
                Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-19 10:06 +0000
                Re: jonesforth: taking up the challenge Lars Brinkhoff <lars.spam@nocrew.org> - 2013-06-19 12:27 +0200
                Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-19 10:44 +0000
                Re: jonesforth: taking up the challenge Lars Brinkhoff <lars.spam@nocrew.org> - 2013-06-08 21:55 +0200
                Re: jonesforth: taking up the challenge Bill Richards <billrich@gmx.com> - 2013-06-11 14:09 +0000
              Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-08 07:49 +0000
            Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-08 07:47 +0000
              Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-08 00:59 -0700
                Re: jonesforth: taking up the challenge Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-06-08 16:40 -0500
                Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-13 01:24 +0000
  Re: jonesforth: taking up the challenge Mark Wills <markrobertwills@yahoo.co.uk> - 2013-06-07 00:37 -0700
    Re: jonesforth: taking up the challenge Paul Rubin <no.email@nospam.invalid> - 2013-06-07 00:53 -0700
    Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-07 14:49 +0000
      Re: jonesforth: taking up the challenge Bill Richards <billrich@gmx.com> - 2013-06-11 14:13 +0000
  Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-12 14:21 +0000
  Re: jonesforth: taking up the challenge the_gavino_himself <visphatesjava@gmail.com> - 2013-06-15 23:22 -0700
    Re: jonesforth: taking up the challenge "Elizabeth D. Rather" <erather@forth.com> - 2013-06-15 21:26 -1000
      Re: jonesforth: taking up the challenge Alex McDonald <blog@rivadpm.com> - 2013-06-16 12:58 -0700
      OT Making fun of gavino. was Re: jonesforth: taking up the challenge albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-06-19 10:52 +0000

csiph-web