Live data from Hacker News

Better C – A subset of D Programming Language

dlang.org

131–140 of 360 posts

Re: Better C – A subset of D Programming Language

#131
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…

+1, I cringed when Herb Sutter released the 'Almost Always Auto' C++ presentation on YouTube. Sure, auto has its place, and I personally use it, but I just knew that less experience devs would go nuts with it, and it'd only make their lives easier for a short time.

Re: Better C – A subset of D Programming Language

#132

Walter here - AMA!

Would you be open to being interviewed for the Computer History Museum? I suggested this in the CHM feedback form, but I'm not sure if it disappeared into the void or if the form actually even works. I know that sometimes even their search chokes.

See their Oral Histories collection: https://www.computerhistory.org/collections/oralhistories/

Re: Better C – A subset of D Programming Language

#133

Earlier quoted context omitted.

Personally I dislike var/auto in languages because I like having types explicitly written. But in case of languages like Java or Kotlin you can move the cursor over the variable name and you will see the type, also you can right-click and select "replace with explicit type" and it will work. In D, IDEs struggle with templates and can rarely index templated code (no wonder, because most of the code doesn't exist until…

A well designed language should be usable from a text editor. Even in 2020.

A good dev uses an IDE. In 2020.

Re: Better C – A subset of D Programming Language

#134
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…

Personally I dislike var/auto in languages because I like having types explicitly written. But in case of languages like Java or Kotlin you can move the cursor over the variable name and you will see the type, also you can right-click and select "replace with explicit type" and it will work. In D, IDEs struggle with templates and can rarely index templated code (no wonder, because most of the code doesn't exist until…

Hard disagree.

   MyClass myVar = new MyClass()
is not DRY. It also makes it practical to use complicated structures out of generics/templates without killing the developer With, Declarations>.

Re: Better C – A subset of D Programming Language

#135

Earlier quoted context omitted.

A well designed language should be usable from a text editor. Even in 2020.

A good dev uses an IDE. In 2020.

This is a really tired argument that we don't need to get into right now. Different things appeal to different people.

Re: Better C – A subset of D Programming Language

#136

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?

Book "Learning D" by Mike Parker

Re: Better C – A subset of D Programming Language

#137
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.

We have 100kLOC of not -betterC but D without its runtime. If you write a -betterC library normally you can use it with normal D, but the reverse isn't true.

Re: Better C – A subset of D Programming Language

#138
post #109
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.

I'm not looking for an alternative to C but I used this quarantine to start nim, and it feels quite right until now

Nim actually happens to be a very good better C. The fact that it compiles to C is a key feature of that.

Re: Better C – A subset of D Programming Language

#139

Earlier quoted context omitted.

Not in D, it isn't, for performance reasons. It takes an input range and returns a type that iterates through that range applying the callable (doesn't have to be a function!) to each element as requested .

>It takes an input range Which should have a type. >and returns a type that iterates through that range Which should have a type. The entire point is that this is a solved problem, there is no excuse to simply throw up our hands and say "screw documentation we'll just say this function is a mystery". Functor f => (a -> b) -> f a -> f b And please don't miss the point and tell me D doesn't have Functor. The entire poi…

> > It takes an input range > Which should have a type.

It does. That'd the `Range` here: https://dlang.org/phobos/std_algorithm_iteration.html#.map.m...

> > and returns a type that iterates through that range > Which should have a type.

It does. But the name of that type depends on the type of the range and on the callable.

> Functor f => (a -> b) -> f a -> f b

This doesn't work because the return type isn't `f b`, it's `g b` where g depends on what f is. It also depends on the callable, because the first parameter isn't necessary a function. The closest is

Callable c, Range r0 => c a b -> r0 a -> r1 b

Where `r1` isn't even a concrete type but a type that depends on both `c` and `r0` and is made up on-the-fly (per instantiation).

> Documentation is good.

I agree. How would you suggest improving the signature of map given that D doesn't have typeclasses? Or with types that depend on other types in the template?

Re: Better C – A subset of D Programming Language

#140
post #135

Earlier quoted context omitted.

A good dev uses an IDE. In 2020.

This is a really tired argument that we don't need to get into right now. Different things appeal to different people.

And text editor users are wrong.
Post reply on HN