August 10, 2021
On Tue, Aug 10, 2021 at 11:29:35AM -0700, Walter Bright via Digitalmars-d wrote: [...]
> A friend mine (a very smart one) back in college one day decided to
> learn programming. He got the Fortran specification(!), read it, and
> wrote a program.

Hey, what better way to learn a language than to get to the very definition of it? ;-)


> The program ran correctly, but incredibly slowly. Baffled, he took it to his programmer friend for help. The friend laughed, and said here's the problem: you're writing to a file in a loop:
> 
>     loop
>         open the file
>         append a character
>         close the file
> 
> instead of:
> 
>    open the file
>    loop
>       append character
>    close the file
> 
> My friend said he followed the spec, which said nothing at all about how file I/O actually worked.

:-D

What the spec *doesn't* say is often just as important as, if not more important than, what it does say. :-)

Reminds me of learning a foreign language by reading a dictionary... you can learn all the words, and even consult a book on grammar, but will it survive the first encounter with a native speaker?  ;-)  True story: one time, I found a particular foreign word from a dictionary, and thought that was how you referred to a particular thing.  So I used that word with a native speaker.  He stared at me for a moment with this strange look of incomprehension, and then suddenly comprehension gleamed in his eyes, and with a smile he explained that this was an archaic word that is no longer in widespread use, and that people these days use a different word for the same thing.  He further added that if I were to use that word with somebody younger than him, they probably wouldn't even understand what it meant.

Such is the peril of learning a language by spec without understanding the context in which it operates. :-)


T

-- 
Almost all proofs have bugs, but almost all theorems are true. -- Paul Pedersen
August 10, 2021
On Tue, Aug 10, 2021 at 06:46:57PM +0000, Paul Backus via Digitalmars-d wrote:
> On Tuesday, 10 August 2021 at 17:47:48 UTC, H. S. Teoh wrote:
[...]
> > OT1H the idealist in me screams "please break my code, fix the language to remove all the broken stuff!".  OTOH the long-term code maintainer in me shakes his fists every time a compiler upgrade breaks one of my old projects.
> > 
> > The solution to the conundrum is, accretion rather than replacement. Let the old code compile.  Complain about deprecations if you have to, but don't ever make it not compile (unless it was an outright bug to have compiled in the first place).  But new code can use the new stuff and benefit from it.
> 
> Of course, the obvious counterargument is that this approach is exactly how you end up with a language like C++: powerful in the hands of experts, with a large and successful ecosystem, but packed to the gills with pitfalls and footguns for beginners to hurt themselves with.
[...]

Very true.

Which is why one time I brought up this idea of embedding language version in source files.  Perhaps right after the module declaration there could be an optional version declaration that states which language version the source file was written for:

	module mymodule;
	version = 2.097;
	...

If the version declaration is earlier than the current compiler version, it would enter compatibility mode in which it emulates the behaviour of a previous language version.  But if the version declaration is up-to-date or omitted, the compiler would apply the latest version of the language, which may or may not break older features.  That gives us a way to fix flaws in the language and reverse design decisions that were wrong in hindsight, yet without breaking old code.  Newer code would then be encouraged to use the latest language version, that does not have the pitfalls of older language versions.

Of course, in practice this will add a whole ton of extra work for the compiler devs, especially once the number of supported language versions increases.  And it's not clear what to do if an older language construct has to interact with a newer, incompatible language feature.  So I'm not sure how practical this will be.  But if we could somehow pull it off, then we could *both* evolve the language and retain backward compatibility at the same time.


T

-- 
Fact is stranger than fiction.
August 10, 2021
On Tuesday, 10 August 2021 at 19:18:47 UTC, H. S. Teoh wrote:
> Of course, in practice this will add a whole ton of extra work for the compiler devs, especially once the number of supported language versions increases.  And it's not clear what to do if an older language construct has to interact with a newer, incompatible language feature.  So I'm not sure how practical this will be.  But if we could somehow pull it off, then we could *both* evolve the language and retain backward compatibility at the same time.
>
>
> T

Better in this case to have semi or full code migrator, that will automatically upgrade source code to latest version of d compiler. Then you won't require any extensive support of older versions of language, in the compiler itself.
August 10, 2021
On Tue, Aug 10, 2021 at 07:23:52PM +0000, Alexandru Ermicioi via Digitalmars-d wrote:
> On Tuesday, 10 August 2021 at 19:18:47 UTC, H. S. Teoh wrote:
> > Of course, in practice this will add a whole ton of extra work for the compiler devs, especially once the number of supported language versions increases.  And it's not clear what to do if an older language construct has to interact with a newer, incompatible language feature.  So I'm not sure how practical this will be.  But if we could somehow pull it off, then we could *both* evolve the language and retain backward compatibility at the same time.
[...]
> Better in this case to have semi or full code migrator, that will automatically upgrade source code to latest version of d compiler. Then you won't require any extensive support of older versions of language, in the compiler itself.

This has been brought up many times, but I still see no actual progress in this area.

We really need to make dfix a part of the official compiler default installation so that it's officially supported, and not merely an afterthought.

Or even better yet, make it a part of the compiler (or at least auto-spawned by the compiler, the same way the linker is).  The less external tools the user needs to manually invoke to make the upgrade happen, the better.  In the ideal scenario, the act of running the compiler would auto-upgrade the source code in-place, and compile that instead of the original code.

Of course, this may be too intrusive, so maybe hide it behind a compiler switch?  When the switch is specified the compiler invokes dfix on the user's behalf, replaces the input file(s) with the upgraded versions, and compiles them, all in one go.  Imagine how much better it is, if we could just:

	apt-get install dmd	# upgrade dmd, including dfix
	dmd -i -auto-upgrade my_project/*.d -of=profit
	./profit

and have everything Just Work(tm), rather than having to:

	apt-get install dmd			# upgrade compiler
	dmd -i my_project/*.d -of=profit	# tons of compile errors
	dfix					# oops, dfix not up-to-date
	dmd -i my_project/*.d -of=profit	# still compile errors
	apt-get install dfix			# need to upgrade dfix
	dfix
	dmd -i my_project/*.d -of=profit	# about time
	./profit				# already lost profit here :-P


T

-- 
Amateurs built the Ark; professionals built the Titanic.
August 10, 2021
On Tuesday, 10 August 2021 at 17:47:46 UTC, Walter Bright wrote:
> On 8/9/2021 8:15 AM, bachmeier wrote:
>> I did not study unsigned math in college.
>
> There are no classes in unsigned math.

Primary school is where unsigned arithmetic is tought. :-)


August 11, 2021
On Tuesday, 10 August 2021 at 21:51:51 UTC, Patrick Schluter wrote:
> On Tuesday, 10 August 2021 at 17:47:46 UTC, Walter Bright wrote:
>> On 8/9/2021 8:15 AM, bachmeier wrote:
>>> I did not study unsigned math in college.
>>
>> There are no classes in unsigned math.
>
> Primary school is where unsigned arithmetic is tought. :-)

With unbound storage, base 10 and no wrapping.
August 11, 2021
On Tuesday, 10 August 2021 at 21:51:51 UTC, Patrick Schluter wrote:
> On Tuesday, 10 August 2021 at 17:47:46 UTC, Walter Bright wrote:
>> On 8/9/2021 8:15 AM, bachmeier wrote:
>>> I did not study unsigned math in college.
>>
>> There are no classes in unsigned math.
>
> Primary school is where unsigned arithmetic is taught. :-)

No. There are classes in unsigned math - but very much later.
They are called "Finite Fields Arithmetic" or even "binary polynomials over finite fields" and although it its not too complicated, it assumes a lot of base math knowledge to be understood well.
August 11, 2021
On 8/10/21 2:51 PM, Patrick Schluter wrote:

> Primary school is where unsigned arithmetic is tought. :-)

I was surprised at how quickly my son learned negative numbers at probably the age of 5 in less than 5 minutes. I am not exaggerating! I only said: "You know the numbers and you know zero... Well, actually there are the negative numbers on the other side too." (I used colored domino pieces to represent those three kinds.) That was it! :)

I would show off to my friends by asking my son:

-- "Let's say we are reading a book with copyright 2009. How old *were* you when that book was published?"

After thinking 2 seconds:

-- "Negative 4!"

:)

Ali

August 17, 2021
On Sunday, 8 August 2021 at 16:45:23 UTC, Max Samukha wrote:
> On Sunday, 8 August 2021 at 16:15:00 UTC, Kyle Ingraham wrote:
>
>>
>> Why the personal attack? What does it add here?
>
> I did it out of frustration with an issue that has a long history. Shouldn't have done that, sorry. I promise not to post here again.

Definitely post here again. I only asked about something I had also been frustrated with. Don’t hold back your contribution because of my questions.
August 17, 2021
On Sunday, 8 August 2021 at 16:38:41 UTC, Adam D Ruppe wrote:
> On Sunday, 8 August 2021 at 16:15:00 UTC, Kyle Ingraham wrote:
>> Why the personal attack?
>
> That's directly addressing the argument, not a personal attack.
>
> Imagine going to a mechanic and saying "my car shakes and thumps" and getting the answer "just don't drive it then, no more shaking!"
>
> True, but presumably you were driving the car for a reason, like maybe you had some place to be and that's not going to change. So you need some kind of solution. Maybe it is to ride a bike or take the bus, but you can't just ignore that need while saying "the problems went away".

I got the same as what you describe up to “You have just dismissed the problems caused by your solution…”. I just felt there was more there without background context that didn’t need to be there.