Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Peace was the way. -- Kirk, "The City on the Edge of Forever", stardate unknown


devel / comp.lang.forth / .Re: Lisp benefits against other functional programming languages

SubjectAuthor
* .Re: Lisp benefits against other functional programming languagesRobert L.
`* Re: .Re: Lisp benefits against other functional programming languagesHans Bezemer
 `* Re: .Re: Lisp benefits against other functional programming languagesDoug Hoffman
  +* Re: .Re: Lisp benefits against other functional programming languagesminf...@arcor.de
  |`- Re: .Re: Lisp benefits against other functional programming languagesDoug Hoffman
  +* Re: .Re: Lisp benefits against other functional programming languagesJali Heinonen
  |+- Re: .Re: Lisp benefits against other functional programming languagesDoug Hoffman
  |`* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
  | `* Re: .Re: Lisp benefits against other functional programming languagesRon AARON
  |  `* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
  |   +* Re: .Re: Lisp benefits against other functional programming languagesminf...@arcor.de
  |   |`- Re: .Re: Lisp benefits against other functional programming languagesHans Bezemer
  |   +- Re: .Re: Lisp benefits against other functional programming languagesRon AARON
  |   `* Re: .Re: Lisp benefits against other functional programming languagesKrishna Myneni
  |    `* Re: .Re: Lisp benefits against other functional programming languagesminf...@arcor.de
  |     `* Re: .Re: Lisp benefits against other functional programming languagesKrishna Myneni
  |      `* Re: .Re: Lisp benefits against other functional programming languagesminf...@arcor.de
  |       `- Re: .Re: Lisp benefits against other functional programming languagesKrishna Myneni
  `* Re: .Re: Lisp benefits against other functional programming languagesHans Bezemer
   +* Re: .Re: Lisp benefits against other functional programming languagesminf...@arcor.de
   |`- Re: .Re: Lisp benefits against other functional programming languagesMarcel Hendrix
   `* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
    `* Re: .Re: Lisp benefits against other functional programming languagesRon AARON
     `* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      +* Re: .Re: Lisp benefits against other functional programming languagesRon AARON
      |+* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      ||+- Re: .Re: Lisp benefits against other functional programming languagesdxforth
      ||`* Re: .Re: Lisp benefits against other functional programming languagesRon AARON
      || `* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      ||  `* Re: .Re: Lisp benefits against other functional programming languagesRon AARON
      ||   +* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      ||   |`* Re: .Re: Lisp benefits against other functional programming languagesRon AARON
      ||   | +- Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      ||   | `* Re: .Re: Lisp benefits against other functional programming languagesHans Bezemer
      ||   |  `* Re: .Re: Lisp benefits against other functional programming languagesRon AARON
      ||   |   `* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      ||   |    `* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      ||   |     `* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      ||   |      `* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      ||   |       `* Re: .Re: Lisp benefits against other functional programming languagesBrian Fox
      ||   |        `* Tail call optimization (was: .Re: Lisp benefits ...)Anton Ertl
      ||   |         `* Re: Tail call optimization (was: .Re: Lisp benefits ...)Hans Bezemer
      ||   |          `* Re: Tail call optimization (was: .Re: Lisp benefits ...)Anton Ertl
      ||   |           `- Re: Tail call optimization (was: .Re: Lisp benefits ...)Hans Bezemer
      ||   +* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      ||   |`- Re: .Re: Lisp benefits against other functional programming languagesRon AARON
      ||   `- Re: .Re: Lisp benefits against other functional programming languagesMarcel Hendrix
      |`* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      | +- Re: .Re: Lisp benefits against other functional programming languagesRon AARON
      | +- Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      | `* Re: .Re: Lisp benefits against other functional programming languagesrussell mcmanus
      |  +* Re: .Re: Lisp benefits against other functional programming languagesminf...@arcor.de
      |  |`- Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      |  `* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      |   `* Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      |    `- Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      +* Re: .Re: Lisp benefits against other functional programming languagesAnton Ertl
      |`- Re: .Re: Lisp benefits against other functional programming languagesPaul Rubin
      `- Re: .Re: Lisp benefits against other functional programming languagesDoug Hoffman

Pages:123
.Re: Lisp benefits against other functional programming languages

<t0hs0f$80v$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17189&group=comp.lang.forth#17189

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!wJZeCq1idI/5+crep3oBKg.user.46.165.242.75.POSTED!not-for-mail
From: No_spamm...@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.forth
Subject: .Re: Lisp benefits against other functional programming languages
Date: Sat, 12 Mar 2022 10:17:54 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <t0hs0f$80v$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="8223"; posting-host="wJZeCq1idI/5+crep3oBKg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: XanaNews/1.18.1.6
X-Notice: Filtered by postfilter v. 0.9.2
 by: Robert L. - Sat, 12 Mar 2022 10:17 UTC

> > qsort [] = []
> > qsort (x:xs) = qsort smaller ++ [x] ++ qsort larger
> > where
> > smaller = [y | y <- xs, y < x],
> > larger = [y | y <- xs, y >= x]
> >
> > Very brief, to the point and easy to read (if you understand the list
> > generation syntax). However, let's examine it against the Lisp version.
> > The Lisp version is equally simple:
> >
> > (defun qsort (list)
> > (if (null list)
> > nil
> > (let* ((x (car list))
> > (xs (cdr list))
> > (smaller (loop for y in xs when (< y x) collect y))
> > (larger (loop for y in xs when (>= y x) collect y)))
> > (append (qsort smaller) (list x) (qsort larger)))))
>
> or with some syntactic sugar (list comprensions and
> the select-match macro from Stephen Adams (1990 ;-) )
> it looks like this (in Common Lisp!):
>
> (amanda qs (l)
> () => '()
> (pivot . x) => (append (qs [y (y <- x) (< y pivot)])
> (list pivot)
> (qs [y (y <- x) (>= y pivot)])))

Gauche Scheme or Racket:

(use srfi-1) ;; car+cdr for Gauche
or
(require srfi/1) ;; car+cdr for Racket
(require srfi/8) ;; receive for Racket
(require srfi/26) ;; cut for Racket

(define (qsort L)
(if (null? L)
'()
(receive (x xs) (car+cdr L)
(define-values (smaller larger) (partition (cut < <> x) xs))
(append (qsort smaller) (list x) (qsort larger)))))

(qsort
'(21 20 15 6 14 17 0 1 10 12 19 3 7 16 13 5 2 9 4 11 18 8))

===>
(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21)

In Forth?

Re: .Re: Lisp benefits against other functional programming languages

<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17195&group=comp.lang.forth#17195

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:2293:b0:600:2b7b:2a19 with SMTP id o19-20020a05620a229300b006002b7b2a19mr9329354qkh.408.1647094998272;
Sat, 12 Mar 2022 06:23:18 -0800 (PST)
X-Received: by 2002:a05:6214:5007:b0:436:5f36:1819 with SMTP id
jo7-20020a056214500700b004365f361819mr9675338qvb.29.1647094998111; Sat, 12
Mar 2022 06:23:18 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sat, 12 Mar 2022 06:23:17 -0800 (PST)
In-Reply-To: <t0hs0f$80v$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <t0hs0f$80v$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
Subject: Re: .Re: Lisp benefits against other functional programming languages
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Sat, 12 Mar 2022 14:23:18 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 40
 by: Hans Bezemer - Sat, 12 Mar 2022 14:23 UTC

On Saturday, March 12, 2022 at 11:17:56 AM UTC+1, Robert L. wrote:
Do something useful with your time, my favorite incel. I got another challenge for you:

Sometimes, when testing whether the solution to a task (for example, here on Rosetta Code) is correct, the difference in floating point calculations between different language implementations becomes significant.

For example, a difference between 32 bit and 64 bit floating point calculations may appear by about the 8th significant digit in base 10 arithmetic.

Task

Create a function which returns true if two floating point numbers are approximately equal.

The function should allow for differences in the magnitude of numbers, so that, for example,
100000000000000.01 may be approximately equal to 100000000000000.011,
even though 100.01 is not approximately equal to 100.011.

If the language has such a feature in its standard library, this may be used instead of a custom function.

Show the function results with comparisons on the following pairs of values:

100000000000000.01, 100000000000000.011 (note: should return true)
100.01, 100.011 (note: should return false)
10000000000000.001 / 10000.0, 1000000000.0000001000
0.001, 0.0010000001
0.000000000000000000000101, 0.0
sqrt(2) * sqrt(2), 2.0
-sqrt(2) * sqrt(2), -2.0
3.14159265358979323846, 3.14159265358979324

Answers should be true for the first example and false in the second, so that just rounding the numbers to a fixed number of decimals should not be enough. Otherwise answers may vary and still be correct.

: test-f~ ( f1 f2 -- )
1e-18 \ epsilon
f~ \ AproximateEqual
if ." True" else ." False" then
;
In Scheme?

Hans Bezemer

Re: .Re: Lisp benefits against other functional programming languages

<6231998a$0$697$14726298@news.sunsite.dk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17282&group=comp.lang.forth#17282

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Date: Wed, 16 Mar 2022 04:02:14 -0400
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.7.0
Subject: Re: .Re: Lisp benefits against other functional programming languages
Content-Language: en-US
Newsgroups: comp.lang.forth
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
From: dhoffman...@gmail.com (Doug Hoffman)
In-Reply-To: <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 21
Message-ID: <6231998a$0$697$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 47b808da.news.sunsite.dk
X-Trace: 1647417738 news.sunsite.dk 697 glidedog@gmail.com/68.55.82.126:49538
X-Complaints-To: staff@sunsite.dk
 by: Doug Hoffman - Wed, 16 Mar 2022 08:02 UTC

On 3/12/22 9:23 AM, Hans Bezemer wrote:
> I got another challenge for you:
>
> Sometimes, when testing whether the solution to a task (for example,
> here on Rosetta Code) is correct, the difference in floating point
> calculations between different language implementations becomes
> significant. [snip]

You will never hear from him about your counter-challenge. But
mentioning Rosetta Code is useful if he were truly interesting in
comparing Forth solutions to Scheme or whatever. Of course there is
already a Forth QuickSort in Rosetta that he could have easily found.

I have found some very useful Forth code snippets here on clf.
For example, you once placed here a simple and efficient string sort
that I have since used many times. Thanks for that. :-)

Another example is Albert van der Horst's efficient linked list sort.
There are other examples too numerous to mention.

-Doug

Re: .Re: Lisp benefits against other functional programming languages

<b5169883-fdec-4f1d-a63c-b3c87ca99edcn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17284&group=comp.lang.forth#17284

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5b4d:0:b0:2e1:dcd4:cfb7 with SMTP id n13-20020ac85b4d000000b002e1dcd4cfb7mr7360980qtw.285.1647419851542;
Wed, 16 Mar 2022 01:37:31 -0700 (PDT)
X-Received: by 2002:a05:6214:27cf:b0:43f:5969:7169 with SMTP id
ge15-20020a05621427cf00b0043f59697169mr14464082qvb.37.1647419851372; Wed, 16
Mar 2022 01:37:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 16 Mar 2022 01:37:31 -0700 (PDT)
In-Reply-To: <6231998a$0$697$14726298@news.sunsite.dk>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b5169883-fdec-4f1d-a63c-b3c87ca99edcn@googlegroups.com>
Subject: Re: .Re: Lisp benefits against other functional programming languages
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Wed, 16 Mar 2022 08:37:31 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 23
 by: minf...@arcor.de - Wed, 16 Mar 2022 08:37 UTC

Doug Hoffman schrieb am Mittwoch, 16. März 2022 um 09:02:20 UTC+1:
> On 3/12/22 9:23 AM, Hans Bezemer wrote:
> > I got another challenge for you:
> >
> > Sometimes, when testing whether the solution to a task (for example,
> > here on Rosetta Code) is correct, the difference in floating point
> > calculations between different language implementations becomes
> > significant. [snip]
>
> You will never hear from him about your counter-challenge. But
> mentioning Rosetta Code is useful if he were truly interesting in
> comparing Forth solutions to Scheme or whatever. Of course there is
> already a Forth QuickSort in Rosetta that he could have easily found.

Indeed Robert L's sportive invitations are mostly as brainless as
"hey, I got a hammer, you got a screwdriver, can you nail as well as me?"

Nevertheless sometimes they can produce a smile, or put a finger on
Forth's strengths and weaknesses. Some guys are tempted to respond
but often have to resort to a non-standard Forth dialect.

Re: .Re: Lisp benefits against other functional programming languages

<6231aa7c$0$697$14726298@news.sunsite.dk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17285&group=comp.lang.forth#17285

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Date: Wed, 16 Mar 2022 05:14:33 -0400
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.7.0
Subject: Re: .Re: Lisp benefits against other functional programming languages
Content-Language: en-US
Newsgroups: comp.lang.forth
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<b5169883-fdec-4f1d-a63c-b3c87ca99edcn@googlegroups.com>
From: dhoffman...@gmail.com (Doug Hoffman)
In-Reply-To: <b5169883-fdec-4f1d-a63c-b3c87ca99edcn@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 20
Message-ID: <6231aa7c$0$697$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 18a00da0.news.sunsite.dk
X-Trace: 1647422076 news.sunsite.dk 697 glidedog@gmail.com/68.55.82.126:49204
X-Complaints-To: staff@sunsite.dk
 by: Doug Hoffman - Wed, 16 Mar 2022 09:14 UTC

On 3/16/22 4:37 AM, minf...@arcor.de wrote:

> Indeed [his] sportive invitations are mostly as brainless as
> "hey, I got a hammer, you got a screwdriver, can you nail as well as me?"

Yes. I would say "hey I got a do-it-all programmer's-swiss-army-knife,
you have just a box of basic tools (hammer, screwdriver, etc)".

> Nevertheless sometimes they can produce a smile, or put a finger on
> Forth's strengths and weaknesses. Some guys are tempted to respond

Agreed. I have been guilty of responding. I try not to do that anymore. :-)

> but often have to resort to a non-standard Forth dialect.

Those that are Forth-related like 8th or Oforth (or non-ANS) I usually
find interesting.

-Doug

Re: .Re: Lisp benefits against other functional programming languages

<a40c4100-45c8-483f-baa4-2a962f69bacan@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17287&group=comp.lang.forth#17287

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a37:485:0:b0:67b:3bd:e14d with SMTP id 127-20020a370485000000b0067b03bde14dmr20011472qke.645.1647424646990;
Wed, 16 Mar 2022 02:57:26 -0700 (PDT)
X-Received: by 2002:a05:6214:5007:b0:436:5f36:1819 with SMTP id
jo7-20020a056214500700b004365f361819mr22033088qvb.29.1647424646760; Wed, 16
Mar 2022 02:57:26 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 16 Mar 2022 02:57:26 -0700 (PDT)
In-Reply-To: <6231998a$0$697$14726298@news.sunsite.dk>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:999:608:bb82:85fc:b3bf:2ffb:5ad2;
posting-account=kiOBZQoAAADFsAs31ZHaefxTuQxv84Wm
NNTP-Posting-Host: 2001:999:608:bb82:85fc:b3bf:2ffb:5ad2
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a40c4100-45c8-483f-baa4-2a962f69bacan@googlegroups.com>
Subject: Re: .Re: Lisp benefits against other functional programming languages
From: jali.hei...@gmail.com (Jali Heinonen)
Injection-Date: Wed, 16 Mar 2022 09:57:26 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 5
 by: Jali Heinonen - Wed, 16 Mar 2022 09:57 UTC

keskiviikko 16. maaliskuuta 2022 klo 10.02.20 UTC+2 Doug Hoffman kirjoitti:
> Another example is Albert van der Horst's efficient linked list sort.
> There are other examples too numerous to mention.
>

Can linked list be sorted efficiently? I think only good way with linked list is insertion sort. I personally like circular list with common head/tail that acts as sentinel. That way you don't have to separately test head and tail nodes.

Re: .Re: Lisp benefits against other functional programming languages

<6231bbd4$0$692$14726298@news.sunsite.dk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17288&group=comp.lang.forth#17288

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Date: Wed, 16 Mar 2022 06:28:33 -0400
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.7.0
Subject: Re: .Re: Lisp benefits against other functional programming languages
Content-Language: en-US
Newsgroups: comp.lang.forth
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<a40c4100-45c8-483f-baa4-2a962f69bacan@googlegroups.com>
From: dhoffman...@gmail.com (Doug Hoffman)
In-Reply-To: <a40c4100-45c8-483f-baa4-2a962f69bacan@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 18
Message-ID: <6231bbd4$0$692$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 45e23d23.news.sunsite.dk
X-Trace: 1647426516 news.sunsite.dk 692 glidedog@gmail.com/68.55.82.126:49241
X-Complaints-To: staff@sunsite.dk
 by: Doug Hoffman - Wed, 16 Mar 2022 10:28 UTC

On 3/16/22 5:57 AM, Jali Heinonen wrote:
> keskiviikko 16. maaliskuuta 2022 klo 10.02.20 UTC+2 Doug Hoffman kirjoitti:
>> Another example is Albert van der Horst's efficient linked list sort.

> Can linked list be sorted efficiently?

I guess that depends on one's definition of efficient. You can judge
this one for yourself:

https://groups.google.com/g/comp.lang.forth/c/9CThNEkqLrw/m/e9cQVQfEBgAJ

-Doug

> I think only good way with linked list is insertion sort. I
> personally like circular list with common head/tail that acts as
> sentinel. That > way you don't have to separately test head and tail
> nodes.

Re: .Re: Lisp benefits against other functional programming languages

<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17289&group=comp.lang.forth#17289

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:e1c:b0:47d:87eb:18b2 with SMTP id y28-20020a05620a0e1c00b0047d87eb18b2mr20290861qkm.527.1647430708107;
Wed, 16 Mar 2022 04:38:28 -0700 (PDT)
X-Received: by 2002:a05:620a:2481:b0:67b:39ef:b3eb with SMTP id
i1-20020a05620a248100b0067b39efb3ebmr20279949qkn.188.1647430707863; Wed, 16
Mar 2022 04:38:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 16 Mar 2022 04:38:27 -0700 (PDT)
In-Reply-To: <6231998a$0$697$14726298@news.sunsite.dk>
Injection-Info: google-groups.googlegroups.com; posting-host=82.95.228.79; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 82.95.228.79
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
Subject: Re: .Re: Lisp benefits against other functional programming languages
From: the.beez...@gmail.com (Hans Bezemer)
Injection-Date: Wed, 16 Mar 2022 11:38:28 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 82
 by: Hans Bezemer - Wed, 16 Mar 2022 11:38 UTC

On Wednesday, March 16, 2022 at 9:02:20 AM UTC+1, Doug Hoffman wrote:
> You will never hear from him about your counter-challenge.
That's a shame - really. Because I set 'em up in a way it could benefit others.

> But mentioning Rosetta Code is useful if he were truly interesting in
> comparing Forth solutions to Scheme or whatever.
Rosetta code is awesome - I just wish there were more useful tasks there.
"12 days of Xmas" and "99 bottles of beer" hardly make library candidates.
But there IS useful stuff there to rip as well..

> Of course there is
> already a Forth QuickSort in Rosetta that he could have easily found.
4tH supports a large list of sorts - in two categories. I recently added an in place radix sort
(unfortunately - not as efficient as I had hoped) and a binary quicksort. Some taking
additional pragmas to influence their behavior.

So I don't feel have a lacks of sorting routines ;-)

Algorithm Library
Slow sort slowsort.4th
Stooge sort stoosort.4th
Cycle sort cyclsort.4th
Pancake sort pancsort.4th
Radix sort LSB radxsort.4th
Bubble sort bublsort.4th
Cocktail sort cocksort.4th
Cocktail sort
(improved) coc2sort.4th
Simple sort simpsort.4th
Simple sort
(improved) ismpsort.4th
Selection sort selcsort.4th
Insertion sort instsort.4th
Insertion sort
(improved) ins2sort.4th
Binary Insertion sort binssort.4th
Oyelami sort (MDIS) oyelsort.4th
Circle sort circsort.4th
Circle sort (improved) cir2sort.4th
Bitonic sort bitosort.4th
Merge sort mergsort.4th
Odd-even merge sort odevsort.4th
Tim sort (simple) timsort.4th
Shell sort shelsort.4th
Shell sort (A033622) shelsort.4th
Shell sort (A108870) shelsort.4th
Comb sort com2sort.4th
Heap sort hea2sort.4th
Binary Quick sort binquick.4th
Intro sort intrsort.4th
Quick sort qsort.4th
Quick sort
(unsafe) qsort.4th

> I have found some very useful Forth code snippets here on clf.
> For example, you once placed here a simple and efficient string sort
> that I have since used many times. Thanks for that. :-)
Must have been CircleSort - I developed that one. Yes, it carries quite a bang for the buck.
> Another example is Albert van der Horst's efficient linked list sort.
> There are other examples too numerous to mention.
Point is - I rarely encounter problems that involve lists. Neither professionally nor personally.
I know there are people swearing lists are THE best thing since sliced bread, but I rarely find
a problem that says: "Yeah, lists!". I once developed a lib for handling lists, but then I
found out the problem I had invented it for would be better served by an ordinary array.

Later, when I developed the "INI file manager", yeah - that one worked fine with lists -
and it was applied there. Next problem, I haven't found any use for the "INI file manager" yet.
I got an "INI file interpreter" as well and that one has been used several times.

It happens quite often I develop stuff - either because a user requests it or because I
think it will be useful and then sits on the shelf for years without use. Like a string stack. First,
I developed one which allowed you to build several ones and you could swap values. Then I
built one that just allows you to build several of 'em. Finally, I built one that allows only
one, but is quite fast, easy to handle and quite compact. Guess which one has been used most? ;-)

The same with associative arrays, regex engines, printf, etc. It gets build, it seldom gets used (by me),
while others are found in almost every program. Like BREAK?
https://sourceforge.net/p/forth-4th/wiki/I%20need%20a%20BREAK%3F/

You'd almost think I'm a Forth programmer.. ;-)

Hans Bezemer

Re: .Re: Lisp benefits against other functional programming languages

<764a678d-c07f-4e82-8c2b-f6b73ef3eccan@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17290&group=comp.lang.forth#17290

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:2586:b0:67b:1141:ce24 with SMTP id x6-20020a05620a258600b0067b1141ce24mr21185853qko.542.1647433172637;
Wed, 16 Mar 2022 05:19:32 -0700 (PDT)
X-Received: by 2002:ac8:5a88:0:b0:2e1:bbda:3b21 with SMTP id
c8-20020ac85a88000000b002e1bbda3b21mr19652455qtc.307.1647433172416; Wed, 16
Mar 2022 05:19:32 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 16 Mar 2022 05:19:32 -0700 (PDT)
In-Reply-To: <292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk> <292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <764a678d-c07f-4e82-8c2b-f6b73ef3eccan@googlegroups.com>
Subject: Re: .Re: Lisp benefits against other functional programming languages
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Wed, 16 Mar 2022 12:19:32 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 20
 by: minf...@arcor.de - Wed, 16 Mar 2022 12:19 UTC

the.bee...@gmail.com schrieb am Mittwoch, 16. März 2022 um 12:38:29 UTC+1:
> Point is - I rarely encounter problems that involve lists. Neither professionally nor personally.
> I know there are people swearing lists are THE best thing since sliced bread, but I rarely find
> a problem that says: "Yeah, lists!".

FWIW Forth high level code can be stored in lists whose 1st element is a (sub)list with header
information. In this way a Forth program (or library) becomes a searchable list database
very similar to a Prolog database. Through pattern matching it is rather easy to implement
peephole optimization, superinstructions, and compilation to machie code including
dead code elimination (I know it works because I did all this 40 ys ago using Turbo Prolog on DOS).

But as you said, when you don't need lists, don't use them. ;-)

Re: .Re: Lisp benefits against other functional programming languages

<2022Mar16.170645@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17293&group=comp.lang.forth#17293

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Wed, 16 Mar 2022 16:06:45 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 19
Message-ID: <2022Mar16.170645@mips.complang.tuwien.ac.at>
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com> <6231998a$0$697$14726298@news.sunsite.dk> <a40c4100-45c8-483f-baa4-2a962f69bacan@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="70b3dba7209a5776b66641c29af5e7d3";
logging-data="4139"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18rB7xKgi8jd31ocXBu9wgr"
Cancel-Lock: sha1:OM/OlcxNWmal7zrB7oZUdL9CEVg=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Wed, 16 Mar 2022 16:06 UTC

Jali Heinonen <jali.heinonen@gmail.com> writes:
>Can linked list be sorted efficiently?

Mergesort has O(n ln n) performance. Quicksort has the usual
quadratic worst case, and it's more expensive to avoid this case in a
pre-sorted list than in a pre-sorted array, but it also does ok (with
O(n ln n) achievable in the pre-sorted case, too.

But I would not use lists if I want to sort them. And I would not
sort them. What's the obsession with sorting? I have not needed a
sort in Forth in the 38 years since I started using it. And IIRC not
in C, either.

- 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 2021: https://euro.theforth.net/2021

Re: .Re: Lisp benefits against other functional programming languages

<t0t3nd$le4$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17294&group=comp.lang.forth#17294

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Wed, 16 Mar 2022 18:37:01 +0200
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <t0t3nd$le4$1@dont-email.me>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<a40c4100-45c8-483f-baa4-2a962f69bacan@googlegroups.com>
<2022Mar16.170645@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 16 Mar 2022 16:37:01 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="cc109ce4792372e0022657864188d61b";
logging-data="21956"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zAhtRYHdqPyoYqdWy54YJ"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:WZeE+335BuPfDhKnAnEUhn0JFl4=
In-Reply-To: <2022Mar16.170645@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Ron AARON - Wed, 16 Mar 2022 16:37 UTC

On 16/03/2022 18:06, Anton Ertl wrote:
> Jali Heinonen <jali.heinonen@gmail.com> writes:
>> Can linked list be sorted efficiently?
>
> Mergesort has O(n ln n) performance. Quicksort has the usual
> quadratic worst case, and it's more expensive to avoid this case in a
> pre-sorted list than in a pre-sorted array, but it also does ok (with
> O(n ln n) achievable in the pre-sorted case, too.
>
> But I would not use lists if I want to sort them. And I would not
> sort them. What's the obsession with sorting? I have not needed a
> sort in Forth in the 38 years since I started using it. And IIRC not
> in C, either.

Really? I've needed sorting for a variety of applications (in 8th, or
C/C++, or any other language -- the language is besides the point).

I did add a 'heap' datastructure in 8th to accomplish sort-on-reception
of data, which is nice, but not always useful.

Re: .Re: Lisp benefits against other functional programming languages

<85881e76-47bc-463e-904b-4b94238b30a2n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17295&group=comp.lang.forth#17295

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:4104:b0:42c:1db0:da28 with SMTP id kc4-20020a056214410400b0042c1db0da28mr799286qvb.67.1647453954071;
Wed, 16 Mar 2022 11:05:54 -0700 (PDT)
X-Received: by 2002:ac8:7f0e:0:b0:2e1:e86f:c73 with SMTP id
f14-20020ac87f0e000000b002e1e86f0c73mr939064qtk.535.1647453953910; Wed, 16
Mar 2022 11:05:53 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!3.us.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Wed, 16 Mar 2022 11:05:53 -0700 (PDT)
In-Reply-To: <764a678d-c07f-4e82-8c2b-f6b73ef3eccan@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f14:600:b963:7d4a:8bd5:bf5b;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f14:600:b963:7d4a:8bd5:bf5b
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk> <292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<764a678d-c07f-4e82-8c2b-f6b73ef3eccan@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <85881e76-47bc-463e-904b-4b94238b30a2n@googlegroups.com>
Subject: Re: .Re: Lisp benefits against other functional programming languages
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Wed, 16 Mar 2022 18:05:54 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 20
 by: Marcel Hendrix - Wed, 16 Mar 2022 18:05 UTC

On Wednesday, March 16, 2022 at 1:19:33 PM UTC+1, minf...@arcor.de wrote:
[..]
> FWIW Forth high level code can be stored in lists whose 1st element is a (sub)list with header
> information. In this way a Forth program (or library) becomes a searchable list database
> very similar to a Prolog database. Through pattern matching it is rather easy to implement
> peephole optimization, superinstructions, and compilation to machie code including
> dead code elimination (I know it works because I did all this 40 ys ago using Turbo Prolog on DOS).
>
> But as you said, when you don't need lists, don't use them. ;-)

In my iSPICE, each device is a CREATE DOES> type Forth word that performs run-time
code generation. The devices are organized in lists, linked by their NT. Apart from
code-generation, these lists are also used to insert the device stamps in the MNA matrix
and to print results, show device info, generate netlist information etc.. This is done
through a number of 'methods'. All the list members execute at least once per simulation
step.

I would hesitate to call this object-oriented code, but it sure is the most efficient and
flexible method I could come up with.

-marcel

Re: .Re: Lisp benefits against other functional programming languages

<87o825a2zq.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17297&group=comp.lang.forth#17297

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Wed, 16 Mar 2022 16:31:37 -0700
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <87o825a2zq.fsf@nightsong.com>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="80178ad18d9573a27085e0ebfb83acd0";
logging-data="9828"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/o2CVKPo5AnOFJZtIIWY/7"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:CZDdo0q5FkI9DrkTSwUM3qwMGdk=
sha1:PTOFDbF3GinXqCn4Kkzf6Z2gdnc=
 by: Paul Rubin - Wed, 16 Mar 2022 23:31 UTC

Hans Bezemer <the.beez.speaks@gmail.com> writes:
> Point is - I rarely encounter problems that involve lists. Neither
> professionally nor personally. I know there are people swearing lists
> are THE best thing since sliced bread, but I rarely find a problem
> that says: "Yeah, lists!".

Lists are natural and intuitive to use in some languages, such as (heh)
Lisp. So they are used a lot there. I've also used them plenty of
times in C. I think in Forth, they're less easy to use, and
applications that want them don't come up as often, so they're not seen
as much.

Re: .Re: Lisp benefits against other functional programming languages

<t0ufjd$g3n$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17299&group=comp.lang.forth#17299

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Thu, 17 Mar 2022 07:05:47 +0200
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <t0ufjd$g3n$1@dont-email.me>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 17 Mar 2022 05:05:49 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="008a2778a3b7218b044b2d2fb504248a";
logging-data="16503"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Q+dfwNahoHhJh6nap8s7R"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:tuBWWOoq8/NByifaF5R+74L0c4g=
In-Reply-To: <87o825a2zq.fsf@nightsong.com>
Content-Language: en-US
 by: Ron AARON - Thu, 17 Mar 2022 05:05 UTC

On 17/03/2022 1:31, Paul Rubin wrote:
> Hans Bezemer <the.beez.speaks@gmail.com> writes:
>> Point is - I rarely encounter problems that involve lists. Neither
>> professionally nor personally. I know there are people swearing lists
>> are THE best thing since sliced bread, but I rarely find a problem
>> that says: "Yeah, lists!".
>
> Lists are natural and intuitive to use in some languages, such as (heh)
> Lisp. So they are used a lot there. I've also used them plenty of
> times in C. I think in Forth, they're less easy to use, and
> applications that want them don't come up as often, so they're not seen
> as much.

They're natural for the languages which are based around them, but how
many real-world problems revolve around lists (and which can't be
handled as naturally with arrays)?

I agree with The Beez on this. I had considered adding lists (to 8th),
but couldn't see any argument for them over arrays. And of course, you
can create all the Lispy-list-words using an array as the 'list'.

Not a problem I've had a reason to solve, TBH.

Re: .Re: Lisp benefits against other functional programming languages

<87fsnh9mds.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17300&group=comp.lang.forth#17300

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Wed, 16 Mar 2022 22:30:23 -0700
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <87fsnh9mds.fsf@nightsong.com>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="80178ad18d9573a27085e0ebfb83acd0";
logging-data="22811"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18LKxHfbSPqYUYFngihv19r"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:DB3lP2ptGRieZb8ua2lz8KgQ0LI=
sha1:yC53xLaoKJl3VdtGquDCdFw4Ymk=
 by: Paul Rubin - Thu, 17 Mar 2022 05:30 UTC

Ron AARON <clf@8th-dev.com> writes:
> They're natural for the languages which are based around them, but how
> many real-world problems revolve around lists (and which can't be
> handled as naturally with arrays)?

Traditionally the Forth word list is implemented as a list. You can
cons new items onto a list in constant time til you run out of memory,
without having to know the final size in advance. Resizeable arrays are
nice, but resizing usually means having to copy the data around.
Somehow (some) Forthers who won't tolerate occasional GC pauses are ok
with array resizing.

> I agree with The Beez on this. I had considered adding lists (to 8th)...

I think resizeable arrays are more usable now than they were in the old
days on memory starved systems. Resizing usually means allocating a
large chunk of new memory (e.g. doubling the old size of the array), so
you have lots of memory that is allocated but unused.

Lists are also natural if you program in functional style, since you
don't have to mutate existing objects (consing is just new allocations:
the old stuff stays the same). The immutable equivalent of arrays is
balanced trees, which are way more complicated to implement.

Re: .Re: Lisp benefits against other functional programming languages

<t0uhor$v0v$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17301&group=comp.lang.forth#17301

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Thu, 17 Mar 2022 07:42:50 +0200
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <t0uhor$v0v$1@dont-email.me>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 17 Mar 2022 05:42:51 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="008a2778a3b7218b044b2d2fb504248a";
logging-data="31775"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+8zHuSdVwkXqb2MjkM9PRG"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:v12glyKOYJau19C1SXZWW8OUgHQ=
In-Reply-To: <87fsnh9mds.fsf@nightsong.com>
Content-Language: en-US
 by: Ron AARON - Thu, 17 Mar 2022 05:42 UTC

On 17/03/2022 7:30, Paul Rubin wrote:
> Ron AARON <clf@8th-dev.com> writes:
>> They're natural for the languages which are based around them, but how
>> many real-world problems revolve around lists (and which can't be
>> handled as naturally with arrays)?
>
> Traditionally the Forth word list is implemented as a list. You can
> cons new items onto a list in constant time til you run out of memory,

Right. Reva Forth's dictionary was implemented as a list, while 8th's is
a map (associative-array, hash-table).

With a list, adding is constant time, but lookup is O(n). With the map,
lookup is constant time while adding is between constant and O(n) most
of the time (depending on the load factor).

> without having to know the final size in advance. Resizeable arrays are
> nice, but resizing usually means having to copy the data around.
> Somehow (some) Forthers who won't tolerate occasional GC pauses are ok
> with array resizing.

I haven't found array-resizing to be anywhere near significant in terms
of performance. Maybe that's just an artifact of usage-pattern, I don't
know.

What I do know is that dynamic arrays are incredibly useful.

>
>> I agree with The Beez on this. I had considered adding lists (to 8th)...
>
> I think resizeable arrays are more usable now than they were in the old
> days on memory starved systems. Resizing usually means allocating a
> large chunk of new memory (e.g. doubling the old size of the array), so
> you have lots of memory that is allocated but unused.

That depends on your memory utilization pattern. Quite often (in
practice) the memory is simply resized in-place, nothing gets moved. Of
course, "modern" machines are extremely fast (compared to embedded
controllers and the like).

>
> Lists are also natural if you program in functional style, since you
> don't have to mutate existing objects (consing is just new allocations:
> the old stuff stays the same). The immutable equivalent of arrays is
> balanced trees, which are way more complicated to implement.

I don't understand this. Arrays are just as immutable as balanced trees.
Or, rather, just as mutable. Either can be modified.

Yes, balanced trees are a bit complex to implement; 8th has three
varieties built-in, for different use-cases. Debugging them was a lot of
fun...

Re: .Re: Lisp benefits against other functional programming languages

<87bky59h1r.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17302&group=comp.lang.forth#17302

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Thu, 17 Mar 2022 00:25:36 -0700
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <87bky59h1r.fsf@nightsong.com>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="80178ad18d9573a27085e0ebfb83acd0";
logging-data="4452"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jpbhA/YoXJzyUFmc+eSH7"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:zhGBhf2XUGZDSbIrWF1tH/wLcOY=
sha1:9mV5p5bTXeV6KnV6uWSIzrvfcNU=
 by: Paul Rubin - Thu, 17 Mar 2022 07:25 UTC

Ron AARON <clf@8th-dev.com> writes:
> I haven't found array-resizing to be anywhere near significant in
> terms of performance.

For 8th, it probably doesn't matter, just that it introduces small
pauses, as gc usually does as well. 8th is gc'd iirc. In fact plenty
of soft realtime systems use gc, but some Forthers go berserk when gc is
mentioned.

> Quite often (in practice) the memory is simply resized in-place,
> nothing gets moved.

In that case there was unused memory past the existing array boundary.

> Of course, "modern" machines are extremely fast (compared to embedded
> controllers and the like).

There's a speed-memory tradeoff, so even on a slower machine you can
limit the resize overhead, by reserving enough extra space on each
resize. A huge amount of Knuth vol 1 going back to the 1960s is about
this ;).

> I don't understand this. Arrays are just as immutable as balanced
> trees. Or, rather, just as mutable. Either can be modified.

If you want a fast lookup structure that can be updated without
mutation, balanced trees can do that, arrays really can't. You might
like Chris Okasaki's book "Purely Functional Data Structures".

Re: .Re: Lisp benefits against other functional programming languages

<2022Mar17.082842@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17303&group=comp.lang.forth#17303

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Thu, 17 Mar 2022 07:28:42 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 30
Message-ID: <2022Mar17.082842@mips.complang.tuwien.ac.at>
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com> <6231998a$0$697$14726298@news.sunsite.dk> <292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com> <87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me> <87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="b2d48990e0675cc7fa059364b140bc50";
logging-data="14456"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+y02ifp1Kvcf5UBrbbO770"
Cancel-Lock: sha1:NOmBE7wsUjNWovq068ieNbjwyqY=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Thu, 17 Mar 2022 07:28 UTC

Ron AARON <clf@8th-dev.com> writes:
>On 17/03/2022 7:30, Paul Rubin wrote:
>> Lists are also natural if you program in functional style, since you
>> don't have to mutate existing objects (consing is just new allocations:
>> the old stuff stays the same). The immutable equivalent of arrays is
>> balanced trees, which are way more complicated to implement.
>
>I don't understand this. Arrays are just as immutable as balanced trees.
>Or, rather, just as mutable. Either can be modified.

His point is: If you have a language that does not support changing
existing data structures, you program by creating a new item that
represents the new state. In case of an array this means copying all
the data that is not changed. In the case of a tree this means
copying only the unchanged data in changed nodes and their ancestor
nodes. For large data structures, this is much more efficient.
Therefore, functional programs use trees instead of arrays.

>Yes, balanced trees are a bit complex to implement; 8th has three
>varieties built-in, for different use-cases.

What are the use cases? I have not found a serious use for search
trees in my programming, much less balanced search trees.

- 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 2021: https://euro.theforth.net/2021

Re: .Re: Lisp benefits against other functional programming languages

<2022Mar17.085213@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17305&group=comp.lang.forth#17305

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Thu, 17 Mar 2022 07:52:13 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 18
Message-ID: <2022Mar17.085213@mips.complang.tuwien.ac.at>
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com> <6231998a$0$697$14726298@news.sunsite.dk> <292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com> <87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me> <87fsnh9mds.fsf@nightsong.com>
Injection-Info: reader02.eternal-september.org; posting-host="b2d48990e0675cc7fa059364b140bc50";
logging-data="14456"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zyTrMnFHQQ9trqxZqDsUD"
Cancel-Lock: sha1:5kL0+coHwjDNY+Dcr2Cg9ZkP0Sc=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Thu, 17 Mar 2022 07:52 UTC

Paul Rubin <no.email@nospam.invalid> writes:
>I think resizeable arrays are more usable now than they were in the old
>days on memory starved systems.

The typical approach on memory-starved systems was static arrays at
best configurable on startup (but more typically in the source code;
in Forth that is actually the same). The data either fits or it does
not. If it does not, you can get a little wiggle room by configuring
some data structure larger (but configuring a different one smaller to
make all fit), but other than that you are out of luck. Resizable
arrays don't give you more capability, only more convenience.

- 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 2021: https://euro.theforth.net/2021

Re: .Re: Lisp benefits against other functional programming languages

<t0uq7e$4i5$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17306&group=comp.lang.forth#17306

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Thu, 17 Mar 2022 19:07:08 +1100
Organization: Aioe.org NNTP Server
Message-ID: <t0uq7e$4i5$1@gioia.aioe.org>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
<87bky59h1r.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="4677"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Thu, 17 Mar 2022 08:07 UTC

On 17/03/2022 18:25, Paul Rubin wrote:
> Ron AARON <clf@8th-dev.com> writes:
>> I haven't found array-resizing to be anywhere near significant in
>> terms of performance.
>
> For 8th, it probably doesn't matter, just that it introduces small
> pauses, as gc usually does as well. 8th is gc'd iirc. In fact plenty
> of soft realtime systems use gc, but some Forthers go berserk when gc is
> mentioned.

We still remember it from Microsoft BASIC days. In fact anything 'dynamic'
prompts us to ask 'do I really need that?' - including ALLOCATE, circular
buffers and other bandwagons as may be passing through.

Re: .Re: Lisp benefits against other functional programming languages

<2022Mar17.085721@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17307&group=comp.lang.forth#17307

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Thu, 17 Mar 2022 07:57:21 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 36
Message-ID: <2022Mar17.085721@mips.complang.tuwien.ac.at>
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com> <6231998a$0$697$14726298@news.sunsite.dk> <a40c4100-45c8-483f-baa4-2a962f69bacan@googlegroups.com> <2022Mar16.170645@mips.complang.tuwien.ac.at> <t0t3nd$le4$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="b2d48990e0675cc7fa059364b140bc50";
logging-data="14456"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18d6f0QVcrOdqAnAIZH3s1e"
Cancel-Lock: sha1:AVYSjg4CiSpPL5TN/kG16aP8cjk=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Thu, 17 Mar 2022 07:57 UTC

Ron AARON <clf@8th-dev.com> writes:
>
>
>On 16/03/2022 18:06, Anton Ertl wrote:
>> What's the obsession with sorting? I have not needed a
>> sort in Forth in the 38 years since I started using it. And IIRC not
>> in C, either.
>
>Really? I've needed sorting for a variety of applications (in 8th, or
>C/C++, or any other language -- the language is besides the point).

The language is important. In most languages sorting is not needed,
but the shell has tools such as join and uniq that require sorted
inputs (or, in the case of many uses of uniq, are useless without
sorting first); with hash-table-based equivalents of these tools most
of my uses of sort in shell scripts could be eliminated, and thus most
of my uses of sorting. Of course, in my shell usage there is still
the following usage:

Sorting is useful for human consumption, so I sometimes do it as last
step on the output of a Forth or C program (and I have a nice shell
tool called sort for that). But sorting is normally not useful for
internal operations of programs; hashing is almost always better
there.

There is an exception: You need to associate a value with the
next-larger (or next-smaller) key in a lookup table without being able
to compute that key (e.g., because it is the next power-of-two). But,
as mentioned, I have not come across that situation.

- 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 2021: https://euro.theforth.net/2021

Re: .Re: Lisp benefits against other functional programming languages

<dc8b2b49-8015-4a17-b7c6-1b10632804c9n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17308&group=comp.lang.forth#17308

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:120a:b0:2e1:c9ba:e99b with SMTP id y10-20020a05622a120a00b002e1c9bae99bmr2757459qtx.685.1647508019588;
Thu, 17 Mar 2022 02:06:59 -0700 (PDT)
X-Received: by 2002:a05:620a:4547:b0:67d:674e:f182 with SMTP id
u7-20020a05620a454700b0067d674ef182mr2148102qkp.99.1647508019422; Thu, 17 Mar
2022 02:06:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 17 Mar 2022 02:06:59 -0700 (PDT)
In-Reply-To: <2022Mar17.085721@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=79.224.111.239; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 79.224.111.239
References: <t0hs0f$80v$1@gioia.aioe.org> <9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk> <a40c4100-45c8-483f-baa4-2a962f69bacan@googlegroups.com>
<2022Mar16.170645@mips.complang.tuwien.ac.at> <t0t3nd$le4$1@dont-email.me> <2022Mar17.085721@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <dc8b2b49-8015-4a17-b7c6-1b10632804c9n@googlegroups.com>
Subject: Re: .Re: Lisp benefits against other functional programming languages
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Thu, 17 Mar 2022 09:06:59 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 37
 by: minf...@arcor.de - Thu, 17 Mar 2022 09:06 UTC

Anton Ertl schrieb am Donnerstag, 17. März 2022 um 09:12:13 UTC+1:
> Ron AARON <c...@8th-dev.com> writes:
> >
> >
> >On 16/03/2022 18:06, Anton Ertl wrote:
> >> What's the obsession with sorting? I have not needed a
> >> sort in Forth in the 38 years since I started using it. And IIRC not
> >> in C, either.
> >
> >Really? I've needed sorting for a variety of applications (in 8th, or
> >C/C++, or any other language -- the language is besides the point).
> The language is important. In most languages sorting is not needed,
> but the shell has tools such as join and uniq that require sorted
> inputs (or, in the case of many uses of uniq, are useless without
> sorting first); with hash-table-based equivalents of these tools most
> of my uses of sort in shell scripts could be eliminated, and thus most
> of my uses of sorting. Of course, in my shell usage there is still
> the following usage:
>
> Sorting is useful for human consumption, so I sometimes do it as last
> step on the output of a Forth or C program (and I have a nice shell
> tool called sort for that). But sorting is normally not useful for
> internal operations of programs; hashing is almost always better
> there.
>
> There is an exception: You need to associate a value with the
> next-larger (or next-smaller) key in a lookup table without being able
> to compute that key (e.g., because it is the next power-of-two). But,
> as mentioned, I have not come across that situation.

A practical application example:
Alarm logs in realtime control systems are one area where sorting is
required for output on display, reports, data extraction and analysis.
When this could touch time-critical functions, sorting is often supported by
background indexing while new alarms are added to the alarm tables.
IOW fancy sorting algorithms or data movement are not necessary here.

Re: .Re: Lisp benefits against other functional programming languages

<t0uvic$qr9$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17310&group=comp.lang.forth#17310

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Thu, 17 Mar 2022 11:38:19 +0200
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <t0uvic$qr9$1@dont-email.me>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
<87bky59h1r.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 17 Mar 2022 09:38:20 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="008a2778a3b7218b044b2d2fb504248a";
logging-data="27497"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18eihgKkgIEl9ErmE+mBROR"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:OeEUo5X9fvKw+s8jx+cSdgzj1No=
In-Reply-To: <87bky59h1r.fsf@nightsong.com>
Content-Language: en-US
 by: Ron AARON - Thu, 17 Mar 2022 09:38 UTC

On 17/03/2022 9:25, Paul Rubin wrote:
> Ron AARON <clf@8th-dev.com> writes:
>> I haven't found array-resizing to be anywhere near significant in
>> terms of performance.
>
> For 8th, it probably doesn't matter, just that it introduces small
> pauses, as gc usually does as well. 8th is gc'd iirc. In fact plenty
> of soft realtime systems use gc, but some Forthers go berserk when gc is
> mentioned.

8th is GC'd, but on a continual basis (reference-counting), so the cost
of GCing is relatively constant rather than stop-the-world kind of thing.

>
>> Quite often (in practice) the memory is simply resized in-place,
>> nothing gets moved.
>
> In that case there was unused memory past the existing array boundary.

Exactly. It is very much dependent on the memory allocator in use.

>
>> Of course, "modern" machines are extremely fast (compared to embedded
>> controllers and the like).
>
> There's a speed-memory tradeoff, so even on a slower machine you can
> limit the resize overhead, by reserving enough extra space on each
> resize. A huge amount of Knuth vol 1 going back to the 1960s is about
> this ;).

I've got his books :)

>
>> I don't understand this. Arrays are just as immutable as balanced
>> trees. Or, rather, just as mutable. Either can be modified.
>
> If you want a fast lookup structure that can be updated without
> mutation, balanced trees can do that, arrays really can't. You might
> like Chris Okasaki's book "Purely Functional Data Structures".

I'm unsure what you mean, then, by 'mutation'...

Re: .Re: Lisp benefits against other functional programming languages

<t0v0m9$4qq$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17312&group=comp.lang.forth#17312

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Thu, 17 Mar 2022 11:57:28 +0200
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <t0v0m9$4qq$1@dont-email.me>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<292c2ba5-aa78-43d3-acee-05c3f669a9a8n@googlegroups.com>
<87o825a2zq.fsf@nightsong.com> <t0ufjd$g3n$1@dont-email.me>
<87fsnh9mds.fsf@nightsong.com> <t0uhor$v0v$1@dont-email.me>
<2022Mar17.082842@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 17 Mar 2022 09:57:29 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="008a2778a3b7218b044b2d2fb504248a";
logging-data="4954"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UPNCpOoZZSr7NXolxMEgQ"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:iNYKPgYKjyG3OfqUgpY00eD/BUE=
In-Reply-To: <2022Mar17.082842@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Ron AARON - Thu, 17 Mar 2022 09:57 UTC

On 17/03/2022 9:28, Anton Ertl wrote:
> Ron AARON <clf@8th-dev.com> writes:
>> On 17/03/2022 7:30, Paul Rubin wrote:
>>> Lists are also natural if you program in functional style, since you
>>> don't have to mutate existing objects (consing is just new allocations:
>>> the old stuff stays the same). The immutable equivalent of arrays is
>>> balanced trees, which are way more complicated to implement.
>>
>> I don't understand this. Arrays are just as immutable as balanced trees.
>> Or, rather, just as mutable. Either can be modified.
>
> His point is: If you have a language that does not support changing
> existing data structures, you program by creating a new item that
> represents the new state. In case of an array this means copying all
> the data that is not changed. In the case of a tree this means
> copying only the unchanged data in changed nodes and their ancestor
> nodes. For large data structures, this is much more efficient.
> Therefore, functional programs use trees instead of arrays.

OK.

>
>> Yes, balanced trees are a bit complex to implement; 8th has three
>> varieties built-in, for different use-cases.
>
> What are the use cases? I have not found a serious use for search
> trees in my programming, much less balanced search trees.

The tree varieties supported are plain binary-tree, b-tree, and BK-tree.
This last is a particularly useful tree if you have a metric function
(for example, Levenshtein distance), very useful for word-similarity
look-up.

As for the other two, they're not particularly dissimilar in use, just a
matter of some efficiency (in memory usage).

In terms of use-cases? Well, my users asked for them -- so I presume
they had particular uses in mind.

Re: .Re: Lisp benefits against other functional programming languages

<t0v0s8$6hp$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17313&group=comp.lang.forth#17313

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: clf...@8th-dev.com (Ron AARON)
Newsgroups: comp.lang.forth
Subject: Re: .Re: Lisp benefits against other functional programming languages
Date: Thu, 17 Mar 2022 12:00:39 +0200
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <t0v0s8$6hp$1@dont-email.me>
References: <t0hs0f$80v$1@gioia.aioe.org>
<9f5fd43a-7fa6-4611-8fbf-6d2a77fe0de6n@googlegroups.com>
<6231998a$0$697$14726298@news.sunsite.dk>
<a40c4100-45c8-483f-baa4-2a962f69bacan@googlegroups.com>
<2022Mar16.170645@mips.complang.tuwien.ac.at> <t0t3nd$le4$1@dont-email.me>
<2022Mar17.085721@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 17 Mar 2022 10:00:40 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="008a2778a3b7218b044b2d2fb504248a";
logging-data="6713"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zI448ukbPsZtco583lw19"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:Cbyjc31HBQiTeaeLlroulsHkq80=
In-Reply-To: <2022Mar17.085721@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Ron AARON - Thu, 17 Mar 2022 10:00 UTC

On 17/03/2022 9:57, Anton Ertl wrote:
> Ron AARON <clf@8th-dev.com> writes:
>>
>>
>> On 16/03/2022 18:06, Anton Ertl wrote:
>>> What's the obsession with sorting? I have not needed a
>>> sort in Forth in the 38 years since I started using it. And IIRC not
>>> in C, either.
>>
>> Really? I've needed sorting for a variety of applications (in 8th, or
>> C/C++, or any other language -- the language is besides the point).
>
> The language is important. In most languages sorting is not needed,
> but the shell has tools such as join and uniq ...

> Sorting is useful for human consumption...

Well, and there you are. Sorting is obviously useful in user-facing
applications (of course, not always and not everywhere).

Presenting a list of names or places is most often done as a sorted
list, because it's easier for a (normal) user to scan a sorted list.

The language used for the application isn't important, because the need
for sorting user-facing data (among other examples) is present
regardless of the language. Some languages make it easier than others,
but there's a reason even C has qsort() in the library.

Pages:123
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor