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


Groups > comp.lang.forth > #43803

Re: Question about checking the stack

From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.forth
Subject Re: Question about checking the stack
Date 2015-11-25 23:05 -0800
Organization A noiseless patient Spider
Message-ID <87y4dldyuu.fsf@nightsong.com> (permalink)
References (2 earlier) <juednR9M3ch-9sjLnZ2dnUU7-Yf46u6z@supernews.com> <87k2p5g4n0.fsf@nightsong.com> <FMmdnUE8u_yT1svLnZ2dnUU7-Yn46u6z@supernews.com> <8737vtfrk9.fsf@nightsong.com> <47ydnYNjvc2dHcvLnZ2dnUU7-Yv46u6z@supernews.com>

Show all headers | View raw


"Elizabeth D. Rather" <erather@forth.com> writes:
> I certainly don't plan to be developing on a system that is different
> from the one the program is running on. So I'm thinking about the
> finished program's timing.

Interesting.  I always prefer to develop on a workstation if possible.
Some machine dependent things of course have to be deveoped on the
target, but even with those, workstation-side emulators can help.

> I don't know what kinds of programs you write, but a lot of the
> applications we work on have performance targets 

Even for such programs though, there are usually a few tight loops
where the performance critical stuff is.  The initializations,
terminal i/o, etc. can be quite unoptimized and still be fine.

> Because I'll find it in the length of time it takes you to respond to
> that error message.

Eh?  First you have to see there was an error, then you have to
find there was an underflow at the dup, then you have to figure out
what caused the underflow.  With an error check at the dup, I get
to skip the first two steps and then we're in exactly the same place.

It's even worse if you use a word like ?dup where you think there might
be a legitimate zero on the stack, but the stack is actually empty.  The
?dup puts a zero there and the program keeps going.  Even with that very
fine grained testing it still sounds likely to create confusion.

> Well, I like everything to run fast all the time. We've heard too many
> times, "Oh, you can't use Forth for that, it's too slow!" 

I just did some timings on a Scaleway arm7, simple loops counting to 1e8.

Gforth 0.7.2 (non-fast, from Debian 8 repo) took 4.4 seconds
Gforth-fast took 3.4 seconds
Mecrisp 2.1.6 took less than 1 second
Python, the language I use all day, took 1 minute 16 seconds.

So Forth is beating Python by 15x to maybe 100x.  Despite this, the slow
speed of Python is usually not a problem for my apps.  They spend most
of their time waiting for network i/o, or call libraries (generally
written in C) for their computation intensive parts.  If the program is
still too slow (that happens sometimes) I can write the slow parts in
C++ or some other language while keeping the non-speed-critical control
and coordination parts in Python, which is much more convenient to code
in.  It's a good trade.

I'm sure that any reasonable Forth even with those stack checks will
still be much faster than Python.  I also know the relative market size
of the two languages, so Python must be doing something right, or else
people usually don't care that much about the interpreter speed.

> It's nice to be able to show people it's performing as well as
> whatever they're familiar with.

Sure, so compile in optimized mode that turns off the checks.

> I also hate simulation, because simulators are never perfect, and it's
> an extra step to have to figure out what's different when you get on
> the real hardware.

I generally find simulators to be worth the bother, because you then
don't have to muck with the actual hardware--which can be hard to get
your hands on, requires messy setup, needs manual operations so it's
hard to automate testing, etc.  But I guess it depends on what you're
doing.

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


Thread

Question about checking the stack Chris Curl <ccurl609@gmail.com> - 2015-11-24 22:31 -0800
  Re: Question about checking the stack Lars Brinkhoff <lars.spam@nocrew.org> - 2015-11-25 07:46 +0100
    Re: Question about checking the stack Chris Curl <ccurl609@gmail.com> - 2015-11-24 23:09 -0800
      Re: Question about checking the stack Ron Aaron <rambamist@gmail.com> - 2015-11-25 09:16 +0200
  Re: Question about checking the stack Paul Rubin <no.email@nospam.invalid> - 2015-11-24 23:19 -0800
    Re: Question about checking the stack "Elizabeth D. Rather" <erather@forth.com> - 2015-11-24 22:05 -1000
      Re: Question about checking the stack Paul Rubin <no.email@nospam.invalid> - 2015-11-25 13:17 -0800
        Re: Question about checking the stack "Elizabeth D. Rather" <erather@forth.com> - 2015-11-25 13:58 -1000
          Re: Question about checking the stack Paul Rubin <no.email@nospam.invalid> - 2015-11-25 18:00 -0800
            Re: Question about checking the stack "Elizabeth D. Rather" <erather@forth.com> - 2015-11-25 17:44 -1000
              Re: Question about checking the stack Paul Rubin <no.email@nospam.invalid> - 2015-11-25 23:05 -0800
                Re: Question about checking the stack "Elizabeth D. Rather" <erather@forth.com> - 2015-11-25 21:38 -1000
                Re: Question about checking the stack Ron Aaron <rambamist@gmail.com> - 2015-11-26 09:49 +0200
                Re: Question about checking the stack "Elizabeth D. Rather" <erather@forth.com> - 2015-11-25 22:42 -1000
                Re: Question about checking the stack anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-26 14:51 +0000
                Re: Question about checking the stack Paul Rubin <no.email@nospam.invalid> - 2015-11-30 13:00 -0800
                Re: Question about checking the stack hughaguilar96@gmail.com - 2015-11-30 21:54 -0800
                Re: Question about checking the stack Julian Fondren <julian.fondren@gmail.com> - 2015-12-01 04:24 -0800
                Re: Question about checking the stack Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-12-01 05:07 -0800
                Re: Question about checking the stack Julian Fondren <julian.fondren@gmail.com> - 2015-12-01 06:02 -0800
                Re: Question about checking the stack "Elizabeth D. Rather" <erather@forth.com> - 2015-12-01 19:30 -1000
                Re: Question about checking the stack Albert van der Horst <albert@spenarnc.xs4all.nl> - 2015-12-01 14:47 +0000
                Re: Question about checking the stack Chris Curl <ccurl609@gmail.com> - 2015-12-01 11:56 -0800
                Re: Question about checking the stack Alfred Singlestone <vitonis@gmail.com> - 2015-12-03 05:48 -0800
                Re: Question about checking the stack "Elizabeth D. Rather" <erather@forth.com> - 2015-12-03 09:24 -1000
                Re: Question about checking the stack Chris Curl <ccurl609@gmail.com> - 2015-12-03 21:10 -0800
                Re: Question about checking the stack "Elizabeth D. Rather" <erather@forth.com> - 2015-12-03 20:52 -1000
                Re: Question about checking the stack Chris Curl <ccurl609@gmail.com> - 2015-12-04 06:08 -0800
                Re: Question about checking the stack Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-12-01 20:32 +0000
                Re: Question about checking the stack "Elizabeth D. Rather" <erather@forth.com> - 2015-12-01 19:32 -1000
                Re: Question about checking the stack Lars Brinkhoff <lars.spam@nocrew.org> - 2015-12-01 08:18 +0100
                Re: Question about checking the stack Alfred Singlestone <vitonis@gmail.com> - 2015-11-27 06:25 -0800
                Re: Question about checking the stack Ron Aaron <rambamist@gmail.com> - 2015-11-28 17:55 +0200
                Re: Question about checking the stack mhx@iae.nl - 2015-11-28 08:24 -0800
                Re: Question about checking the stack Ron Aaron <rambamist@gmail.com> - 2015-11-28 20:54 +0200
                Re: Question about checking the stack "Elizabeth D. Rather" <erather@forth.com> - 2015-11-28 11:32 -1000
                Re: Question about checking the stack Paul Rubin <no.email@nospam.invalid> - 2015-11-28 19:17 -0800
                Re: Question about checking the stack Ron Aaron <rambamist@gmail.com> - 2015-11-29 07:30 +0200
                Re: Question about checking the stack Alfred Singlestone <vitonis@gmail.com> - 2015-11-29 09:41 -0800
                Re: Question about checking the stack minforth@arcor.de - 2015-11-30 01:48 -0800
                Re: Question about checking the stack "Elizabeth D. Rather" <erather@forth.com> - 2015-11-30 08:03 -1000
                Re: Question about checking the stack hughaguilar96@gmail.com - 2015-11-28 19:09 -0800
                Re: Question about checking the stack Paul Rubin <no.email@nospam.invalid> - 2015-11-26 00:03 -0800
                Re: Question about checking the stack "Elizabeth D. Rather" <erather@forth.com> - 2015-11-25 22:49 -1000
                Re: Question about checking the stack hughaguilar96@gmail.com - 2015-11-26 10:59 -0800
            Re: Question about checking the stack franck.bensusan@gmail.com - 2015-11-25 21:03 -0800
          Re: Question about checking the stack Alfred Singlestone <vitonis@gmail.com> - 2015-11-27 06:14 -0800
  Re: Question about checking the stack "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-11-25 04:54 -0500
  Re: Question about checking the stack François <francois.ganza@wanadoo.fr> - 2015-11-25 03:09 -0800
  Re: Question about checking the stack anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-25 12:53 +0000
    Re: Question about checking the stack Paul Rubin <no.email@nospam.invalid> - 2015-11-25 09:02 -0800
      Re: Question about checking the stack Bernd Paysan <bernd.paysan@gmx.de> - 2015-11-25 18:53 +0100
        Re: Question about checking the stack Paul Rubin <no.email@nospam.invalid> - 2015-11-25 12:01 -0800
      Re: Question about checking the stack anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-25 17:26 +0000
  Re: Question about checking the stack François <francois.ganza@wanadoo.fr> - 2015-11-25 13:51 -0800
  Re: Question about checking the stack Chris Curl <ccurl609@gmail.com> - 2015-11-28 09:29 -0800
    Re: Question about checking the stack Alfred Singlestone <vitonis@gmail.com> - 2015-11-28 12:03 -0800
  Re: Question about checking the stack François <francois.ganza@wanadoo.fr> - 2015-12-01 06:15 -0800
  Re: Question about checking the stack Chris Curl <ccurl609@gmail.com> - 2015-12-01 14:05 -0800
    Re: Question about checking the stack "Elizabeth D. Rather" <erather@forth.com> - 2015-12-01 19:35 -1000
    Re: Question about checking the stack dunno <dunno@dunno.dunno> - 2015-12-03 03:40 +0000

csiph-web