April 30, 2022

On Saturday, 30 April 2022 at 07:07:31 UTC, Tobias Pankrath wrote:

>

On Saturday, 30 April 2022 at 06:30:46 UTC, Ola Fosheim Grøstad wrote:

>

On Friday, 29 April 2022 at 20:17:38 UTC, Walter Bright wrote:

>

I've seen endless lists of features people wanted to add to C and C++. None of them were CTFE. When we added it to D, people were excited and surprised.

Not if they had a decent CS background, it is a well known strategy for speeding up programs. Wikipedia also points out a working C++ prototype from 2003, so I doubt they needed outside influence to move in that direction.

Sometimes a good idea from academia needs a practical example (D in this case) to show its usefulness before I sees widespread adoption. That doesn't mean that it was invented by D, or that there is no prior art.

Those pratical examples precede D's existence by decades, and what you are mentioning is not what Walter asserts, rather that it was D that brought it to the world.

As if all those people doing CS research in programming languages needed D's existence to notice what is know in academia for decades.

April 30, 2022

On Friday, 29 April 2022 at 07:56:15 UTC, bauss wrote:

>

No matter how good your library solutions are then you can never implement async/await in a clear fashion without the compiler emitting you a state machine for it.

Seems to me that coroutine support is sufficient?

April 30, 2022
On Friday, 29 April 2022 at 19:44:09 UTC, max haughton wrote:
> On Friday, 29 April 2022 at 18:26:46 UTC, Paulo Pinto wrote:
>> On Friday, 29 April 2022 at 18:05:42 UTC, Walter Bright wrote:
>>> On 4/29/2022 10:00 AM, Paulo Pinto wrote:
>>>> On Friday, 29 April 2022 at 15:28:16 UTC, Walter Bright wrote:
>>>>> On 4/27/2022 8:59 AM, Satoshi wrote:
>>>>>> [...]
>>>>>
>>>>> Other languages have taken inspiration from D, such as ranges and compile time expression evaluation.
>>>>>
>>>>> ....
>>>> 
>>>> Sorry, Lisp, ML, CLU and Smalltalk did it first, D was surely not the first in this regard.
>>>> 
>>>> Plenty of SIGPLAN papers on the subject.
>>>
>>> Those were interpreters first and added native code generation later. D did is the other way around, and the native code generating compilers started doing it soon afterwards.
>>
>> Decades before D was even an idea.
>>
>> Again, SIGPLAN.
>
> Which papers?

Given that the point is compile time execution and ranges, with compiled code.

Lets start with Lisp macros and reduce ourselves to the first generation of Lisp compilers that were relatively known.

Interlisp-D at Xerox PARC, http://www.softwarepreservation.org/projects/LISP/interlisp_family,  1983.

Don't be deceived by the references to bytecode or vm, Dorado workstations used microcoded CPUs loaded on boot, hardly any different from modern Intel/AMD CPUs doing on the fly translations from CISC to their RISC internals.

But if you want to be pedantic about the very first Lisp compiler with macros support, it was created in 1962

https://web.archive.org/web/20201213195043/ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-039.pdf

Or a version that is still in use, like Allegro Common, first release in 1985.

http://www.softwarepreservation.org/projects/LISP/common_lisp_family

Maybe Lisp isn't the thing, we can turn our attention to the ML linagage with MetaML (2000) or Template Haskell (2002), being two of most well known examples,

https://www.sciencedirect.com/science/article/pii/S0304397500000530

https://userpages.uni-koblenz.de/~laemmel/TheEagle/dl/SheardPJ02.pdf

Switching gears to ranges, we have Smalltalk-80 collections as one possible example,

https://www.researchgate.net/publication/2409926_Interfaces_and_Specifications_for_the_Smalltalk-80_Collection_Classes


April 30, 2022
On Saturday, 30 April 2022 at 08:32:19 UTC, Paulo Pinto wrote:
> On Friday, 29 April 2022 at 19:44:09 UTC, max haughton wrote:
>
> Switching gears to ranges, we have Smalltalk-80 collections as one possible example,
>
> https://www.researchgate.net/publication/2409926_Interfaces_and_Specifications_for_the_Smalltalk-80_Collection_Classes

Let's focus on smalltalk, what syntax do you use to choose if your code snippet should run at runtime or in compiletime? Not the entire program, but 50% compile-time and 50% runtime.

April 30, 2022
On Saturday, 30 April 2022 at 08:56:55 UTC, Daniel N wrote:
> On Saturday, 30 April 2022 at 08:32:19 UTC, Paulo Pinto wrote:
>> On Friday, 29 April 2022 at 19:44:09 UTC, max haughton wrote:
>>
>> Switching gears to ranges, we have Smalltalk-80 collections as one possible example,
>>
>> https://www.researchgate.net/publication/2409926_Interfaces_and_Specifications_for_the_Smalltalk-80_Collection_Classes
>
> Let's focus on smalltalk, what syntax do you use to choose if your code snippet should run at runtime or in compiletime? Not the entire program, but 50% compile-time and 50% runtime.

You're focusing on the wrong apple, the Smalltalk example was related to ranges outside of the functional programmig family.

So can focus instead on Lisp as one possible example, use macros for the 50% at compile time, leave the rest of the code using streams for the ranges part of the equation.

If you don't like parentheses, that is also possible in Dylan or Template Haskell.

D hasn't invented anything newer here, and regardless of the wishfull thinking that it did, you won't find any references to D as inspiration to those features in modern languages papers like HOPL, rather to those that have preceeded it.
April 30, 2022
On Saturday, 30 April 2022 at 08:56:55 UTC, Daniel N wrote:
> Let's focus on smalltalk, what syntax do you use to choose if your code snippet should run at runtime or in compiletime? Not the entire program, but 50% compile-time and 50% runtime.

naive solution: cost estimation via an ast walker, just like inliners do.
April 30, 2022
On 4/30/2022 1:02 AM, Paulo Pinto wrote:
> As if all those people doing CS research in programming languages needed D's existence to notice what is know in academia for decades.

Bjarne Stroustrup has a PhD in CS. Why didn't C++ have it? Why does every iteration of C++ make CTFE work more like D's?

Why didn't any of the other mainstream native compiled languages have it? Fortran? Ada? Pascal? Modula 2? (The latter two by CS academic researcher Niklaus Wirth.)

CTFE is a *huge* win. Why was this well-known thing languishing in complete obscurity?
April 30, 2022
On 4/30/2022 12:07 AM, Paulo Pinto wrote:
> On Friday, 29 April 2022 at 20:17:38 UTC, Walter Bright wrote:
>> I've seen endless lists of features people wanted to add to C and C++. None of them were CTFE. When we added it to D, people were excited and surprised.
> Only those lacking sound CS background in language research.


Bjarne Stroustrup and Niklaus Wirth are PhD CS researchers. The C++ illuminati is full of CS academics.

Why did zero of them propose it for C++? Instead, we got all this excitement over the *discovery* that one could execute programs at compile time with C++ templates. A discovery made by academics.

Why did none say "why don't we just interpret the function instead of this absurd template metaprogramming technique?"
April 30, 2022
On 4/30/2022 12:35 AM, Max Samukha wrote:
> On Friday, 29 April 2022 at 20:17:38 UTC, Walter Bright wrote:
>> On 4/29/2022 12:10 PM, Walter Bright wrote:
>>> So why did other native languages suddenly start doing it after D did to the point of it being something a language can't skip anymore?
>>
>> I've seen endless lists of features people wanted to add to C and C++. None of them were CTFE. When we added it to D, people were excited and surprised.
> 
> Your lists are not representative. When D added it, our reaction was more like "finally, somebody did that!".

I'm open to a reference to one that does have it, that predates D's CTFE.


> And even today, the feature is only marginally useful because of the countless forward reference bugs. I recently filed one more (https://issues.dlang.org/show_bug.cgi?id=22981), which is not a CTFE bug per se but was encountered in another futile attempt to generate code with CTFE in a reasonable manner.

I'm sorry about the problems you encountered, but as you say they are forward reference issues, not about CTFE. You couldn't get that code to work in C++, either, because C++ does not allow forward references at all.

Thanks for submitting a well-done bug report on it.
April 30, 2022
On 4/30/2022 12:05 AM, Paulo Pinto wrote:
> On Friday, 29 April 2022 at 19:10:32 UTC, Walter Bright wrote:
>> So why did other native languages suddenly start doing it after D did to the point of it being something a language can't skip anymore?
> They didn't, they got inspired by those that preceded D, you just want to believe D was the cause.

The timing suggests strongly otherwise.

C++'s discovery that templates could be used for CTFE suggests otherwise, too. All those articles about it never mentioned just interpreting an ordinary function instead.