Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Old programmers never die, they just become managers.


devel / comp.lang.ada / does a safer language mean it is slower to run?

SubjectAuthor
* does a safer language mean it is slower to run?Nasser M. Abbasi
+* Re: does a safer language mean it is slower to run?Niklas Holsti
|`* Re: does a safer language mean it is slower to run?robin vowels
| `* Re: does a safer language mean it is slower to run?Niklas Holsti
|  `- Re: does a safer language mean it is slower to run?Randy Brukardt
+* Re: does a safer language mean it is slower to run?Dmitry A. Kazakov
|`* Re: does a safer language mean it is slower to run?Jerry
| `- Re: does a safer language mean it is slower to run?Gautier write-only address
+- Re: does a safer language mean it is slower to run?Jeffrey R.Carter
+* Re: does a safer language mean it is slower to run?Luke A. Guest
|`- Re: does a safer language mean it is slower to run?Kevin Chadwick
`- Re: does a safer language mean it is slower to run?Shark8

1
does a safer language mean it is slower to run?

<u5rjg8$1dr0c$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9702&group=comp.lang.ada#9702

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nma@12000.org (Nasser M. Abbasi)
Newsgroups: comp.lang.ada
Subject: does a safer language mean it is slower to run?
Date: Wed, 7 Jun 2023 22:55:51 -0500
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <u5rjg8$1dr0c$1@dont-email.me>
Reply-To: nma@12000.org
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 8 Jun 2023 03:55:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="10163296a3ae74866e04f644b70d04bc";
logging-data="1502220"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194yr9hnMKNko9oXMuomIXo"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:ybPFFfNnPHi25blH1seSOcWLGog=
Content-Language: en-US
 by: Nasser M. Abbasi - Thu, 8 Jun 2023 03:55 UTC

Some folks in this thread

https://discourse.julialang.org/t/comparison-of-rust-to-julia-for-scientific-computing/78508

"I’m not an expert, but my feeling is that Rust is a “safer” language,
which to me means it must be slower."

etc..

Some in that thread seem to argue that a safer language
will/could be slower than otherwise.

Since Ada is known to be one of the safest languages,
do others here feel there is any truth to this?

I thought that by having more type information in the language,
the compile will be able to make more optimizations (because it
know more), and hence the generated code should actually be
faster, not slower with a language that is less safe?

I am not a compiler expert but what do others here think?

--Nasser

Re: does a safer language mean it is slower to run?

<kedceaFqcp3U1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9703&group=comp.lang.ada#9703

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.holsti@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: does a safer language mean it is slower to run?
Date: Thu, 8 Jun 2023 09:57:14 +0300
Organization: Tidorum Ltd
Lines: 43
Message-ID: <kedceaFqcp3U1@mid.individual.net>
References: <u5rjg8$1dr0c$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net rlAlf82gORVaBHUu8zCFUAZfWkFXxn7llIy/KJoAgq6GSPTpXk
Cancel-Lock: sha1:dOb37qriBWf9C5dMPr3cV0J6ETw=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:102.0)
Gecko/20100101 Thunderbird/102.6.1
Content-Language: en-US
In-Reply-To: <u5rjg8$1dr0c$1@dont-email.me>
 by: Niklas Holsti - Thu, 8 Jun 2023 06:57 UTC

On 2023-06-08 6:55, Nasser M. Abbasi wrote:
> Some folks in this thread
>
> https://discourse.julialang.org/t/comparison-of-rust-to-julia-for-scientific-computing/78508
>
> "I’m not an expert, but my feeling is that Rust is a “safer” language,
> which to me means it must be slower."
>
> etc..
>
> Some in that thread seem to argue that a safer language
> will/could be slower than otherwise.
>
> Since Ada is known to be one of the safest languages,
> do others here feel there is any truth to this?
>
> I thought that by having more type information in the language,
> the compile will be able to make more optimizations (because it
> know more), and hence the generated code should actually be
> faster, not slower with a language that is less safe?
>
> I am not a compiler expert but what do others here think?

If a language needs run-time checks to ensure safety, those checks
usually take some time, making for slower execution.

If a language has a type system and compilation-time (legality) rules
such that the compiler can prove that some run-time checks are not
needed, that reduces or eliminates the slow-down. This is the case for Ada.

The effect of type information on optimization is harder (at least for
me) to understand. If the type information lets the compiler assume that
some objects are not aliased, that can help optimization because more
computation can be done in registers alone, without using main memory.
This applies to Ada, but also applies to standard C, for example,
although some people use non-standard C features (compiler options) to
negate this.

However, when comparing the "speed" of two languages and their two
implementations I think that the implementations usually matter more
than the languages.

Re: does a safer language mean it is slower to run?

<u5s1rk$1eprk$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9704&group=comp.lang.ada#9704

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: does a safer language mean it is slower to run?
Date: Thu, 8 Jun 2023 10:00:52 +0200
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <u5s1rk$1eprk$1@dont-email.me>
References: <u5rjg8$1dr0c$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 8 Jun 2023 08:00:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="120999917a328fef50d63d6e07827727";
logging-data="1533812"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/c9oSaCHmwE0JbV/7Mavu+deqz46DsjmU="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:FiQ4yRJS+xOxXvAS3uSrgioJibo=
In-Reply-To: <u5rjg8$1dr0c$1@dont-email.me>
Content-Language: en-US
 by: Dmitry A. Kazakov - Thu, 8 Jun 2023 08:00 UTC

On 2023-06-08 05:55, Nasser M. Abbasi wrote:
> Some folks in this thread
>
> https://discourse.julialang.org/t/comparison-of-rust-to-julia-for-scientific-computing/78508
>
> "I’m not an expert, but my feeling is that Rust is a “safer” language,
> which to me means it must be slower."

I think comparison is misplaced. Julia is an interpreted language, very
slow, on par with Python. It has memory mapped arrays like Ada does, but
lacks Python's precompiled modules. The syntax is wonderfully arbitrary
and unpredictable...

> Some in that thread seem to argue that a safer language
> will/could be slower than otherwise.

> Since Ada is known to be one of the safest languages,
> do others here feel there is any truth to this?
>
> I thought that by having more type information in the language,
> the compile will be able to make more optimizations (because it
> know more), and hence the generated code should actually be
> faster, not slower with a language that is less safe?
>
> I am not a compiler expert but what do others here think?

If safety is prevention of logical errors (bugs) you and your team and
people deploying the software could make, then techniques and processes
determine the outcome. The language can only support certain techniques.
Of these techniques and processes some may require run-time overhead.
When people compare languages, they frequently do programming techniques
instead. As it was observed many decades ago:

"Besides, the determined Real Programmer can write Fortran programs in
any language."

And finally, if you determined to use some technique, then lack of
language support makes the language less safe. E.g. if you are in some
agile programming lager then semantic constraints imposed by Ada would
make things only worse.

Even Brainf*ck might be the safest language under circumstances... (:-))

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: does a safer language mean it is slower to run?

<u5s4p4$1facv$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9705&group=comp.lang.ada#9705

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spam.jrcarter.not@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: does a safer language mean it is slower to run?
Date: Thu, 8 Jun 2023 10:50:44 +0200
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <u5s4p4$1facv$1@dont-email.me>
References: <u5rjg8$1dr0c$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 8 Jun 2023 08:50:45 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="eec3476987453bbce272b9fdedcffe1f";
logging-data="1550751"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+VAmlOYTFUxJeE8iiyIeCnaV1RH+wKhaI="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:z5GQppewSe2h9+oO2WBdWgMWJws=
Content-Language: en-US
In-Reply-To: <u5rjg8$1dr0c$1@dont-email.me>
 by: Jeffrey R.Carter - Thu, 8 Jun 2023 08:50 UTC

On 2023-06-08 05:55, Nasser M. Abbasi wrote:
>
> Some in that thread seem to argue that a safer language
> will/could be slower than otherwise.
>
> Since Ada is known to be one of the safest languages,
> do others here feel there is any truth to this?

Equivalent programs in compiled, non-GC languages have equivalent execution
times. Robert Dewar famously had a set of equivalent Ada and C programs that
produced identical machine code when compiled with gcc. So this is false.

The problem is getting equivalent programs. If the safe language includes
run-time checks, then equivalent checks must be manually added to the unsafe
language. Ada.Text_IO is not equivalent to C's I/O facilities. And so on.

Once consequence of this is that both programs will be equally correct. What is
usually compared is a correct (run-time checks) program in the safe language to
an incorrect (no run-time checks) program in the unsafe language.

About optimization, Tartan made its living selling highly optimizing C compilers
for TI chips, which came with a free C compiler. They also made highly
optimizing Ada compilers, which did a better job of optimization than their C
compilers. This was documented in

C vs Ada: arguing performance religion
(https://dl.acm.org/doi/10.1145/216578.216583)

which discusses four advantages Ada (83) has over C for optimization.

See also

Ada Outperforms Assembly: A Case Study
(https://www2.seas.gwu.edu/~adagroup/sigada-website/lawlis.html)

TI bought Tartan and sold its Ada compilers to DDC-I.

--
Jeff Carter
"Monsieur Arthur King, who has the brain of a duck, you know."
Monty Python & the Holy Grail
09

Re: does a safer language mean it is slower to run?

<u5sriv$1hu9f$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9706&group=comp.lang.ada#9706

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: laguest@archeia.com (Luke A. Guest)
Newsgroups: comp.lang.ada
Subject: Re: does a safer language mean it is slower to run?
Date: Thu, 8 Jun 2023 16:19:59 +0100
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <u5sriv$1hu9f$1@dont-email.me>
References: <u5rjg8$1dr0c$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 8 Jun 2023 15:20:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fb8ecc98c45e2caa875c21c77afdc85d";
logging-data="1636655"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18cPJ1LFWtuDAp2XZl1/FNIzT4KDdQRKDE="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.2
Cancel-Lock: sha1:5HHEbnpag/5yWha/d4K6dMTNDtw=
In-Reply-To: <u5rjg8$1dr0c$1@dont-email.me>
Content-Language: en-GB
 by: Luke A. Guest - Thu, 8 Jun 2023 15:19 UTC

On 08/06/2023 04:55, Nasser M. Abbasi wrote:
> Some folks in this thread
>
> https://discourse.julialang.org/t/comparison-of-rust-to-julia-for-scientific-computing/78508
>
> "I’m not an expert, but my feeling is that Rust is a “safer” language,
> which to me means it must be slower."

What these idiots ^ never do is define "slow," slow compared to WHAT?
They also don't seem to realise we basically use supercomputers now,
these things are way more powerful than the 8-bit/16-bit cpu's of the
70's and 80's. This mentality has come from there where optimisation at
the assembly level to pick the faster (less clock cycles) instructions.

And they always just say "Oh, that's SLOW!" I had the same when I joined
that games company, "we don't use virtuals, because they're SLOW." No,
they might be a tad slower in clock cycles.

These people also don't do safety, they don't do checks most of the time
and just want to make stuff as "fast" as possible without doing anything
to make sure it works correctly.

Re: does a safer language mean it is slower to run?

<191a99f6-8886-4831-9a1f-5261e15062b1n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9707&group=comp.lang.ada#9707

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:648:0:b0:75e:bb25:e0bd with SMTP id 69-20020a370648000000b0075ebb25e0bdmr309qkg.6.1686263551605;
Thu, 08 Jun 2023 15:32:31 -0700 (PDT)
X-Received: by 2002:a81:7607:0:b0:565:e903:6ad9 with SMTP id
r7-20020a817607000000b00565e9036ad9mr551128ywc.9.1686263551159; Thu, 08 Jun
2023 15:32:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Thu, 8 Jun 2023 15:32:30 -0700 (PDT)
In-Reply-To: <u5s1rk$1eprk$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=184.98.40.171; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG
NNTP-Posting-Host: 184.98.40.171
References: <u5rjg8$1dr0c$1@dont-email.me> <u5s1rk$1eprk$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <191a99f6-8886-4831-9a1f-5261e15062b1n@googlegroups.com>
Subject: Re: does a safer language mean it is slower to run?
From: list_email@icloud.com (Jerry)
Injection-Date: Thu, 08 Jun 2023 22:32:31 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Jerry - Thu, 8 Jun 2023 22:32 UTC

On Thursday, June 8, 2023 at 1:00:55 AM UTC-7, Dmitry A. Kazakov wrote:
> I think comparison is misplaced. Julia is an interpreted language, very
> slow, on par with Python. It has memory mapped arrays like Ada does, but
> lacks Python's precompiled modules. The syntax is wonderfully arbitrary
> and unpredictable...
[I guess this is OT.] Julia is a hot mess. Rather than being interpreted, it uses a just-in-time compiler, so they claim they have the solution to the "two-language problem" of prototyping in a slow language such as Python then re-writing in a compiled language for speed. There are problems. Julia has a bad habit of forgetting that it compiled a program before (no saved binary between sessions) so it has to re-compile it each time. (I think there are work-arounds but not intended for mere mortals.) Julia folks seem to have invented the phrase "time to first plot" because much of the Julia ecosystem is written in Julia so it has to go off and compile the plotters before you can make the first plot, or something like that. However, using Julia in Visual Studio Code where there is a very nice notebook Jupyter environment plus a very clever hybrid of a REPL and standard editor, is quite delightful. There is a set of officially published instructions for getting maximum speed from Julia https://docs.julialang.org/en/v1/manual/performance-tips; when printed as as PDF, it spans 36 pages and uses terminology and concepts that only an expert will know. People love Julia for its multiple-dispatch feature whereby it automatically generates a different version of a subroutine for every combination of argument and result that it can discover. (This behavior can be overridden by using ----- optional typing!) If you think dynamic typing is 180 degrees from strong typing, I would suggest that it is now only 90 degrees from strong typing, with Julia's brand new opportunities for accidentally calling a subroutine that you didn't even know existed now occupying the 180 degree position.

Re: does a safer language mean it is slower to run?

<f0b40784-4984-4a4a-b8d0-4d9ac47989f9n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9711&group=comp.lang.ada#9711

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:6214:18f1:b0:626:28c7:2078 with SMTP id ep17-20020a05621418f100b0062628c72078mr766711qvb.11.1686400394754;
Sat, 10 Jun 2023 05:33:14 -0700 (PDT)
X-Received: by 2002:a25:ce44:0:b0:bad:e8b:17d4 with SMTP id
x65-20020a25ce44000000b00bad0e8b17d4mr907297ybe.7.1686400394591; Sat, 10 Jun
2023 05:33:14 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sat, 10 Jun 2023 05:33:14 -0700 (PDT)
In-Reply-To: <191a99f6-8886-4831-9a1f-5261e15062b1n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a02:1210:2e90:8100:f952:3f2c:48c9:323c;
posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG
NNTP-Posting-Host: 2a02:1210:2e90:8100:f952:3f2c:48c9:323c
References: <u5rjg8$1dr0c$1@dont-email.me> <u5s1rk$1eprk$1@dont-email.me> <191a99f6-8886-4831-9a1f-5261e15062b1n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f0b40784-4984-4a4a-b8d0-4d9ac47989f9n@googlegroups.com>
Subject: Re: does a safer language mean it is slower to run?
From: gautier_niouzes@hotmail.com (Gautier write-only address)
Injection-Date: Sat, 10 Jun 2023 12:33:14 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1501
 by: Gautier write-only a - Sat, 10 Jun 2023 12:33 UTC

Good to learn that there is a searchable name "two-language problem" for that issue.
Another, not-well-known, solution, is Ada (with HAC on the prototyping side, and GNAT or other full-Ada systems on the production side)...

Re: does a safer language mean it is slower to run?

<uah3fe$ti2f$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9884&group=comp.lang.ada#9884

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: kc-usenet@chadwicks.me.uk (Kevin Chadwick)
Newsgroups: comp.lang.ada
Subject: Re: does a safer language mean it is slower to run?
Date: Thu, 3 Aug 2023 20:42:22 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <uah3fe$ti2f$1@dont-email.me>
References: <u5rjg8$1dr0c$1@dont-email.me> <u5sriv$1hu9f$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 3 Aug 2023 20:42:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1fc5f8b7d2a78a1edcc2d7bd7a4e49c3";
logging-data="968783"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+qMBGRgTbCjq9qZF0bDW218odYLlhkkY4="
User-Agent: PhoNews/3.12.0 (Android/13)
Cancel-Lock: sha1:MJ+dpnvN1lyIs8Owh8a162WoA8w=
In-Reply-To: <u5sriv$1hu9f$1@dont-email.me>
 by: Kevin Chadwick - Thu, 3 Aug 2023 20:42 UTC

On 08/06/2023 16:19, Luke A. Guest wrote:
>On 08/06/2023 04:55, Nasser M. Abbasi wrote:
>> Some folks in this thread
>>
>> https://discourse.julialang.org/t/comparison-of-rust-to-julia-for-scientific-computing/78508
>>
>> "I’m not an expert, but my feeling is that Rust is a “safer” language,
>> which to me means it must be slower."
>

Rust isn't a safer language. Rust is more targetted at the heap which is
slower than the stack. Additionally if you use Adas type system well then
you can remove input validation checks again making Ada faster. The
compiler is better and safer at optimising checks away.

--
Regards, Kc

Re: does a safer language mean it is slower to run?

<c5c09218-e170-4c16-b793-024683f21568n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10153&group=comp.lang.ada#10153

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:622a:1a1d:b0:417:fcf8:905c with SMTP id f29-20020a05622a1a1d00b00417fcf8905cmr57131qtb.10.1696015392779;
Fri, 29 Sep 2023 12:23:12 -0700 (PDT)
X-Received: by 2002:a05:6870:5b9c:b0:1e1:40df:f0d1 with SMTP id
em28-20020a0568705b9c00b001e140dff0d1mr826601oab.11.1696015392391; Fri, 29
Sep 2023 12:23:12 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.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.ada
Date: Fri, 29 Sep 2023 12:23:11 -0700 (PDT)
In-Reply-To: <u5rjg8$1dr0c$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=76.113.94.233; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC
NNTP-Posting-Host: 76.113.94.233
References: <u5rjg8$1dr0c$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c5c09218-e170-4c16-b793-024683f21568n@googlegroups.com>
Subject: Re: does a safer language mean it is slower to run?
From: onewingedshark@gmail.com (Shark8)
Injection-Date: Fri, 29 Sep 2023 19:23:12 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 106
 by: Shark8 - Fri, 29 Sep 2023 19:23 UTC

On Wednesday, June 7, 2023 at 9:55:55 PM UTC-6, Nasser M. Abbasi wrote:
> Some folks in this thread
>
> https://discourse.julialang.org/t/comparison-of-rust-to-julia-for-scientific-computing/78508
>
> "I’m not an expert, but my feeling is that Rust is a “safer” language,
> which to me means it must be slower."
>
> etc..
>
> Some in that thread seem to argue that a safer language
> will/could be slower than otherwise.
>
> Since Ada is known to be one of the safest languages,
> do others here feel there is any truth to this?
>
> I thought that by having more type information in the language,
> the compile will be able to make more optimizations (because it
> know more), and hence the generated code should actually be
> faster, not slower with a language that is less safe?
>
> I am not a compiler expert but what do others here think?
>
> --Nasser

An interesting proposition fueled by two differing intuitions: one, saying that mandatory checks must necessarily slow things down, and the other saying that having more information allows for greater optimization.

We can, of course, walk through a few simple/trivial examples to flesh out which intuition is more correct.

FIRST, let's consider Array-access in Ada, which mandates a check on the index:

Subtype Real is Float range Float'Range; -- Removing NaN, INF, etc.
Type Real_Vector is array (Positive range <>) of Real;
Function Normalize(Input : in Real_Vector) return Real_Vector is

Function Maximum return Real is
Begin
-- Start w/ Negative-most number; geturn the maximum.
Return Result : Real:= Real'First do
For Index in Input'Range loop
Result:= Real'Max(Result, Input(Index));
end loop;
End return;
End Maximum;

Begin
case Input'Length is
when 0 => Return Input;
when 1 => Return (1 => 1.0);
when others =>
Return Result : Real_Vector(Input'Range) do
declare
Max : Real renames Maximum;
begin
For Index in Result'Range loop
Result(Index):= Input(Index) / Max;
End loop;
end;
End return;
end case;
End Normalize;

In the above, we see the control of the For-loop, "Index", which takes its values from the input (directly or indirectly), and therefore the indexing of Input(Index) *cannot* be outside the bounds of the array, Input. This means that we can omit the checks altogether as Index is bound to the constraints of the array. And we can deduce this directly from the source, at compile-time, therefore allowing us to remove the checks altogether.

SECOND, consider:

Type Window is tagged private;
Type Window_Pointer is access all Window'Class;
Subtype Window_Handle is not null Window_Pointer;

Procedure Set_Title( Object : Window_Handle; Text : String );

In the above, we see that Object is an access to Window'Class which excludes Null -- since this constraint is enforced to the parameter on-call, in the body the compiler can assume that "Object /= Null" is true.

THIRD, similar to the second:

Type Safe_Text is String
with Dynamic_Predicate => (for all Ch of Safe_Text => Ch in 'a'..'z'|'A'..'Z'|' '||'0'..'9');
Function Transform( Input : Safe_Text ) return Safe_Text;

X : Safe_Text := Transform(Transform(Transform(Transform( Whatever ))));

in the above, we note that the parameter is checked for conformance, raising exception CONSTRAINT_ERROR if it fails, and is guaranteed to either return a Safe_Text value or else raise an exception -- applying these, we can eliminate all the checks for the parameter except the innermost, thus optimizing in a way that you cannot if your input and output types were more broad..

So, the intuition that "more information provides more optimization opportunity" is the correct one.

Re: does a safer language mean it is slower to run?

<868c2fa0-9480-45e7-899f-28c8993aafaan@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10214&group=comp.lang.ada#10214

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:6214:4b12:b0:66c:fe6b:ff4d with SMTP id pj18-20020a0562144b1200b0066cfe6bff4dmr317325qvb.6.1698253318929;
Wed, 25 Oct 2023 10:01:58 -0700 (PDT)
X-Received: by 2002:aca:240a:0:b0:3b2:e46e:448c with SMTP id
n10-20020aca240a000000b003b2e46e448cmr5916815oic.3.1698253318667; Wed, 25 Oct
2023 10:01:58 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 25 Oct 2023 10:01:58 -0700 (PDT)
In-Reply-To: <kedceaFqcp3U1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=49.184.135.245; posting-account=L5wwzgoAAAAfQcZzW8eLJKqyFogVIeWA
NNTP-Posting-Host: 49.184.135.245
References: <u5rjg8$1dr0c$1@dont-email.me> <kedceaFqcp3U1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <868c2fa0-9480-45e7-899f-28c8993aafaan@googlegroups.com>
Subject: Re: does a safer language mean it is slower to run?
From: robin51@dodo.com.au (robin vowels)
Injection-Date: Wed, 25 Oct 2023 17:01:58 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3855
 by: robin vowels - Wed, 25 Oct 2023 17:01 UTC

On Thursday, 8 June 2023 at 16:57:17 UTC+10, Niklas Holsti wrote:
> On 2023-06-08 6:55, Nasser M. Abbasi wrote:
> > Some folks in this thread
> >
> > https://discourse.julialang.org/t/comparison-of-rust-to-julia-for-scientific-computing/78508
> >
> > "I’m not an expert, but my feeling is that Rust is a “safer” language,
> > which to me means it must be slower."
> >
> > etc..
> >
> > Some in that thread seem to argue that a safer language
> > will/could be slower than otherwise.
> >
> > Since Ada is known to be one of the safest languages,
> > do others here feel there is any truth to this?
> >
> > I thought that by having more type information in the language,
> > the compile will be able to make more optimizations (because it
> > know more), and hence the generated code should actually be
> > faster, not slower with a language that is less safe?
> >
> > I am not a compiler expert but what do others here think?
..
> If a language needs run-time checks to ensure safety, those checks
> usually take some time, making for slower execution.
..
Some language features need run-time checks. These checks cannot be
carried out at compile time.
..
PL/I has some features that require run-time checks. When the computer
hardware has certain facilities, that support does not take extra execution time.
For example, floating-point overflow and integer overflow are detected by the
hardware on the IBM S/360 and subsequent machines including up to the latest
System z. Such detections cause an interrupt that can be handled by the PL/I
program. On the PC, integer overflow can cause an interrupt.
..
> If a language has a type system and compilation-time (legality) rules
> such that the compiler can prove that some run-time checks are not
> needed, that reduces or eliminates the slow-down. This is the case for Ada.
..
Range is not one of them.
..
> The effect of type information on optimization is harder (at least for
> me) to understand. If the type information lets the compiler assume that
> some objects are not aliased, that can help optimization because more
> computation can be done in registers alone, without using main memory.
> This applies to Ada, but also applies to standard C, for example,
> although some people use non-standard C features (compiler options) to
> negate this.
>
> However, when comparing the "speed" of two languages and their two
> implementations I think that the implementations usually matter more
> than the languages.

Re: does a safer language mean it is slower to run?

<kpt5bvFifdfU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10215&group=comp.lang.ada#10215

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!news.mb-net.net!open-news-network.org!news.mind.de!bolzen.all.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.holsti@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: does a safer language mean it is slower to run?
Date: Wed, 25 Oct 2023 21:33:35 +0300
Organization: Tidorum Ltd
Lines: 67
Message-ID: <kpt5bvFifdfU1@mid.individual.net>
References: <u5rjg8$1dr0c$1@dont-email.me> <kedceaFqcp3U1@mid.individual.net>
<868c2fa0-9480-45e7-899f-28c8993aafaan@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net rBI+W18eInVpANF6rmMieQ3rYcSn6pbWWYjqmXMgJuciBEEpwB
Cancel-Lock: sha1:73b7RSYd/Ma3zKYISyDElkbkz6k= sha256:OVDUQWHBZJ2tMSp3TgRD5ONYbTo7H97+zLwlHPqlZV4=
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <868c2fa0-9480-45e7-899f-28c8993aafaan@googlegroups.com>
 by: Niklas Holsti - Wed, 25 Oct 2023 18:33 UTC

On 2023-10-25 20:01, robin vowels wrote:
> On Thursday, 8 June 2023 at 16:57:17 UTC+10, Niklas Holsti wrote:
>> On 2023-06-08 6:55, Nasser M. Abbasi wrote:
>>> Some folks in this thread
>>>
>>> https://discourse.julialang.org/t/comparison-of-rust-to-julia-for-scientific-computing/78508
>>>
>>> "I’m not an expert, but my feeling is that Rust is a “safer” language,
>>> which to me means it must be slower."
>>>
>>> etc..
>>>
>>> Some in that thread seem to argue that a safer language
>>> will/could be slower than otherwise.
>>>
>>> Since Ada is known to be one of the safest languages,
>>> do others here feel there is any truth to this?
>>>
>>> I thought that by having more type information in the language,
>>> the compile will be able to make more optimizations (because it
>>> know more), and hence the generated code should actually be
>>> faster, not slower with a language that is less safe?
>>>
>>> I am not a compiler expert but what do others here think?
> .
>> If a language needs run-time checks to ensure safety, those checks
>> usually take some time, making for slower execution.
> .
> Some language features need run-time checks. These checks cannot be
> carried out at compile time.
> .
> PL/I has some features that require run-time checks. When the computer
> hardware has certain facilities, that support does not take extra execution time.
> For example, floating-point overflow and integer overflow are detected by the
> hardware on the IBM S/360 and subsequent machines including up to the latest
> System z. Such detections cause an interrupt that can be handled by the PL/I
> program. On the PC, integer overflow can cause an interrupt.
> .
>> If a language has a type system and compilation-time (legality) rules
>> such that the compiler can prove that some run-time checks are not
>> needed, that reduces or eliminates the slow-down. This is the case for Ada.
> .
> Range is not one of them.

/Some/ range checks in Ada can certainly be verified at compile time.
For example:

type ABCD is (A, B, C, D);
subtype BCD is ABCD range B .. D;

procedure Foo (X : in BCD)
is
Y : ABCD := X;
Z : ABCD := ABCD'Pred(Y);
...

The initialization of Y formally involves a range check of X, but since
BCD is a subtype of ABCD, the check can be elided at compile time.
Likewise, the initialization of Z, with its computation of the Pred,
formally includes a range check of Y, but since Y /= A can easily be
proved, that range check can also be elided.

The most important type of check that can be elided at Ada compile time
is array index check. Because arrays have specific index types in Ada,
the compiler can often prove that the index expression will be in range.

Re: does a safer language mean it is slower to run?

<uhsaos$19pmp$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10235&group=comp.lang.ada#10235

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: randy@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: does a safer language mean it is slower to run?
Date: Tue, 31 Oct 2023 20:48:42 -0500
Organization: A noiseless patient Spider
Lines: 88
Message-ID: <uhsaos$19pmp$1@dont-email.me>
References: <u5rjg8$1dr0c$1@dont-email.me> <kedceaFqcp3U1@mid.individual.net> <868c2fa0-9480-45e7-899f-28c8993aafaan@googlegroups.com> <kpt5bvFifdfU1@mid.individual.net>
Injection-Date: Wed, 1 Nov 2023 01:48:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="dc455c77e2b113aecc4a5931cd453a02";
logging-data="1369817"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18LQhw/A+ahhSdrmA4Kgor3OmUk2FiA5GA="
Cancel-Lock: sha1:qTT+3RSVcni3cRGzo2+AEL4ByTg=
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-RFC2646: Format=Flowed; Response
X-Priority: 3
X-MSMail-Priority: Normal
 by: Randy Brukardt - Wed, 1 Nov 2023 01:48 UTC

"Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message
news:kpt5bvFifdfU1@mid.individual.net...
> On 2023-10-25 20:01, robin vowels wrote:
>> On Thursday, 8 June 2023 at 16:57:17 UTC+10, Niklas Holsti wrote:
>>> On 2023-06-08 6:55, Nasser M. Abbasi wrote:
>>>> Some folks in this thread
>>>>
>>>> https://discourse.julialang.org/t/comparison-of-rust-to-julia-for-scientific-computing/78508
>>>>
>>>> "I'm not an expert, but my feeling is that Rust is a "safer" language,
>>>> which to me means it must be slower."
>>>>
>>>> etc..
>>>>
>>>> Some in that thread seem to argue that a safer language
>>>> will/could be slower than otherwise.
>>>>
>>>> Since Ada is known to be one of the safest languages,
>>>> do others here feel there is any truth to this?
>>>>
>>>> I thought that by having more type information in the language,
>>>> the compile will be able to make more optimizations (because it
>>>> know more), and hence the generated code should actually be
>>>> faster, not slower with a language that is less safe?
>>>>
>>>> I am not a compiler expert but what do others here think?
>> .
>>> If a language needs run-time checks to ensure safety, those checks
>>> usually take some time, making for slower execution.
>> .
>> Some language features need run-time checks. These checks cannot be
>> carried out at compile time.
>> .
>> PL/I has some features that require run-time checks. When the computer
>> hardware has certain facilities, that support does not take extra
>> execution time.
>> For example, floating-point overflow and integer overflow are detected by
>> the
>> hardware on the IBM S/360 and subsequent machines including up to the
>> latest
>> System z. Such detections cause an interrupt that can be handled by the
>> PL/I
>> program. On the PC, integer overflow can cause an interrupt.
>> .
>>> If a language has a type system and compilation-time (legality) rules
>>> such that the compiler can prove that some run-time checks are not
>>> needed, that reduces or eliminates the slow-down. This is the case for
>>> Ada.
>> .
>> Range is not one of them.
>
>
> /Some/ range checks in Ada can certainly be verified at compile time. For
> example:
>
> type ABCD is (A, B, C, D);
> subtype BCD is ABCD range B .. D;
>
> procedure Foo (X : in BCD)
> is
> Y : ABCD := X;
> Z : ABCD := ABCD'Pred(Y);
> ...
>
> The initialization of Y formally involves a range check of X, but since
> BCD is a subtype of ABCD, the check can be elided at compile time.
> Likewise, the initialization of Z, with its computation of the Pred,
> formally includes a range check of Y, but since Y /= A can easily be
> proved, that range check can also be elided.
>
> The most important type of check that can be elided at Ada compile time is
> array index check. Because arrays have specific index types in Ada, the
> compiler can often prove that the index expression will be in range.

Right. And programmers can often write their code to ensure that no range
check will be needed. The most obvious case occurs in loops:

for I in Arr'range loop
... Arr(I) ... -- Needs no range check, since I can never be outside
of the legal range of the array index.
end loop;

(Of course, the element for loop disposes with the array indexing
altogether, which is even better.)

Randy.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor