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


Groups > comp.lang.forth > #54745

Re: Really?

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: Really?
Date 2017-02-09 08:57 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2017Feb9.095708@mips.complang.tuwien.ac.at> (permalink)
References <1239a88b-a574-401b-9454-50ac7e000049@googlegroups.com> <5899a408.386236853@news.eternal-september.org> <87shnqw989.fsf@nightsong.com> <2017Feb7.183554@mips.complang.tuwien.ac.at> <87k291w3et.fsf@nightsong.com>

Show all headers | View raw


Paul Rubin <no.email@nospam.invalid> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>>different development style than Forth or C, where you have to be
>>>careful to not give back hard-earned gains.
>> If you run into that problem, there probably is something wrong with
>> your basic architecture or your code, and the "gains" are actually a
>> burden.
>
>What I've seen with large C programs is that bugs are elusive--they lurk
>around for a long time before even being noticed, they they're hunted
>for a while before any pattern emerges, and then they're often quite
>hard to diagnose and fix.  So old C programs are valuable because
>they're "seasoned": much effort has been spent finding and chasing bugs
>over the years, that has to be re-done if you toss out the code.
>
>By comparison, the mantra with fancy typed languages like Ocaml is that
>once you fix all the compile-time type errors the code tends to work.
>With latently typed languages like Python, you avoid every sort of
>compile-time error, and in return you get a lot of early runtime errors
>that give exact stack traces and are easy to debug.  You don't invest
>nearly the debugging time as you do in C so the program doesn't gain as
>much value as it ages.

That's totally contrary to my perception (except that, yes, the static
typechecking believers have this mantra; that does not mean that it is
true).  The kind of bugs that compile-time type checking catches or
that run-time type checking catches tend to be the easy ones.  If you
catch such a bug after a long time (because you did not test for it,
and apparently the users did not exercise that case, either), it is
still an easy bug.  And aging does not make code more valuable.

Of course, if you have invested quite a bit of effort into the code,
that is one way to determine its value; a related one is the effort
that replacing it would cost.  Another is the value that the users of
the code (including programmers calling it) derive from it; If the
code restricts the usage, and causes complexity in the callers, it's
actually a burden.

>I had a significant change in perspective when I got involved in a
>Python project dealing with a large (terabytes) data corpus.  The motto
>there was basically that data is gold but code is crap.  I'd been used
>to hearing it the other way around.  We were constantly writing
>throwaway programs to munch the data one way or another, but replacing
>the data (collected over decades) would have been impossible.

What is valuable depends on the project.  And in a project where you
have to do lots of one-off data analyses, you are likely to use a
language that makes that easy, rather than writing assembly-language
programs with fine-tuning for maximum performance, expecially if your
programs are disk-bound anyway.

>> Concerning run-time checks, if you think that helps, put them into your
>> code.
>
>The trouble is that errors happen in exactly the places you don't expect
>them to, or else they wouldn't be errors ;).  Yes some asserts here and
>there are good, but pervasive checking catches a lot of stuff that could
>go unnoticed.  Think of all the subscript errors in Fortran and C
>programs over the years.  

The errors that run-time checking in languages like Python checks for
are errors that the Python implementors expected, otherwise they would
not have put them in; and if the checks catch something, it's obvious
that errors can occur in places where one expects errors.*

Anyway, if you want subscript checking, then go ahead, implement it,
and use it.  If you want to check that you are accessing the right
structure, put a magic number in the structure, and check it in the
field words.

*) Actually, I guess that most of the hard errors occur in places
where one expects them; this reminds me of an anecdote by Richard
Feinmann, where he inspected an Uranium enrichment facility.  They
showed him the plans, he asked about a specific part, and they
realized that there was an error there, and viewed him as a genius for
seeing that error right away, while he actually described it as just a
random inquiry.  My guess is that he asked about a particularly
complex part of the plan, and it's much more likely that there is an
error there than in the easy parts.

>> If you are used to garbage collection, you may find that hard, and
>> requiring you to think outside the box of your usual practices.
>> Programming like in a GC language and trying to put in FREEs where
>> necessary will not lead to good results.
>
>For lots of purposes, single-ownership pointers (std::unique_ptr) in C++
>can take the place of GC with almost no overhead and not too much
>programmer effort.  But they rely on the C++'s so-called RAII paradigm,
>where a value's type signature can tell the compiler to call
>user-supplied code when the value goes out of scope, and also operator
>overloading to track the movement of values from one place to another.
>It's much easier than manual alloc/free and I don't think it can be done
>in Forth.

Freeing memory (or other reseources) on leaving the definition where
it was ALLOCATEd (which is the limitation of RAII in C++) is certainly
possible in Forth:

: alloc-exec ( ... u xt -- ... )
  \ allocate u memory at addr and call xt ( ... addr -- ... ); 
  \ on leaving xt, free the memory.
  >r allocate throw dup {: addr :} r> catch addr free throw throw ; 

Usage:

  500 [: ( addr -- ) ... do some computation with the buffer ... ;] alloc-exec

>But, the Boehm GC works pretty well in C and sounds ok for
>Forth (you'd know better than me about that).

The funny thing is that, even though I wrote a conservative garbage
collector for Forth, I have not really used it; in those cases where
it would have been compatible with other requirements, it did not seem
necessary.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2016: http://www.euroforth.org/ef16/

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


Thread

Really? Mark Wills <markwills1970@gmail.com> - 2017-02-06 06:46 -0800
  Re: Really? foxaudioresearch@gmail.com - 2017-02-06 07:20 -0800
  Re: Really? polymorph self <jackvanc3@gmail.com> - 2017-02-06 08:58 -0800
  Re: Really? rickman <gnuarm@gmail.com> - 2017-02-06 13:06 -0500
  Re: Really? hughaguilar96@gmail.com - 2017-02-06 11:25 -0800
  Re: Really? "HAA" <someone@microsoft.com> - 2017-02-07 11:45 +1100
  Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-06 15:38 -1000
    Re: Really? hughaguilar96@gmail.com - 2017-02-07 09:50 -0800
  Re: Really? Rod Pemberton <NeedNotReplyHere@xrsevnneqk.cem> - 2017-02-06 23:39 -0500
    Re: Really? Mark Wills <markwills1970@gmail.com> - 2017-02-07 08:04 -0800
    Re: Really? "HAA" <someone@microsoft.com> - 2017-02-08 11:04 +1100
      Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-07 23:42 -0800
        Re: Really? "HAA" <someone@microsoft.com> - 2017-02-08 20:12 +1100
          Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-08 02:44 -0800
          Re: Really? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-02-08 17:48 +0000
            Re: Really? Alex <alex@rivadpm.com> - 2017-02-08 18:43 +0000
              Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-08 15:24 -0800
            Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-08 16:26 -0800
    Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-07 22:45 -0800
      Re: Really? hughaguilar96@gmail.com - 2017-02-07 22:50 -0800
    Re: Really? clozaga@gmail.com - 2017-02-08 21:03 -0800
      Re: Really? clozaga@gmail.com - 2017-02-08 21:04 -0800
      Re: Really? hughaguilar96@gmail.com - 2017-02-11 20:01 -0800
        Re: Really? Alex <alex@rivadpm.com> - 2017-02-12 16:26 +0000
          Re: Really? hughaguilar96@gmail.com - 2017-02-12 16:52 -0800
            Re: Really? Alex <alex@rivadpm.com> - 2017-02-13 09:49 +0000
              Re: Really? minforth@arcor.de - 2017-02-13 07:03 -0800
              Re: Really? hughaguilar96@gmail.com - 2017-02-13 13:41 -0800
                Re: Really? Alex <alex@rivadpm.com> - 2017-02-13 22:32 +0000
                Re: Really? hughaguilar96@gmail.com - 2017-02-15 11:42 -0800
                Re: Really? Alex <alex@rivadpm.com> - 2017-02-15 20:41 +0000
                Re: Really? hughaguilar96@gmail.com - 2017-02-17 09:42 -0800
                Re: Really? Alex <alex@rivadpm.com> - 2017-02-17 22:22 +0000
          Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-12 19:24 -1000
            Re: Really? Alex <alex@rivadpm.com> - 2017-02-13 08:49 +0000
  Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-07 11:01 +0000
    Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-07 03:06 -0800
      Re: Really? hughaguilar96@gmail.com - 2017-02-07 09:35 -0800
      Re: Really? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-02-07 17:35 +0000
        Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-07 23:24 -0800
          Re: Really? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-02-09 08:57 +0000
            Re: Really? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-02-09 13:24 +0100
              Re: Really? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-02-11 15:32 +0000
      Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-07 20:42 +0000
        Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-07 13:58 -1000
          Re: Really? hughaguilar96@gmail.com - 2017-02-07 21:51 -0800
            Re: Really? rickman <gnuarm@gmail.com> - 2017-02-08 01:47 -0500
              Re: Really? hughaguilar96@gmail.com - 2017-02-07 22:52 -0800
                Re: Really? rickman <gnuarm@gmail.com> - 2017-02-08 03:34 -0500
                Re: Really? Alex <alex@rivadpm.com> - 2017-02-08 13:43 +0000
                Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-08 15:39 -1000
                Re: Really? hughaguilar96@gmail.com - 2017-02-08 22:39 -0800
                Re: Really? Alex <alex@rivadpm.com> - 2017-02-09 08:56 +0000
                Re: Really? hughaguilar96@gmail.com - 2017-02-09 14:36 -0800
                Re: Really? Alex <alex@rivadpm.com> - 2017-02-10 08:33 +0000
                Re: Really? Alex <alex@rivadpm.com> - 2017-02-09 09:03 +0000
                Re: Really? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-02-09 10:51 +0100
                Re: Really? john <anon@example.com> - 2017-02-09 11:54 +0000
                Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-09 09:30 -1000
                Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-09 14:14 +0000
                Re: Really? Alex <alex@rivadpm.com> - 2017-02-09 14:37 +0000
                Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-09 15:24 +0000
                Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-09 12:01 -0800
                Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-10 01:09 +0000
                Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-09 18:19 -0800
                Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-09 16:30 -1000
                Re: Really? hughaguilar96@gmail.com - 2017-02-09 19:16 -0800
                Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-10 16:29 +0000
                OT: [ was re: Really?] Foreign aid Alex <alex@rivadpm.com> - 2017-02-10 17:30 +0000
                Re: OT: [ was re: Really?] Foreign aid Cecil Bayona <cbayona@cbayona.com> - 2017-02-10 11:46 -0600
                Re: OT: [ was re: Really?] Foreign aid Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-02-10 11:54 -0600
                Re: OT: [ was re: Really?] Foreign aid Alex <alex@rivadpm.com> - 2017-02-10 18:05 +0000
                Re: OT: [ was re: Really?] Foreign aid Alex <alex@rivadpm.com> - 2017-02-10 17:55 +0000
                Re: OT: [ was re: Really?] Foreign aid Cecil Bayona <cbayona@cbayona.com> - 2017-02-10 12:04 -0600
                Re: OT: [ was re: Really?] Foreign aid Alex <alex@rivadpm.com> - 2017-02-10 18:07 +0000
                Re: OT: [ was re: Really?] Foreign aid Cecil Bayona <cbayona@cbayona.com> - 2017-02-10 12:57 -0600
                Re: OT: [ was re: Really?] Foreign aid Alex <alex@rivadpm.com> - 2017-02-10 19:26 +0000
                Re: OT: [ was re: Really?] Foreign aid Cecil Bayona <cbayona@cbayona.com> - 2017-02-10 14:04 -0600
                Re: OT: [ was re: Really?] Foreign aid Alex <alex@rivadpm.com> - 2017-02-11 09:35 +0000
                Re: Really? hughaguilar96@gmail.com - 2017-02-10 16:33 -0800
                Static type checking (was: Really?) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-02-10 11:07 +0000
                Re: Really? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-02-11 15:16 +0000
                Re: Really? Cecil Bayona <cbayona@cbayona.com> - 2017-02-11 10:20 -0600
                Re: Really? hughaguilar96@gmail.com - 2017-02-11 19:02 -0800
                Re: Really? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-02-10 17:31 +0100
                Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-08 15:34 -1000
              Re: Really? "Elizabeth D. Rather" <erather@forth.com> - 2017-02-07 21:15 -1000
              Re: Really? Paul Rubin <no.email@nospam.invalid> - 2017-02-07 23:46 -0800
        Re: Really? hughaguilar96@gmail.com - 2017-02-07 22:47 -0800
          Re: Really? Ron Aaron <rambamist@gmail.com> - 2017-02-08 08:52 +0200
    Re: Really? rickman <gnuarm@gmail.com> - 2017-02-07 06:29 -0500
      Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-07 20:47 +0000
        Re: Really? rickman <gnuarm@gmail.com> - 2017-02-07 16:23 -0500
          Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-08 09:47 +0000
            Re: Really? rickman <gnuarm@gmail.com> - 2017-02-08 05:13 -0500
              Re: Really? stephen@mpeforth.com (Stephen Pelc) - 2017-02-08 11:23 +0000
    Re: Really? Cecil Bayona <cbayona@cbayona.com> - 2017-02-07 09:49 -0600
  Really? Mark Wills <markwills1970@gmail.com> - 2017-02-09 00:30 -0800
    Re: Really? "HAA" <someone@microsoft.com> - 2017-02-10 10:32 +1100
      Re: Really? hughaguilar96@gmail.com - 2017-02-09 17:22 -0800

csiph-web