update issues
This commit is contained in:
parent
04a346d851
commit
2a68cfbf63
44 changed files with 1201 additions and 318 deletions
|
@ -12,6 +12,7 @@
|
|||
|
||||
% id = "01H9R1KJESJ0G0VQAW994ZHR0S"
|
||||
- take the following example:
|
||||
|
||||
```cpp
|
||||
class ComfyZone
|
||||
{
|
||||
|
@ -41,16 +42,16 @@
|
|||
- this can be _very_ hard to spot if you have a big class with lots of declarations inside.
|
||||
|
||||
% id = "01H9R1KJESCJ3VC8ATPYFDCPSP"
|
||||
- this can be worked around by banning access modifiers from appearing in `#ifdef`s, but you have to *realize* that this might happen
|
||||
- this can be worked around by banning access modifiers from appearing in `#ifdef`s, but you have to _realize_ that this might happen
|
||||
|
||||
% id = "01H9R1KJES4ZYHVADDF80WAXH6"
|
||||
- and I've seen instances of this exact thing occurring in the Unreal Engine codebase, which is *full* of long lists of declarations (made even longer by the prevalence of `UPROPERTY()` specifiers)
|
||||
- and I've seen instances of this exact thing occurring in the Unreal Engine codebase, which is _full_ of long lists of declarations (made even longer by the prevalence of `UPROPERTY()` specifiers)
|
||||
|
||||
% id = "01H9R1KJES182MCV2V0A4VHKKX"
|
||||
- even if we didn't have the preprocessor, that access modifier is state _you_ have to keep track of
|
||||
|
||||
% id = "01H9R1KJESH7PWNKCKW3H0WJHW"
|
||||
- I very often find myself needing to scroll upward after <kbd>Ctrl</kbd>-clicking on a field or function declaration, just to find out if I can use it
|
||||
- I very often find myself needing to scroll upward after `<kbd>Ctrl</kbd>`{=html}-clicking on a field or function declaration, just to find out if I can use it
|
||||
|
||||
% id = "01H9R1KJESFE6F1D4J5PA5Q381"
|
||||
- (thankfully IDEs are helpful here and Rider shows you a symbol's visibility in the tooltip on hover, but I don't have Rider on code reviews)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
% id = "01J0VN48B2Z5BFFEZCEYG63662"
|
||||
- obviously the simplest way would be to just use the C library.
|
||||
|
||||
```cpp
|
||||
int main(void)
|
||||
{
|
||||
|
@ -35,7 +36,7 @@
|
|||
- this approach has the nice advantage of being really simple, but it doesn't work well if you build your codebase on RAII.
|
||||
|
||||
% id = "01J0VN48B2CT2DVHEB1HGK8KB7"
|
||||
- and as much as I disagree with using it *everywhere* and injecting object-oriented design into everything, RAII is actually really useful for OS resources such as an `SDL_Window*`.
|
||||
- and as much as I disagree with using it _everywhere_ and injecting object-oriented design into everything, RAII is actually really useful for OS resources such as an `SDL_Window*`.
|
||||
|
||||
% id = "01J0VN48B2SX6GX0B3AKDVHGFX"
|
||||
- to make use of RAII you might be tempted to wrap your `SDL_Window*` in a class with a destructor…
|
||||
|
@ -81,6 +82,7 @@ struct window
|
|||
|
||||
% id = "01J0VN48B2E1X2G415P1TNG4CJ"
|
||||
- copying windows doesn't really make sense, so we can delete the copy constructor and copy assignment operator…
|
||||
|
||||
```cpp
|
||||
struct window
|
||||
{
|
||||
|
@ -99,6 +101,7 @@ struct window
|
|||
|
||||
% id = "01J0VN48B2AAD3SKFWNDMYV4FV"
|
||||
- so we'll also want an explicit move constructor and a move assignment operator:
|
||||
|
||||
```cpp
|
||||
struct window
|
||||
{
|
||||
|
@ -129,6 +132,7 @@ struct window
|
|||
|
||||
% id = "01J0VN48B2TFMXQRPPKJXEEX2E"
|
||||
- with all of this combined, our final `window` class looks like this:
|
||||
|
||||
```cpp
|
||||
struct window
|
||||
{
|
||||
|
@ -205,10 +209,12 @@ struct window
|
|||
|
||||
% id = "01J0VN48B2WZ9PAX0W5W2ZMPPN"
|
||||
- albeit I'll admit that writing
|
||||
|
||||
```cpp
|
||||
int width;
|
||||
SDL_GetWindowSize(&window, &width, nullptr);
|
||||
```
|
||||
|
||||
just to obtain the window width does _not_ spark joy.
|
||||
|
||||
% id = "01J0VN48B2DCN9PPHHC818NPMD"
|
||||
|
@ -246,6 +252,7 @@ this is what _smart pointers_ are for after all - our good friends `std::shared_
|
|||
% id = "01J0VN48B2NBTZ62YDNKMDN1CC"
|
||||
- to set a custom deleter for an `std::shared_ptr`, we provide it as the 2nd argument of the constructor.
|
||||
so to automatically free our `SDL_Window` pointer, we would do this:
|
||||
|
||||
```cpp
|
||||
int main(void)
|
||||
{
|
||||
|
@ -272,6 +279,7 @@ this is what _smart pointers_ are for after all - our good friends `std::shared_
|
|||
}
|
||||
}
|
||||
```
|
||||
|
||||
and that's all there is to it!
|
||||
|
||||
% id = "01J0VN48B2WHNDKVBSDJRTYG4T"
|
||||
|
|
|
@ -5,7 +5,7 @@ scripts = [
|
|||
]
|
||||
|
||||
% id = "01J291S06DS12DCFTNKJ27BNSQ"
|
||||
- *ooh I'm sure this one is gonna be really controversial but here I go*
|
||||
- _ooh I'm sure this one is gonna be really controversial but here I go_
|
||||
|
||||
% id = "01J291S06DRH9SP8K1QE03JVK8"
|
||||
- time and time again I've heard from people just how horrible JavaScript is, but I beg to differ.
|
||||
|
@ -31,15 +31,19 @@ you already have it on your computer.
|
|||
|
||||
% id = "01J2931RRHFPEH3D5MWEKGXGAE"
|
||||
- don't believe me? let me show you:
|
||||
```javascript i-am-showing-you-right-now
|
||||
|
||||
{:program=i-am-showing-you-right-now}
|
||||
```javascript
|
||||
console.log("see?") // and if you have JavaScript enabled, you can edit this!
|
||||
```
|
||||
```output i-am-showing-you-right-now
|
||||
|
||||
{:program=i-am-showing-you-right-now}
|
||||
```output
|
||||
see?
|
||||
```
|
||||
|
||||
% id = "01J2931RRHDZ979VTF2SN3J9CB"
|
||||
- and this goes for pretty much every modern personal computing device on the planet nowadays - *you can already run JavaScript on it.*
|
||||
- and this goes for pretty much every modern personal computing device on the planet nowadays - _you can already run JavaScript on it._
|
||||
|
||||
% id = "01J2931RRHEMZY9M5W3EG666YK"
|
||||
- sure it may not be the cleanest language in terms of design, but JavaScript running anywhere and everywhere is its superpower.
|
||||
|
@ -48,7 +52,7 @@ you already have it on your computer.
|
|||
- JavaScript being available on everyone's computers makes it a super-accessible programming language to learn: all you have to do is open your web browser and go to the console in its Developer Tools.
|
||||
|
||||
% id = "01J2931RRH51K35C80Z2NHSVRW"
|
||||
- moreso, if you are building a website and would like to embed a language interpreter (like me,) *you already have JavaScript for that.*
|
||||
- moreso, if you are building a website and would like to embed a language interpreter (like me,) _you already have JavaScript for that._
|
||||
|
||||
% id = "01J2931RRH65HHY6BQ7N0P9MX9"
|
||||
- yes, you could in theory embed [Lua][page:programming/languages/lua], but for most cases JavaScript is Already There and there is nothing wrong with it.
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
but the designers of Lua had the restraint to just have One.
|
||||
|
||||
% id = "01HRG2RJC13YK030EPGMKM9H8H"
|
||||
- tables are extremely powerful in what they can do, because they're more than just a way of structuring data - they also allow for interfacing with the language *syntax* through operator overloading
|
||||
- tables are extremely powerful in what they can do, because they're more than just a way of structuring data - they also allow for interfacing with the language _syntax_ through operator overloading
|
||||
|
||||
% id = "01HRG2RJC1PDZFB2WBW7D827KF"
|
||||
+ in fact object oriented programming in Lua is typically done by overloading the `[]` indexing operator.
|
||||
|
@ -56,18 +56,18 @@
|
|||
local fallback = { b = 2 }
|
||||
local base = { a = 1 }
|
||||
|
||||
-- The __index field can be both a function *and* a table.
|
||||
-- The __index field can be both a function _and_ a table.
|
||||
-- { __index = the_table } is a shorthand for { __index = function (t, k) return the_table[k] end }
|
||||
setmetatable(base, { __index = fallback })
|
||||
assert(base.b == 2)
|
||||
```
|
||||
|
||||
% id = "01HRG2RJC23XH1053A69MQJD4N"
|
||||
- I'll be honest that I don't like the standard library of Lua from a usability standpoint, but maybe it *doesn't need to be bigger*.
|
||||
- I'll be honest that I don't like the standard library of Lua from a usability standpoint, but maybe it _doesn't need to be bigger_.
|
||||
it's similar to the principles of [Go](https://go.dev/), where the language encourages using dumb constructs rather than super clever code with lots of abstraction.
|
||||
|
||||
% id = "01HRG2RJC2P3832KTQMANBHGE6"
|
||||
- though unlike Go, Lua has the goal of being *small* because it needs to be *embeddable*, especially given it's used in very constrained environments in the real world. (microcontrollers!)
|
||||
- though unlike Go, Lua has the goal of being _small_ because it needs to be _embeddable_, especially given it's used in very constrained environments in the real world. (microcontrollers!)
|
||||
|
||||
% id = "01HRG2RJC2S3V38FM6DB0481WK"
|
||||
- therefore there are technical, not just ideological reasons to keep the library small.
|
||||
|
@ -76,10 +76,10 @@
|
|||
- and I really like that from an embedder's standpoint, it's possible to completely disable certain standard library modules for sandboxing!
|
||||
|
||||
% id = "01HRG2RJC2W4MK96FMWRTS8QCJ"
|
||||
- Lua also knows *very* well how much syntax sugar to have to make writing code pleasant, but not to overdose it so much as to give you instant diabetes.
|
||||
- Lua also knows _very_ well how much syntax sugar to have to make writing code pleasant, but not to overdose it so much as to give you instant diabetes.
|
||||
|
||||
% id = "01HRG2RJC28DT0TZT47WPABD65"
|
||||
+ as an example, there's function call syntax: you can pass it a string or table *literal*, which is just enough to enable some really nice DSLs without making the grammar too complex.
|
||||
+ as an example, there's function call syntax: you can pass it a string or table _literal_, which is just enough to enable some really nice DSLs without making the grammar too complex.
|
||||
|
||||
% id = "01HRG2RJC2CVKS9CFVQ9HJSBH4"
|
||||
- once upon a time I dreamed up a DSL for building GUIs using this sugar.
|
||||
|
@ -97,7 +97,7 @@
|
|||
```
|
||||
|
||||
% id = "01HRG2RJC2T7BF6XS3T7Q8AXW2"
|
||||
- ***JUST LOOK AT HOW CLEAN IT IS!*** with no need to [invent magic syntax](https://www.typescriptlang.org/docs/handbook/jsx.html) or anything!
|
||||
- _*JUST LOOK AT HOW CLEAN IT IS!*_ with no need to [invent magic syntax](https://www.typescriptlang.org/docs/handbook/jsx.html) or anything!
|
||||
|
||||
% id = "01HRG2RJC2D69JYCWQXSF2FQNY"
|
||||
- the only missing thing then would be list comprehensions to be able to transform data into GUI elements, but even that can be ironed over using function literals:
|
||||
|
@ -122,7 +122,7 @@
|
|||
}
|
||||
```
|
||||
|
||||
interpret this code however you want, but *damn* it looks clean. again with no magic syntax!
|
||||
interpret this code however you want, but _damn_ it looks clean. again with no magic syntax!
|
||||
|
||||
% id = "01HRG2RJC2PA5KE0DH0RRFGW9E"
|
||||
- there is also the incredibly useful sugar for indexing tables by string literals: instead of `table["x"]` you can write down `table.x`
|
||||
|
@ -136,10 +136,10 @@
|
|||
the parameter is explicit, there is just sugar for passing it into functions and declaring functions with it.
|
||||
|
||||
% id = "01HRG2RJC2FF05JWQ6KHS4Y5WF"
|
||||
- I really wish Lua had at least *a* form of static typing though, since knowing about errors you make early is _really_ helpful during development.
|
||||
- I really wish Lua had at least _a_ form of static typing though, since knowing about errors you make early is _really_ helpful during development.
|
||||
|
||||
% id = "01HRG2RJC2JP3HRTVMAQ22HDVE"
|
||||
+ it regularly happened to me that a type error I made only occured at *some point* later during runtime; and then you have to track down a reproduction case and make a fix at the source. not fun.
|
||||
+ it regularly happened to me that a type error I made only occured at _some point_ later during runtime; and then you have to track down a reproduction case and make a fix at the source. not fun.
|
||||
|
||||
% id = "01HRG3MJ0KGZ8T4KHMV6KZXDK4"
|
||||
- there's also the ugly case I had with a division by zero in the last rewrite of [Planet Overgamma][def:planet_overgamma/repo], which caused a NaN to propagate through physics and into rendering, causing a crash.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue