242 points · by ingve · 9y ago · 184 comments
D seems to be a nice language, but I found the editor integration wasn't the best. I also found it annoying that the docs used `auto` all the time, so you could never figure out the right type annotations for their APIs (e.g. I want to call the foo API and return its value from my method, but the docs all use `auto` to refer to its return value, so I don't know how to annotate my method.)
I liked Nim better in almost every way but one: the compiler was fickle and would just fail silently sometimes.
Happy to see you paint Nim in a (sort of) positive light, I hope I can help with this one negative.
> I liked Nim better in almost every way but one: the compiler was fickle and would just fail silently sometimes.
Can you give some examples and elaborate on what you mean by "fail silently"? Did you at least get a segfault?
It's been a while, but as I recall, on Windows - it was difficult to find a supported way to output Unicode on the console in a sane, portable way (write utf8 nim source code, get wide strings in Windows console and utf8 under eg Linux) - and I think I also had some problems getting off the ground with statically linking sdl2 (again on Windows).
The build/package/config system appear to in a bit of flux?
[ED: and I think there were old open issues and forum posts for both problems, hence no new bug reports...]
It seems that the progress on that issue has stalled. It's unfortunate but we do have limited man-power and rely on the community to help us out, this does mean that at this stage it helps if you don't mind getting your hands dirty with potential bugs.
Unless one of us are directly affected by a bug, or we see a large number of users affected by it, it's unlikely that we will focus on it. Not much we can do there sadly. I hope you can understand.
Regarding static linking I would say that it's challenging for most languages. Especially on Windows. If you pop into our IRC/Gitter channel[2] though I'm sure somebody would help you out. You can also probably get pretty far by asking C users for help.
Regarding the build system, perhaps you are referring to the fairly recent addition of NimScript? I think that has stabilised by now. But if you've got any specific questions about it then feel free to ask them.
As for how it failed, it did not segfault. It just stopped and dumped me back out on the terminal with no output at all.
(I'm on OSX 10.12.6.)
Next time please create an issue on GitHub[1], you don't have to worry about creating a small example either, as long as you give us all the code to compile it.
Also, you can use auto too + Template constraints would help you here.
Seeing MapResult!R map(R, alias fn)(R range) makes it seem like MapResult is a thing you can reference/use. But it's an internal struct, so it's neither accessible not documented. That's a whole lot more confusing than having auto and documenting that the result is an input range.
typeof(var).stringof.writeln;
Fortunately, the programmer gets to decide which to use.
Could I ask about your thoughts regarding Go (which has much less syntax and fewer features than all of the above). Have you looked into it?
In fact, I think Go doesn't quite deserve the reputation it has as being a simple language. It's a familiar language, and it's a bare-bones language, but that's not the same thing as being simple.
One last thing that was interesting: I got more null pointer runtime exceptions in Go than I expected (vs none in Nim, for example). Granted, I'm a Go n00b, but I'm also a Nim and Dart n00b, and didn't have nearly as much trouble with those two languages (aside from the aforementioned compiler bugs).
I really wish modern statically typed languages would rid us of null pointer errors once and for all. This is totally possible with Option types, but seems to rarely be done. I wonder why?
---
Thanks for your answers!
So I know you don't want to rehash what's easy to find elsewhere, but your perspective is different because you wrote a Clojure interpreter. It's not the same as what I can find from people who just use languages.
You just list:
>(e.g. no generics, error handling littering my code and obscuring intent, etc).
But could you flesh out this litany of complaints, even if it's common? I just want to know your version of that list, without the 'etc'. It's not going to be the same as other people's - different things will bother you or come to mind for you. I'm trying to understand these from your perspective and background. (which is unusual.)
Secondly, you write "but that's not the same thing as being simple". I don't really understand. Here on HN, people say you can pick up Go in an "afternoon" and become proficient in "a week".
You write that it is not simple but I don't know what you mean in specific, even when you write as a "Go n00b". This reply will be particularly interesting to me, because, since you've literally written an interpreter, compared to an average user, everything is simple for you.
Like, think of a standard designer who has first dabbled in Javascript and for some reason picks up Go. Whatever isn't "simple" for them would ordinarily be super-simple for you. So what's not "simple" for you is like obscure string physics to a person who is barely a programmer at all. I'm really curious what parts you didn't find simple.
Thank you.
honestly i think, had they gone in the direction of D as a better Python, and application development, they would have made bigger wins (in terms of popularity) ... better tooling, better ide, refactoring, better GC, better libraries ... better faster programs
The better C market, on the other hand, hasn't seen any real contender other than C++ gain traction for decades. Rust is trying now and it could get there, but its still a massive opportunity.
I'm sure it's possible to write more highly optimized code in Python, but it never seems to be the case with the code bases I've worked with. With my own code (a few years ago now), I spent significant time optimizing and the final result was something that was still significantly slower than C/C++. Overall, for my work, I couldn't see an advantage.
Am I just doing it wrong? Currently Go seems far more appealing to me and I've enjoyed using it (maybe I should also try Rust).
Go will be a significant speedup over Python, but likely won't quite match the speed of C/C++ for most tasks. Then again, the ease of development in Go will likely be noticeably better than in C or C++. Rust could potentially match the speed of C++, but it's a much more complex language than Go, so it will take some time to master. (Personally, having spent a large amount of time programming in Rust, I find myself more productive than in Go due to the powerful abstractions present in the former and lacking in the latter, but conventional wisdom is that this won't be the case for most people, and it certainly won't be when you're first learning Rust).
EDIT: Anecdotally I've heard that D is a nice language, but I have no experience with it, so I can't comment on how productive it is or how fast D code will run.
It's squarely aimed at high performance numerics and scientific programming, but is in fact a general purpose language with great potential. It's already very, very efficient (written using LLVM), yet has a lot of the clean elegance of Python.
I've tested several other languages that might be good for my purposes. From what I have seen, Rust is not ideal because of the acknowledged poor support for multi dimensional arrays [1] and the strange semantics for floats (due to the need to be «correct» in presence of NaNs).
Two options that might become interesting once they gain a stable status are Julia [2] and Chapel [3]. The former might be exactly what you are you looking for; the latter is ok if you usually run your codes on HPC platforms. But be prepared to face some friction when sharing your work with colleagues or publishing papers: the little penetration of these two languages in the scientific world implies that people will face difficulties in using/understanding how your code works.
[1] Look for «array» in the page https://users.rust-lang.org/t/on-rust-goals-in-2018-and-beyo...
For the cases where the data-manipulation functionality desired is missing and pure Python is problematic performance wise, one can use Cython to bridge the gap.
Or if that is not enough, write those functions in C against the NumPy C API, and expose that as Python APIs.
Usually when writing scientific code in Python you're going to want to at the very least use numpy. It wraps various C functions for many time consuming tasks.
To get the most out of numpy you're going to have to vectorize you're code, as python's looping constructs are notoriously slow. Instead of writing something like
for i in range(0, len(v)):
v[i] = w[i]**2 + w[i]
You'd write something more along the lines of v[:] = w**2 + wAnd Go itself is some years old now (created in either 2007 or 2009 - according to its Wikipedia article - maybe they mean initial creation and first release for public use, by those two year values). So Go is about either 8 or 10 years old. And that makes D either 16 or 18 years old.
>Go had a lot of success breaking into the Python market, why couldn't D have instead if they had put their efforts there from the beginning?
So when D was new or just a few years old (13 to 16 years ago, say), the Python market was a lot smaller that it is today or has been for the last few years. It might not have even been a target for them, for that or any other reason - another reason could be that Walter is from a systems and compiler background, so might not have been too interested in the domain of interpreted languages (just guessing here, maybe he will comment on this). But BTW, D can be used almost like a scripting language due to its speed of compilation. See rdmd command and the "Why D?" and "D as a scripting language" articles on the Infognition blog (a google away).
Also fast compilation, which D also has.
BetterC is a way for C programmers to gradually move to memory safety without disrupting their valuable, tested investment in working code.
From what I can gather, it succeeded pretty well at that, lacking maybe some hype. The recent open-sourcing of the toolchain might help though.
I don't believe that one second, every language strives to be popular and reach large adoption, since more developers == more maintainers == bigger ecosystem == more reach into enterprise.
Simon Peyton-Jones from the Haskell community explaining exactly that: "What happens if [a language] become successful too quickly? You can't change anything!" https://www.youtube.com/watch?v=re96UgMk6GQ&t=1395
Just like you would like to be personally successful, but won't sell your soul or betray your principles for it.
D could be marketed as a better Python and it has enough features to qualify.
I can find things I like and dislike about each of the new languages I try, but it kind of feels like there are a glut of options for me right now, and each one has held mostly positive surprises. Good problem to have: too many new languages that don't give me a headache, hard to choose.
It's not fundamentally incompatible with "Better C" semantics, especially if there are no exceptions.
Exceptions have two issues:
1. D exceptions currently require the GC. There is a Pull Request to fix that, but it isn't incorporated yet.
2. More problematic is the Dwarf exception handling mechanism requires a language specific "personality" handler. This is supplied by the D runtime library. Trying to trick the C runtime library one into working with D isn't a solved problem at the moment.
I'm not exactly sure what you mean here, but all I really want is guaranteed destructors. Can we just have those?
It's a good thought. D as Better C is new for us, and we'll be flexible in making it work better.
Thank you guys
"But it is possible we can find ways to add them back in."
Over my dead body
Regarding embedded, there were some progress lately, but still needs some improvements.
(2) Memory usage during compile can get out of control resulting in mid-build crashes if sufficient memory is not available.
(3) Setting up of a simple http server should be made simple. (ideally the way Go allows to convert any regular Go program to a http server)
Are there any docs about this anywhere? http://dlang.org/spec/betterc.html doesn't really describe this stuff.
Documentation for the individual features mentioned:
http://dlang.org/spec/function.html#safe-functions
> array overflow checking
http://dlang.org/spec/arrays.html#bounds
> guaranteed initialization of locals
http://dlang.org/spec/type.html http://dlang.org/spec/declaration.html#void_init
> no more stray pointers into expired stack frames
DIP1000 describes D's scoped pointers approach to memory safety - https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md. This is work in progress and the document doesn't reflect latest state of things. Conceptually, scoped slices/pointers/references are similar to concept of borrowing that you guys have in Rust.
I used to work on OO database engine that handles billions of records.
I end up rewriting/overloading my own new/delete and redesign everything how data is load/store around it. Shorten the open/close document time from hours to seconds for large documents.
Basically, one can easily mmap billions of records directly into data structures accessible by C API easily in a few ms. One can dispose billions of records also in a few ms. I saw similar design patterns from the sqlite code base.
Language with memory safety (GC) design in mind won't allow anything like that as far as I know.
I love to see some D experts prove me wrong.
The great thing about C is once you write it, you never really have to worry about the language changing 15 years down-the-line and breaking your code. The GNU version might have a similar property, since GNU tools stay around for a long time.
Probably a lot of work though and I'm not sure why anybody would bother.
That is why .NET Native and CoreRT exist.
.NET 4.6 got a few news ways to control when the GC is allowed to run.
Also C# got its reference types improved on version 7, and the roadmap up to 8.0 includes a few more goodies, like spans.
int main(char** argv, int argc) {
Really? :-)But it doesn't affetc the opertaion of the prorgam (I did test it).
Edit: fixed it
**env
?)...