5 comments

  • WalterBright6 hours ago
    I haven't announced my keynote yet, but it's about various ways of handling errors and their tradeoffs. This has inspired some spirited debate in the D forums! I'm looking forward to engaging with everyone.
    • gregdaniels4215 hours ago
      Ages ago in C++ there was the hope of having the standard library give more error codes and use error values instead of full exceptions. Zig has some excellent innovations in that direction, any hope of that in D?<p>Edit: I think it was called &quot;Herbception&quot;s after Herb Sutter, and it really sounded like a good idea to me
      • WalterBright5 hours ago
        It&#x27;s been a while since I looked at Zig. I couldn&#x27;t say anything intelligent about it without some study.<p>I used to be a big fan of C++ exceptions, but eventually soured on it for various reasons. Here&#x27;s an article partially addressing it from a while back:<p><a href="https:&#x2F;&#x2F;dlang.org&#x2F;articles&#x2F;exception-safe.html" rel="nofollow">https:&#x2F;&#x2F;dlang.org&#x2F;articles&#x2F;exception-safe.html</a>
        • germandiago3 hours ago
          I think there is nothing better than exceptions + RAII for error handling since exceptions cannot be ignored by accident.<p>I would classify D&#x27;s scope exit&#x2F;failure&#x2F;success as RAII actually, even if D uses a GC.<p>Sometimes you might not need exceptions and something like std::expected or optional is better.<p>In my case I use expected for some network APIs since I expect failures to happen out of my control aspart of the flow of my program, but I do not see why I would not use exceptions in many other situations, such as for non-ignorsble errors. I could think of a lack of disk space or some other fatal error thst is not under the control of the program.<p>If you forget to handle this, the error will cascade.<p>Also, exceptions do not make the signature of a function change (at least not in C++, Java checked exceptions is different). This means that the plasticity for adding errors at any depth of the call stack augments without bypassing any error silently.<p>All in all, I would say exceptions should be the main mechanism in normal circumstances and for expected errors you csn use error&#x2F;result types.
          • WalterBright3 hours ago
            &gt; I would classify D&#x27;s scope exit&#x2F;failure&#x2F;success as RAII actually, even if D uses a GC.<p>D&#x27;s scope exit&#x2F;failure&#x2F;success is built on top of RAII and has nothing to do with the GC.<p>&gt; I would say exceptions should be the main mechanism in normal circumstances and for expected errors you csn use error&#x2F;result types.<p>Come to DConf (or watch the live stream) and I hope I can change your mind, or at least challenge your conclusions!
            • germandiago1 hour ago
              &gt; D&#x27;s scope exit&#x2F;failure&#x2F;success is built on top of RAII and has nothing to do with the GC.<p>What I meant here (I do not know the mechanism) is that I am aware that D has a GC. This means, correct me if I am wrong, that D does not use destructors (like C++) for scope exit&#x2F;failure&#x2F;success, though they are scoped mechanisms (RAII-like).<p>&gt; Come to DConf (or watch the live stream)<p>I always follow D (even if I did not use it intensively). I have extremely high respect for you as a language designer and as a technician. Your knowledge is very refined, so I never take your opinions lightly.<p>Probably one of the most knowledgeable persons in the industry for native language design. However, I am far and cannot attend, so I will definitely watch it.<p>&gt; or at least challenge your conclusions!<p>No problem in challenging them. I am always open to do things better. This is just my practical experience as I implement stuff so far.<p>I currently think exceptions seems like a good default mechanism (apparently at least) compared to alternatives. But I also think other mechanisms have their place and can&#x2F;should be used even in the same program, just for different things.<p>All mechanisms have trade-offs. I just talked about defaults from my POV for the kind of software I develop (mostly server-side, some client-side, and not embedded in the extremely constrained sense).<p>-----------------------------<p>One question: I tried to use D several times in my career (20 years of C++ experience here, roughly). I found it a lot of fun. I like it better than more &quot;modern languages&quot;. I like the plasticity D provides. But I am not sure how it would work if I want to do:<p><pre><code> 1. backend (server-side mainly, Linux is main platform, x86-64) 2. desktop + android and iOS (being mobile more important than desktop) 3. web assembly (even more important than mobile at this moment, could change). 4. backwards compatibility (heard complaints of versions breaking stuff frequently around). 5. interaction with C++. </code></pre> I do like D a lot, but the problems I had before were more related to tooling (autocomplete, I use mainly Emacs but did not try for a few years) and toolchain maturity.<p>It would be ready for all of the above? Also, very very handy would be to wrap C++ code and C code. I saw that D had an ongoing effort for C++ compatibility better than other languages, but I am afraid it could be half-broken. Even if it is, it is documented what works and what does not work? That would help a lot.<p>Thanks.
          • gregdaniels4213 hours ago
            &gt; I would classify D&#x27;s scope exit&#x2F;failure&#x2F;success as RAII actually, even if D uses a GC.<p>It has better than that, but it is a bit clunky compared with C++(just use struct instead of class). You can have proper destructors, but if you have a container you need to be more careful than in C++.<p>In D exceptions are the default like in C++ and you have to opt out with nothrow or extern(C) or betterC.<p>Really try some D code in a bigger situation it is 90% good and almost worth using over C++, but if you can&#x27;t have GC it is a huge pain, but better than C.
            • WalterBright1 hour ago
              I&#x27;ve never understood why GC would be a huge pain. It makes some things a lot easier, like Compile Time Function Execution.<p>Also, recently the GC implementation received a big modernization upgrade.
      • wannabe442 hours ago
        It was the throwing values proposal. Bjarne was not satisfied with the proposal because it didn&#x27;t interact well with existing exceptions code.
        • jeffreygoesto12 minutes ago
          I loved the comparison of HerbCeptions with expected in <a href="https:&#x2F;&#x2F;m.youtube.com&#x2F;watch?v=GC4cp4U2f2E" rel="nofollow">https:&#x2F;&#x2F;m.youtube.com&#x2F;watch?v=GC4cp4U2f2E</a>, a very insightful easy of looking at that topic and really entertaining, too.
    • macoovacany5 hours ago
      Going to include the common lisp condition system in the comparison?
      • WalterBright5 hours ago
        I tried Lithp a couple times, but it never caught on with me. I wouldn&#x27;t know what the best techniques for Lithp error handling would be.<p>I can never get past the ugly syntax.
    • swyx4 hours ago
      would you ever do an SF edition? would be happy to host for you. i do a lot of conferences.
  • gregdaniels4216 hours ago
    First day seems very LLM heavy, and sounds quite odd for Phobos 3. I would like to see Phobos 3 be more betterC forward, since I have found D to be nicer than C for WASM, but you can&#x27;t use most nice things. Having a default RAII vector class for betterC and a hashmap would be super nice too.<p>Edit: Also would be nice to adopt move and copy semantics even closer to C++ and maybe need less explicit moves, and ideally less mess with calling __xdtor when trying to do RAII
    • destructionator4 hours ago
      we shipped druntime on emscripten on the opend side almost two years ago, supporting everything but threads and exceptions (i tested on emcc 3.1.69, i heard a later version of emscripten broke, im not sure). see my blog post from release time: <a href="https:&#x2F;&#x2F;dpldocs.info&#x2F;this-week-in-arsd&#x2F;Blog.Posted_2024_10_25.html" rel="nofollow">https:&#x2F;&#x2F;dpldocs.info&#x2F;this-week-in-arsd&#x2F;Blog.Posted_2024_10_2...</a><p>there&#x27;s a contributor working with both upstream and opend adding wasi support as well, and he also got exception support working, we&#x27;ll probably ship that next month.<p>so the full d story on wasm is progressing too.
      • gregdaniels4214 hours ago
        What exactly is the openD Canon D split about, and as a regular person, which one should I use? Any other details you could give, or background? I haven&#x27;t followed any of that and have no clue.
        • destructionator4 hours ago
          I have no confidence left in the leadership of old D. This is an example: porting druntime to emscripten wasn&#x27;t actually that hard to do, I did it in about a week of spare time in between kid and day job. Their solution, in so much as they pay attention to it at all, is to just point at betterC which remains half-assed for about a decade now (search my blog archives, here&#x27;s one with them talking about &quot;A betterC standard library&quot; from December 2016 - <a href="https:&#x2F;&#x2F;arsdnet.net&#x2F;this-week-in-d&#x2F;2016-dec-18.html" rel="nofollow">https:&#x2F;&#x2F;arsdnet.net&#x2F;this-week-in-d&#x2F;2016-dec-18.html</a> - and none of that has materialized ).<p>You might say if it is so easy, why not do it upstream? It takes <i>years</i> of political arguments and random ghosting to get anything done up there, all while constant (regression inducing) code churn breaks your PRs every other month, so you spend 3x the time rebasing than you ever spent writing the implementation before it is merged...... if it ever gets merged at all. I have several successful contributions to upstream D, it happens, but most the work done there is ignored. You might get some encouraging forum replies, but when it comes time to ship it? Crickets. Several former D contributors jumped ship for Zig many years ago, and it was a real loss for us (and real gain for them).<p>With the opend, I know if it works and delivers real world value, I can ship a release, dmd and ldc together, so minimal duplicated waste work.<p>What should you use? idk, opend is basically my pet project, provided in the hope that it will be useful, but THIS SOFTWARE IS PROVIDED `&#x27;AS IS″ AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE so your mileage may vary. Still, I maintain about a half million lines of code, some of which is quite old, so keeping some stability is important to me while moving forward with select common-sense, incremental improvements. Most D code works fine either way though, I&#x27;ve done web programming a long time, in the old school tradition, so words like &quot;progressive enhancement&quot; and &quot;graceful degradation&quot; are meaningful to me, even when being a compiler maintainer.
          • gregdaniels4213 hours ago
            &gt; point at betterC which remains half-assed for about a decade now (search my blog archives, here&#x27;s one with them talking about &quot;A betterC standard library&quot; from December 2016 - <a href="https:&#x2F;&#x2F;arsdnet.net&#x2F;this-week-in-d&#x2F;2016-dec-18.html" rel="nofollow">https:&#x2F;&#x2F;arsdnet.net&#x2F;this-week-in-d&#x2F;2016-dec-18.html</a> - and none of that has materialized ).<p>Oof, yeah that is definitely a pain point. Not to get too personal, but why would you continue to invest so much time in the language if upstream isn&#x27;t accommodating?<p>Has WalterBright had any comments on this? He usually is so vocal, any hope of a remerge of the OpenD changes in to CanonD?<p>Anyway, I appreciate you trying to advance Dlang, I fight for it all the time at work, and usually get to do stuff in it(I am old and have privileges).
  • bayesnet3 hours ago
    What’s the status of the OpenD fork?[0] I see Adam is still active there but I’m not sure if it’s had any impact beyond losing him as an upstream contributor.<p>[0]: <a href="https:&#x2F;&#x2F;opendlang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;opendlang.org&#x2F;</a>
  • qwe----35 hours ago
    I don&#x27;t know why but dlang continues to draw me - I&#x27;ve really enjoyed many of the talks in the past
    • vips7L4 hours ago
      I always try it every few years, but I can never figure out how to get a good ide experience. I’ve tried both VSCode and IntelliJ. I most recently tried to make it work for advent of code last year. Maybe I’m just too used to how good the IDE experience for Java is?
    • swyx4 hours ago
      for those (like me) completely new but interested in new programming languages - can you or similar minds summarize the current appeal?
      • zem4 hours ago
        it&#x27;s an evolutionary (as opposed to revolutionary) language; it is in many ways a reimagining of c++ based on decades of observing the latter&#x27;s flaws and weaknesses in the real world. if you&#x27;re in the c or c++ ecosystem already you will likely find D a pleasant set of improvements to c++.
        • WalterBright4 hours ago
          For example, C and C++ still cannot compile this:<p><pre><code> int foo() { return bar(); } int bar() { return 3; }</code></pre>
          • vips7L4 hours ago
            Is it because bar is defined after foo?
            • WalterBright3 hours ago
              Yes.<p>It has deleterious consequences. One solution is to add a forward declaration, which is the kind of busywork a language is supposed to eliminate.<p>Another is to reverse the natural order of functions, with the implementation functions at the top and the interface of the module at the bottom.<p>After all, do you read a website from top to bottom or bottom to top?
              • CapsAdmin54 minutes ago
                Lua has the same problem with local functions, and Lua was the first language I learned that I still use today. So it feels very natural for me to see local functions with no dependencies at the top, and the ones with the most dependencies at the bottom. (but you can work around this in lua with globals, forward declarations, functions in tables, etc)<p>So I guess I kind of prefer seeing helper functions at the top and the main logic at the bottom most of the time.
  • OSaMaBiNLoGiN6 hours ago
    Good language.