[Dlang Episode 97] D Language - assert

Поділитися
Вставка
  • Опубліковано 3 чер 2024
  • ►Full DLang Series Playlist: • D Language (DLang) Pro...
    ►Find full courses on: courses.mshah.io/
    ►Join as member to get perks: / @mikeshah
    ►Lesson Description: In this lesson I show you how to use assert expressions. 'asserts' are a key tool for testing the correctness of your program. However, asserts are really tools for developers as a 'contract' to ensure that during development time, things that most always be true are indeed true. We should use asserts liberally to test our programs, then we can use 'release' and '-check=assert=off' to remove asserts when deploying to clients. As a best practice, asserts should not contain state changes, but only test a true or false condition of the state of a program at a given time. We'll later look at how asserts and 'static asserts' at compile-time can also be used. As always, share your interesting use cases with the community in the discussion below!
    ►Please like and subscribe to help the channel!
    ►UA-cam Channel: / mikeshah
    ►Join our free community: courses.mshah.io/communities/...
  • Наука та технологія

КОМЕНТАРІ • 18

  • @twenty-fifth420
    @twenty-fifth420 26 днів тому

    Happy episode 100! Time to 'assert' this is the best episode ever, until episode 101 comes out.
    Then, we can do 'D a Day 101 Days' and we can all sing!

    • @MikeShah
      @MikeShah  26 днів тому +2

      Indeed! With Ali's lecture, and the two teasers this would be the 100th episode! Perhaps for lesson 100, we'll have to do something special :)

    • @twenty-fifth420
      @twenty-fifth420 26 днів тому

      @@MikeShah That is a surprise for longevity since that means you basically been doing this for just about/over two years, huh?
      I think I propose something fun for a special.
      I actually used the c import once and I forgot lol. It was the printf function, I thought D was more 'c like'.
      Maybe you can do an episode on the standard C libs wrapped? Especially since I am also trying to get Raylib to work for a GUI app.

  • @disdroid
    @disdroid 25 днів тому

    Assertions are null operations in non-debug builds. Instead, enforce from std exception can be used.

    • @MikeShah
      @MikeShah  25 днів тому +1

      Yes, we're going to talk about enforce soon :)

  • @GaryChike
    @GaryChike 25 днів тому +1

    D'asserts?! .. yum yum!!!!

  • @bsdooby
    @bsdooby 26 днів тому +1

    asserts are run-time based; but they are used during the development phase. Thus, there is static assert for compile-time based checks; isn't it?

  • @user-fz6yn3sb4s
    @user-fz6yn3sb4s 24 дні тому +1

    great video sir .
    one request of starting DSA series pls

    • @MikeShah
      @MikeShah  23 дні тому

      Cheers! And noted :)

  • @bsdooby
    @bsdooby 26 днів тому

    Do you or other D devs use the language in some CI/CD environment, for testing, profiling, etc.?

    • @aberba
      @aberba 26 днів тому

      As the sole purpose of the language?
      D has testing built-in which can be triggered in a CI/CD environment. There are third-party testing libraries too for other styles of writing tests

    • @bsdooby
      @bsdooby 26 днів тому

      @@aberba say you have a project, written in D (for a Jenkins or SonarQube env.) …

    • @aberba
      @aberba 26 днів тому

      @@bsdooby sure, I don't think it should be an issue in any other language.

    • @MikeShah
      @MikeShah  26 днів тому +1

      @@bsdooby I've used things like Github Actions with D no problem (github recognizes D as well). Tools like dscanner can be integrated into the pipeline as well. Soon I'll talk about some more of the features in dlang like 'unittest' 'coverage' 'profiler' etc. that you can use with tools like Jenkins

    • @bsdooby
      @bsdooby 26 днів тому

      @@MikeShah COOL 😎 As always: looking forward for these clips!