9 ms·
Introduction to Dlang [video]
- aaaaaaaaaaab 4y ago
- no-dr-onboard 4y ago
- NickNaraghi 4y agogo huskies! :-)
- mealkh 4y agoVery cool to see this gaining traction, my favourite hedgefonds-I-never-got-to-work-at introduced D to me and I believe it's one of the more interesting projects in languages right now.
- thaway786 4y agoYeah, D language is a playground in PL theory. It is the next C++.
- acehreli 4y agoThat historically backwards: C++ has been catching up to D since C++11.
- thaway786 4y agoSure, that's what makes C++ one of the worst PLs. Just break for every decade or so to fix things for good. What's D been doing meanwhile? D community and the authors know its short comings for over a decade now, which are the reasons for its lack of adoption even in the open source world. Most of the D code is yet to be written, tbh. If D can't break stuff to fix the mistakes with defaults, why was all the hatred marketing towards C++? Was it a failed strategy trying to kill C++, so let's just surrender to it via core.stdcpp? PS: Yes, D has the best interop with C++ in the world and even better interop with C as the memory model is same!
- terminalcommand 4y agoGo Ali! When I was a little kid trying to get my feet wet with programming, Ali used to write on a Turkish programming forum, ceviz.net. He used to patiently answer all my questions. Since then I learned English and got out of touch with the Turkish community. I am surprised to see him on HN!
- acehreli 4y agoWonderful to see you here as well! :)
- m00dy 4y agoDo you know Mr.Stop as well ? He 's almost old as Ali in Turkish scene. He has been reversing bits and bytes though.
- terminalcommand 4y agoI haven't come across him. He may have preceeded my time and abilities at that time:). I hanged around in ceviz.net during middle school, I guess around 2008-2010. Before that I was to small to write code. My parents had bought me a Javascript book and teach yourself c++ from Herbert Schildt from a local bookstore. Javascript book was easy, C++ book was hard :). So I abandoned the book shortly after learning cin, cout, iostream and Ali was there to help me out write some programs. I still remember this. I had written a basic calculator in c++, insert number 1, insert operator, insert number 2 kind of something. Ali wrote to me why don't you write it so that it doesn't require you to enter seperate inputs. That question lingered on my mind for a long time and led me into learning about parsing and writing interpreters years later.
- acehreli 4y agoAMA I am the speaker.
- toxik 4y agoDid Rust eat your (the D community’s) lunch?
- acehreli 4y agoIt is definitely chewing on it. :) D's advantage over Rust is its familiar syntax and semantics. C, C++, Java, C#, Python, etc. programmers feel at home once they learn some differences. I heard others say "D is what C++ should have been" and "Compiled Python". I did use Rust for a brief period in a project where the experienced Rust programmer among us was throwing '&' characters here and there to make the code compile, seemingly randomly in many cases. Personally, I remember fighting with impedance issues with the many different string types of Rust. All of this spells a steeper learning curve to me. I think D is familiar to programmers of many other languages.
- primeblue 4y ago
- glandium 4y agoThe inconvenient truth about strings is that strings are hard, and even Rust doesn't have enough string types.
- WalterBright 4y agoD doesn't actually have string types, either, what it does have is `string` is just an alias for: const(char)[] meaning you can treat it like any other array.
- tialaramex 4y agoWhile researching this comment I read some of the D library documentation and found what I think is probably a docbug at this URL: https://dlang.org/phobos/std_utf.html#.byUTF https://dlang.org/phobos/std_utf.html#.byUTF "Throws: UTFException if invalid UTF sequence and useReplacementDchar is set to UseReplacementDchar.yes" My guess is that this is a mistake and should instead say UseReplacementDchar.no since it makes sense to throw an exception if you can't use U+FFFD here, rather than do both. Anyway, in my view this is bad the same way the Billion Dollar Mistake is bad, and Rust made the right choice here. Arrays of stuff are great, but they aren't strings. Having to sprinkle "or maybe not" cases all over these libraries because of course these might not really be strings, results in exception fatigue from your developers, which in turn results in lower quality software and more effort for the conscientious developers who stick it out. D's strings are less stupid than C's (and thus some of the C++ strings) but they're still just arrays which are maybe but maybe not actually text.
- synergy20 4y agohow is D different from C/c++/rust/zig for system programming? what's the major selling point? is it good for embedded(no GC) use cases? what stopped it from becoming universally used?
- acehreli 4y ago> how is D different I don't know Zig yet. I had an opinion long time ago that nobody should use C anymore; I would suggest C++ at least because it has constructors and templates. D's [Better C](https://dlang.org/spec/betterc.html https://dlang.org/spec/betterc.html) would be my go-to at this time. C++ is getting better but it's still very difficult to get right: It depends mainly on programmer attention e.g. to follow 400+ [guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines). Rust is "different" but it has the borrow checker as a safety tool. D's [live functions](https://dlang.org/spec/ob.html https://dlang.org/spec/ob.html) and other [memory safety](https://dlang.org/blog/2022/10/08/dip1000-memory-safety-in-a-modern-systems-programming-language-part-2/ https://dlang.org/blog/2022/10/08/dip1000-memory-safety-in-a...) features are closing the gap there. > major selling point I am copying slide 59 here: D provides competitive advantage by helping happy programmers produce correct programs pragmatically. Slide 8 lists what D does not have, which can explain why D has not gained popularity that it deserves. For example, nobody can sell D as "Google's language" or "Apple's language".
- synergy20 4y agomakes sense, thanks!
- no_wizard 4y agoIs there a way to enable safe "D" by default, rather than using the `@safe` (what looks to be) modifier?
- acehreli 4y agoNo. We had a very long discussion about safe-by-default on the forums but failed to reach a consensus. As I understand it, for safe-by-default to work, either all C libraries would have @trusted D bindings written, or all of them would have to be assumed to be @trusted. Most of the community wanted explicit @trusted annotations, Walter and others favored assuming them to be @trusted (or was it assumed @safe?) was the way to go. So, no safe-by-default at this time. :/
- Decabytes 4y agoI like programming in D. And I think that it can exist in a world with Rust/Zig/Go/blub. My personal opinion/pitch for D. 1. I found D pretty easy to learn and use so getting productive in it was easier for me than Rust. 2. D has a lot of improvements to C++ that make it more ergonomic (no header files! built in package management!) 3. D has a lot of flexibility to go up and down the stack in complexity as well as interface with existing c/c++ code. a. Need to use d for scripting like Python? use Rdmd b. Need to interface with c code and can't depend on the D compiler? use -betterC ^1 c. Need a quick and dirty way to use C code without creating bindings? use importC d. Can't use the garbage collector? use @nogc e. Need to interface with C++? use extern (C++) D's flexibility is its greatest strength and weakness. It can do a lot of things but not all of its features are ergonomic. A lot of that just has to do with man power. If it had a community as large as C++ things would be different. Using the examples in 3, you could use Ds features and write a kernel with @nogc, a user interface for that kernel using regular D, and create build scripts using rdmd. To see a c++ person perspective on D watch this video^2 1. https://wiki.dlang.org/D_on_esp32/esp8266(llvm-xtensa%2Bldc)_and_how_to_get_started https://wiki.dlang.org/D_on_esp32/esp8266(llvm-xtensa%2Bldc)... 2. DConf '22: Ray Tracing in (Less Than) One Weekend with DLang -- Mike Shah https://www.youtube.com/watch?v=nCIB8df7q2g https://www.youtube.com/watch?v=nCIB8df7q2g
- bachmeier 4y agoI use D to interface with C code and C APIs. Started using it for that purpose in June 2013 and haven't looked back. Used Rust and Go first, did not like either, and have been happy using D ever since. Over time the interoperability with C has gotten even stronger - to the point that you don't need to write bindings for the most part, and you can even directly compile C code as part of your project.
- dan-robertson 4y agoAre you saying you tried rust in 2013 and found it unsuitable? I think it was a pretty different thing back then. Though obviously that doesn’t mean D isn’t a great choice.
- systems 4y agoI think its important to share few negatives about D 1. It have no edge, its not the best system language, and far from a good application language (mainly because of the eco system) 2. Fragile community, low number of user and the community forum is toxic frequently 3. It doesnt have strong leadership, D doesnt have a good roadmap, and constantly changing vision 4. Its a big language, and considering the drawbacks, its too big to have such critical drawbacks I cant really think of any solid reason, why anyone would invest in D, except if they are already knee deep into it for some historical reasons D is not a horrible language, but today there are so many better choices, and the language is too big, to risk investing in it
- destructionator 4y ago> the community forum is toxic frequently what exactly does this mean?
- bachmeier 4y agoIt means people make posts like this poster has made here. (This is an honest answer based on my experience.)
- systems 4y agoactually this very accurate, but it doesnt make anything i said less true or accurate
- systems 4y agotons of bikeshedding posts, ones that criticize D lack of vision/focus and misfortune
- acehreli 4y agoI heard Discord may have negative posts as well but I find the official D newsgroups (with a forum interface) very friendly and clean. Minimal moderation seems to help there.
- neverartful 4y agoI was just thinking about possibly using D for one of my personal projects. The tricky part (for me) is the application needs AWS S3 interoperability. Anyone cross that bridge with D? I did some searching and didn't find any S3 libraries for D. Could D's interoperability with other languages like C or C++ be used here to make use of one of those libraries?
- johannes1234321 4y agoI wouldn't go the way via C or C++, but start by building a thin wrapper over http libraries. In the end what these are are rest apis.
- neverartful 4y agoI know what you're saying, and I'm often inclined to do that, but in the case of S3 it's a heck of a lot of work/time. Have rolled my own for smaller APIs though.
- WalterBright 4y ago> Could D's interoperability with other languages like C or C++ be used here to make use of one of those libraries? That's what the interoperability is for!
- neverartful 4y agoCool! I might have to give it a try.
- skocznymroczny 4y agothere's some AWS/S3 libraries available, but they all seem to be in alpha stage https://code.dlang.org/search?q=aws https://code.dlang.org/search?q=aws
- p0nce 4y agoMade a few examples here to kickstart D usage: https://github.com/p0nce/DIID https://github.com/p0nce/DIID
- vram22 4y agoSimilar (in goal). https://jugad2.blogspot.com/search/label/DLang?m=0 https://jugad2.blogspot.com/search/label/DLang?m=0
- cassepipe 4y agoI don't know when I'll be using this language but I definitely want to
- rychco 4y agoD wasn’t on my radar until recently, when I was curious if there were any languages with C++ interop out of the box. The two languages I stumbled on were Nim & D, although they understandably have some caveats. After spending some time reading the docs, I’m really interested in trying out both, but especially D. Side Note: Why don’t I ever hear about Nim anymore??? It’s version 1.68 (and presumably stable), has very approachable syntax, claims great performance, provides a package manager, and allows the GC to be turned off (much like Dlang). What gives?
- svnpenn 4y ago> Why don’t I ever hear about Nim anymore? Nim has some serious technical debt, and it seems they don't have the manpower for it: https://github.com/nim-lang/Nim/issues/14719 https://github.com/nim-lang/Nim/issues/14719
- cb321 4y agoA language, its stdlib, and its package ecosystem all relate, but are also distinct. It's not hard to do your own TLS/SLS wrapper with whatever defaults you like. When I run `nimble search ssl`, it seems at least 4 people have done such. This is just to pick on your example. There is surely much other technical debt in the compiler itself. The solution to low manpower, if you otherwise like Nim (or D), is to try to help the open source effort at whatever level you can: do your own packages, tutorials/documentation, etc.
- pjmlp 4y ago.NET (on Windows only), by having C++/CLI, which currently is up to date to C++17, plus language extensions for .NET environment.
- Decabytes 4y ago> Side Note: Why don’t I ever hear about Nim anymore??? It’s version 1.68 (and presumably stable), has very approachable syntax, claims great performance, provides a package manager, and allows the GC to be turned off (much like Dlang). What gives? I don't know if it's still the case. But there were issues with Nim executables being incorrectly flagged as viruses in Windows. ^1 1.https://github.com/nim-lang/Nim/issues/17820 https://github.com/nim-lang/Nim/issues/17820
- LAC-Tech 4y agoEvery time I try D it just feels unfinished. From memory running unit tests printed some weird error, which everyone just ignores. Also importC isn't what you think it is - it's for statically compiling C files in your source directory, not importing foreign C libs you've installed on your system. I definitely think there's a place for a GC'd, memory efficient, natively compiled language. I just wish after all these years it felt mature.
- acehreli 4y ago> unit tests printed some weird error I am not aware of a common issue like that but D has bugs. > Also importC isn't what you think it is That's contrary to my tests: I installed libplot on my system, 'import'ed its .h file to my D source code, called C functions from D, linked with -L-lplot and it worked. > not importing foreign C libs you've installed on your system Maybe you mean something else with "importing" but I installed a foreign C library on my system and it just worked without any hand-written D bindings for it.
- LAC-Tech 4y agoI am not aware of a common issue like that but D has bugs. Not an error I suppose, but doesn't fill me with confidence nonetheless. $ dub test No source files found in configuration 'library'. Falling back to "dub -b unittest". Performing "unittest" build using /home/lewis/dlang/dmd-2.100.2/linux/bin64/dmd for x86_64. myproject ~master: building configuration "application"... Linking... Running myproject Hello world! (dmd-2.100.2)[lewis@lightgrey myproject]$ micro source/app.d (dmd-2.100.2)[lewis@lightgrey myproject]$ dub test No source files found in configuration 'library'. Falling back to "dub -b unittest". Performing "unittest" build using /home/lewis/dlang/dmd-2.100.2/linux/bin64/dmd for x86_64. myproject ~master: building configuration "application"... Linking... Running myproject core.exception.AssertError@source/app.d(9): unittest failure ---------------- ??:? _d_unittestp [0x555fe0e339b1] source/app.d:9 void app.__unittest_L8_C1() [0x555fe0e328b8] ??:? void app.__modtest() [0x555fe0e33888] ??:? int core.runtime.runModuleUnitTests().__foreachbody6(object.ModuleInfo) [0x555fe0e3d9c2] ??:? int object.ModuleInfo.opApply(scope int delegate(object.ModuleInfo)).__lambda2(immutable(object.ModuleInfo)) [0x555fe0e3b88f] ??:? int rt.minfo.moduleinfos_apply(scope int delegate(immutable(object.ModuleInfo))).__foreachbody2(ref rt.sections_elf_shared.DSO) [0x555fe0e42a83] ??:? int rt.sections_elf_shared.DSO.opApply(scope int delegate(ref rt.sections_elf_shared.DSO)) [0x555fe0e42f5b] ??:? int rt.minfo.moduleinfos_apply(scope int delegate(immutable(object.ModuleInfo))) [0x555fe0e42a11] ??:? int object.ModuleInfo.opApply(scope int delegate(object.ModuleInfo)) [0x555fe0e3b861] ??:? runModuleUnitTests [0x555fe0e3d80e] ??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])).runAll() [0x555fe0e342d8] ??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])).tryExec(scope void delegate()) [0x555fe0e34265] ??:? _d_run_main2 [0x555fe0e341ce] ??:? _d_run_main [0x555fe0e33f97] /home/lewis/dlang/dmd-2.100.2/linux/bin64/../../src/druntime/import/core/internal/entrypoint.d:29 main [0x555fe0e328dd] ??:? __libc_start_main [0x7f1a0be25e09] ../sysdeps/x86_64/start.S:120 _start [0x555fe0e327c9] 1/1 modules FAILED unittests Program exited with code 1
- thaway786 4y agoGood talk Ali. All these talks are for people who create small, standalone programs and tools. For history, I hated D back in 2006/7. But post Andrei joining D was fantastic. It was very easy to jump into D's standard library and understand it's inner workings. Over those years I created and maintained apps, services and microservices written in D. It was pleasure writing programs in D. Its compile time features make it pleasurable to write algorithms and refactor at ease. But it was horribly painful to debug production issues. GC crashes day in and day out. Missing ecosystem of libraries and tools. vibe-d was unstable, so we had to create our own HTTP2 library. There's very little tooling to figure out what's going on when things go wrong. Templates in D are awesome for compile time, but it's the opposite case with GC and runtime. D's built in attributes are like family members who don't like each other but are trying to live in a single room. What else do you expect of such programs? You try to observe/log from your transport layer, but when you get deep into BetterC layer, you can't use loggers as they use GC. OK, write your own nogc logger, but that doesn't work well with default logger. The cycle repeats for every single attribute and every single behavior during runtime. It's just a mess. Until I read the source code of Rust standard library a year or so ago. It was not as pleasant as D, but it was easy to understand and pickup the language. I switched jobs a year ago and instructed our teams to experiment with Rust even though I had decades of expertise with C++ and a decade with D. The immediate benefit we saw was Rust's opinionated error handling, which proved to be the right approach to most of common programming mistakes. We started using Tokio and all praises to it. No going back! Personally, I can ask my teams to use D when it has all the sane defaults of Rust and a good ecosystem. Otherwise it is way too expensive to maintain as there's no benefit of portability as well. We now write all code in Rust and ship it across different platforms seamlessly, including Android, iOS, Windows, Linux and macOS. One language and code to rule them all. Few recommendations to @WalterBright as he is on HN. Personal recommendations: 1. You created D because you felt the pain of the C++ programmers. Appreciate it and thank you for that. Over the years you've built up "the curse of knowledge bias" with D. Start using D as a new programmer to the language and the ecosystem. Come out of your MicroEMACS shell and use a modern editor/IDE like VSCode and see how lacking the tooling is. WebFreak has done an amazing job with code-d[1]. But it is in no competition to Rust's IDE support. 2. Use all the features of D in a non-compiler, long running, real life ML/microservices project. You will see the pains of GC. 3. Unit testing != assert 4. Scoped exit != RAII General recommendation: SWITCH TO SANE DEFAULTS! 1. @safe by default. Allow hiding all C interfaces under @unsafe. Retire once for all @trusted/@system. @safe => @unsafe 2. BetterC by default 3. Immutable/const by default 4. @nogc by default. That is @nogc => @gc 5. Rust like opinionated error handling and remove exceptions. At least make nothrow default and introduce throw. 7. Reduce the attribute bloat: https://dlang.org/spec/attribute.html https://dlang.org/spec/attribute.html Feedback to D community from learnings in Rust community: 1. Learn to work on team projects to improve D ecosystem instead of shitty ideas about "Signatures", etc. 2. DIP1000 for safety is open for like 7 years and has no conclusion and still NOBODY cares. Just saying that D is alive and community is awesome are just a jokes. D has lost it's "brains" and there are just a few hanging around at the moment, unfortunately. 3. There's not even a standard dfmt template for Phobos/Druntime. Bring one and you will possibly gain contributors. Yes, Rust code doesn't look elegant with littered angle brackets and &' across the code base, no templates, makes programmers life difficult, etc. But we can live with all that and still have peaceful nights (and weekends) without calls from production support, when compared to downtimes due to half baked features in D (I didn't mention about @live in preview yet). In the end, a language is not great/usable by itself (that's why there's no money in writing programming languages), but by it's rich ecosystems and community. D was created for novice programmers originally (as programmer's language), but the idea is long dead. It is a mess at this point. You need to be a seasoned/experienced programmer to even maintain a large code base. Using D itself is a code smell, IMHO. Sorry for venting out, I was the one who recommended D at my past workplace and I was just frustrated my decision and it's consequences. [1] https://marketplace.visualstudio.com/items?itemName=webfreak.code-d https://marketplace.visualstudio.com/items?itemName=webfreak...
- kajaktum 4y agoWhy do so many modern language still prefer validation over parse? Is there any benefit to validation aside from some vague claims about optimization? See: strings in D.
- skocznymroczny 4y agoPersonally I am mostly happy with D, but it is missing out on the WASM revolution, where Rust, C and C++ dominate.
- WalterBright 4y agoAli is the author of "Programming in D".
- JohnBerea 4y agoAnd Walter ^ is the author of "D" itself : )
- googlryas 4y agoAnd John Berea ^ wrote this comment
- mistercheph 4y agoAnd I wrote this comment.
- havandprohacker 4y agoI need a link
- acehreli 4y agohttp://ddili.org/ders/d.en/index.html http://ddili.org/ders/d.en/index.html
- reil_convnet 4y agoThis is a very well structured talk.