Andrei Alexandrescu: Three Unlikely Successful Features of D

Download this episode

Download Video

Description

Designing a programming language has a strong subjective component.

There are features - such as type and property inference - that many would agree are useful, subject to proper language integration. But then there are features of which utility is not immediately obvious, and that could go either way when it comes to community adoption and scaling up to real, large programs. This talk discusses three such features of D - seemingly unimportant, maybe greeted with a ho-hum by the community, but today ubiquitously used and enjoyed.

Download:

Slides

Tag:

D

Day:

3

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      chethan

      Would the video be posted here?

    • User profile image
      dcuccia

      It looks like they're being edited and posted in chronological order.

    • User profile image
      Charles

      Videos will be posted in the order they get done... Smiley Stay tuned. Slides are live...

      C

    • User profile image
      andrei_alex​andrescu

      Martin Nowak found a bug in my generalized palindrome implementation, sigh. There are many possible fixes, his proposed one being among the simplest.

      The idea here is that if the range is left at exactly one element, it can't be reduced from both sides (one size suffices).

      bool palindrome(Range)(Range range) {
          for (; !range.empty; range.popFront(), range.empty || range.popBack()) {
              if (range.front != range.back)
                  return false;
          }
          return true;
      }

    • User profile image
      mpusz

      I think that the D features you presented just rocks Cool

      I have a question if you think that C++ based ScopeGuard or Boost.ScopeExit with std::uncaught_exception() usage can be the same robust as in D?

    • User profile image
      mpusz

      Some first naive implementation:

      http://gist.github.com/dab4bec98a0baa2ebabe

    • User profile image
      ZenJu

      It should be mentioned that the error handling example of C++ is not inherent to the language and shouldn't be considered modern anymore. There is a superiour way to achieve automatic undo behavior in case of errors:
      scope guard + C++11 lambdas

      Now guess who invented former :)
      I'm a little curious why this didn't find a mention at all?

    • User profile image
      ZenJu

      Okay, my question was answered at the end of the talk...

      "cannot detect exceptional return"
      Usually this is not a problem since there is only a single place where the "task is fully completed", that is where you place the "dismissed". All other code paths, e.g. exception, premature return, do not matter.

      > Some first naive implementation
      Why not use an elaborate one?
      Like Loki's:
      http://loki-lib.cvs.sourceforge.net/viewvc/loki-lib/loki/include/loki/ScopeGuard.h?revision=1.6&view=markup

      Or an C++11 optimized version:
      http://pastebin.com/n0CwK3Um

    • User profile image
      GertJan

      Ha busted!

      Always thought you had to be from another planet, you blew it with that move at 11:55!

      Keep it up! Really starting to see the point for D, to me it has a bright future. If you can implement pattern matching you will rule the planet with this (after some libs are converted obviously).
      Wish I could use it here..

    • User profile image
      golnazal

      opening thread

    • User profile image
      Evgeny​Panasyuk

      I have implemented scope(failure) and scope(success) in C++. https://github.com/panaseleus/stack_unwinding

      For example:

      try
      {
          int some_var=1;
          cout << "Case #1: stack unwinding" << endl;
          scope(exit)
          {
              cout << "exit " << some_var << endl;
              ++some_var;
          };
          scope(failure)
          {
              cout << "failure " << some_var  << endl;
              ++some_var;
          };
          scope(success)
          {
              cout << "success " << some_var  << endl;
              ++some_var;
          };
          throw 1;
      } catch(int){}

       

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.