Monday, March 13, 2023

Digest for comp.lang.c++@googlegroups.com - 8 updates in 3 topics

David Brown <david.brown@hesbynett.no>: Mar 13 08:17PM +0100

On 13/03/2023 16:18, Kalevi Kolttonen wrote:
 
> Yes, it is functional.
 
> There are no for or while loops in Erlang, but you
> have to use recursion instead.
 
That's standard for functional programming languages.
 
> trickiest or "craziest". In so many other programming languages,
> we take it for granted that the values of variables can change
> during the program execution.
 
Again, that is the norm for functional programming languages. It is
even becoming common in non-functional languages for immutable
"variables" to be the default. A high proportion of variables in C or
C++ never need to be changed after their initialisation or first
assignment, and it is much easier to reason about the correctness of the
code if the values of variables never changes.
 
But it is certainly the case that functional programming involves
thinking about things in a somewhat different fashion from imperative
programming. And some tasks are easier in one style, others in a
different style.
 
 
>>> They use Erlang in some mobile phone networks, and with
 
>> IIRC thats why ericsson wrote it.
 
> Correct.
 
The motto for Erlang is "write once, run forever". It's most fun
feature, IMHO, is the extent to which you can replace code while
everything is still running. The idea is that you don't have to stop
your entire mobile phone network just because you want to update the
software.
 
> and it says there is one notable new application written
> in Erlang: WhatsApp. Maybe the client code is not Erlang,
> but the server infrastructure is.
 
There's a lot more software written in Erlang than just WhatsApp. As
well as being vital to many mobile phone and telecommunications
networks, it is used in a lot of server systems that require high
reliability and massive scalability. Of course it depends on what you
call "notable".
 
There is also Elixir that builds on Erlang, running on the same virtual
machine.
David Brown <david.brown@hesbynett.no>: Mar 13 08:21PM +0100

On 13/03/2023 18:02, Keith Thompson wrote:
 
> That's not entirely true. Extensions (which are explicitly permitted by
> the standard) can take the form of an implementation defining behavior
> that is not defined by the standard.
 
I was using the term "undefined behaviour" here to mean behaviour that
is not defined by the standards, the implementation, or any other
relevant specification. It's fine to use things that are defined only
in a particular implementation - although of course the result is not
portable. (For example, with "gcc -fwrapv", signed integer overflow is
fully defined.)
 
I could have been clearer about that in my post, however.
kalevi@kolttonen.fi (Kalevi Kolttonen): Mar 13 07:31PM

>> There are no for or while loops in Erlang, but you
>> have to use recursion instead.
 
> That's standard for functional programming languages.
 
I know.
 
> C++ never need to be changed after their initialisation or first
> assignment, and it is much easier to reason about the correctness of the
> code if the values of variables never changes.
 
That I didn't know. I thought immutable variables were a pretty
unique part of Erlang.
 
> thinking about things in a somewhat different fashion from imperative
> programming. And some tasks are easier in one style, others in a
> different style.
 
Yes, the mental model is different.
 
> everything is still running. The idea is that you don't have to stop
> your entire mobile phone network just because you want to update the
> software.
 
I agree that it is a fantastic feature to have. I know of no
other language that has it.
 
> networks, it is used in a lot of server systems that require high
> reliability and massive scalability. Of course it depends on what you
> call "notable".
 
Right, the definition of "notable" is important here, but without
doubt WhatsApp qualifies with flying colors. It still has lots
of users worldwide despite emerging competition.
 
> There is also Elixir that builds on Erlang, running on the same virtual
> machine.
 
Yes, I noticed that when reading the Wikipedia article. They also have
programming language Lua running on BEAM virtual machine.
 
br,
KK
Keith Thompson <Keith.S.Thompson+u@gmail.com>: Mar 13 12:53PM -0700

> portable. (For example, with "gcc -fwrapv", signed integer overflow
> is fully defined.)
 
> I could have been clearer about that in my post, however.
 
The standard defines "undefined behavior" as "behavior for which this
document [the standard] imposes no requirements". I recommend not using
that particular phrase with a different meaning.
 
Certainly relying on behavior that isn't defined either by the standard,
by any applicable secondary standard, or by the implementation is a bad
idea.
 
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for XCOM Labs
void Void(void) { Void(); } /* The recursive call of the void */
Paavo Helde <eesnimi@osa.pri.ee>: Mar 14 12:01AM +0200

13.03.2023 21:31 Kalevi Kolttonen kirjutas:
>> code if the values of variables never changes.
 
> That I didn't know. I thought immutable variables were a pretty
> unique part of Erlang.
 
For example, a string variable in Python is kind of immutable AFAIK. You
can replace it, but you cannot change it. If there are multiple
references to the string, the other references will continue to point to
the old string even if some path pointing to it is replaced by a new
string, in a COW fashion. So the string acts like an immutable
atomic/scalar value and any references to it only serve as a tool for
memory optimization and cannot be used for modification of data visible
via other references.
 
At least that's what I've gathered, I'm no expert in Python.
Bonita Montero <Bonita.Montero@gmail.com>: Mar 13 09:27PM +0100

Am 13.03.2023 um 20:11 schrieb Mr Flibble:
 
> The code is not wrong; ...
 
It is because your type is not conditionally used as with my example.
Your both compilers are just more tolerant than MSVC.
Bonita Montero <Bonita.Montero@gmail.com>: Mar 13 09:27PM +0100

Am 13.03.2023 um 20:11 schrieb Mr Flibble:
 
> Yes there are various workarounds including using C++20 features but
> that doesn't alter the fact that the code in my defect report is well
> formed and VS2022 is wrong to reject it. ...
 
MSVC is corrent because your denendent type doesn't exist.
Jack <invalid@invalid.net>: Mar 13 07:28PM

In this article, we'll look at a super handy ranges view in C++23 -
views::zip. In short, it allows you to combine two or more ranges and
iterate through them simultaneously. Let's see how to use it.
 
<https://www.cppstories.com/2023/view-zip/>
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: