Live data from Hacker News

Programming in D: Tutorial and Reference

ddili.org

71–80 of 134 posts

Re: Programming in D: Tutorial and Reference

#71
post #51

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…

speaking of typescript and dart, the language i was really rooting for in that niche was haxe. wish it had gotten more mainstream.

[deleted]

Re: Programming in D: Tutorial and Reference

#73
post #54
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 Ruby syntax doesn't seem that different to many other languages. For example: xs.filter(x => x & 1).sort().join(", ") // JavaScript xs & filter odd & sort & map show & intercalate ", " -- Haskell Python seems to be the odd one out. Imo, its list comprehensions are confusing as hell to "newcomers". For example, when a list comprehension has multiple `for`s, what order are they nested in?

> ... confusing as hell to "newcomers". For example, when a list comprehension has multiple `for`s, what order are they nested in?

I get that this is just a rhetorical question to make a point about newcomers, and I do agree it's not immediately obvious, but for the record: you can imagine any "if"s and "for"s in a list comprehension are nested statements in the same order. So, for example, this:

   l = [
      y.foo()
      for x in my_list
      if x.blah() > 7
      for y in x.ys()
   ]
Is equivalent to this:

   l = []
   for x in my_list:
       if x.blah() > 7:
           for y in x.ys():
               l.append(y.foo())
So the least comprehension is basically in left to right order with the one exception of the actual expression to be added to the list (like y.foo() in the example above).

Re: Programming in D: Tutorial and Reference

#74
post #54

Earlier quoted context omitted.

The Ruby syntax doesn't seem that different to many other languages. For example: xs.filter(x => x & 1).sort().join(", ") // JavaScript xs & filter odd & sort & map show & intercalate ", " -- Haskell Python seems to be the odd one out. Imo, its list comprehensions are confusing as hell to "newcomers". For example, when a list comprehension has multiple `for`s, what order are they nested in?

> ... confusing as hell to "newcomers". For example, when a list comprehension has multiple `for`s, what order are they nested in? I get that this is just a rhetorical question to make a point about newcomers, and I do agree it's not immediately obvious, but for the record: you can imagine any "if"s and "for"s in a list comprehension are nested statements in the same order. So, for example, this: l = [ y.foo() for x…

Yeah, I know, I know. But I imagine many people would mentally want to bracket [e for x in xs for y in ys] like [(e for x in xs) for y in ys] and thus conclude that y is the outer loop.

Re: Programming in D: Tutorial and Reference

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

> Ruby has the best syntax with regards to blocks/lambdas/closures.

A bit of Smalltalk shining through Ruby.

Re: Programming in D: Tutorial and Reference

#76

Earlier quoted context omitted.

What essential features are missing for you?

For game development? I imagine having to use only structs but not classes would be something that forces a "non idiomatic D" experience. Dynamic arrays sound like something that's very useful for a game. I don't know, there are plenty of features that are incompatible with better C that makes D, D. Generally speaking, garbage collection would be the biggest in my opinion.

Yeah this person is asking how to make the smallest executable. They don’t want garbage collection.

Re: Programming in D: Tutorial and Reference

#77
post #70
post #64

Earlier quoted context omitted.

What pains me in Python adoption, beyond its use as Perl replacement, is that we have so much better dynamic languages with advanced JIT implementations, but have to reach out writing extensions in native languages instead. At least Python as DSL for GPU JIT compilers is a thing now. Yes, I know about PyPy in the corner looking for attention.

> we have so much better dynamic languages with advanced JIT implementations What are some of these better languages that you're referring to? (The usual dynamic language JITs I hear people praise are LuaJIT and Chez. And V8. And the JVM?)

I'd suggest F#, Clojure, Elixir, Scala, and TS, if that counts.

Re: Programming in D: Tutorial and Reference

#78

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…

Ruby is in the running, so to speak, so of course that means there are thousands of people who agree with you. I'm not one of them. The fact that Ruby did not take of as much as Python did, even though there was all that RnR hype, is a testament to that. I don't think your examples are readable. What is |x| x.odd? ? (question mark pun intended) This is just "cleverness". I, personally, want my programming language to use method to use a keyword like "is" instead of operand?[question mark operator]

Re: Programming in D: Tutorial and Reference

#79
post #70
post #64

Earlier quoted context omitted.

What pains me in Python adoption, beyond its use as Perl replacement, is that we have so much better dynamic languages with advanced JIT implementations, but have to reach out writing extensions in native languages instead. At least Python as DSL for GPU JIT compilers is a thing now. Yes, I know about PyPy in the corner looking for attention.

> we have so much better dynamic languages with advanced JIT implementations What are some of these better languages that you're referring to? (The usual dynamic language JITs I hear people praise are LuaJIT and Chez. And V8. And the JVM?)

Smalltalk, Self, whose research lead to Hotspot and V8, Common Lisp.

And the usual, in Python everything is dynamic, well it is even more so in an image based live coding environment, where any break into the debugger, with code changes and resume execution can come back to a complete different world.

Additionally there are features like Smalltalk become: message, where two objects can change places everywhere they are used in the image, and current execution.

Re: Programming in D: Tutorial and Reference

#80
It's been about 10 years since I last dipped my toes in the D waters.

At the time (v 2.067) I stumbled across some surprisingly bad warts in the standard library that prevented me from using it for my intended purposes which writing software tools for bioinformatics.

As other posters have noted, language elegance is secondary to the ecosystem when you want to get things done.

For anyone who has been using D for an extended period, has the D ecosystem improved / expanded considerably in the last 5-10 years?

Post reply on HN