"Programming consists mainly of labor to create a product. But programming is not just labor towards an end product. It is also labor towards making the labor itself easier." - Bisqwit. A beautiful simple, and precise quote to demonstrate the realities programmers go through in life.
@tomyyoung2624 Жыл бұрын
yes cest de la scrap
@RobertMilesAI7 жыл бұрын
I implemented something very much like this for a chatbot with a lot of modules. It had a kind of subsumption architecture where each module would be shown the input message in turn, and if a module thought it could handle the message, it would be the one to respond. This meant the output was sometimes very confusing and hard to debug. So I added a 'why' data structure that every module had to fill whenever they responded to a message. So then if the bot said something weird you could say "bot, why did you say that?" and it would reply using the contents of the 'why' data structure, like "You said 'what is the capital of england?', which seemed to be a geography question, so I asked Wolfram Alpha and it said 'London', so I said 'London' "
@Bisqwit7 жыл бұрын
The exciting thing about neural network based AIs today is that they are totally _incapable_ of providing justifications for their decisions, much like little children (at least until they think hard enough). It’s all basically a number soup from which a decision emerges somehow.
@RobertMilesAI7 жыл бұрын
Yeah! In this way they're really the same as the vast majority of the brain as well. If you find a bug in your visual cortex (like an optical illusion), you can't ask it "Why did you decide these parallel lines are sloping towards each other?" (upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Caf%C3%A9_wall.svg/1200px-Caf%C3%A9_wall.svg.png), the neural network is just a 'black box'. But there's some interesting work being done on making the artificial ones more legible. I think it's pretty important for safety reasons to be able to understand why a neural net behaves as it does, maybe I'll cover some of that research for my AI Safety channel :)
@animowany1117 жыл бұрын
+Robert Miles There is a lot of research put into visualizing neural nets. Do you remember Google DeepDream? That is an attempt at visualization. It adapts the input to maximize the activation of a single neuron, or a group of neurons, so you see that one neuron detects eyes, another neuron detects trees, and some other neuron detects windows. As a side effect, it produces images from an LSD trip.
@computerfis7 жыл бұрын
It is really an exciting age to be a part of (:
@josealvim15566 жыл бұрын
Oh, I wondered why I recognised your name! Your videos about AI in computerphile always peaked my interest. I had no idea you had a channel of your own, good to know :D
@maxfortin92117 жыл бұрын
Thank you for being my absolute favorite programming channel!
@MrVankog7 жыл бұрын
Max Fortin Do you have suggestions for any others? I really like the sessions from Coding Train (formerly known Coding Rainbow). The guy is amazing and I love the concept.
@maxfortin92117 жыл бұрын
MrVankog Computerphile. All the way. It's a little more theoretical but it's honestly awesome. Cherno also does a well done tutorial on c plus plus and other languages.
@MrVankog7 жыл бұрын
Max Fortin Computerphile, how could I forget ^^ Yeah, but often times the videos over there are not what I'm expecting of it. Too often it's only a history lesson or an interview or philosophical questions (sometimes interesting, sometimes not). And if interesting stuff is shown, it's often not deep enough for me. Mostly it's just a shallow overview of a topic. So generally they are aiming for people who are new to programming and information science and thus are mostly not nerdy enough for me. ^^ On the other side of the spectrum there is Bisqwit who is so deep in the field that I often just plain out. *g
@jamesbalajan38507 жыл бұрын
+MrVankog If you like graphics programming, which Bisqwit does a lot check out Hopson. He even uses a similar soundtrack.
@ReagueOfRegends7 жыл бұрын
Bisqwit, don't beat your Finnish accent up. I'm an American who quite likes Finnish culture, and I find the language particularly fascinating (hence my user name), and I'm sure many people feel the same. Great video as always.
@MrPixifan7 жыл бұрын
Great video! As a novice programmer, I very much enjoy videos like these that are not so syntax heavy, but rather more conceptual or guideline focused. I hope to see more of this kind from you!
@HusseinbergDude4 жыл бұрын
This channel is Gold. I’m so glad I found this. Thank you for making these videos. You inspire me. I hope you keep making more videos.
@ricardo.mazeto7 жыл бұрын
Totally off topic comment. KZbinrs usually celebrate subscription count in decimal order. It would be cool to see you commemorating by powers of two. 65K, 128K subs. Or more precisely, 65.536, 131072 subs.
@Bisqwit7 жыл бұрын
I considered 32768, 33333, and other such numbers, but it’s been such a silly ride with daily view & subscription counts varying as much as by a factor of 100 from a day to the next, thanks to KZbin algorithms, that I haven’t even had time to make a video that wouldn’t be pointless by the time it’s ready. Incidentally it has made it almost impossible to use KZbin analytics to profile what works (in terms of SEO) and what does not, because there are no patterns, at all. If you are interested, you can check out socialblade.com/youtube/user/bisqwit/monthly and look at the graphs to see what I am talking about.
@hxveyyy55217 жыл бұрын
I have no clue what you are saying but i love your voice
@GodofWar15156 жыл бұрын
This was very educational. I enjoyed the fun examples and exercises you used. I hope you make more of these videos.
@DamianReloaded7 жыл бұрын
One drawback I've often seen in my own code is the state of mind one's into when writing the comment. Imagine you've been embedded into coding for weeks and you comment something in such a way that it looks perfectly clear, because you understand the context (which may span across many source files). Then you quit the code for months to work on something else and when you come back, the comment is anything but clear. It actually seems to make no sense at all! ^_^
@ETXAlienRobot2016 жыл бұрын
Or when there are no comments! XD
@r1pfake5216 жыл бұрын
Or when the comment is wrong and you try to understand how the code is supposed to do what the comment states until you give up / realize that the comment is just wrong
@comradepeter875 жыл бұрын
Yep. That's happened to me multiple times and I hate it XD.
@tomyyoung2624 Жыл бұрын
yes making any sense whatsoever.
@daan69957 жыл бұрын
Never been this early on one of your videos, wanted to say I love pretty much all types of videos you put out, keep up the good work :D
@jamesbalajan38507 жыл бұрын
Excellent tips for debugging code. These tips should be in the book "Code Complete" due to how useful they are. In most cases we do need to know not just how, but why.
@samiurkhan2 жыл бұрын
A little late to the discussion but I wanted to add a useful pattern here is to create a set of reasons why you're program might change state and declare them as a set of extern const char pointers). When the state changes, you pass this parameter. That way you can better predict and control the size of the compiled binary since string literals can get out of hand/overused in larger projects. I observe that Python and Go have this pattern (using error libraries) and C/C++ would benefit from the user doing that kind of work. As always, great paradigm, cheers Bisqwit!
@MrVankog7 жыл бұрын
Oh, please more of this. Coding patterns and best practices are totally intriguing to me. :-)
@EnderCrypt7 жыл бұрын
idk who this guy is, i dont even know why im watching this, but this has such high production value! subscribed
@twiksify7 жыл бұрын
Nice work, this reminds me of how an AI decision tree can be used to describe why each step is issued. For example if you ask the AI of a car to drive from A to B the steps might be ReleaseHandbreak-SetGearboxToNeutral-StartEngine-SetGearboxToDrive-ApplyGas-DriveToB-StopEnigine-ApplyHandbreak. You might ask the question why did you set the gearbox to drive and the decision tree will reply because I needed to apply gas.
@j56797 жыл бұрын
Please note that all shown mutex examples generate undefined behavior. Locking a mutex multiple times from the same thread without unlocking is UB. std::recursive_mutex would solve this problem in this case. Furthermore, instead of manually locking and unlocking, I'd suggest using std::lock_guard to fully make use of RAII. It also makes sure that the mutex is unlocked even if an exception is thrown between .lock() and .unlock().
@Bisqwit7 жыл бұрын
I totally agree about std::lock_guard and RAII. The reason I did not use that was the line number count: I didn’t want to need to shrink the font to fit more lines on screen. And as for std::recursive_mutex, it would not have evoked the deadlock effect, and that would have foiled the lesson. And while nested locking is undefined for std::mutex, it does result in a predictable deadlock on all platforms I have used it on, and trying to craft a lesson around the same effect without undefined behavior would have needlessly complicated this lesson with irrelevantities. To make sense of this, consider that the “std::mutex” on the screen is just a placeholder for a platform-specific non-standard mutex object. There _is_ no std::recursive_mutex or std::lock_guard for this platform unless you make them yourself. I used std-objects in the example code for brevity and for the ease of getting the point across. In any case, thank you for your input.
@gubx427 жыл бұрын
Just laughed out loud at code comments at 1:03 It really is a window in the world of professional development.
@TBasianeyes7 жыл бұрын
The one at 1:20 got me.
@ihato85357 жыл бұрын
Many people have this innate repulsion against personalizing computer code (with the notable exception of printf() and comments) as if they think human traces don't belong in computer code or that mere strings will somehow affect code performance. Fantastic video by the way!
@MrHack4never7 жыл бұрын
Why do some programmers use signed int's in situations where the numbers only will go positive? e.g. runtime, counters, etc.
@Bisqwit7 жыл бұрын
That’s a good question. Maybe ‘int’ is considered a general purpose type suitable for counting and such and ‘unsigned’ is too pedantic. This is not my view, I do use unsigneds whenever I don’t explicitly need signed values, but I imagine that is how people think. It is worth noting that the code shown at 0:57 is not mine; it is copied¹ from a well-known open-source project from the late 1980s. ¹) With minimal changes; the original code is K&R.
@lolisamurai7 жыл бұрын
sometimes you need to pass around integers between functions that accept signed and you don't wanna be casting it or suppressing warnings, or maybe you will compare those integers to a signed integer later on. it's also pretty common to make stuff return negative values for errors and the result as a positive value for success. because of these reasons, I often end up making everything signed just in case. it's ultimately preference
@PixelOutlaw7 жыл бұрын
Great video as always Bisqwit! As others have said I like your accent. Your English has always been very good and clear. Anyway, this gives me a video to help my friends "get it" when it comes to the why of programming.
@rcookie51287 жыл бұрын
seems like a legit paradigm to better counter upcoming errors! Thanks!
@MinimumOverkill7 жыл бұрын
Very cool technique, I don't do this too often but adding extra context parameters to your functions is a fairly solid solution for finding bugs. For debugging this is admittedly it's a lot less time-consuming than doing hex address math on paper, or doing blind breakpoint bisection until finding the bug. I will say though, I think if you do this sort of diagnostic in a hot path of your code in a performance-demanding program like a game or audio mixer, you may want to consider only using const char* or std::string_view (if you're in C++14 or later world), since that will avoid potentially-costly std::string(const char*) construction that can add up as you pass string literals as const std::string& parameters, and this will slightly delay the costs of passing around extra context until the parameters are actually used, while keeping copies off of the normal/success path. Alternatively, maybe having this context parameter behind a #define, so it is discarded unless running in debug or optimized-but-extra-diagnostics executables, would be another way to go. Another way I like is to assert on a failure condition, and use a debugger to break at the failed assertion point. The context is in the stackframe that caused the assertion, and then you can inspect the locals and call stack. This is pretty common to use via assert() or some other similar forced-breakpoint constructs like "__asm int 3" (on x86) etc, but maybe someone out there could use the reminder, as opposed to using printf. The downside to the raw assert method is typically the program aborts after the assert so you can't resume further, and even if you could resume (in the case of __asm int 3 / __debugbreak() / etc) it interrupts the flow of the program if you want to capture some timing-sensitive info multiple times without constant debugger pauses. Also, it mandates having a debugger, whereas the added-context method allows you to potentially share builds with other people and collect logs of all the failures later. I can see the value in that for long-running applications like games, emulators or network applications.
@jarrad20007 жыл бұрын
Nice idea! BTW: did you take a look at blender as a video editor yet?
@Bisqwit7 жыл бұрын
No, I have not.
@doriphor7 жыл бұрын
Looking forward to your next livestream! I hope it happens soon :)
@Bisqwit7 жыл бұрын
Me too! Thank you.
@ZLau137 жыл бұрын
For once a Bisqwit video I understand. I should appreciate documentation more but often what I do (demoscene) just requires visible results as soon as possible and the product only needs to run once for the compo :D
@TheVoidOne48687 жыл бұрын
Can anyone explain to me why there is a deadlock in the mutex example when there are is only one thread?
@Bisqwit7 жыл бұрын
Consider this simple¹ implementation of a mutex: struct mymutex { private: volatile bool locked = false; public: void lock() { while(locked != false) { /* busyloop */ } locked = true; } void unlock() { locked = false; } }; Now consider what happens if we have this code: mymutex test; test.lock(); test.lock(); // lock again The first time around, lock() will test “locked” and see it’s false. So it will not loop. It sets “locked”=true. The second time around, lock() will see “locked” is not false, so it will loop, waiting for _someone_ to set it false. And it never happens because it is a single-threaded program, so it loops forever, jamming the program. In my example this situation happens because the lock is acquired at the beginning of WriteBytes(), and while the lock is being held, WriteBytes() calls WriteByte() that also tries to lock the mutex. So, two lock() calls without an unlock() in between. _____________ ¹) This is simple, but actually _unsafe_ for use with threads. Its merit is it’s concise enough to drive the point across without having to explain atomic compare-and-swap functions.
@TheVoidOne48687 жыл бұрын
Bisqwit thank you very much for the explanation, I got it now. In fact I didn't see that WriteBytes calls WriteByte( I don't know why I didn't see that lol) and I thought that it was a trivial race condition problem with multiple threads but I couldn't find the multiple threads in the main. Thank you again for the time you dedicated to answer to my question. Keep up the good work! PS I didn't know about reason parameters and I have to say that your idea is very helpful and I am thinking of trying it out on my projects too.
@frogofdeparture5 жыл бұрын
Would it be possible to isolate these reason parameters to debug builds with some template/preprocessor/build system magic? More importantly, could it be done practically?
@yoloop937 жыл бұрын
Really useful tip. More of these please!
@Fellintr2 жыл бұрын
Now, I usually hate when people tell me how I should program. But this is actually a good idea!
@MegaHalobro7 жыл бұрын
hey joel, I program on windows 10 using an intel i5 with my code compiled with a recent minGw32 version(I fully installed the complete version in august) and using SDL2, will any code you have posted compile for me, I want to use your code to help me exercise my c++ knowledge, but as long as I can execute it
@ricardo.mazeto7 жыл бұрын
termbin.com/4d6b. What does this code do? Is this supposed to be an easter egg or its just a random IOCCC entry? I pipe random strings into it, it just cuts the 1st 5 letters.
@Bisqwit7 жыл бұрын
Here is the proper way to invoke that program: cat title-key scrambled.vob | ./efdtt >clear.vob You can find the source code in its originally released form here: www.cs.cmu.edu/~dst/DeCSS/Gallery/bowley-efdtt-dvdlogo.html
@ricardo.mazeto7 жыл бұрын
Hmm, turns out that this code unscrambles CSS, the DVD standard's copyright protection mechanism, from a .vob file. Cool! Thanks Bisqwit.
@jerrisharun44197 жыл бұрын
I want to become chess player but I started chess career at age of 19 but I'm amateur player ....I seen many biography of chess players like Bobby Fischer Carlson anand they started to play chess ..At age of 6 ..I feel confused ...Im helpless please give me a steady mind....And I wanna become programmer but idon't know what to choose ...Im confused I don't know abt programming but u started to play pc ...And operate at 1st grade ...But I'm having interest I can sit in front of pc 24 hrs a day ...I don't know what to do...pls help me....Sorry for my English I don't know English tat much
@Bisqwit7 жыл бұрын
English is not your problem, but punctuation is. It is the style where you trail off with "…" every few words, as if you are _wind,_ speaking into the wind: Words with no beginning and no end, no structure, just passages and pieces from an endless stream of thoughts. You are a human being. Learn to use punctuation other than "…".
@Kane-52637 жыл бұрын
A great thing to add to our daily code, i'm sure of it, and never through about something like that, thank you for the idea! But after thinking about it another W add to the What and the Why come to my mind, it's the When. What do you think is the beast approach to set it? Before creating the function? When we have something that "work"? At another time? How do you set it yourself when you use it?
@niteshmalani37425 жыл бұрын
I have .Ex4 file can you teach me how to remove protection on it. Is it possible ?
@Bisqwit5 жыл бұрын
Never heard.
@niteshmalani37425 жыл бұрын
@@Bisqwit give me your email I will sent you .ex4 file kindly check and tell me in this file eiditng is possible ?
@niteshmalani37425 жыл бұрын
@@Bisqwit how to convert Ex4 file in source code ?
@MrBrax3 жыл бұрын
this saved me in my most recent program, good thing i remembered this tip
@lehuynh76374 жыл бұрын
3:41 which program that you used to separate windows?
@Bisqwit4 жыл бұрын
Libreoffice Impress.
@guilhermealveslopes5 жыл бұрын
Reason parameters are amazing, instead of having the why in design only, we have the why inside the code itself!!!
@LukasanaTK7 жыл бұрын
Bisqwit did you ever try object pascal, if yes what do you think about Modern Object Pascal compared to C++?
@Bisqwit7 жыл бұрын
I used to program in Turbo / Borland Pascal before I began learning C++. Delphi (Object Pascal) is mostly derived from Borland Pascal. I enjoyed it a lot, but C++ is better. I haven’t been keeping tabs on how Pascal has been doing in the last two decades.
@Tinfoilpain7 жыл бұрын
Also you can use clang's -fsanitize=thread to catch any possible race conditions. It's very impressive.
@Bisqwit7 жыл бұрын
On platforms where it is available.
@rebuffedsalmon62647 жыл бұрын
How can I get the source code for his code editor? I have the executable, but I would really like to port this code editor so that it can be used in newer versions of Windows.
@Bisqwit7 жыл бұрын
It is not very portable code. It is designed around the limitations of 16-bit DOS and the obsolete pre-standard Borland C++ compiler, with only enough testing that it _appears_ to work in videos. If you search the comment sections of enough of my videos, you will eventually find the source code, but I highly suggest you do not waste your time with it, for reasons explained above and below. I would not even have made the editor to begin with, but Joe, the editor that I _actually_ use for all my programming, does not run in DOS, and back when I began making these videos, DOSBox was practically the only environment where I could record videos because all my computers were too slow for desktop recording. So I made a clone of Joe (well, nowhere nearly as full-featured, but with enough features to be able to show editing in a video). You are much better off running the real thing, which is Joe. Aside from the Mario, it looks and behaves exactly the same. It even runs in Windows, if you install either Msys (www.mingw.org/wiki/msys) or Cygwin (www.cygwin.com/). You can see me using it in Windows in this video: kzbin.info/www/bejne/bXrIgGp5jquXb6c
@jamesbalajan38507 жыл бұрын
Cool alternative to standard unit testing. I have couple of questions though Bisqwit. When you create production level code for a company do you follow clean code design methodology do you use macros, and do you use justified programming? Another question I have, which may be a little bit tedious because you have probably heard this before, yet I am curious as to when your next educational video will be released. And, as a final question, can we connect on LinkedIn as professionals?
@Bisqwit7 жыл бұрын
1) I only use the principle of this video for particular situations where it is warranted. 2) Should be coming actually within a week or so; it is being rendered right now. 3) I rather infrequently approve (some of) requests I receive on LinkedIn.
@jamesbalajan38507 жыл бұрын
Thanks for the reply
@EnvyThaGamez7 жыл бұрын
Bisqwit, I am very interested in learning python since talking to my Father's cousin who is an astrophysicist. She described how the language is quickly being widely used. For instance, she mentioned how NASA is beginning to adopt python and how the language being "modular" is one of its strengths. However, I still do not know the best method to approach learning it. Could you recommend a strategy, or the best resource for learning in your opinion? I love everything you have done on this channel!
@Bisqwit7 жыл бұрын
Python is a language I usually recommend for beginners, too. But to be honest I have no idea where you would go for material for beginners to learn Python programming. Not because it does not exist, but because I have not been looking for such material. I am pinning your post to give it more visibility for a moment so that others can hopefully give good answers!
@jchevertonwynne7 жыл бұрын
reddit r/learnpython had a load of resources on the sidebar, you might find them useful i really love python, favourite language i've used yet. so much quicker to write than java, and you basically write pseudocode that works!
@EnvyThaGamez7 жыл бұрын
Thank you!
@jimmoriarty33817 жыл бұрын
if you're willing to pay some money, you can check out the programming courses on udemy.com. At the time of writing this they're charging just 19.99 i got it and it seemed pretty gooooood(idubbbz). Also check out this website : www.stavros.io/tutorials/python/. It goes through the basics of python very swiftly. not saying u'll learn python in the 10 minutes it suggested, but it will definitely be a worthy read for someone interested in python(WARNING: it will be MUCH easier to read if you are already familiar with programming, but still, u know, just save the page and maybe it'll help you one day :)
@Anlerolo7 жыл бұрын
Hi Bisqwit, many people use Python in combination with C++. It helps getting more out of your time, as you obtain the advantages of both languages. Perhaps it could be a good theme for a tutorial video. Thanks for your videos, they are great!
@AkamiChannel5 жыл бұрын
Your videos make me happy.
@Bisqwit5 жыл бұрын
Glad to hear that!
@sznio7 жыл бұрын
Can this be feasibly implemented in the real world scenarios? The mutex example is a really good usage of this paradigm, I once ended up actually creating something like this when debugging a deadlock on a platform that didn't support pthreads (on Linux or other pthread platform, such deadlock as illustrated will immediately fault and let you know that you attempted to lock a mutex twice in the same thread). I think that forcing a programmer to explain themselves on every state change will cause them to ~~slowly descend into madness~~ stop paying attention to them and write "foo" in each one. This could be a feasible feature, if a programming language implemented it as a core feature, not tacking it onto already oversized C++.
@peace29417 жыл бұрын
Hello, just discovered the channel and i was wondering what tool he was using to auto type the code, i searched for it on his website but didn't find anything Thanks
@Bisqwit7 жыл бұрын
Maybe you need to watch a video instead: kzbin.info/www/bejne/a3XEZ42vhq-de5I
@peace29417 жыл бұрын
Thank you sir for the quick answer, awesome job !!
@Vextrove2 жыл бұрын
That is most definitely a Bach piece, although I don't remember its BWV number. I believe it may be a movement of one of the French/English/Italian suites, due to the way it is structured and certain musical elements used in the piece. It is definitely a keyboard piece though.
@Bisqwit2 жыл бұрын
I later found that it is Bach's Invention No. 15. Thanks for commenting!
@tomyyoung2624 Жыл бұрын
@@Bisqwit Yes a djinn,
@AlwaysTeachingable7 жыл бұрын
Bisqwit today I was a little bit worried about my bad documentation habits and there it goes ! A great video that helps me make better documentation, are you a djinn? :^) P.S keep doing what you love bisqwit I really appreciate your hard work
@Bisqwit7 жыл бұрын
Not a djinn, nor any other creature from the tales of 1000 and 1 nights. Just pure statistics :-) Thank you for commenting!
@per-axelskogsberg38617 жыл бұрын
This was actually really interesting and helpful. It is going to make collaboration alot easier. Thanks.
@The1wsx105 жыл бұрын
that strchr function looks like one that would benefit from micro optimization, since its the type of function that would be called a lot from many different places
@Norhther7 жыл бұрын
Really cool! I want more of those kind of videos
@Shadlock01337 жыл бұрын
Don't know if you checked it, but Rust has something similar builtin into standard library with Result and Option. Both have expect function, which does more or less what you explained in video.
@animowany1117 жыл бұрын
Except that .expect causes a panic (aka program halts) if the result is error, or option is missing. This encourages passing the error state further up in the program, which may or may not be a good thing. (You lose information on what initially caused the error, but functions can handle errors gracefully)
@thalesfm7 жыл бұрын
Passing the error along works similar to how exceptions do on other languages, but it generates more predictable control flow than using try-catch blocks IMO.
@ThreevanGH7 жыл бұрын
The classical piece is Bach's Invention No. 15.
@Bisqwit7 жыл бұрын
Thank you!
@sickysore7 жыл бұрын
thank you, your channel is amazing
@tomyyoung2624 Жыл бұрын
Yes I have yes!
@moji82257 жыл бұрын
Kudos for your efforts...just perfect ! thanks
@darkkevinyou7 жыл бұрын
Is this the bug mentioned in the errata? "The terminating null byte is considered part of the string, so that if c is specified as '\0', these functions return a pointer to the terminator." - strchr(3)
@Bisqwit7 жыл бұрын
Yes, that is correct.
@typedef_7 жыл бұрын
I was just about to ask "why" you locked in both WriteByte and WriteBytes haha. Cool.
@Bisqwit7 жыл бұрын
Both are user-callable functions, that’s why. But it is difficult to hide an “elusive” bug for education purposes in 50 lines of code that are all in plain sight, so forgive me if it seems silly. :-)
@Green-zp4le6 жыл бұрын
First of all, thanks for all the effort you put into your videos -- they're great and enjoyable to watch :-). Have you considered poking a bit into type theory and constructive mathematics? It turns out that there is an isomorphism between writing programs and proving propositions in logic (called the Curry-Howard isomorphism). In essence, it tells us that we can write our propositions as types in a programming language, and any program that inhabits that type is a proof of that proposition. Programming languages such as OCaml make use of this idea to implement something akin to propositional logic, but it is taken to a more of an extreme in proof assistants like Agda and Coq. A middle ground would probably be Haskell, which has a couple of more practical features of such type theories, but doesn't push it to an extreme and aims to be a programming language first. In essence, what this lets us do is express some of the invariants that we want our code to obey and we can check that it's the case statically (modulo implementation bugs, of course!). I'd be quite interested in seeing video from you trying to convey these terms in a simpler way and demonstrating some of the more fun aspects of it :-) (I am more than happy to answer any queries you might have, by the way). Thanks again for all your effort!
@Bisqwit6 жыл бұрын
It is a bit too academic and theoretical for my interests.
@Green-zp4le6 жыл бұрын
Fair enough, keep up the good work regardless! :-)
@greatwhite66197 жыл бұрын
Me: *Adds why parameters to all functions.* co-worker: WTF WHAT THE HELL HAVE YOU DONE ARE YOU OUT OF YOUR FUCKING MIND?!?!? AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
@haroldmcbroom78075 жыл бұрын
We think along similar lines, but you address a part of an equation I thought would never be possible... The _"Why"_ In robotics, we'll never have anything less than a chat bot, unless we teach the machine to respond based on it's purpose and proximity to others around itself, and attempt to solve the who, what, when, and where of the person it has come into contact with. Using this algorithm, I hypothetically take it a step further. A virus... The mind is to the human what a virus is to a machine; Who says a virus has to be bad, it's only the purpose for which you use a virus that determines moral intent. I propose the following, if it is at all possible... Game Concept to solve the problem of semi-spontaneous Artificial Intelligence within NPC's in a video game, to relieve the pressure of the master program having to do all the work itself. Artificial Intelligence, in my opinion should be external to the master program, rather than the program controlling dozens of AI's at any given time. Introduction to a limited virus that is quarantined within the confines of the gaming environment, it's only purpose is towards self-awareness, survival, and being aware of it's surroundings. Example Player Harold leases some space aboard a Space Station, and decides to turn that space into a Fast Food burger joint. He furnishes the restaurant, buys a cash register, and a computer for Human Resources related tasks, the only thing missing is the employees. He accesses his computer and goes to the Job Board, clicks on the food industry, and looks at all the possible NPC candidates and the skills they will bring to the job. These NPC's are not yet in the game, but once Harold clicks "hire", the game creates these NPC's and a virus is attached, giving it "life". Each spawned NPC has a "checklist" assigned to it, sort of like a pre-flight checklist in the aviation field. But this "checklist" is for AI's. It starts asking questions... How is my health... Am I hungry, thirsty... What do I want to do... My checklist says I have a job lined up, so I better be on my way, as I do not want to be late on my first day on the job. Per our agreed upon contract, I will be working such and such hours, but after that I am free to do as I please... but while I'm working, my mind must stay focused on the job. With every AI in the game, asking and answering the questions on their personalized check list, we create a game in which the AI's feel spontaneously real. Some jobs AI's take, after the required positions have been filled, may act as stepping stones to bigger and better paying job opportunities, after they've met the prerequisites having worked a lower end job, meaning, some of them have aspirations to rise above their current jobs, to pursue other opportunities, but recognize in order to meet a long term objective, shorter term goals must first be met. My question to you, Mr. Bisqwit, is such a virus possible, and how small can a virus be, if it's only task is to access data from some form of checklist, whatever efficient manner we can come up with to achieve this, as well to figure out path finding in order to reach those locations. There's also the concept of "virtual variables", which are variables in game, that are only visible in scope to AI's based on their training. For instance if an AI is trained in engineering, will not have access or even be aware of medical related events on screen, thus, AI's only have access locally to those events they are qualified for, and that goes for the player as well.
@r3ap3rpy6 жыл бұрын
Awesome video, excellent explanation.
@chaorrottai6 жыл бұрын
Why not use lock guards? Or a variable wrapper with a lock and lock guards? I just recently wrote one myself, tested it against many threads as win10 will let me generate. // Thread safe primitive/object wrapper template class tsafe { public: template tsafe(z val){ var = val; } t get() { std::lock_guard destrMutex(mut); return var; } bool set(t& val) { std::lock_guard destrMutex(mut); return var = val; } void directAccess(std::function func) { std::lock_guard destrMutex(mut); func(var); } // BASIC OPERATOR OVERLOADS // Asingment bool operator =(tsafe val) { std::lock_guard destrMutex(mut); var = val.get(); return true; } template bool operator =(z val) { std::lock_guard destrMutex(mut); return var = val; } // Addition t operator +(tsafe val) { std::lock_guard destrMutex(mut); var += val.get(); return var; } template t operator +(z val) { std::lock_guard destrMutex(mut); var += val; return var; } void operator +=(tsafe val) { std::lock_guard destrMutex(mut); var += val.get(); } template void operator +=(z val) { std::lock_guard destrMutex(mut); var += val; } // Subtraction t operator -(tsafe& val) { std::lock_guard destrMutex(mut); var -= val.get(); return var; } template t operator -(z& val) { std::lock_guard destrMutex(mut); var -= val; return var; } void operator -=(tsafe val) { std::lock_guard destrMutex(mut); var -= val.get(); } template void operator -=(z val) { std::lock_guard destrMutex(mut); var -= val; } // Division t operator /(tsafe& val) { std::lock_guard destrMutex(mut); var /= val.get(); return var; } template t operator /(z& val) { std::lock_guard destrMutex(mut); var /= val; return var; } void operator /=(tsafe val) { std::lock_guard destrMutex(mut); var /= val.get(); } template void operator /=(z val) { std::lock_guard destrMutex(mut); var /= val; } // Multiplication t operator *(tsafe& val) { std::lock_guard destrMutex(mut); var *= val.get(); return var; } template t operator *(z& val) { std::lock_guard destrMutex(mut); var *= val; return var; } void operator *=(tsafe val) { std::lock_guard destrMutex(mut); var *= val.get(); } template void operator *=(z val) { std::lock_guard destrMutex(mut); var *= val; } // COMPARISON OPPERATORS bool operator = val.get(); } template bool operator >=(z& val) { std::lock_guard destrMutex(mut); return var >= val; } bool operator ==(tsafe& val) { std::lock_guard destrMutex(mut); return var == val.get(); } template bool operator ==(z& val) { std::lock_guard destrMutex(mut); return var == val; } bool operator !=(tsafe& val) { std::lock_guard destrMutex(mut); return var != val.get(); } template bool operator !=(z& val) { std::lock_guard destrMutex(mut); return var != val; } private: t var; std::mutex mut; };
@Bisqwit6 жыл бұрын
This implies you have the full C++ standard library at disposal. I was just doing an example, and to make the code actually compilable by most people (so that it is not entirely just hand-waving) I used std::mutex. Ignore that, just imagine it is some platform-specific thing like core_util_atomic_cas_u8() from mbed. The point is not threads. The point is provide a trace of rationales. By the way, why did you write one yourself? Standard C++ has prefectly good std::unique_lock and std::lock_guard already.
@wojciechsura3 жыл бұрын
"Every fool can write code, which is understandable by the computer. Good programers writes code, which is understandable by humans"
@justanormalperson7 жыл бұрын
why would i myself bark commands at a computer? i can make a program to automate that so i don't have to
@wallabra4 жыл бұрын
pair? What?! Also, you're aware std::string is an owned type and you just copy it over the whole prot array, right? Just use a std::string* pointer type (or std::shared_ptr), and set those values to its address. (If scope becomes an issue, push it to a reference-counted reason set, and point at the item there instead!) And, instead of the redundant bool value, just initialize it to NULL :) Either way, I do like the concept! I do not like that it mostly depends on runtime execution aspects, like the stack and function arguments. I would prefer if it were more transparent, so that while it does not affect execution, things like debuggers could easily fetch attached justifications to function calls or expression fragments (akin to how Python attaches docstrings to callables!).
@Bisqwit4 жыл бұрын
Yes, I am aware that the string is getting copied. For a 512 kiloelement array with 20-character labels this means like 10 MB of RAM used. It is a cheap price to pay of simplicity of programming. The moment you introduce pointers, the program complexity increases: Null pointer dereferences, use after free, circular dependencies, memory leaks, all that stuff. Stuff that may come bite you causing perplexing crash/corruption issues the moment you are not paying attention. You are adding hurdles for the programmer for no reason. It is better to have code that you can identify on sight that this _works_ and can cause no issues. The more tightropes you add, the more likely someone will fall and injury themselves. A ROM hack insertor program is not a performance critical piece of software. _If_ this developer tool occupies 200 MB of RAM for the whole 20 seconds that it runs while linking stuff, compressing images and so on, and you run it on a laptop that has 2 GB of RAM, it is hardly worth spending optimization effort in.
@wallabra4 жыл бұрын
@@Bisqwit Well, all that stuff that bites you will only bite you wherever you use it, which is why you need to keep the code modular. In this case, you should perhaps add a few extra functions (and make them static or protected or something) that handles the low-level details of storing strings as pointers for you, while returning an empty string if the pointer is NULL. May I take a better look at it? I'd love to help! Perhaps as a fork, but nonetheless!
@wbuchmueller7 жыл бұрын
Another name for this approach could be "Reason Driven Development" or RDD for short since we already have TDD etc.
@MrVankog7 жыл бұрын
Wilhelm Buchmüller at the start of the video I was compelled to call it the same as Behavior Driven Development. But his examples showed me that justified programming is on a much lower level.
@Bisqwit7 жыл бұрын
I appreciate the synergy, but unlike Test Driven Development, what I introduce in this video is not a mechanism that _drives_ the entire development process. It is just a way of annotating your code in a way that may provide benefit in future at both run time and when reading source code. Unlike TDD, it can be even added as an afterthought.
@akj76 жыл бұрын
Clap Clap Clap. This is really impressive. I do want to know why you work as a bus driver while you seem to have more programming knowledge than most programmer i know and maybe the story about your family.
@MrGeekGamer7 жыл бұрын
I don't really think that adding a lot of extra code to explain why is any more helpful than say, adding assertions in most cases.
@ZLau137 жыл бұрын
Hey are you a professional developer these days? I thought you drove buses! Tell me about it, I'm curious :)
@inimk7 жыл бұрын
luutifa0 >> I heard that he wanted to get away from programming so be became a cab driver. I hope he got over it :)
@Bisqwit7 жыл бұрын
The bus company downsized due to competitive tendering, and I lost my job 1,5 years ago. Nowadays I do embedded programming at Etteplan IoT (former Espotel).
@xamael19897 жыл бұрын
You sir are great programmer
@niteshmalani37425 жыл бұрын
How to convert source code ?
@Bisqwit5 жыл бұрын
Into what?
@niteshmalani37425 жыл бұрын
@@Bisqwit I have .Ex4 extension file and I don't know how to convert this file or how to editing this file ..can you check this file and tell me ..sent me your email so I sent file into your email
@Bisqwit5 жыл бұрын
You spoke of source code. From: en.wikipedia.org/wiki/Source_code Quote: *In computing, source code is any collection of code, possibly with comments, written using a **_human-readable_** programming language, usually as plain text.* As for your Ex4 file, look into the documentation of the program that you made the file with.
@niteshmalani37425 жыл бұрын
@@Bisqwit this is only for how to coding source code ...I don't need this How to edit .ex4 file ?? How to decompile .ex4 file ??
@Bisqwit5 жыл бұрын
Look into the documentation of the program that you made the file with.
@christopherchamberlain84777 жыл бұрын
The only problem I have with this style of coding is the runtime cost of doing this. It'd be hard to justify a reason parameter if its used in a situation that is already occupying heavy memory or tight loops that execute 10 million times... but if there was a way to develop this pattern into a compile time removal ( like #DEFINE #IFDEF stuff ), then this might be a interesting pattern to follow.
@Bisqwit7 жыл бұрын
Obviously no guideline is to be applied religiously in every possible situation.
@christopherchamberlain84777 жыл бұрын
Woah, thanks for the instantaneous reply O_O . Anyway, this seems quite useful, and I'm sure I've implicitly done this sort of thing to fix problems in the past without thinking about it as a specific sort of pattern. I can imagine myself, inserting this into the code... solving the bug, and then removing it.
@skejeton2 жыл бұрын
As an option, a global could work, or some kinda registry
@Lak37 жыл бұрын
Great video, once again =)
@victorfds4 жыл бұрын
Excelente vídeo!
@grproteus4 жыл бұрын
This should be taught at Programming 101.
@Rand00815 жыл бұрын
"We spend effort in naming functions, variables, methods and function parameters meaningfully [...] just so we can understand later." You don't know how much you are way too much optimist.
@phildem4143 жыл бұрын
Something to think about ! 🤔 Principles always rule.
@srjskam7 жыл бұрын
Drive Ř. What's the story behind that?
@Bisqwit7 жыл бұрын
That letter occurs in the Czech language. In my early childhood I watched some children’s tv shows that were made in Czechoslovakia, and while they were dubbed in Finnish (and thus I was denied the opportunity to learn anything about the language or about its phonology), the letter Ř sat in my head until many years later when I figured out why it’s in my head. I decided to honor this fact in this video when I was making a faux command prompt.
@srjskam7 жыл бұрын
A fine letter, probably best known from Dvořák. Sometimes accented letters are a bit opaque, but ř does look like it sounds, something like ž+r.
@Bisqwit7 жыл бұрын
You have a penchant for languages, I gather.
@srjskam7 жыл бұрын
You could say that. Unfortunately my knowledge of languages is wide but very shallow.
@MateoHrastnik7 жыл бұрын
In my opinion adding a why-parameter feels kind of hacky. If C++ had some kind of way to implement reflection this could be done without burdening the user of the function with the need to pass parameters that are unneeded for the function to actually work. However, as C++ has it's limitations, I guess the why-parameters are a better-than-nothing method for preventing bugs or speeding up bug-fixing.
@perplexedmoth7 жыл бұрын
H& 1Cloud it's in the video where he passes a const char *why parameter for runtime diagnostics purposes to critical functions.
@Bisqwit7 жыл бұрын
1Cloud, that question is answered in the video. Suggest you watch it before replying to comments concerning its content. :-)
@Bisqwit7 жыл бұрын
There are captions too. And even on-screen interstitial headers/plaques that say as much. I mean, why are you here if you are not watching/listening the video?
@LambOfDemyelination7 жыл бұрын
Will you ever do a video on any of the popular interpreted programming language such as Ruby, JS or Python?
@Bisqwit7 жыл бұрын
Maybe! I don’t know. I mostly make videos about topics that excite me at some particular time. I haven’t been doing anything with Ruby, JS or Python in a long time.
@IrizarryBrandon7 жыл бұрын
This looks like a pretty good idea, actually. :)
@kari40567 жыл бұрын
I miss you bis;(
@tomascanevaro42927 жыл бұрын
What did you study in collage?
@Bisqwit7 жыл бұрын
“College” is a USA/Britain thing so the answer is _mu._ I went to a trade school (en.wikipedia.org/wiki/Vocational_school) in the 1990s, but the line was electrical engineering; there was no computer programming related school (that I knew of) back then. After that and after army, I went to this kind of school: en.wikipedia.org/wiki/University_of_applied_sciences_%28Finland%29 , but I never finished even a year (and all I learned there was some physics and math, which the education system seemed overwhelmingly biased towards) because I got full time employed.
@TheSuperTubeMan7 жыл бұрын
I assume then you are self-taught?
@chrisd41577 жыл бұрын
> and all I learned there was some physics and math Isn't that useful for Embedded development? As far as I know, Signal Processing, Control Engineering, Hybrid Systems and so on are big parts of it and they're based on Math and Electrical Engineering. But I don't know anything about Embedded jobs in practice. I'm still a CS student. Is a good grasp of Electrical Engineering helpful in your job? I'm looking at Embedded as a possible field I'd like to go into after Uni (I like low-level development) but my EE (and Physics) skills are almost non-existent currently. I'm planning to fix that eventually though.
@redsusoverparadise27003 жыл бұрын
This has what had happened after I let my computer scan a philosophy book.
@Embedonix7 жыл бұрын
Well, very good reasons...but in embedded systems....that would cause too much overhead :(
@Bisqwit7 жыл бұрын
It really depends. The mutex example I showed in this video is (modified) from an actual project at work. It runs in a 8 MHz processor with 20 kilobytes of RAM, and it is not too heavy.
@multimartax7 жыл бұрын
great video as always, can't wait for the next
@kamilchen47 жыл бұрын
thank you!
@metaorior3 жыл бұрын
i love you man.. you are of my family
@TeboShepherd2 жыл бұрын
Oh man I wonder what the original 'a bit too pretentious' name was? Was it G0dØfK0D3? Or TheBestFinn?
@Bisqwit2 жыл бұрын
Something like that.
@hexwrench44337 жыл бұрын
Just make sure your sober or you'll be caught in an ever increasing anger loop.
@didaloca6 жыл бұрын
Took me far too long to realize why lock was being called twice.
@radityaarhya7 жыл бұрын
Where are you bisqwit ?
@Bisqwit7 жыл бұрын
Hello! I am still making videos. The current ones just happen to be taking long time to make. You can follow me on Twitter, I post updates there regularly about my videos and random things I have on my mind. twitter.com/RealBisqwit You can think of it as the official blog of my KZbin channel, as long as KZbin itself does not have this sort of tool.
@Nellak20115 жыл бұрын
Anyone else expecting to see an esoteric programming language?
@ricardo.mazeto7 жыл бұрын
I like classical music, but I never heard this piece before. Not my cup of tea. I tried Shazam, it fails miserably.
@Bisqwit7 жыл бұрын
Ricardo Mazeto Dang. I was hoping someone could identify it besides the game it is from. Sounds like Bach because of the syncopation.
@ricardo.mazeto7 жыл бұрын
But in the video description, it says "Composer: Kenji Yamamoto". Maybe it was composed just for that game.
@Bisqwit7 жыл бұрын
It was indeed Bach, just as I thought. ThreevanGH correctly identified it as _Bach’s Invention No. 15._ You can listen to it here: kzbin.info/www/bejne/nqq3cmd5iZVgpqM or here: kzbin.info/www/bejne/aaKkh6qmlJd7esk
@ricardo.mazeto7 жыл бұрын
I think I prefer the 8-bit version. Haha. EarthWork Jim 2 also have 2 (AFAIK) great Bach songs, "Vilii People (Moonlight Sonata Mov 1)" (kzbin.info/www/bejne/gIjQfJ2ho86WeKs) and "See Jim Run, Run Jim Rum (Moonlight Sonata Mov 3)" (kzbin.info/www/bejne/an2bhXujbdOEfpY). My favorite Bach pieces.
@Bisqwit7 жыл бұрын
At least for Moonlight Sonata, I do greatly prefer hearing it on a piano. kzbin.info/www/bejne/aWaVon-NprCBY7c , kzbin.info/www/bejne/haSyhpafoN56iM0 . That’s not Bach though, that’s Beethoven.
@prilik7 жыл бұрын
If anyone wants to take a crack at deciphering the code that borders the video, here is a pastebin of it :) QHJR3kzi
@Bisqwit7 жыл бұрын
You can post full URL links too. Also check out the prior comments. Also, your pastebin gives “This page is no longer available. It has either expired, been removed by its creator, or removed by one of the Pastebin staff.”
@prilik7 жыл бұрын
Whoops, didn't see that 😅 Neat!
@sqoonman5 жыл бұрын
Sad, because i could give only one like :(. Thank you so much for this tip
@CTimmerman7 жыл бұрын
My docstrings justify my commands.
@greob7 жыл бұрын
The amount of work put in this video is impressive. Thanks!
@MagikGimp7 жыл бұрын
But who was code?
@Bisqwit7 жыл бұрын
What.
@MagikGimp7 жыл бұрын
knowyourmeme.com/memes/then-who-was-phone I was playing on the fact that you'd already covered three of the 6 W questions (who, what when, where, why and how) so adding a reference to a famous meme seemed appropriate for one of the next ones. Come on man, you're supposed to be an intelligent nerd! :0
@Bisqwit7 жыл бұрын
Intelligence and knowledge of memes are not related.
@Kart4Lake5 жыл бұрын
i realize that autogen english subtile with NO mistake!