Live data from Hacker News

Programming in D: Tutorial and Reference

ddili.org

41–50 of 134 posts

Re: Programming in D: Tutorial and Reference

#41

I constantly feel like inferior languages are picked up, while superior languages are discarded. It's almost as if the universe had a law: "inferior technology is always preferred no matter how hard you seethe". Examples: * Python preferred over Ruby * TypeScript preferred over Dart or even JavaScript (which is fine and, as a bonus, doesn't require compilation step like TS) * Go is preferred over Crystal and D. While…

It's quite subjective what you consider to be better. Is Ruby better than Python? Maybe so, but Ruby only ever had one killer app that is Rails while Python has a vast ecosystem. Is Crystal better than Go? Maybe so, but Go ist just so much more mature (plus the ecosystem argument).

Re: Programming in D: Tutorial and Reference

#42

Earlier quoted context omitted.

Languages do not matter as much as you think. Ecosystems are everything. Twice in my life I started companies (the first one took all my life savings) and in both cases the right call was what you called an "inferior language". I actually liked D very much, and WB had been a personal hero of mine when I was in college. But I am not betting my career on an ecosystem built around by a single brilliant guy. For high-sta…

D's ImportC feature makes it super easy to access C libraries from D code. That means D fits right in with a C ecosystem, as it's no longer necessary to attempt to translate the .h files into D. It's not perfect, as some people cannot resist using the C preprocessor for some bizarre constructions. I used to write those bizarre things myself in C, and was proud of my work. But one day I decided to remove them all, and…

One area where Go, C# and Rust beat D is packages in a few different ways.

For C# Microsoft eventually embraced NuGet their package manager, and used it to put core packages that don't need to be fully available OOTB but can then benefit from frequent updates on a per project basis as opposed to updating the entire language runtime.

For Go it was the out of the box packages, like if I want to make a website, I can pull in net/http and their templating packages that come out of the box with Go, maybe a reasonably simple core maintainer package or packages that go into Dub would be a strong selling point. Right now Vibe.d is the only option for web dev, but there's no reason a much simpler web server couldn't exist.

For Rust, I just really love Cargo, I think its one of the nicest package managers I've ever used.

The other thing that would really help D is if something significant is built around D, whether it be a framework (like what Rails did for Ruby) or some major application that needs D to function at its core and is used by many, this could be a groundbreaking modern IDE, or anything really, a database that uses the best bits and pieces of D to scale, or even a really rich cross-platform GUI stack (my kingdom for std.gui to be a thing in D, and reasonably exhaustive).

I wish I had unlimited time and money, I would invest it in D. Alas, I'm not a language maintainer, just a guy who loves really good tools.

Re: Programming in D: Tutorial and Reference

#43

Earlier quoted context omitted.

> Python preferred over Ruby ... Perhaps what you're describing is having a niche opinion. If you had some opinions, like a preference for "Everything must be done in as many ways as possible with funky characters" or "I hate indentation", it would certainly seem that the world is against you. But, perhaps, you just really smart and can remember the intention of all the complicated code you wrote a year ago, so you d…

> "Everything must be done in as many ways as possible with funky characters" Are you sure you're not talking about Perl here? Because there are very few "funky characters" in Ruby and code written in it tends to be very readable, more so than Python in many cases. I agree with OP. While Python is not a bad language, Ruby is a better language in general, and I'm reminded of it every time I have to work in Python (whi…

To a beginner who is used to ordinary imperative languages, that Ruby line is extremely difficult to understand. Is `.filter` a method or a property of `xs`? Is `{ |x| x.odd? }` an argument to a method or just a statement that comes after `xs.filter`? If it is passed to `.filter`, why does it not have parentheses around it but the `", "` passed to `join` does?

This all makes sense to a person who knows the language a lot, but wrinkles the brain of a newcomer. Too many concepts to juggle in order to understand. On the other hand, the Python one reads quite easily, even if you may have to go right to left.

Re: Programming in D: Tutorial and Reference

#45

Really wanted to like Dlang but I just did not have a good time with it. One of my projects has a really simple server written in nodejs that's basically (in terms of complexity) just an auth'd chatroom, and I wanted to switch it from using raw tcp sockets to websockets. And since the server is so simple, why not refactor it to another language and see if there's no some performance gains from that? I ended up doing…

Tangential, but which of the 7 ended up being the best experience?

Re: Programming in D: Tutorial and Reference

#46
post #43

Earlier quoted context omitted.

> "Everything must be done in as many ways as possible with funky characters" Are you sure you're not talking about Perl here? Because there are very few "funky characters" in Ruby and code written in it tends to be very readable, more so than Python in many cases. I agree with OP. While Python is not a bad language, Ruby is a better language in general, and I'm reminded of it every time I have to work in Python (whi…

To a beginner who is used to ordinary imperative languages, that Ruby line is extremely difficult to understand. Is `.filter` a method or a property of `xs`? Is `{ |x| x.odd? }` an argument to a method or just a statement that comes after `xs.filter`? If it is passed to `.filter`, why does it not have parentheses around it but the `", "` passed to `join` does? This all makes sense to a person who knows the language a…

The only difficulty in Ruby code is the block notation. Even then, it is very similar to constructs in JavaScript, Go, D and a number of other languages -- the only difference form JS would be that instead of `(x) => ...` you write `{ |x| ... }`.

Questions such as

> why does it not have parentheses around it but the `", "` passed to `join` does?

would be exactly the same for JavaScript, Go or D. Ruby has the best syntax with regards to blocks/lambdas/closures.

Re: Programming in D: Tutorial and Reference

#47

Earlier quoted context omitted.

Languages do not matter as much as you think. Ecosystems are everything. Twice in my life I started companies (the first one took all my life savings) and in both cases the right call was what you called an "inferior language". I actually liked D very much, and WB had been a personal hero of mine when I was in college. But I am not betting my career on an ecosystem built around by a single brilliant guy. For high-sta…

D's ImportC feature makes it super easy to access C libraries from D code. That means D fits right in with a C ecosystem, as it's no longer necessary to attempt to translate the .h files into D. It's not perfect, as some people cannot resist using the C preprocessor for some bizarre constructions. I used to write those bizarre things myself in C, and was proud of my work. But one day I decided to remove them all, and…

Any plans to implement Swift like C++ interop?

Re: Programming in D: Tutorial and Reference

#48
post #43

Earlier quoted context omitted.

To a beginner who is used to ordinary imperative languages, that Ruby line is extremely difficult to understand. Is `.filter` a method or a property of `xs`? Is `{ |x| x.odd? }` an argument to a method or just a statement that comes after `xs.filter`? If it is passed to `.filter`, why does it not have parentheses around it but the `", "` passed to `join` does? This all makes sense to a person who knows the language a…

The only difficulty in Ruby code is the block notation. Even then, it is very similar to constructs in JavaScript, Go, D and a number of other languages -- the only difference form JS would be that instead of `(x) => ...` you write `{ |x| ... }`. Questions such as > why does it not have parentheses around it but the `", "` passed to `join` does? would be exactly the same for JavaScript, Go or D. Ruby has the best syn…

I don't know much Ruby outside of a few toy examples I wrote a long time ago. For most languages, there would be parentheses around objects you pass to functions, like `.filter({|x| x.odd? })`. This lends some consistency and makes it easy (for me at least) to understand that an anonymous function is passed to `filter`. Just separating it using spaces feels like Bash, something I find difficult to write anything slightly complicated in.

Re: Programming in D: Tutorial and Reference

#49

Really wanted to like Dlang but I just did not have a good time with it. One of my projects has a really simple server written in nodejs that's basically (in terms of complexity) just an auth'd chatroom, and I wanted to switch it from using raw tcp sockets to websockets. And since the server is so simple, why not refactor it to another language and see if there's no some performance gains from that? I ended up doing…

Tangential, but which of the 7 ended up being the best experience?

It's a tossup between Dart and Bun: Dart has better language features but Bun has better APIs. Since Bun is first and foremost a Javascript runtime, it inherits its annoyances and issues, like the complete lack of pattern matching, or switch expressions at all, or decent enums, etc. That said, Bun includes SQLite support and encryption out of the box, whereas Dart is heavily compartmentalised (https://pub.dev/publishers/dart.dev/packages). Imagine if, in Bun, importing "node:crypto" meant needing a "node:crypto" npm dependency. Dart ekes out the win though, I think.

Re: Programming in D: Tutorial and Reference

#50
post #43

Earlier quoted context omitted.

> "Everything must be done in as many ways as possible with funky characters" Are you sure you're not talking about Perl here? Because there are very few "funky characters" in Ruby and code written in it tends to be very readable, more so than Python in many cases. I agree with OP. While Python is not a bad language, Ruby is a better language in general, and I'm reminded of it every time I have to work in Python (whi…

To a beginner who is used to ordinary imperative languages, that Ruby line is extremely difficult to understand. Is `.filter` a method or a property of `xs`? Is `{ |x| x.odd? }` an argument to a method or just a statement that comes after `xs.filter`? If it is passed to `.filter`, why does it not have parentheses around it but the `", "` passed to `join` does? This all makes sense to a person who knows the language a…

> To a beginner who is used to ordinary imperative languages, that Ruby line is extremely difficult to understand.

I don't understand this argument. You are a beginner only for a tiny fraction of your time using a given programming language. Why are we optimizing a programming language for people who don't know it, instead of optimizing it for people who actually program in it?

Post reply on HN