Justified Programming — Reason Parameters That Answer “Why”
Programmers usually bark commands at computers. Never does the computer ask “why”, and never does the programmer explain themselves. What if we did? Annotate the purpose of your function calls. It may save your day!
This is one of my few lessons that is not tied to any particular programming language. I do use C and C++ in these examples, but it would work just as well in nearly any other programming language.
Twitter: https://twitter.com/RealBisqwit
Liberapay: https://liberapay.com/Bisqwit (alternatives at https://iki.fi/bisqwit/donate.html)
Twitch: https://twitch.tv/RealBisqwit
Homepage: https://iki.fi/bisqwit/
You can contribute subtitles/captions at: https://www.youtube.com/timedtext_video?v=OrQ9swvm_VA Or to any video on my channel at:
https://www.youtube.com/timedtext_cs_panel?tab=2&c=UCKTehwyGCKF-b2wo0RKwrcg
Music:
- Tales of Phantasia :: Retaliation :: Motoi Sakuraba (converted into MIDI and played through OPL3 emulation through homebrew software)
- Famicom Tantei Club Part II: Ushiro ni Tatsu Shōjo :: Dean’s Room :: Kenji Yamamoto (SPC-OPL3 conversion)¹
- Onita Atsushi FMW :: Staff Roll (SPC-OPL3 conversion)
¹) This is probably an adaptation from a concert/fugue/toccata/something by Bach. If you are someone who knows classical music and you recognize this song, please clarify this in the comments! You can listen to the full song at: https://www.youtube.com/watch?v=Xa61vkTf3Vw
The first song can be listened here: https://www.youtube.com/watch?v=Ey10UDi1liE
ERRATA
There is a typo in the strchr code shown at 1:20, my bad! The (~0ul - 1) should be just ~0ul. Coincidentally it does not cause the function to return incorrect values, it just tanks the performance. Without the bug, the dummied out code is 50% faster than the short code, but with the bug, it is 50% slower instead. Note that the SIMD-optimized assembler-coded strchr in glibc for x86_64 is still almost four times faster than the corrected code.
But there is also an actual bug in the strchr code on screen, that causes it to return incorrect values. Can you spot it?
#Bisqwit #Programming #ProgrammingPhilosophy #SelfDocumentingCode
Видео Justified Programming — Reason Parameters That Answer “Why” канала Bisqwit
This is one of my few lessons that is not tied to any particular programming language. I do use C and C++ in these examples, but it would work just as well in nearly any other programming language.
Twitter: https://twitter.com/RealBisqwit
Liberapay: https://liberapay.com/Bisqwit (alternatives at https://iki.fi/bisqwit/donate.html)
Twitch: https://twitch.tv/RealBisqwit
Homepage: https://iki.fi/bisqwit/
You can contribute subtitles/captions at: https://www.youtube.com/timedtext_video?v=OrQ9swvm_VA Or to any video on my channel at:
https://www.youtube.com/timedtext_cs_panel?tab=2&c=UCKTehwyGCKF-b2wo0RKwrcg
Music:
- Tales of Phantasia :: Retaliation :: Motoi Sakuraba (converted into MIDI and played through OPL3 emulation through homebrew software)
- Famicom Tantei Club Part II: Ushiro ni Tatsu Shōjo :: Dean’s Room :: Kenji Yamamoto (SPC-OPL3 conversion)¹
- Onita Atsushi FMW :: Staff Roll (SPC-OPL3 conversion)
¹) This is probably an adaptation from a concert/fugue/toccata/something by Bach. If you are someone who knows classical music and you recognize this song, please clarify this in the comments! You can listen to the full song at: https://www.youtube.com/watch?v=Xa61vkTf3Vw
The first song can be listened here: https://www.youtube.com/watch?v=Ey10UDi1liE
ERRATA
There is a typo in the strchr code shown at 1:20, my bad! The (~0ul - 1) should be just ~0ul. Coincidentally it does not cause the function to return incorrect values, it just tanks the performance. Without the bug, the dummied out code is 50% faster than the short code, but with the bug, it is 50% slower instead. Note that the SIMD-optimized assembler-coded strchr in glibc for x86_64 is still almost four times faster than the corrected code.
But there is also an actual bug in the strchr code on screen, that causes it to return incorrect values. Can you spot it?
#Bisqwit #Programming #ProgrammingPhilosophy #SelfDocumentingCode
Видео Justified Programming — Reason Parameters That Answer “Why” канала Bisqwit
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
PSX Chrono Cross 9h TAS [26 of 52: The Einlazer] Played by BisqwitPortal 2 custom map "Broken Device"PSX Chrono Cross 9h TAS [25 of 52: The Masamune] Played by BisqwitPortal 2 custom map "Red Omen"PSX Chrono Cross 9h TAS [20 of 52: The New Life] Played by BisqwitAdlib theme #54 -- a song made with Scream Tracker 3.2 (composed by Joel Yliluoma)Portal2 with HDRI [combating the greyness!]PSX Chrono Cross 9h TAS [28 of 52: The Grieving] Played by BisqwitPortal 2 custom map "Magician's Boxes"Portal 2 custom map: "Unpoignant Drop Combo"Black Mesa LP Blind PART 24: Pressure Points -- Chapter 9PSX Chrono Cross 9h TAS [39 of 52: The Sky] Played by BisqwitSFC Tales of Phantasia opening & intro & gameplay [FINNISH]NES Memory Visualization: Mega Man [Revision 2]PSX Chrono Cross 9h TAS [11 of 52: The Hydra] Played by BisqwitPortal 2 custom co-op map "Objective"Logic gates introduction through Portal 2 Perpetual Testing InitiativePSX Chrono Cross 9h TAS [45 of 52: The Fate] Played by BisqwitMountainland [two revisions] -- a song made with Scream Tracker 3.2Portal 2 custom map "Turret Overwatch"Black Mesa LP Blind PART 41: Tanks Everyone -- Chapter 12