Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. GPT-6 Sol and Luna(openai.com)
    535comments
  2. Claude Opus 5.5(anthropic.com)
    744comments
  3. Microsoft killed FoxPro in 2007. Anyway, here's FoxPro revived(foxscript.org)
    73comments
  4. OpenAI GPT–6 Astra breaks Enigma message that has resisted solution since 2005(cryptocellar.org)
    350comments
  5. 'We hacked the FBI:' Hackers say they have data on all FBI employees(404media.co)
    181comments
  6. SAML: A fractal of bad design(trailofbits.com)
    60comments
  7. Claude Opus 5.5 Intelligence, Performance and Price Analysis (Max)(artificialanalysis.ai)
    55comments
  8. WordPress: Unauthenticated path traversal leading to conditional RCE(github.com/wordpress)
    72comments
  9. Unreal Agent(unreallabs.ai)
    59comments
  10. ReBarUEFI: Resizable BAR for almost any UEFI system(github.com/xcuri0)
    discuss
  11. An update on how we confirm your age group on Discord(discord.com)
    34comments
  12. Native apps written in TypeScript and CSS(github.com/geastack)
    16comments
  13. How did AMD Ryzen get 50% faster in two years?(lemire.me)
    48comments
  14. Did OpenAI solve the wrong Navier-Stokes problem?(scientificamerican.com)
    34comments
  15. MUNI Heritage Weekend in San Francisco(lawrence.lu)
    35comments
  16. The UV index is not the warm sensation of sunlight on bare skin(asciitweezers.com)
    34comments
  17. Markdown in /src(htmx.org)
    31comments
  18. OpenAI is well positioned to fast-follow Jev(arcturus-labs.com)
    178comments
  19. Show HN: JevBench, a reproducible benchmark for typed decision models(benchmarkheaven.com)
    7comments
  20. The trouble with 'ntile()'(djnavarro.net)
    discuss
  21. Show HN: Training a model to identify AI web content from structure alone(arxiv.org)
    8comments
  22. George Lucas Returns to Earth, Bearing Gifts(commonedge.org)
    29comments
  23. 16-bit Intel 8088 chip (c. 1985)(allpoetry.com)
    13comments
  24. Rabbit Hole: Minimum L-seams(fractalkitty.com)
    5comments
  25. People hooked on vapes try a new way to quit: cigarettes(bloomberg.com)
    65comments
  26. Pentagon says overreliance on AI contributed to missile strike on Iran school(bloomberg.com)
    160comments
  27. Apple has added persistent 'ads' to iOS, and it's driving users crazy(techradar.com)
    426comments
  28. There's a high chance of devices being sold with GrapheneOS preinstalled in 2027(grapheneos.social)
    103comments
  29. Launch HN: Coverage Cat (YC S22) – Umbrella insurance via your personal agent(coveragecat.com)
    19comments
  30. The JavaScript Midlife Crisis(maroun-baydoun.com)
    7comments

Ruminations on D: An Interview with Walter Bright

156 pointsby 10y agodlang.org
78 comments
10y agoHN ↗

    We nailed it with arrays (Jan Knepper’s idea), the
    basic template design, compile-time function execution 
   (CTFE)

One of my favourite things about D is that it has a full compile-time D interpreter. You can do "template metaprogramming", so to speak, in the same language as D itself (it's probably a bit more fair to compare it to how lisp macros are "compile-time").

It's a bit sad that Rust is getting all of the attention in the spotlight, because D is a great, modern, safe language. If you've only heard about D 15 years ago and never tried it again, give it another look. The current D is really a new language, which was briefly called "D2" for a while.

Now, if Symantec could just fix the stupid licence of the reference compiler...

https://forum.dlang.org/thread/lodjbuvdhimrvrdngldy@forum.dl...

10y agoHN ↗

If inline asm or non-portable casts were allowed, D programs would compile inconsistently on different architectures. Compile time IO doesn't make much sense either. Not all limitations are shortcomings.

10y agoHN ↗

  > Compile time IO doesn't make much sense either.

While I agree with D's decision here, there are other languages which do allow anything at compile time. See Jai, for example.

10y agoHN ↗

And Common Lisp, and Scheme, and Elixir, and Clojure, and I'm sure I'm missing a bunch :)

10y agoHN ↗

Even... Haskell! Dundundun! (I'm referring to Template Haskell.)

As it turns out (IME) referencing arbitrary data (such as a database schema queried from a 'live' database) is actually of quite limited value.

Where I actually agree that it makes sense is the 'read-a-checked-in-file-and-generate-code-at-compile-time-from-that'. Otherwise, you're mostly just looking at a lot of pain compared to just generating code (that you might check in).

10y agoHN ↗

Compile time read have sense. For example, reading a XML to build a GUI on complete time instead on runtime (I see you GTK builder).

Actually you can do this on CTFE on D, doing an import of a file and dumping it to an enum. The only big pitfall of this, is that enforces to read the whole file by the compiler.

10y agoHN ↗

I withdraw my claim that compile time IO doesn't make any sense, but it is something I would be worried about. I wouldn't want the executable my build process produces to be changed by what files are laying around on the disk. Mixing in all of the state in the file system with something you want to be mostly stateless (your build process) seems like a dangerous idea to me.

10y agoHN ↗

The compiler already depends on the state of the file system though, notably because it depends on the source code. In the above case, the xml is essentially just another source file that happens to not be in the same language.

An important difference is that the compiler doesn't know it's using that file ahead of time, which could have some unforeseen consequences, but I don't see anything immediately worrying about that fact since the compiler didn't know about the source either at it's own compile time.

10y agoHN ↗

How is it any different from, say, a makefile?

10y agoHN ↗

reading a XML to build a GUI on complete time instead on runtime

It can be done with:

    void[] ctData = import("file.xml");

For example, this feature is used in vibe.d to compile an HTML template language into more optimized code.

10y agoHN ↗

Compile time read have sense.

Considering what we've known about the typical behavior of production programs for decades, why isn't there also an "Initialization Time" in addition to Compile Time and "runtime." (Steady State Time?)

10y agoHN ↗

Some languages do have a "life before main", but it's not always clear that it's a good thing. I don't have a link offhand, but I think it has a bad rap because it's often used to initialize some kind of global state, with all the cons global state brings.

10y agoHN ↗

I remember a study of production Python servers that showed that past an "initialization period" the types of objects in variables settled down and essentially became static. It seems to me that this is a very common across many languages, and that this pattern could be exploited in a number of ways. (Compiling "dynamic" languages in the above case.)

I think it has a bad rap because it's often used to initialize some kind of global state, with all the cons global state brings.

So then what if the language didn't have global state, or only had immutable global state?

10y agoHN ↗

D is a great, modern, safe language

It's very nice, but it isn't memory safe.

10y agoHN ↗

I wonder, could a portable ownership model be implemented with the templates?

10y agoHN ↗

I thought there was a DIP for this, but cannot seem to find it now.

10y agoHN ↗

Not soundly, no. The borrow check requires flow-sensitive analysis. The lifetime typechecker requires subtyping-aware extensions to Hindley-Milner.

10y agoHN ↗

Can you going into some details about this? Like proofs?

10y agoHN ↗

It has been years since I have actively programed in D, so take this with a grain of salt, but my understanding is that D only guarantees memory safety in its @safe subset. See here: https://dlang.org/spec/memory-safe-d.html

Context: safe Rust is also a subset of unsafe Rust. But when people mention a language without qualifiers, they mean whatever the default is. D (appears) to default to a non-memory safe language, and Rust defaults to a memory-safe one. I believe this is what OP meant. (this also ignores the relative feature sets of the various sub/super-sets)

10y agoHN ↗

By default, D has no safeguards to prevent you from doing memory-unsafe things, and afaik no compile-time checks short of marking your main method as @safe. However, because the language is by default memory managed, it is fairly easy to stick to safe code without this by avoiding pointer/cast voodoo.

10y agoHN ↗

Fortunately with array bounds checks and default initialized variables, memory corruptions aren't very common in D.

10y agoHN ↗

Yes, Rust picked the better default and D is too mature to change it now, unfortunately. Likewise with "pure", "const", and maybe even "nothrow" and "nogc".

However, I don't think it is such a big deal, since you can patch it quite well. Mark your main function as @safe and you are force to make everything @safe (or @trusted as a workaround). The type checker will tell you where to look next.

It is interesting that Rust functions are not pure by default. I guess (did not follow the design discussions), because purity is too limiting. D came up with the concept of "weakly pure", which is useful and strong enough. Also you need transitive const to turn a weakly pure into really pure function.

10y agoHN ↗

Always:

    import std.c.stdio;

    int main() {
	int x = 7;
	int* p = &x;
	 printf ("%d\n", *(p + 1));
	return 0;
    }

This compiles in D and violates memory safety.

If you prefer a documentation answer(https://dlang.org/spec/arrays.html#pointers) These are simple pointers to data, analogous to C pointers. Pointers are provided for interfacing with C and for specialized systems work. There is no length associated with it, and so there is no way for the compiler or runtime to do bounds checking, etc., on it.

10y agoHN ↗

Add '@safe' to main()'s declaration and it will no longer compile.

10y agoHN ↗

    import std.stdio;

    @safe int f() {
      int* x = new int(6);
      delete x;  // !!
      return *x; // !!!!
    }

    @safe void main() {
      writeln(f());
    }
10y agoHN ↗

It's close, and we're working to close the remaining gaps.

Probably the biggest memory safety issue is buffer overflows, and D does a good job stopping that (array overflow checking).

10y agoHN ↗

It's a bit sad that Rust is getting all of the attention in the spotlight

This isn't a zero-sum game! D is a fine language.

10y agoHN ↗

There is a limited resource here, which is programmers' time and attention. If everyone is scrambling to Rust, they will probably not give D as much attention. Without attention, D will probably not have a healthy collection of 3rd party libraries and tools.

10y agoHN ↗

I think D have been already given tons of attention, especially in its early years (just like other newer languages). That early-day reception defines the acceptance in, say, next decade---at which Rust has been relatively excelled than D, IMHO.

10y agoHN ↗

To someone with only a passing interest, but a real interest nonetheless, D's position in the spotlight is a lot more comfortable than what's going on with rust. After a while, the way every thread about c, c++, systems programming, or operating systems draws the same predictable rust comments feels like being assaulted by a lunatic wielding a cheese grater.

10y agoHN ↗

I've seen this phenomenon called 'Rustwins law' as it bears striking similarities to Godwin's law in its inevitability.

10y agoHN ↗

If the law suggests that Rust wins, I'm sure the Rust community will not strenuously object.

10y agoHN ↗

If it's going to match Godwin's Law, then whoever mentions Rust automatically loses the argument...

10y agoHN ↗

Godwin's law isn't about losing the argument. It's just an observation that national socialism is going to be mentioned in the limit as the conversation grows without end.

10y agoHN ↗

I took a look again at D this last couple of weeks and it was a way better language than I remembered.

It seems like a very solid language. You can write low level C like code if you really want to, but it defaults to safer, higher level code without losing much efficiency.

I'm going to try it out with some bigger projects. I have some issues. Windows support seems a little flakey but it's ertainly usable (the default dmd compiler works very well on windows but the code it makes isn't the best it could be, and ldc makes much higher quality code, but isn't quite stable on windows. (Although it's certainly looking good enough to use).

I think it's well worth a look. I like it a great deal more than Rust

10y agoHN ↗

I like a lot of things about D, but I don't like the fact that it seems stuck in the OOP fad from 15 or so years ago. Go and Rust have both abandoned this whole idea of making "classes" in favor of constructs like structs, enums, traits and interfaces. I wish D had gone this route as well, but other than that it seems like a nice language.

10y agoHN ↗

Eh.. I wrote a 1000 line linux "system" application in D. Didn't use a single class. All enums and structs pretty much like you would approach it like good "C" programmer while still using all of D's goodness.

10y agoHN ↗

D enums are not the good kind of enums (i.e. sum types, like in Rust), though. Instead they have some silly implementation of sum types using classes in std.variant.

10y agoHN ↗

It's not a class, it's a struct (as a value type), it's fine if you disagree with the idea of OOP, but don't come in with an incorrect assumption of how the language is actually used in the wild.

But sure, I would agree that having a natively implemented variant type would be better, even if this one can serve many of the same purposes.

Class = reference type, supports polymorphism, inheritance

Struct = value type, does not support polymorphism, inheritance

The variant type based on a struct is implemented through the language's metaprogramming facilities.

10y agoHN ↗

this is my primary "complaint" about D; i strongly prefer languages with algebraic datatypes and pattern matching built in. other than that it does indeed look like a beautiful language.

ironically, i haven't really used D for the same reason i haven't really used rust - i've yet to have a project for which ocaml wasn't a better choice. (i know both D and rust address things ocaml doesn't, but they aren't the things i tend to need for my personal projects.)

10y agoHN ↗

You'll never satisfy everyone I guess. For me personally, I wish D went more the OOP route (as the Tango library did in D1 times), rather than the template/metaprogramming way it went with. Some of the error messages from D rival C++ STL template vomit.

10y agoHN ↗

Heh, that's exactly what I do like about D—the generic programming/metaprogramming paradigm instead of OOP.

You can get some very elegant and efficient code with D, while OOP tends to have more runtime overhead.

10y agoHN ↗

I actually almost never use the OOP parts of D because metaprogramming generally offers a more elegant solution to the problem than polymorphism.

That doesn't mean there's no downside to the metaprogramming in terms of project complexity, but once you get past the part where you rebuild the universe from scratch it's smooth sailing.

10y agoHN ↗

I've been using the language since 2013, and I don't think I've ever written a class. My strong preference is functional programming.

10y agoHN ↗

What I found interesting is that the two high profile projects mentioned in the post written in D are no longer maintained, which is kind of weird.

10y agoHN ↗

Maybe they are completely finished and bug free ;-)

10y agoHN ↗

I love D language, and all what it needs is a high profile production project that uses D. and then more people will look into considering using D in their production environment.

10y agoHN ↗

See what Walter says in the interview about that.

10y agoHN ↗

You were 42 when you started working on D and I guess it is the first language you designed? Talk about why you started working on it so late...

What kind of question is that? Anders Hejlsberg was what, 39 when he started working on C# and 52 with Typescript? It's the same as with screenplays. You start writing when you have experience.

10y agoHN ↗

It struck me as odd, too, but then I realized I didn't know the cultural background of interviewer or interviewee and maybe it was a welcome, completely normal question. It's useful to keep your own dispositions in mind when analyzing someone else's conversation.

10y agoHN ↗

Not valid, since question comes preloaded with an assumption language designers start a lot earlier ("so late").

10y agoHN ↗

That's a fair point. I hadn't looked at it that way.

10y agoHN ↗

maybe. perhaps they're referring to his long career and curious about what motivated him at that point to pursue the project versus times previous.

10y agoHN ↗

When you put it that way, could be that as well. Bad interviewer is bad, I guess.

10y agoHN ↗

I think serial PL designer Wouter van Oortmerssen started creating languages in his teens...

10y agoHN ↗

Programming Amiga E by Wouter van Oortmerssen was such a joy compared to C back in the day.

10y agoHN ↗

Standard disclaimer: It's been a while since I watched that video, but this was before Rust 1.0, and so all statements about Rust in it should be taken with a grain of salt. Lots changed.

10y agoHN ↗

Great, I will stop worrying about that, then. I'd actually been meaning to re-watch this specifically to double check for a while.

10y agoHN ↗

Good point, and I suppose some of the same may be the case about the other languages as well. My own disclaimer, though it shouldn't really be needed: I only put the link out of interest. No points to make.

10y agoHN ↗

Definitely didn't assume you were. Because there was so much interest in Rust pre-1.0, there's a lot of outdated material out there, and so it can confuse people. https://github.com/rust-lang/rust/issues/14954 specifically was a huuuuge headache for a long time.

This is slowly changing, of course, the farther we get away from 1.0. I still worry about it, though.

10y agoHN ↗

Cool. Then it's good that you're raising these points.

10y agoHN ↗

D has a similar problem. There is quite some outdated material on D1 out there. :)

10y agoHN ↗

Yes. There are pages that start with dlang.org/phobos/... and others that start with dlang.org/library/... I need to confirm but I think the "Phobos" ones are for the current library of D(ver)2 and "library" ones are for Tango, a different library that diverged from the standard one during the D1 days - something like that. I think I read that they have later sort of unified again, either that, or Tango is obsolete or less recommended. Maybe others who know more can comment.

10y agoHN ↗

Everything on dlang.org is fine. The phobos/ and library/ sections are two versions of the same content, generated from the same source files at the same time. The library/ stuff is the future, but not completely polished yet.

The obsolete stuff is dsource.org. Most of it does not compile anymore and has no maintainers. If you are looking for libraries to use, go to https://code.dlang.org/.

Phobos is the standard library. Tango is a D1 projects. Most of it has been ported and integrated into Phobos now. Some people still like the Tango XML library: https://github.com/SiegeLord/Tango-D2

10y agoHN ↗

Wow, didn't know that stuff. Thanks for explaining.

10y agoHN ↗

I don’t worry too much about that. I spend my efforts making D the best language possible, and let the metrics take care of themselves. It’s like being a CEO; he shouldn’t be sweating the stock price, he should be working on making money for the company, then the stock price will take care of itself.

I wish this mindset was more prevalent in open source. I find that the best (most well-designed and useful) projects are those that don't concern themselves with marketing.