Live data from Hacker News

Wc in D: 712 Characters Without a Single Branch

dlang.org

31–40 of 89 posts

Re: Wc in D: 712 Characters Without a Single Branch

#31
post #23

Gave myself a quick D lesson just to understand the approach to flags here (Yes.keepTerminator rather than just a meaningless bool). Turns out D lets you define a template with any args you like, in this case taking a string for a name of a Flag type, which in turn contains an enum with 'yes' and 'no' boolean values. This means that you can only use the right type of Flag, with a matching name, and its yes/no value.…

D is getting named function arguments, which will make the "meaningless bool" a bit more meaningful.

Re: Wc in D: 712 Characters Without a Single Branch

#32

I'm wavering between D and Rust for which one could be used as a better alternative to C++. (Though I don't see C++ getting replaced anytime soon.) Even if Rust is getting most of the attention, D also seems to be a strong candidate.

D is also getting an Ownership/Borrowing system:

https://github.com/dlang/dmd/pull/10747

Re: Wc in D: 712 Characters Without a Single Branch

#33

I find D easier to grok coming from a Java/Python background.

D is an amazing language. But what eventually put me off is the lack of documentation for installing and linking libraries in the compilers.

This is a bit perplexing. Libraries don't need to be installed, you simply put them in a directory, add a path to it in the command to the compiler, and list the library on the command to the compiler.

Just as you would for C and C++.

Other languages may need libraries to be installed, but not D.

Re: Wc in D: 712 Characters Without a Single Branch

#34
post #6

I find D easier to grok coming from a Java/Python background.

My only issue is that it's far more complicated than Java and for a language that fills that same niche it's hard for me to justify putting my resources into learning it even though I do like a lot of the features.

Java is indeed a simpler language, much simpler. Unfortunately, my experience with Java is it is too simple - I had to write way too much boilerplate over and over.

Re: Wc in D: 712 Characters Without a Single Branch

#37
post #23

Gave myself a quick D lesson just to understand the approach to flags here (Yes.keepTerminator rather than just a meaningless bool). Turns out D lets you define a template with any args you like, in this case taking a string for a name of a Flag type, which in turn contains an enum with 'yes' and 'no' boolean values. This means that you can only use the right type of Flag, with a matching name, and its yes/no value.…

D is getting named function arguments, which will make the "meaningless bool" a bit more meaningful.

How will that work with c compatibility?

Re: Wc in D: 712 Characters Without a Single Branch

#38

I'm wavering between D and Rust for which one could be used as a better alternative to C++. (Though I don't see C++ getting replaced anytime soon.) Even if Rust is getting most of the attention, D also seems to be a strong candidate.

Rust is definitely more difficult but it has it benefits, I guess? For me as a Python guy D was just easier both concept wise and syntax wise. I could write a relatively complex algorithm after 2 weeks of reading a D programming book with just standard ops. And it was definitely faster. Maybe not as fast as C but I felt efficient. Personally, I liked that D does pray FP like Scala while also being a multiparadigm language. Aaand it is definitely more readable.

Re: Wc in D: 712 Characters Without a Single Branch

#39

Earlier quoted context omitted.

D is getting named function arguments, which will make the "meaningless bool" a bit more meaningful.

How will that work with c compatibility?

That's a very good question! When connecting with C code, the C functions being called will need to conform to O/B principles as far as the interface to the function is concerned. It's the same issue as calling unsafe code - the compiler can't check it, the programmer has to.

But if you use D as a BetterC compiler, then the D compiler can check the O/B rules in the code.

Functions that are O/B checked are marked with the `@live` attribute, meaning that you'll be able to incrementally use O/B in the code. This is much like how you can use the `pure` attribute to incrementally write functionally pure code.

Post reply on HN