Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #15560

Re: Forth as a polarising language

From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.forth
Subject Re: Forth as a polarising language
References (12 earlier) <42098575.CBZ8BYJVEi@sunwukong.fritz.box> <7xzk5148ba.fsf@ruckus.brouhaha.com> <9166513.gd9qQuK4mJ@sunwukong.fritz.box> <7xzk50m3uf.fsf@ruckus.brouhaha.com> <4730306.fNe2lVOm3c@sunwukong.fritz.box>
Date 2012-09-09 15:14 -0700
Message-ID <7xehmax2rm.fsf@ruckus.brouhaha.com> (permalink)
Organization Nightsong/Fort GNOX

Show all headers | View raw


Bernd Paysan <bernd.paysan@gmx.de> writes:
> "Undefined" behavior is something language lawyers tend to use.  A 
> computer is a fully deterministic state machine, there is no undefined 
> behavior.

Undefined in the sense that it can't be deduced just from the program
text.  It depends on the complete state of the machine including the OS,
compiler output, etc, which are outside the programmer's control.  And
the machine state at bottom is truly nondeterministic, because it
depends on what order things have happened in, which depends on things
like disk latency variations and external I/O events.  Disk latency is
controlled in part by physically random, turbulent airflow inside the
disk drive.  This is sometimes used as a source of entropy for
cryptographic RNG's.

> So a Lisp program won't segfault while a C or Forth program will.  The 
> Lisp program still prints error messages which disrupt the normal 
> control flow of that program.  From the program's point of view, this 
> behavior is still "undefined", it won't know what to do.  Termination is 
> a good idea.

Of course it knows what to do: termination is well-defined.  In a
long-running system you probably want to add some failover mechanism to
recover from the crash.

> In contrast, a Haskell program with such a type error even doesn't 
> compile.  That's what I consider strong typing.

OK, fair enough.  

>> Scheme and Python raise errors if you do that.
> But they treat integers/bignums/floats as interchangeable.

Scheme doesn't:

    guile> (/ 5 3)
    5/3
    guile> (/ 5.0 3.0)
    1.66666666666667

Python treated 5/3 as truncating integer division in version 2 but as
giving a floating result in version 3, because apparently the integer
result confused beginners.  I think I'd prefer raising an exception so I
can make sure the program does exactly what I intended.  Haskell doesn't
do any automatic conversions and I find it actually reassuring that it
doesn't.  Supplying a manual conversion is trivial when it's what you
want.

> The more popular instruments are ones where you get a reasonable tune 
> out at first try.  

The most popular instrument around here is probably the guitar, and it's
much harder for beginners to get good sound from a guitar from than a
piano or a wind instrument, or maybe even a violin (no idea about
alphorn).  Or the flute: it's hard to get any sound at all at first,
whether good or bad.  I think people play what they like to listen to,
and if they're into it enough to get any good, they'll also persist
through rough spots at the beginning.

> My experience is that the type system gets rid of 5%, while adding
> 200% of its own.  Yes, I've used the "wrong" strong typed languages,

Well, it's also partly subjective, and partly a matter of style, and
maybe also partly a matter of how much of your programming day is spent
dealing with code that you wrote yourself, versus code (even good,
well-documented code) written by other people.  If you're hired to add a
new feature that intersects significant chunks of an existing,
million-line program, a type system may help you more than it would help
if you're developing a small program from scratch.

> and then had to rewrite that into
> i := when i = 15 then 0 else i + 1;
> ...  because VHDL otherwise caused an exception (it *did* compile).

Oh man, I wonder if what was really needed was some kind of declaration
of a 4-bit binary counter, i.e. the variable really was indeed the wrong
type.  What does it mean for VHDL to throw a runtime exception
anyway????

> Forth is the assembly code of the b16, and yes, I've done something
> like that using "real" microcontroller assembly code (PIC17): It is a
> nightmare.

Meh, the PIC instruction set is ugly but it's tractable.  I know a guy
who programmed those things and did amazing stuff with them.  Yeah,
Forth was probably easier, but if you're making 10 million of something,
1 cent saved on the hardware per unit is $100,000 which is worth some
extra development time.

>>> MSP430 ... in C.  It's more than 16k long...
> The sort-of same program written in PIC17 assembly language was 8k long...
> I've heard this "it's not possible", "you must be comparing apples to 
> bananas" and all that stuff often enough.  Redefining the problem until 
> a small program can solve it is part of Forth's philosophy, it's not 
> just the code density of 5 bit per instruction that matters.

I'm having trouble figuring out what a battery monitor needs to do that
wants that much code space (16k or 8k).  I think we have to treat this
MSP430 thing as indeterminate.  The MSP430 has 16-bit instructions but
they are like the PDP-11, with enough registers and addressing modes
that each instruction can do the equivalent of multiple 5-bit
operations.  So I doubt there's a huge difference in code density,
whether it's better or worse.  In an ASIC, the b16 core is probably
smaller by enough to make up for some code space disadvantage anyway.

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


Thread

Re: Article Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-08-29 23:00 -0700
  Re: Article Mark Wills <markrobertwills@yahoo.co.uk> - 2012-08-30 01:47 -0700
    Re: Article anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-30 12:13 +0000
  Re: Article "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-08-30 11:31 -0400
    Missing from USENET - was [Re: Article] Richard Owlett <rowlett@pcnetinc.com> - 2012-08-30 10:37 -0500
      Missing from USENET - was [Re: Article] Mark Wills <markrobertwills@yahoo.co.uk> - 2012-08-30 10:30 -0700
  Re: Article hughaguilar96@yahoo.com - 2012-08-30 19:56 -0700
    Re: Article awegel@arcor.de (Alex Wegel) - 2012-08-31 12:35 +0200
  Re: Article "Greg Bailey" <greg@greenarraychips.com> - 2012-08-31 17:51 -0700
    Re: Article Whammo <sidciavic@gmail.com> - 2012-08-31 18:22 -0700
    Re: Article Mark Wills <forthfreak@gmail.com> - 2012-09-01 01:04 -0700
      Re: Article Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-09-02 16:18 -0700
    Re: Article Alex McDonald <blog@rivadpm.com> - 2012-09-01 01:48 -0700
    Re: Article rickman <gnuarm@gmail.com> - 2012-09-02 18:38 -0400
    Re: Article Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-09-02 16:59 -0700
    Re: Article Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-09-03 13:07 -0500
      Re: Article Alex McDonald <blog@rivadpm.com> - 2012-09-03 14:25 -0700
      Re: Article Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-09-04 17:04 -0700
        Re: Article Ron Aaron <rambamist@gmail.com> - 2012-09-05 06:23 +0300
    Re: Article "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-09-03 18:17 -0400
      Re: Article "Elizabeth D. Rather" <erather@forth.com> - 2012-09-03 12:37 -1000
        Re: Article "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-09-04 04:48 -0400
          Re: Article Alex McDonald <blog@rivadpm.com> - 2012-09-04 03:39 -0700
            Re: Article "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-09-05 02:48 -0400
          Re: Article awegel@arcor.de (Alex Wegel) - 2012-09-04 13:18 +0200
            Re: Article Bernd Paysan <bernd.paysan@gmx.de> - 2012-09-04 16:03 +0200
              Re: Article "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-09-05 03:29 -0400
            Re: Article "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-09-05 03:24 -0400
          Re: Article John Passaniti <john.passaniti@gmail.com> - 2012-09-04 08:12 -0700
            Re: Article "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-09-05 16:06 -0400
          Re: Article Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-09-04 11:35 -0500
            Re: Article "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-09-05 02:40 -0400
              Re: Article Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-09-05 13:28 -0700
          Re: Article "Elizabeth D. Rather" <erather@forth.com> - 2012-09-04 08:32 -1000
            Re: Article "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-09-05 02:22 -0400
              Re: Article John Passaniti <john.passaniti@gmail.com> - 2012-09-05 10:08 -0700
                Re: Article "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-09-05 16:07 -0400
                Re: Article John Passaniti <john.passaniti@gmail.com> - 2012-09-05 13:39 -0700
              Re: Article Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-09-05 13:35 -0700
            Re: Article "Ed" <invalid@nospam.com> - 2012-09-07 17:24 +1000
            Re: Article "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-09-07 05:28 -0400
              Re: Article Mark Wills <markrobertwills@yahoo.co.uk> - 2012-09-07 03:28 -0700
              Re: Article Ron Aaron <rambamist@gmail.com> - 2012-09-07 13:31 +0300
                Re: Article jacko <jackokring@gmail.com> - 2012-09-07 06:33 -0700
                Re: Article Howerd <howerdo@yahoo.co.uk> - 2012-09-07 09:06 -0700
              Re: Article Howerd <howerdo@yahoo.co.uk> - 2012-09-07 09:03 -0700
        Re: Article Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-09-04 16:45 -0700
      Re: Article John Passaniti <john.passaniti@gmail.com> - 2012-09-03 21:38 -0700
        Re: Article "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-09-05 02:51 -0400
          Re: Article John Passaniti <john.passaniti@gmail.com> - 2012-09-05 10:49 -0700
            Re: Article "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-09-05 16:20 -0400
        Re: Article "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-09-05 16:06 -0400
          Re: Article John Passaniti <john.passaniti@gmail.com> - 2012-09-05 13:32 -0700
            Re: Article Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-09-05 13:50 -0700
              Re: Article John Passaniti <john.passaniti@gmail.com> - 2012-09-05 22:34 -0700
                Re: Forth as a polarising language Paul Rubin <no.email@nospam.invalid> - 2012-09-07 14:05 -0700
                Re: Forth as a polarising language Bernd Paysan <bernd.paysan@gmx.de> - 2012-09-08 01:53 +0200
                Re: Forth as a polarising language Paul Rubin <no.email@nospam.invalid> - 2012-09-07 18:22 -0700
                Re: Forth as a polarising language Bernd Paysan <bernd.paysan@gmx.de> - 2012-09-09 00:08 +0200
                Re: Forth as a polarising language Paul Rubin <no.email@nospam.invalid> - 2012-09-08 17:34 -0700
                Re: Forth as a polarising language Bernd Paysan <bernd.paysan@gmx.de> - 2012-09-09 15:57 +0200
                Re: Forth as a polarising language Mark Wills <markrobertwills@yahoo.co.uk> - 2012-09-09 08:12 -0700
                Re: Forth as a polarising language Bernd Paysan <bernd.paysan@gmx.de> - 2012-09-09 22:07 +0200
                Re: Forth as a polarising language Paul Rubin <no.email@nospam.invalid> - 2012-09-09 15:14 -0700
                Re: Forth as a polarising language Bernd Paysan <bernd.paysan@gmx.de> - 2012-09-10 01:52 +0200
                Re: Forth as a polarising language Paul Rubin <no.email@nospam.invalid> - 2012-09-09 19:17 -0700
                Re: Forth as a polarising language Bernd Paysan <bernd.paysan@gmx.de> - 2012-09-10 15:01 +0200
                Re: Forth as a polarising language Paul Rubin <no.email@nospam.invalid> - 2012-09-10 07:00 -0700
                Re: Forth as a polarising language Bernd Paysan <bernd.paysan@gmx.de> - 2012-09-11 01:07 +0200
                Re: Forth as a polarising language Paul Rubin <no.email@nospam.invalid> - 2012-09-10 18:47 -0700
                Re: Forth as a polarising language Elizabeth D Rather <erather@forth.com> - 2012-09-10 16:08 -1000
                Re: Forth as a polarising language anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-09-11 07:51 +0000
                Re: Forth as a polarising language Bernd Paysan <bernd.paysan@gmx.de> - 2012-09-11 19:24 +0200
                Re: Forth as a polarising language Bernd Paysan <bernd.paysan@gmx.de> - 2012-09-11 21:40 +0200
                Re: Forth as a polarising language "Elizabeth D. Rather" <erather@forth.com> - 2012-09-09 14:58 -1000
                Re: Forth as a polarising language Paul Rubin <no.email@nospam.invalid> - 2012-09-09 18:24 -0700
                Re: Forth as a polarising language Anonymous <nobody@remailer.paranoici.org> - 2012-09-09 13:42 +0000
                Re: Forth as a polarising language mhx@iae.nl (Marcel Hendrix) - 2012-09-08 10:34 +0200
                Re: Forth as a polarising language Doug Hoffman <glidedog@gmail.com> - 2012-09-08 07:06 -0400
                Re: Forth as a polarising language mhx@iae.nl (Marcel Hendrix) - 2012-09-08 16:14 +0200
                DEFER (was: Forth as a polarising language) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-09-08 16:47 +0000
                Re: Forth as a polarising language Doug Hoffman <glidedog@gmail.com> - 2012-09-09 04:22 -0400
                OOP (was: Forth as a polarising language) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-09-08 11:38 +0000
                Re: OOP Doug Hoffman <glidedog@gmail.com> - 2012-09-08 08:19 -0400
                Re: OOP mhx@iae.nl (Marcel Hendrix) - 2012-09-08 16:41 +0200
                Re: OOP Doug Hoffman <glidedog@gmail.com> - 2012-09-09 04:24 -0400
                Re: Forth as a polarising language mhx@iae.nl (Marcel Hendrix) - 2012-09-09 12:03 +0200
                Re: Forth as a polarising language "A. K." <akk@nospam.org> - 2012-09-09 13:20 +0200
                Re: Forth as a polarising language Doug Hoffman <glidedog@gmail.com> - 2012-09-10 08:33 -0400
                Re: OOP mhx@iae.nl (Marcel Hendrix) - 2012-09-08 16:54 +0200
                Re: OOP Doug Hoffman <glidedog@gmail.com> - 2012-09-09 04:12 -0400
                OOP (was: Forth as a polarising language) mhx@iae.nl (Marcel Hendrix) - 2012-09-08 16:28 +0200
                Re: OOP (was: Forth as a polarising language) mhx@iae.nl (Marcel Hendrix) - 2012-09-08 16:56 +0200
                Re: OOP (was: Forth as a polarising language) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-09-08 15:00 +0000
                Re: OOP (was: Forth as a polarising language) Roger Ivie <rivie@ridgenet.net> - 2012-09-08 11:56 -0500
                Re: OOP Doug Hoffman <glidedog@gmail.com> - 2012-09-09 04:20 -0400
                Re: Forth as a polarising language Bernd Paysan <bernd.paysan@gmx.de> - 2012-09-09 00:15 +0200
                Re: Forth as a polarising language Bernd Paysan <bernd.paysan@gmx.de> - 2012-09-09 00:50 +0200
                Re: Forth as a polarising language mhx@iae.nl (Marcel Hendrix) - 2012-09-09 03:12 +0200
                Re: Forth as a polarising language Bernd Paysan <bernd.paysan@gmx.de> - 2012-09-09 16:01 +0200
                Re: Forth as a polarising language "Elizabeth D. Rather" <erather@forth.com> - 2012-09-09 14:54 -1000
                [OT] Newsreader problem - was [Re: Forth as a polarising language] Richard Owlett <rowlett@pcnetinc.com> - 2012-09-10 06:33 -0500
                Re: [OT] Newsreader problem - was [Re: Forth as a polarising language] Doug Hoffman <glidedog@gmail.com> - 2012-09-10 08:16 -0400
                Re: [OT] Newsreader problem - was [Re: Forth as a polarising language] Doug Hoffman <glidedog@gmail.com> - 2012-09-10 08:28 -0400
                Re: [OT] Newsreader problem - was [Re: Forth as a polarising language] anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-09-10 12:43 +0000
                Re: [OT] Newsreader problem - was [Re: Forth as a polarising language] Doug Hoffman <glidedog@gmail.com> - 2012-09-10 09:24 -0400
                Re: [OT] Newsreader problem - was [Re: Forth as a polarising language] Richard Owlett <rowlett@pcnetinc.com> - 2012-09-10 08:12 -0500
                Re: [OT] Newsreader problem - was [Re: Forth as a polarising language] Doug Hoffman <glidedog@gmail.com> - 2012-09-10 09:32 -0400
                Re: [OT] Newsreader problem - was [Re: Forth as a polarising language] "Elizabeth D. Rather" <erather@forth.com> - 2012-09-10 07:40 -1000
                Re: [OT] Newsreader problem - was [Re: Forth as a polarising language] Richard Owlett <rowlett@pcnetinc.com> - 2012-09-10 14:42 -0500
                Re: Forth as a polarising language Doug Hoffman <glidedog@gmail.com> - 2012-09-10 07:59 -0400
                Re: Forth as a polarising language rickman <gnuarm@gmail.com> - 2012-09-10 12:27 -0400
                Re: Forth as a polarising language "Elizabeth D. Rather" <erather@forth.com> - 2012-09-10 07:44 -1000
                Re: Forth as a polarising language rickman <gnuarm@gmail.com> - 2012-09-10 12:30 -0400
            Re: Article "Ed" <invalid@nospam.com> - 2012-09-09 14:13 +1000
              Re: Article John Passaniti <john.passaniti@gmail.com> - 2012-09-11 11:26 -0700
                Re: Article "Paul E. Bennett" <Paul_E.Bennett@topmail.co.uk> - 2012-09-11 21:02 +0100
                Re: Article vandys@vsta.org - 2012-09-11 20:37 +0000
                Re: Article "Ed" <invalid@nospam.com> - 2012-09-12 20:01 +1000
              Re: Article Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-09-11 16:50 -0700
                Re: Article Mark Wills <forthfreak@gmail.com> - 2012-09-12 00:45 -0700
                Re: Article Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-09-12 18:44 -0700
                Re: Article Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-09-12 20:26 -0700
                Re: Article "Ed" <invalid@nospam.com> - 2012-09-12 20:47 +1000
    Re: Article Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-09-06 19:28 -0700
      Re: Article John Passaniti <john.passaniti@gmail.com> - 2012-09-07 09:57 -0700

csiph-web