News for hackers. Stuff that matters.
Re:DigitalMars C/C++ Compiler by WalterBright on Tuesday May 22, 2018 @09:10PM (#17130805)
Walter here. AMA.
Re:DigitalMars C/C++ Compiler by greenhouse_gas on Tuesday May 22, 2018 @09:41PM (#17130926)
How does it feel having your "life's work"[1] becoming big enough to be noticed, but ignored by the mainstream?

You created the first "better C" out there to get any traction, it had a perfect name (B -> C -> D), but due to factors that were partially [2] outside your control [3], D's niche got eaten by Go and Rust.

[1]. The D programming language. [2]. I've seen people blaming the D to D2.0 transition, but D was a niche language before too. I've also seen people blame D for not having an Open Source compiler for years, but neither did Java, and it took off anyways. [3]. Such as Sun's marketing, or the general push to scripting languages between 1995-2010 (such as perl, tcl, PHP, Ruby, Python and Node)

Re:DigitalMars C/C++ Compiler by WalterBright on Tuesday May 22, 2018 @11:11PM (#17131241)
When I started, I was well aware of:

"Certainty of death. Small chance of success. What are we waiting for?"

https://www.youtube.com/watch?v=8joT0oFuGoI

For a language without a megacorp pushing it, D is spectacularly successful. Consider:

1. It's developed by volunteers who work on it for the joy of it without remuneration.

2. People who spend the effort to get past the learning curve find it very pleasing and productive.

3. Other major languages have been continuously copying D's features :-)

4. Corporations that have adopted it for mission critical use have told me that D is their "secret weapon" that allows them to out-maneuver and out-innovate their competitors.

It's like the music business - you don't have to be the Beatles to have a very good career.

Re:DigitalMars C/C++ Compiler by thawkins on Wednesday May 23, 2018 @02:07AM (#17131751)
Walter, I have been using your products way back since before Zortech, at the time it was the only C++ system that I could get to work with the Phar Lap DOS extender to create big binaries.

Thank you for all your hard work, your products formed the center on my early career, and most of what i know i learned using your tools.

Note I particularly loved "Zed" the text editor that came with the early toolchain.

Regards Tim Hawkins, a grateful hacker.

Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @04:11AM (#17132218)
Welcs!
Re:DigitalMars C/C++ Compiler by dvfjsdhgfv on Wednesday May 23, 2018 @03:48AM (#17132102)
> It's like the music business - you don't have to be the Beatles to have a very good career.

I think you're too humble here. The quality of D is no lower than the competing products backed by huge corporations.

I also vaguely remember using Symantec C++, it was a refreshing alternative to the competitors of the time, and I had very pleasant experience using it.

Re:DigitalMars C/C++ Compiler by laumars on Wednesday May 23, 2018 @02:17AM (#17131779)
> It's like the music business - you don't have to be the Beatles to have a very good career.

That is an inspired quote. I shall steal that and use it whenever anyone argues "why x when y already exists".

Re:DigitalMars C/C++ Compiler by vram22 on Wednesday May 23, 2018 @04:39PM (#17138043)
>whenever anyone argues "why x when y already exists".

Yes, seen many people argue that, including to me, e.g. about some of my blog posts, which show hand-rolled ways of doing things when a library for that exists. I guess often such people are not doing anything much themselves, and don't get that people can create something in the same area where something else exists, for any number of reasons, even just for sheer fun, love of the field, or for teaching beginners.

Re:DigitalMars C/C++ Compiler by schlupa on Thursday May 24, 2018 @03:54AM (#17141959)
or simply to have control over the code.
Re:DigitalMars C/C++ Compiler by vram22 on Saturday May 26, 2018 @12:50PM (#17162978)
Yes, good point. When it is not a blog post but real-life project code, I sometimes do it for that reason you mention.
Re:DigitalMars C/C++ Compiler by codyguy on Tuesday May 22, 2018 @11:32PM (#17131307)
> "Certainty of death. Small chance of success. What are we waiting for?"

You are an inspiration Walter !!

Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @02:41AM (#17131846)
My favorite line from the movie.
Re:DigitalMars C/C++ Compiler by bausshf on Thursday May 24, 2018 @05:59AM (#17142543)
> It's like the music business - you don't have to be the Beatles to have a very good career.

For someone who is in both the music business, but also a D programmer for many years, I got to say this was the most inspirational quote I have ever read and it'll be my inspiration in both fields.

Re:DigitalMars C/C++ Compiler by bachmeier on Wednesday May 23, 2018 @05:53AM (#17132716)
> D's niche

That represents a misunderstanding of D. Unlike Go and Rust, which were built for one specific use case (Go for the work done at Google, and Rust for writing a browser), D is an all-around good general purpose programming language. If it did have a niche, it would be as a C replacement, and it is the best available tool for that.

Your comment also implies that D is not used. Download statistics, forum activity, and the existence of users suggests otherwise.

Re:DigitalMars C/C++ Compiler by steveklabnik on Wednesday May 23, 2018 @09:57AM (#17134192)
Rust was built to be good for browsers, but also as a general purpose language. We’ve made decisions in the past to not include things the Servo folks wanted, for example.
Re:DigitalMars C/C++ Compiler by gravypod on Tuesday May 22, 2018 @10:21PM (#17131051)
I'm a little confused. I've heard of Digital Mars around the internet but I don't know what it is or why the company was started.

For my entire life as a Software Engineer the idea of a close sourced or proprietary compiler was just alien to me.

What set you down the path of writing compilers? Did anyone buy licenses to your compilers? Why was D started?

A more technical question: Was there any abstraction/pattern that has been deeply rooted into your code base that you are unable to change due to prevalence yet this pattern/abstraction makes it more difficult to maintain your code base? In any other words: have there been any mistakes made?

Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @12:06AM (#17131421)
digitalmars.com !

When I started, everything was closed source. Open source was inconceivable.

I started writing compilers in order to speed up my game Empire (www.classicempire.com). Compilers turned out to be more interesting :-)

Yes, many bought licenses.

D was started because I got bored with retirement (6 weeks of watching TV will do that do you). My ideas for improving C++ met with enormous resistance. So I did my own language. Ironically, D features have steadily been adopted by C++.

> have there been any mistakes made?

Haha, I could spend months responding to that!

Probably the worst abstraction in the DMC code base is the use of linked lists. They're slow, cache-unfriendly, and leaky. I learned my lesson with DMD, which uses adjustable arrays instead.

I've tried encapsulating the lists, like CodeBuilder in the back end, but it's a LOT of work to get that in. It wouldn't have been so much work if the list abstraction didn't leak the structure of the list at every opportunity.

Re:DigitalMars C/C++ Compiler by krylon on Wednesday May 23, 2018 @01:51AM (#17131706)
> I started writing compilers in order to speed up my game Empire (www.classicempire.com). Compilers turned out to be more interesting :-)

That seems to be a recurring pattern in the history of software. Unix was created for similar reasons (to create a self-hosted development environment for game), and the Linux kernel started out as a terminal emulator.

Re:DigitalMars C/C++ Compiler by glandium on Wednesday May 23, 2018 @07:07AM (#17133084)
> D was started because I got bored with retirement (6 weeks of watching TV will do that do you).

Waw, you retired "young".

Re:DigitalMars C/C++ Compiler by fetbaffe on Wednesday May 23, 2018 @07:48AM (#17133312)
Thank you for Empire, Walter! One of the best turn-based strategy computer games ever created. Many hours of fun.
Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @03:26PM (#17137298)
> One of the best turn-based strategy computer games ever created.

Who'd have thought that would ever happen? I wrote it simply because it was the game I wanted to play.

Re:DigitalMars C/C++ Compiler by wildmusings on Tuesday May 22, 2018 @09:35PM (#17130898)
I just want to thank you for all your work on this. DMC is the very first C compiler I ever used, back in the early/mid 2000s. It was my first real foray into programming, and I was running Windows XP. I remember liking that DMC was free and no-BS. Unlike some of the competition (at least as far as 11-year-old me understood), it didn’t want me to install a whole IDE or other craziness along with it. Good to see that the project is still going.
Re:DigitalMars C/C++ Compiler by WalterBright on Tuesday May 22, 2018 @09:40PM (#17130920)
Thanks for the kind words! I'm auld skool in that I like command line tools, and DMC++ reflects that in not requiring an IDE. The actual compiler and libraries are pretty small.

Back in the aulden days, it could also be run directly from the distribution CD without requiring an install. These days the "install" is merely unzipping the file.

Re:DigitalMars C/C++ Compiler by TallGuyShort on Tuesday May 22, 2018 @10:38PM (#17131120)
Same here! 11 year old me got Turbo C++ as a birthday gift. Once I learned the language, I was frustrated at how Microsoft and Borland and everyone tried to lock you into their ecosystem. MinGW was an option but Digital Mars was the bee's knees. A big stepping stone to my eventual career.
Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @04:44AM (#17132359)
Nice! I didn't get any access to a computer till I was 16. I had to punch cards and hand them to the teacher who'd run them as batch jobs. In college all students had accounts on the college PDP-10, a marvelous machine for its day.
Re:DigitalMars C/C++ Compiler by codyguy on Tuesday May 22, 2018 @11:23PM (#17131276)
Dear Walter,

Thank you for the great work you are doing.

If you could get people to include D in the benchmarks / shootouts that get published it would help improve the popularity of D.

FYI - Thatneedle.com already uses it for part of the backend data processing workflow.

Re:DigitalMars C/C++ Compiler by WalterBright on Tuesday May 22, 2018 @11:50PM (#17131357)
Isaac Gouy is the gatekeeper for the shootout, and he refuses to include D for reasons he's refused to elucidate.

I stopped publishing benchmarks myself 15 years ago as people always assumed my thumb was on the scale.

Re:DigitalMars C/C++ Compiler by igouy on Wednesday May 23, 2018 @11:34AM (#17134971)
>> for reasons he's refused to elucidate

For the simplest reasons that I have stated to you many times!

Including every language implementation that the language author would like to have included is more work than I am willing to do, period.

Sept 13 2008: 63 language implementations were shown-

https://web.archive.org/web/20080913030117/http://shootout.a...

- currently, 27 language implementations are shown.

You could truthfully say "he refuses to include [at-least 30 language implementations]". In that regard, there's nothing special about D.

Re:DigitalMars C/C++ Compiler by exikyut on Wednesday May 23, 2018 @11:48AM (#17135097)
I have no context regarding the history of the benchmarks game. With that in mind, I have a question:

What about you create a technical specification (including both technical depth and common-sense breadth) for what kind of benchmark you'll accept, throw the whole thing on GitHub, and then refuse 99% of pull requests? :) (ie, only accept really really good quality benchmark implementations)

Eventually, enough developers unimpressed that Language X is not adequately represented would step up to the plate and maintain good-quality benchmark code. (This could get pretty interesting with rapidly-evolving languages like Rust.)

Obviously this is all very ideal and I can see so many ways such an endeavor could go horribly wrong, sure. I can also very easily see you having floated such an idea then discarded it for reasons I haven't even thought of.

Re:DigitalMars C/C++ Compiler by igouy on Wednesday May 23, 2018 @12:15PM (#17135339)
What about I work to publish crowd-sourced programs and measurement scripts: so that anyone can make their own comparisons, on their own hardware, against whatever other language implementations they want to write programs for :-)

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re:DigitalMars C/C++ Compiler by exikyut on Wednesday May 23, 2018 @08:53PM (#17139975)
Ah; that certainly works too!

The only thing I wonder about is allowing any given set of hardware to be compared with another set of hardware with anything approaching accuracy.

What would be awesome is if someone could figure out whether they'd need Raspberry Pi Zero to run some algorithm or if they could get away with just using a BBC Micro:Bit, by looking at a benchmark run submitted to the site from an i9-7940X.

Sadly I suspect the amount of realtime introspection needed (memory speed, practical cache coherency (per level), bus saturation, instructions used per cycle) would make this difficult - particularly because, even if a given benchmark was going to go fishing for performance counter info (and I just learned that even the Gen1's ARM 1176-based PMU provides a few, including one that counts instructions), benchmarking memory I/O is a bit harder; PCI DMA MMIO debug cards only map a small range of memory, like 256k or so, and I don't know if such cards can back the region with actual RAM. I suspect the access latency would be so different than from normal RAM that even if this did exist it'd never be used. Sigh.

And then differences in compiler optimization approach would have to be taken into account, and thorough understanding of assembly language for all target architecture(s) would be needed to have the time of day to page through the diff analysis...

Hmm, I think "simple" got left behind a few thousand miles ago. It's kinda (morbidly?) fascinating how different that different architectures are on the ground, hah.

Re:DigitalMars C/C++ Compiler by exikyut on Wednesday May 23, 2018 @11:26PM (#17140853)
Oops:

- To clarify, I meant the Gen1 Raspi.

- I now realize (after having actually had a proper look) that while the Micro:Bit does use "JavaScript" and "Python", they're different, microcontroller-specific implementations, and I should have used a different example there, like an Intel NUC or perhaps an ODROID board or similar.

Re:DigitalMars C/C++ Compiler by igouy on Friday May 25, 2018 @12:05PM (#17155039)
>> The only thing I wonder about is allowing any given set of hardware to be compared with another set of hardware with anything approaching accuracy.

Just systematically enough to be reminded that a different context may have different relative performance.

Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @03:29PM (#17137333)
You've never explained what your criteria is. Just that you didn't want to include D.
Re:DigitalMars C/C++ Compiler by igouy on Wednesday May 23, 2018 @04:11PM (#17137758)
I always did want to include D — which is why we did include D — of course, we also used to include Scala and Clojure and…
Re:DigitalMars C/C++ Compiler by katastic on Wednesday May 23, 2018 @08:43PM (#17139917)
I know you're publicly directly messaging, but as an outsider to the discussion, I don't see any actual mention in your posts why D isn't included. Just that it "used to be."

There are many of benchmark projects that include D and don't appear to be struggling under any kind of massive burden. For example:

https://github.com/kostya/benchmarks

What are your actual reasons for not keeping D... "scala... and Clojure and ..."? The results in the previous link show D as a massive competitor (sometimes 1st place beating C and C++) on both memory and speed. Wouldn't the purpose of benchmarks be... to highlight useful, highly-scoring languages? Isn't that one of the primary reasons people read benchmarks?

(The D implementations are also often smaller in lines of code, as per this benchmark project:

https://togototo.wordpress.com/2013/08/23/benchmarks-round-t...

)

Re:DigitalMars C/C++ Compiler by igouy on Saturday May 26, 2018 @12:10PM (#17162771)
>> I don't see any actual mention in your posts why D isn't included.

Do you see any mention at kostya/benchmarks of why ".NET Core" or Ada isn't included?

>> … benchmark projects that include D and don't appear to be struggling under any kind of massive burden.

Check when those kostya/benchmarks language implementation versions were released.

>> What are your actual reasons for not keeping…

I don't want to do the work.

Re:DigitalMars C/C++ Compiler by codyguy on Wednesday May 23, 2018 @12:04AM (#17131416)
I was a bit surprised by the inclusion of lesser languages and the omission of D !!

Please share the secret of your tenacity and inspiration in the face of such "setbacks". How do you do it on a day to day basis?

Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @04:39AM (#17132338)
I know how good D is and I have a lot of confidence in it. There are a lot of great people using it that are getting their jobs done faster & better and are thereby making more money. That's what matters to me.

Everybody likes to make more money :-)

Back when I was a brand new engineer at Boeing, I was talking to my lead engineer about the beauty of aerospace engineering. He smiled and said I didn't get it. Boeing wasn't making airplanes, they were building money making machines for airline companies. That the airplane turned out to be a beauty was just a happy side effect!

D isn't about my personal aggrandizement. It's about how effective it is for users at solving their problems and making money for them.

Re:DigitalMars C/C++ Compiler by e12e on Wednesday May 23, 2018 @02:03AM (#17131742)
Has there been any recent discussion on this? I suspect earlier reasons might have included D not being packaged for Debian?

It can be though to shake "early license impressions" - D (dmd specifically) is one example, Ada (FSF GNAT vs AdaCore's GNAT Pro and Ada-gnat - GPL w/o runtime exception) is another.

[ed: if others are interested in "make your own measurements and host it yourself", relevant page with link to code etc appear to be:

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

]

Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @04:20AM (#17132257)
> any recent discussion

Not since I asked him to stop dropping by the D forum to remind us that he wouldn't include D in the shootout.

I've personally lost all interest in it.

(The benchmarks are also small and too easily gamed by the author of the benchmark code, and the compiler developer. I encourage people to run timing tests on their own code, as that is what matters to them.)

Re:DigitalMars C/C++ Compiler by girvo on Wednesday May 23, 2018 @05:23AM (#17132568)
My experience has been that I get better ideas of benchmarks by profiling my real application code, porting the hotspots to the new language or framework within a mostly bare skeleton and testing it. It’s not perfect, but gives me a better idea as to whether moving will actually help!
Re:DigitalMars C/C++ Compiler by exikyut on Wednesday May 23, 2018 @12:03PM (#17135236)
> I encourage people to run timing tests on their own code, as that is what matters to them.

This is the heart of the matter: benchmarking toy and unrelated bits of code amount to the same thing.

I think what people really need is a straightforward, accessible understanding of where a software implementation is inefficient. Design inefficiency can sometimes be "hacked over" (read "paved over") a bit like evening out technical debt; implementation inefficiencies, perhaps not so much. Making a complex database query faster by fiddling with (very) obscure SQL options because a given vendor's query planner is broken in a rare edge-case is one example that comes to mind.

I think it's especially sad when a software implementation becomes renowned for its inefficiency. It kinda takes the heat off in what I would argue is a very unfair way, like it legitimizes slowness like speed isn't a worthy pursuit... and then we wonder why our computers are slow. (Yeah, I'm thinking about Python here... and to a small extent many interpreted languages.)

In the context of D (and now DMC++ :D), so specifically compilers, it would be interesting to know what areas of the language don't generate especially fast code, or what bits might produce code that uses a little memory than it could, etc. Because that's what people really want to know before they take the time to write/port; and if they know about all the instances of "don't do XYZ in this very specific way" ahead of time, maybe they can write the best possible code on the first try! (Design and implementation are intertwined in practice.)

I suspect the list of such "avoid"s may not be long. It might make for a particularly efficient kind of developer user manual.

Re:DigitalMars C/C++ Compiler by e12e on Wednesday May 23, 2018 @11:06AM (#17134737)
I don't really see a big problem with a little bit of gaming on the benchmark-code side; with a few implementations to compare, it might even give some hints for idiomatic efficient code.

Gaming from the compiler/runtime side would be uglier - but I guess it is somewhat mitigated by real languages running the "general release" version.

No harm in "fastest way to list first 1000 prime numbers" being "print static list of first 1000 prime numbers".

Hand there's some value in having a standard benchmark harness that works easily across languages - as a helpful tool with "running your own benchmarks". Assuming the harness is any good, that is.

Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @03:35PM (#17137390)
> I don't really see a big problem with a little bit of gaming on the benchmark-code side

I just got tired of the vitriol leveled at me with no basis. Things like I must have "sabotaged" other compilers. Probably the absolute worst one was when the journalist decided that Datalight Optimum C ran the benchmarks so fast, it must be a compiler bug and removed the benchmark results from his compiler roundup, calling DC a buggy compiler.

The reality was Datalight C was the first C compiler on DOS to do data flow analysis, and it deleted dead code. (Benchmarks of that era did nothing useful, and dfa detected that.) No cheating at all. A couple years later, everyone did dfa.

Re:DigitalMars C/C++ Compiler by petre on Wednesday May 23, 2018 @07:58AM (#17133357)
I did run my own prime number crunching benchmark for fun and D blew Rust away but lagged behind Go. I used mutable Vec and HashSet in Rust, associative arrays and arrays in D, maps and arrays in Go to store the sieves.
Re:DigitalMars C/C++ Compiler by dvfjsdhgfv on Wednesday May 23, 2018 @08:52AM (#17133697)
You see, that's the point - even if you do something as simple, there are many ways to do it (and different compiler versions, especially in the case of D), different optimizations at the code and compiler level and all that - it's practically impossible to have a reliable, comprehensive benchmark.

(That said, D is lightning fast for me!)

Re:DigitalMars C/C++ Compiler by steveklabnik on Wednesday May 23, 2018 @09:55AM (#17134183)
HashSet uses a cryptographically secure hashing algorithm by default, it’s gonna be slow.
Re:DigitalMars C/C++ Compiler by petre on Wednesday May 23, 2018 @12:15PM (#17135335)
What's the Rust equivalent of Go maps or D associative arrays then?
Re:DigitalMars C/C++ Compiler by palmtree3000 on Wednesday May 23, 2018 @12:30PM (#17135464)
The Rust HashMap and HashSet implementations are generic over hasher: you can pick a faster one if you don't have to worry about getting ddos'd. Last I checked, the go-to fast hasher was fnv: https://doc.servo.org/fnv/
Re:DigitalMars C/C++ Compiler by rurban on Thursday May 24, 2018 @06:35PM (#17149104)
How often do I need to explain that this siphash claim of DDOS protection is utter nonsense. siphash can easily be brute forced like every insecure hash function (<256 bits), and proper DDOS protection can only be provided by a proper collision strategy. Even DJB himself does so.
Re:DigitalMars C/C++ Compiler by petre on Thursday May 24, 2018 @02:42AM (#17141582)
Well, it's not in the standard lib and I couldn't get my program to compile. Compare that to D or Go, where you don't have to fight the copiler.
Re:DigitalMars C/C++ Compiler by steveklabnik on Thursday May 24, 2018 @10:40AM (#17144390)
Rust has a different take on the standard library than many other languages. It's kept quite minimal, because it's trivial to use a package.
Re:DigitalMars C/C++ Compiler by petre on Thursday May 24, 2018 @11:34AM (#17145003)
Is there any way to use it directly in the source w/o having to create a Crate.toml and src dirs? Is there a getting started document? Dub recently included such a feature.
Re:DigitalMars C/C++ Compiler by steveklabnik on Thursday May 24, 2018 @11:50AM (#17145173)
That's the hard way. `cargo new` generates both for you, so you don't need to do any of that stuff manually.

If you really, really want to, you could use https://crates.io/crates/cargo-script to do the way you're talking about.

https://doc.rust-lang.org/cargo/ has installation, getting started, a reference, all of that. It needs some work, but for the basics of doing this, it's got it all.

Re:DigitalMars C/C++ Compiler by steveklabnik on Wednesday May 23, 2018 @12:56PM (#17135710)
Yup, this is 100% correct.
Re:DigitalMars C/C++ Compiler by igouy on Wednesday May 23, 2018 @11:39AM (#17135015)
Re:DigitalMars C/C++ Compiler by e12e on Wednesday May 23, 2018 @07:28PM (#17139428)
Not sure why you're getting down voted was about to post something along the same lines (though admittedly linking to a couple of threads, not just the search). But I don't think everyone on hn would be aware of the d forums (nor that it's a rather magnificent piece of "groupware" with usenet and irc support on top of (or should I say beneath) a quick Web interface.

https://github.com/CyberShadow/DFeed

Re:DigitalMars C/C++ Compiler by igouy on Friday May 25, 2018 @01:01PM (#17155640)
From my perspective, the relevant "couple of threads" would be the old discussions which showed various people in the D community actually had the measurement scripts working with D programs: and yet that work becomes abandoned, so there's nothing like —

https://github.com/kostya/crystal-benchmarks-game

Re:DigitalMars C/C++ Compiler by runawaycosine on Wednesday May 23, 2018 @03:21AM (#17131987)
Thank you for the AMA. :)

What is your opinion of Rust?

It seems to me like Rust and D have the same target audience and both want to be the next C++.

Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @03:46PM (#17137517)
Rust and D are very different languages. I suspect the choice between the two is more a matter of personal taste.

D, for example, achieves memory safety in a very different way than D's borrow checker.

Re:DigitalMars C/C++ Compiler by thespirit on Tuesday May 22, 2018 @09:19PM (#17130845)
Has the re-write to D felt productive? May it have been better to start from scratch?

Was the "D as a better C" approach inspired by your want to transition DMC to D?

Re:DigitalMars C/C++ Compiler by WalterBright on Tuesday May 22, 2018 @09:26PM (#17130870)
> Has the re-write to D felt productive?

Yes, it's been oddly satisfying.

> May it have been better to start from scratch?

Ah, the age old question. I can guarantee, though, the answer is no. It took me maybe a couple weeks to convert the entire front end from C++ to D. Contrast that with the Warp preprocessor I wrote for Facebook, which took many months, and I knew what I was doing. And that is just the preprocessor!

Basically, writing a C++ front end takes 10 man years. I know of no effort that took less time, and this is assuming the best in the business doing the writing.

> Was the "D as a better C" approach inspired by your want to transition DMC to D?

Partially, yes. And certainly doing the transition work has improved betterC. Nothing like proving it works than translating a crotchety old horrifyingly complex piece of code written in 1980's style.

I plan on doing this to all my old projects that are still in use.

Re:DigitalMars C/C++ Compiler by loup-vaillant on Wednesday May 23, 2018 @11:57AM (#17135167)
> Basically, writing a C++ front end takes 10 man years.

This is insane. No language needs to be that complex. I guess that's the power of backward compatibility: forcing an entire industry to dig itself into an ever growing hole, because in the short term we move faster by digging than by first clawing our way out.

Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @03:43PM (#17137485)
Mastering C++ takes about 10 years, too :-)

(Yes, you can be productive in C++ in much less time.)

Re:DigitalMars C/C++ Compiler by stochastic_monk on Wednesday May 23, 2018 @12:22AM (#17131459)
I haven’t yet tried D, but it’s on my list. It’s truly impressive to have a C/C++ contender which can actually compare in performance.

It’s a less serious question to ask, but was the name in any way related to Run-DMC, the 80s hip hop group?

Re:DigitalMars C/C++ Compiler by krylon on Wednesday May 23, 2018 @01:58AM (#17131723)
I briefly dipped into D about two years ago. In terms of features, it is similarly big as C++, but a lot more sanity-oriented in terms syntax and semantics. The library ecosystem could be better, but IIRC, it is possible to use C (maybe even C++) libraries from D.

The community is awesome, super friendly and super helpful even in the face of the most stupid newbie-questions I could come up with. ;-)

In the end, I backed out, because the language was too big and complex for my taste and needs. But if you kind-of-like C++, you are likely to fall in love with D.

Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @02:47AM (#17131868)
D is indeed a fully equipped machine shop, but nobody says you have to start with the Bridgeport milling machine. You can write very capable programs with just the C-ish subset.
Re:DigitalMars C/C++ Compiler by krylon on Wednesday May 23, 2018 @07:54AM (#17133336)
I tried, I really did, but then I got distracted by all those shiny features and was unable to resist the temptation to play with them all. :-) I had the same problem with C++.

I will probably give it another try one day, if only for the super-friendly and welcoming community.

Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @02:43AM (#17131852)
No - the comparison never occurred to me.
Re:DigitalMars C/C++ Compiler by exikyut on Wednesday May 23, 2018 @12:19PM (#17135365)
Hopefully you see this

This is a question I'm sure many have: how feasible would it be to get DMC++ emitting Linux code?

D uses the same backend, in theory, but I'm not sure how much divergence there is between the D backend and this code.

Perhaps you could get Hello World to build, make a gigantic list of everything that's broken, and see how much traction (hopefully) appears out of thin air :)

I love tcc for its "oh it already finished" compilation time (300ms :D), even (and especially) on older hardware. I wish there was something out there to compare it with; it's quite unfortunate it sits on its own, because it hasn't had an official release in in 4 or so years.

Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @03:52PM (#17137582)
You're right, the pieces are in place to do it. I've just never taken that last step.
Re:DigitalMars C/C++ Compiler by exikyut on Wednesday May 23, 2018 @11:24PM (#17140839)
Oh, all right!! Cool! I'll definitely be keeping a slightly closer eye on DMC++ now and watching it for changes then, I think :)

I've wanted to play with C++ for quite some time, but (as crazy as it might sound) gcc/clang's multi-second compile times for the smallest of things (eg, messing around with FLTK, which doesn't go that crazy with C++ features) makes tinkering a bit distracting. Multiple seconds for medium+ things, maybe, but tcc has spoilt me when it comes to rapid iteration, heh.

A C++ compiler for Linux with speed reminiscent of (or maybe even similar to!) tcc would have a very big (if quiet) impact for a few people, I reckon. Something nice to have one day.

(Unrelated, but fiddling around to get `dmd -c' + external libphobos.so + ld.lld makes for especially nice compilation speed :) )

Is there any specific reason the last step you speak of hasn't been taken? Just time/inertia, or reluctance for technical reasons? I think many people would be interested to hear what effort you'd want to fold into a Linux release, if there are any technical issues.

Re:DigitalMars C/C++ Compiler by MaxBarraclough on Wednesday May 23, 2018 @11:47AM (#17135088)
Hi Walter, great work as always.

I'm a fan of D as a language, but how do you respond to the question of "We should just go with C# or C++, why go with a middle-ground language like D that few programmers know?"

Given that D --> C++ migrations have happened in the past, this strikes me as D's big challenge: finding its place.

I'm thinking in particular of OpenMW: https://forum.openmw.org/viewtopic.php?t=2189

Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @03:40PM (#17137455)
I ask them how much money they've lost on C/C++ buffer overflows in the past, and how much they're willing to lose on them in the future :-)

Heartbleed. A C buffer overflow bug so disastrously expensive it has it's own logo!

(I know C# doesn't have buffer overflows either, but C# is a much bigger change than going to D, and is less portable.)

Re:DigitalMars C/C++ Compiler by MaxBarraclough on Friday May 25, 2018 @05:10AM (#17151824)
Valid point, buffer-overflows can be disastrous and should be easily preventable, or impossible, in a sensible language.

For OpenMW though, it's not a concern. They're building a single-player video game; the input is always trusted. As far as I can see, they made the right call by moving to C++.

Again, I really like the D language - but I can see why a project manager would go with C++.

Re:DigitalMars C/C++ Compiler by earenndil on Wednesday May 23, 2018 @08:04PM (#17139665)
TBF, c++ has std::vector and std::list.
Re:DigitalMars C/C++ Compiler by renox on Thursday May 24, 2018 @11:14AM (#17144791)
And with the "usual" access '[]' std::vector doesn't bound check either, you have to use 'at' for this (except in some library with some flags ), doesn't seem that safe to me!
Re:DigitalMars C/C++ Compiler by MaxBarraclough on Friday May 25, 2018 @04:54AM (#17151753)
Agree. It strikes me as silly that C++ doesn't provide something like a `CHECKED` macro, so that operator[] could always be range-checked in debug/dev builds, but not in release builds. The two-different-methods approach seems awfully clunky - what ends up happening is that no-one uses the `at` method. I see no good reason not to enable range-checks by default in debug builds.

This 'unsafe by default' philosophy isn't universal in C++ though. The smart-pointer class-templates are always thread-safe, despite the possible performance consequences.

Re:DigitalMars C/C++ Compiler by ximeng on Wednesday May 23, 2018 @08:00AM (#17133367)
What's the business model / long term plan for sustaining development on the compiler / D?
Re:DigitalMars C/C++ Compiler by exikyut on Wednesday May 23, 2018 @12:10PM (#17135285)
Not OP, but https://digitalmars.com/consulting.html has sat around for a while. I get the (un-citeable) impression it has a few takers (simply by virtue of the fact that the link exists, more or less).
Re:DigitalMars C/C++ Compiler by ximeng on Wednesday May 23, 2018 @08:55PM (#17139986)
There is also https://dlang.org/foundation/about.html which has links to a donations page which has around 3k USD a year of income.
Re:DigitalMars C/C++ Compiler by codyguy on Wednesday May 23, 2018 @01:06AM (#17131586)
I was just looking at your classicempire site and stumbled upon the rejection letters!!

Did you take up Sirius's offer to act as broker for 30% cut on deal?

Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @02:43AM (#17131850)
No. 30% is absurdly high.
Re:DigitalMars C/C++ Compiler by codyguy on Wednesday May 23, 2018 @03:17AM (#17131961)
Could you enlighten on how you managed to take those to market after the rejections?
Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @04:41AM (#17132351)
Interstel didn't reject it, and Interstel Empire made history!
Re:DigitalMars C/C++ Compiler by mhd on Wednesday May 23, 2018 @08:33AM (#17133565)
Did the rewrite give you any interesting perspectives on how to structure BetterC differently to both C and D?
Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @03:49PM (#17137546)
More like it just made clear some shortcomings that needed to be fixed.
Re:DigitalMars C/C++ Compiler by le-mark on Wednesday May 23, 2018 @05:54AM (#17132725)
Is the exception handling DMC C++ implements zero cost or setjmp/longjmp based?
Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @03:51PM (#17137573)
C++ EH is never zero cost, despite the hype. Herb Sutter just wrote a proposal to redo the semantics in C++ to reduce the cost of it.

DMC++'s EH is not setjmp/longjmp, it is Windows SEH (Structured Exception Handling) based. The 32 bit DOS extender EH is based on my own table-based design.

Re:DigitalMars C/C++ Compiler by MaxBarraclough on Wednesday May 23, 2018 @11:41AM (#17135034)
I'm pretty clueless here, but from a quick search on GitHub it looks like there's support for NT exception handling, and DWARF exception handling. (I realise this doesn't really answer your question, but it's a start.)

https://github.com/DigitalMars/Compiler/blob/7a33233c/dm/src... https://github.com/DigitalMars/Compiler/blob/7a33233c/dm/src...

Re:DigitalMars C/C++ Compiler by gok on Wednesday May 23, 2018 @02:44AM (#17131858)
Are you adding any features to the C/C++ compiler or just migrating to D?
Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @04:41AM (#17132345)
Never mix migrating with adding features. It's the path to the dahhk side!
Re:DigitalMars C/C++ Compiler by girvo on Tuesday May 22, 2018 @10:31PM (#17131095)
Yours was the compiler I used to learn C++ in 2003. Thank you!
Re:DigitalMars C/C++ Compiler by WalterBright on Wednesday May 23, 2018 @04:44AM (#17132364)
Having nice users like you guys is very gratifying!
Re:DigitalMars C/C++ Compiler by colomon on Tuesday May 22, 2018 @11:16PM (#17131255)
I learned C++ in 1989 using one of his earlier compilers!
Re:DigitalMars C/C++ Compiler by c-smile on Tuesday May 22, 2018 @11:56PM (#17131379)
I still have somewhere Walter's Zortech C++ that was life saver for me at one point.

H/W: i386 machine 25 mhz, 2mb RAM. Internet: No OS: MSDOS IDE: MultiEditor + Zortech C++ Where: in the middle of nowhere - small town between Europe and Asia.

At some point upgraded the whole setup to Symantec C++ on Windows - for unknown now reasons.

Re:DigitalMars C/C++ Compiler by rurban on Thursday May 24, 2018 @06:38PM (#17149118)
For me also Zortech was gold. The Symantec version was also fine.

Loved the compiler and the UI. Best UI ever. Esp. if compared to the Turbo/Borland stuff and then MSVC.