[Dlang Episode 97] D Language - assert
16:08
Пікірлер
@Wannabelokesh
@Wannabelokesh 11 сағат бұрын
Hi mike, thanks for this series. This is for programming language freeks like you and I and many others like us. I have a few recommendations for upcoming videos regarding the series: Haskell, Elixir and F# (especially with pure functional programming oriented mindset).
@muhammadharris4470
@muhammadharris4470 14 сағат бұрын
I have barely heard of D lang still confused over why you would dedicate a huge amount of your time to this. Why not educate on RUST or Zig that would be a natural alternative to C/C++
@fjodorz3474
@fjodorz3474 21 сағат бұрын
Oh that's cool. So I expect it is a pretty big challange for bigger games to fit everything in that update loop. And I'm here worrying about a couple of sound effects and sprites. AAA code has to do all sorts of preloading and offloading I imagine. Guess that's for the future me to figure out more about. Super super cool!
@thegameoflife9179
@thegameoflife9179 23 сағат бұрын
180!! have just been watching Darts 🤣
@lordsoup4287
@lordsoup4287 Күн бұрын
Hey are you continuing this course? Super interesting topic!
@MikeShah
@MikeShah 22 сағат бұрын
Eventually I'd like to do more math & programming videos, but no immediate plans to do this quite yet.
@joegoosebass3958
@joegoosebass3958 Күн бұрын
This is great! I was waiting for you to do a video on this language 🎉
@MikeShah
@MikeShah Күн бұрын
Cheers! Yes, it had been one of the most popular requests :)
@GaryChike
@GaryChike Күн бұрын
Dart is one of the few newer languages that did not go with the Pascal style type annotation `var num1: Integer;` that you now see in almost all the newer languages.
@MikeShah
@MikeShah Күн бұрын
It's interesting to see the switch now to the pascal style type annotation -- I prefer it, though my brain remains hardwired to think in C++ still 😅
@bsdooby
@bsdooby Күн бұрын
Interesting observation
@Kapendev
@Kapendev Күн бұрын
Nice. Would be interesting to see the Raku Programming Language.
@GaryChike
@GaryChike Күн бұрын
He touched on Raku a bit when Mike reviewed Perl I like Raku a lot - a very well thought out language.
@MikeShah
@MikeShah Күн бұрын
@@GaryChike Cheers! Yeah, Raku seems to be one of the more popular requests here :)
@IamLupo
@IamLupo Күн бұрын
Lately i been implementing these cases in assembly NASM with futex linux system calls. Its intresting to learn to know the details how mutex is been build in the background with all these features.
@MikeShah
@MikeShah Күн бұрын
That's awesome -- are you by chance building an operating system or working in embedded? Nice to build these primitives from scratch :)
@IamLupo
@IamLupo Күн бұрын
@@MikeShah I am active in game modding. Like right now my main focus is PS2, PS3, XBOX 360. I basically started to wonder how it worked on different architectures. For AMD and Inter on 64-bit there is "lock" assembly where its also nicely manage by your processor. Ofcourse you still need to manage your thread manually with systemcall to the OS. But once thats done you can implement all these funkie mutex cases. Like shared_mutex and lock them. Mostly ChatGPT helps me and give examples. And 9/10 times those cases doesn't work like i have to fiddle arround to make it nicely work with cmake/nasm.
@MikeShah
@MikeShah 22 сағат бұрын
@@IamLupo Very cool!
@kleinv7212
@kleinv7212 2 күн бұрын
Bless you bro, thanks a bunch. It's very understandable👍🏻
@MikeShah
@MikeShah 2 күн бұрын
Cheers!
@knofi7052
@knofi7052 2 күн бұрын
There is a full featured console development environment with the name 'fp'. And lazarus is a RAD (rapid application development) environment for developing desktop GUI applications. All in all, Free Pascal, with its language features and the support for numerous operating systems, processor architectures and development environments, probably offers a more comprehensive environment for full stack development than many of the currently much more popular programming languages.
@MikeShah
@MikeShah 2 күн бұрын
The free pascal ecosystem and environment is wonderful -- I always will wonder why more do not use it.
@ekempinger
@ekempinger 2 күн бұрын
What are you doing? Show us an entire hour how to use the Google Search Machine to learn more about Odin's programming player! The only one who has to learn something here are you ;-) !! You are a fake
@THE_DOOM_PLAYER
@THE_DOOM_PLAYER 3 күн бұрын
hello mike great video i have a simple question if we put the countdown and the while loop in brackets it would be better?
@MikeShah
@MikeShah 2 күн бұрын
Cheers! Can you show an example or timestamp?
@THE_DOOM_PLAYER
@THE_DOOM_PLAYER 2 күн бұрын
@@MikeShah lets say int main() { {short countdown = 5; while (countdown >= 0) { std::cout << countdown << std::endl; countdown--; } } } does that consider a good practice i mean if i will create a variable for a loop and if statement maybe it is better so that will release some memory. i know its not that huge memory for that example but if i will work on project and there is some variables at some point must be deleted is this an effective way to do it
@MikeShah
@MikeShah 2 күн бұрын
@@THE_DOOM_PLAYER I don't think it hurts -- it helps also 'countdown' from escaping if you use that variable again later on as well (which is one of the benefits of a 'for-loop' with the declaration within the ()'s of a variable.
@xc2530
@xc2530 3 күн бұрын
一看就会,一做就废。 ez to watch how Mike does it, hard to do it by yourself
@MikeShah
@MikeShah 2 күн бұрын
Just takes practice -- you'll get it! :)
@shreyabisen4729
@shreyabisen4729 3 күн бұрын
Thanks for the explanation!
@MikeShah
@MikeShah 3 күн бұрын
Cheers, you are most welcome!
@Sluggernaut
@Sluggernaut 3 күн бұрын
Ok, the function being const even though it was modifying private data members kinda blew my mind. I thought const was stronger than that , disallowing any changes to incoming data, forcing literally any change of any kind to be made to variables/data declared within the function. Very nice! I also had no idea that declaring a lambda was implicitly just creating an entire freaking class within the scope it's declared. That's way less optimized than I imagined, though they're still cool. I just thought they were some more special object than that.
@MikeShah
@MikeShah 3 күн бұрын
Need to capture state somehow I suppose in the functor :) Maybe the compiler is doing something smarter however (i.e. maybe just creating a simple function) where it can -- but I'd have to look at assembly to prove that.
@bsdooby
@bsdooby 4 күн бұрын
Is being a YT channel member a good way to support you, @MikeShah? Or is Patreon or a one-time contribution better suited?
@MikeShah
@MikeShah 3 күн бұрын
That's very kind! Folks are welcome to become members at any level or do super thanks (one-time). I understand folks financial situations are all different, so comments, likes, and engaging in the community are also perfectly fine. I don't have patreon, as I figured folks might want to just keep everything on KZbin.
@barbuceanu2005
@barbuceanu2005 4 күн бұрын
After notify_one, the reporter thread tries to re-aquire the lock, but it is already locked by the worker thread (until the lock goes out of scope). If the lock would not go out of scope in the worker thread, a lock.unlock() would be needed before (or after) notify_one(), in order to allow the reporter thread to re-aquire the lock after wait, otherwise the reporter thread would remain blocked.
@QWin-ir6yq
@QWin-ir6yq 4 күн бұрын
Thanks to you, iterators are my new best friend…loving the combined power of using the .find and .end methods in conditional statements.
@MikeShah
@MikeShah 4 күн бұрын
Cheers!
@Chupe_chupe
@Chupe_chupe 4 күн бұрын
Great video Mike
@MikeShah
@MikeShah 4 күн бұрын
Cheers! You are most welcome!
@twenty-fifth420
@twenty-fifth420 4 күн бұрын
6:15 I might have missed this from other courses, but can struct be anycase. Are these valid? structure, struct_ure, strucTure? Yes, I admit, I am not creative. It is six in the morning and I have no coffee. I am aware D has a mechanism like Nim for creating an escape with keywords, I believe it uses ``` But this I did not know. I always assume PascalCase for udts. That is good to know, but I could be wrong. Anyway, to the actual lesson at hand. Say I wanted to model a character sheet, I assume I can use static asserts for the struct field. Like for example how in DND, you cannot have a certain number of skills and you have a hard max at level 20.
@MikeShah
@MikeShah 4 күн бұрын
Yup, can use static asserts for that. There's also contracts for structs as well (in and out) to enforce these guarantees when testing for instance.
@mm-is6lh
@mm-is6lh 4 күн бұрын
very good. thanks
@MikeShah
@MikeShah 4 күн бұрын
Cheers!
@etooamill9528
@etooamill9528 4 күн бұрын
woagh this is a huge stepup in complexity relative to the previous videos, i'm not complaining just surprised
@MikeShah
@MikeShah 3 күн бұрын
Jumped into talking about memory a bit, but hopefully the code isn't too difficult -- try to play around with it a bit :)
@Hector-bj3ls
@Hector-bj3ls 5 күн бұрын
I picked up Rust in 2015 because I was fed up with C and C++. I tried out D and Go too, but they both have a GC so didn't quite cut it. Go was nice and simple compared to the others, and I liked that, but the perf cost of a GC just kept me away. I built a toy game engine in each language as a comparison. Rust was the hardest but, as Bill said in the video, it was the only real alternative. Over the years I've kept my eye out for a better solution. I saw some of Jon Blow's videos on Jai and was quite interested, but at the time it was fully private and even now it's in private beta. I also tried out Zig, but the syntax just felt wrong to me. Not sure exactly what it is about it. More recently I saw Carbon, and C++2, but again, they're either too new or the syntax is too weird. I'm now using Odin as my main side project language. I'm the head of R&D at my company, so maybe I can sneak it in somewhere haha
@lurker9634
@lurker9634 5 күн бұрын
Mike I love you
@user-fz6yn3sb4s
@user-fz6yn3sb4s 5 күн бұрын
great video sir . one request of starting DSA series pls
@MikeShah
@MikeShah 4 күн бұрын
Cheers! And noted :)
@Chimponaut
@Chimponaut 5 күн бұрын
So is a static pointer stored in the program, but the memory it's pointing to would be on the heap? (if allocated with new)
@MikeShah
@MikeShah 5 күн бұрын
Correct! -- 8 bytes stored for the pointer in static memory is what you get when you load your program (then that will eventually point to a 'heap' of memory elsewhere for that executing process by the operating system).
@kimhyungchae
@kimhyungchae 6 күн бұрын
OMG SO COLL!!
@MikeShah
@MikeShah 6 күн бұрын
Enjoy!
@GaryChike
@GaryChike 6 күн бұрын
D'asserts?! .. yum yum!!!!
@MikeShah
@MikeShah 6 күн бұрын
🍰
@disdroid
@disdroid 6 күн бұрын
Assertions are null operations in non-debug builds. Instead, enforce from std exception can be used.
@MikeShah
@MikeShah 6 күн бұрын
Yes, we're going to talk about enforce soon :)
@abdullah.astro1
@abdullah.astro1 7 күн бұрын
can i use glad instead?
@MikeShah
@MikeShah 7 күн бұрын
We use glad in this video
@Sukhraj_3301
@Sukhraj_3301 7 күн бұрын
Hi sir, at 25:14, how do we say that myArray2 specifically called the copy constructor ?
@MikeShah
@MikeShah 7 күн бұрын
myArray is being 'created by copy' -- thus the copy constructor is invoked as the new object 'myArray2' is being created for the first time. This is not to be confused with the 'assignment operator (i.e. operator=)' -- we are infact invoking the copy constructor at line 41 at 25:14
@twenty-fifth420
@twenty-fifth420 7 күн бұрын
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 7 күн бұрын
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 7 күн бұрын
@@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.
@bsdooby
@bsdooby 7 күн бұрын
Do you or other D devs use the language in some CI/CD environment, for testing, profiling, etc.?
@aberba
@aberba 7 күн бұрын
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 7 күн бұрын
@@aberba say you have a project, written in D (for a Jenkins or SonarQube env.) …
@aberba
@aberba 7 күн бұрын
@@bsdooby sure, I don't think it should be an issue in any other language.
@MikeShah
@MikeShah 7 күн бұрын
@@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 7 күн бұрын
@@MikeShah COOL 😎 As always: looking forward for these clips!
@bsdooby
@bsdooby 7 күн бұрын
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?
@MikeShah
@MikeShah 7 күн бұрын
Correct!
@Android_developer-wl2ul
@Android_developer-wl2ul 7 күн бұрын
Plz do `dart` language too😅, I really enjoy this stuff
@MikeShah
@MikeShah 7 күн бұрын
Cheers! Dart would be a nice one to look at!
@jiachengjang2708
@jiachengjang2708 8 күн бұрын
thankyou very much for making this video! It helped me a lot!!!!!!
@MikeShah
@MikeShah 8 күн бұрын
Cheers!
@yumiyonashi8518
@yumiyonashi8518 8 күн бұрын
thank you sir..Helps a lot..
@MikeShah
@MikeShah 8 күн бұрын
Cheers!
@tsarprince
@tsarprince 8 күн бұрын
Damn so informative!
@MikeShah
@MikeShah 8 күн бұрын
Cheers, happy to hear that!
@bsdooby
@bsdooby 8 күн бұрын
so this is also a way to add tuples w/o using special constructor functions? (apart from Typedef, ofc)
@MikeShah
@MikeShah 8 күн бұрын
Hmm, not sure I understand the question -- you're suggesting using std.tuple to create a new type versus Typedef?
@bsdooby
@bsdooby 7 күн бұрын
@@MikeShah I might rewatch your clip, and study the documentation. Maybe I did not quite understand the usage of `Typedef`.
@MikeShah
@MikeShah 7 күн бұрын
@@bsdooby No worries, feel free to ask again anytime!
@Himshu143
@Himshu143 9 күн бұрын
Thanks 🙏🙏
@MikeShah
@MikeShah 9 күн бұрын
Cheers!
@andreabonannibonanni211
@andreabonannibonanni211 9 күн бұрын
great video!!
@MikeShah
@MikeShah 9 күн бұрын
Cheers!
@bsdooby
@bsdooby 9 күн бұрын
Nintendo ❤
@MikeShah
@MikeShah 9 күн бұрын