Live data from Hacker News

Better C – A subset of D Programming Language

dlang.org

21–30 of 360 posts

Re: Better C – A subset of D Programming Language

#21

Earlier quoted context omitted.

I'm sorry that the question is not really related to your compilers but I'm curious about your opinion on Zig?

I know nothing about Zig.

You should probably address that. It's a serious competitor to D (as better C). At the very least, you might see some ideas worth stealing!

Re: Better C – A subset of D Programming Language

#22
post #3

One thing that really annoyed me about D is that its documentation lists basically every function with an 'auto' return type. Auto should be completely banned from documentation, it's a complete hindrance. It's the single biggest contributor to why I stopped using D for personal projects - I was so tired of having to hunt down what functions are going to return, sometimes having to resort to just using it and looking…

I think it’s really interesting that as dynamically-typed languages increasingly encourage explicit type hints, statically-typed languages are recommending “almost always auto”.

Re: Better C – A subset of D Programming Language

#23
post #8

Walter here - AMA!

Do you know of use of “BetterC” in real-life (i.e: for non-pet projects)? It would be interesting to hear about some real use cases.

BetterC is interesting because it allows you to compile D to WASM. Unfortunately D runtime and GC haven't been ported to WASM yet so they are not fully supported.

Re: Better C – A subset of D Programming Language

#24
post #3

One thing that really annoyed me about D is that its documentation lists basically every function with an 'auto' return type. Auto should be completely banned from documentation, it's a complete hindrance. It's the single biggest contributor to why I stopped using D for personal projects - I was so tired of having to hunt down what functions are going to return, sometimes having to resort to just using it and looking…

The use of Auto is requires in some places because the standard library returns types that cannot be named in the context of the calling function. This happens for example with algortihms that return a custom Range implementation that is declared within the scope of the function implementing the algorithm.

I am not sure what to make of this pattern. At least the documentation should be more explicit about these Voldemort types. Documentation has other issues as well. The standard documentation generator doesn't cope well with version statements (conditional compilation), potentially skipping docs for stuff that wouldn't be compiled into a particular build variant.

Re: Better C – A subset of D Programming Language

#25

Walter here - AMA!

What's the best way for an experienced C programmer who doesn't know C++ to learn D? What's the story in terms of using existing C (or C++) code with BetterC or D in general?

> What's the best way

I'd pick up a comprehensive book like Ali Cehreli's "Programming in D",

https://www.amazon.com/Programming-Tutorial-Reference-Ali-Ce...

and come hang out in the D forums:

https://forum.dlang.org/

Re: Better C – A subset of D Programming Language

#26
post #15
post #14

D is pretty exciting. Seems like a perfect choice for those of us looking for an alternative systems programming language and are not completely convinced we'll be happy in Rust.

Mine is Zig.

Zig is still very experimental though, the language isn’t stable yet

Re: Better C – A subset of D Programming Language

#27
post #3

One thing that really annoyed me about D is that its documentation lists basically every function with an 'auto' return type. Auto should be completely banned from documentation, it's a complete hindrance. It's the single biggest contributor to why I stopped using D for personal projects - I was so tired of having to hunt down what functions are going to return, sometimes having to resort to just using it and looking…

>so tired of having to hunt down what functions are going to return, sometimes having to resort to just using it

With highly generic functions, it's often not possible to know what they'll return without knowing what you'll call them with. Especially given that D functions like "map" and "reduce" tend to return special iterator types so that the compiler is able to smarty fuse them where possible. If D had concepts like C++20, you could probably describe them with something looking like:

    template
    
      concept __SimpleView =                         //     exposition only
        ranges::view && ranges::range &&
        std::same_as, std::ranges::iterator_t> &&
        std::same_as, std::ranges::sentinel_t>;
But at least for me that doesn't seem like it would be much more helpful than just reading the documentation, which states what the function returns, if not necessarily the type.

Re: Better C – A subset of D Programming Language

#28

Walter here - AMA!

What's the best way for an experienced C programmer who doesn't know C++ to learn D? What's the story in terms of using existing C (or C++) code with BetterC or D in general?

> What's the story

You can mix and match C and D code easily in the same program, and to a lesser extent C++ code. This means a larger project can be incrementally converted to D while keeping it running and shipping.

Re: Better C – A subset of D Programming Language

#29

Walter here - AMA!

Hi Walter. I have two and a half questions:

* Regarding the syntax of 'lazy'. It seems to me that it would make for better readability if the lazy keyword were required at the callsite, along the lines of doStuff(lazy getValueUsingExpensiveComputation()); rather than the current syntax where it's not clear at the callsite which, if any, of the arguments are lazy. C# does something similar with ref. What's the thinking behind D's syntax?

* What's the state, and future, of precise garbage collection in D?

Re: Better C – A subset of D Programming Language

#30
post #22
post #3

One thing that really annoyed me about D is that its documentation lists basically every function with an 'auto' return type. Auto should be completely banned from documentation, it's a complete hindrance. It's the single biggest contributor to why I stopped using D for personal projects - I was so tired of having to hunt down what functions are going to return, sometimes having to resort to just using it and looking…

I think it’s really interesting that as dynamically-typed languages increasingly encourage explicit type hints, statically-typed languages are recommending “almost always auto”.

In dynamically typed languages, adding types can stop things blowing up at runtime. In compiled languages, all the type-inference is still done at compile time, so if it compiles than you're not going to get a crash from accidentally adding a string to an integer at runtime.
Post reply on HN