Lurkmastergarbo
kiwifarms.net
- Joined
- Jan 9, 2025
This is functionally the same as saying "I am a furry" again.because its my flavor of social poison.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
This is functionally the same as saying "I am a furry" again.because its my flavor of social poison.
I do frequently put function pointers into structs for poor mans objects. But it very much is the exception, as I live by "have 100 functions operate on 1 data structure, rather than 10 functions each for 10 structures"Structs and functions are enough.
Making state a hidden thing you can treat like a black box. What it lead to was mutable global state that's hidden.Making state management easier. Which it does, but avoiding state is even better and lots of OOP stuff encourages you to put state all over the place, resulting in the spaghetti ball on the right. Doesn't help that a lot of OOP languages are also crippled in other ways.
"Let's try MY mental model, surely it will fix everything!" At least GOF did it while high and in Aspen I guess.
Also I like interchangeable parts. Standard bolts are neat.
A big place where interfaces can help with development is when you're trying to pass ABI barriers, What I essentially mean is when writing mods for games, you have to deal with shit where multiple plugins need to handle one specific kind of data structure. And while you can probably make that a generic pointer, it's a bit easier just to have an interface and a header that they all can just import. Yeah, it's still basically a function under the hood, but it makes it prettier.I do frequently put function pointers into structs for poor mans objects. But it very much is the exception, as I live by "have 100 functions operate on 1 data structure, rather than 10 functions each for 10 structures"
Making state a hidden thing you can treat like a black box. What it lead to was mutable global state that's hidden.
View attachment 9860018
Alan Kay devised a method of programming so simple that children could use it to write massively parallel programs, Object-Orientation, realized through a language named Smalltalk. A Danish idiot named Bjarne Stroustrup made a preprocessor for the C language that bolted a bad imitation of Smalltalk's less important qualities onto it. Now an adult and professional C++ language programmer working on a video game or critical infrastructure struggles to handle a few independent threads of execution, while sporting an insane fetish for efficiency in the small and blindness in the large.What was the selling point behind OOP, again?
I've seen a video on Pharo. Literally what is the difference between that and just using my terminal? I feel like half of these things are just "oh my OS's terminal is a deprecated piece of shit that I don't know how to use."Smalltalk.
If your objects encapsulate global state, then your objects are essentially modules and you're not really getting your money's worth out of OOP. That's a user problem though; common user problem maybe, but still.Making state a hidden thing you can treat like a black box. What it lead to was mutable global state that's hidden.
I try not to use YouTube.I've seen a video on Pharo.
The idea behind a full Smalltalk environment is the system comprising one language, top-to-bottom to the fullest extent possible. Modern Smalltalk implementations hit bedrock in a virtual machine rather than microcode. I'm much more familiar with Lisp listeners of that era, but does escaping the limitations of emulated video terminals not already sound appealing? It's telling that so much of our best virtualizations are predicated on mimicking what physically existed once, since most software is too pitiful to enforce real standards otherwise.Literally what is the difference between that and just using my terminal?
The idea behind a malleable environment is being able to change it as it's used. This is called an image. UNIX is also an image, just an extraordinarily shitty one.I feel like half of these things are just "oh my OS's terminal is a deprecated piece of shit that I don't know how to use."
That has no bearing on this.This kind of coincides with "C not having a package manager" roody-poo you have apt, pacman, dpkg, -etc.
I do frequently put function pointers into structs for poor mans objects. But it very much is the exception, as I live by "have 100 functions operate on 1 data structure, rather than 10 functions each for 10 structures"
Making state a hidden thing you can treat like a black box. What it lead to was mutable global state that's hidden.
View attachment 9860018
I'm brand new to programming, but it is normal to not know which object class inherits which other class and which method takes what parameters from where and where they go from first glance? I tried to learn Flask recently and while I got it to work I ended up just rote memorising certain properties and methods since the documentation is terrible.
Neither, just learningAre you at a workplace or solo?
Thanks for the tip, didn't know such a thing existed.The second I had access to an IDE that could keycombo -> PARENT or keycombo2 -> FIND_USAGES, I started abusing the hell out of it.
tbh you will usually not know how the codebase works unless you have previous experience with it.I'm brand new to programming, but it is normal to not know which object class inherits which other class and which method takes what parameters from where and where they go from first glance? I tried to learn Flask recently and while I got it to work I ended up just rote memorising certain properties and methods since the documentation is terrible.
Flask documentation is pretty decent. If you have a decent editor or a decent editor plugin, it will show you the usage for classes, methods etc.I'm brand new to programming, but it is normal to not know which object class inherits which other class and which method takes what parameters from where and where they go from first glance? I tried to learn Flask recently and while I got it to work I ended up just rote memorising certain properties and methods since the documentation is terrible.
An example of a language that does this correctly (and has a fair number of features ripped off by Python, but unfortunately not this one) would be Icon, where every argument is optional and defaults toI like optional variables in Common Lisp and Ada, so I'm assuming Python fucks it up in some pathetic way. I recall reading that the default values are evaluated once at function definition rather than each time the function's called, for one. The more I learn about programming and Python, the worse the latter looks in every respect, so may I have a link to read more about why it's secretly a good thing the dipshit who made this language refuses to mentor white men?
&null, which gets away with this because it has a convenient feature for providing default values. The unary operator /x succeeds if x has the null value and fails if x has a non-null value (the default action if an expression fails is to skip the rest of the statement and continue on to the next one). Furthermore if x is an assignable variable, then /x is also an assignable value. This means that Common Lisp's(defun f (&optional (a 5) (b 3) (c (+ a b)))
...)
procedure f(a, b, c)
/a := 5
/b := 3
/c := a + b
...
end
def f(a = 5, b = 3, c = None):
if c is None: c = a + b
...
What usecase would there be for interdependant default args?An example of a language that does this correctly (and has a fair number of features ripped off by Python, but unfortunately not this one) would be Icon, where every argument is optional and defaults to&null, which gets away with this because it has a convenient feature for providing default values. The unary operator/xsucceeds ifxhas the null value and fails ifxhas a non-null value (the default action if an expression fails is to skip the rest of the statement and continue on to the next one). Furthermore ifxis an assignable variable, then/xis also an assignable value. This means that Common Lisp's
can be written asCode:(defun f (&optional (a 5) (b 3) (c (+ a b))) ...)
Code:procedure f(a, b, c) /a := 5 /b := 3 /c := a + b ... end
Since Python doesn't provide this and optional arguments have their default values evaluated at definition-time, you have to do abominations like
which becomes really tiresome when you have more than one argument that needs to be treated in this way, since there is absolutely no shorthand for it.Python:def f(a = 5, b = 3, c = None): if c is None: c = a + b ...
Maybe the length or final index of a sequence, which might be useful for something like:What usecase would there be for interdependant default args?
// Pseudocode
func removeSpineSlice(spine: Seq[Vertebra], start: Int = 0, end: Int = spine.length) {
// TODO implement brutal murder
}
That sounds horrifying, even with an easy way to specify defaults. Implicit nullability is another one of those big evils of programming.where every argument is optional and defaults to&null,
Taking a sequence, a start point, and an end point, where start defaults to 0 and end defaults to the length of the sequence. Generally, anything where there's an argument that can sensibly default to something derived from another argument.What usecase would there be for interdependant default args?
In Icon, the big use case would be pattern matching functions. The pattern is that the last three arguments are the string that is being searched, the index to start searching at, and the index to stop searching at. If a string is provided, the starting index defaults to 1, and if it isn't the string defaults to the contents ofWhat usecase would there be for interdependant default args?
&subject and the starting index defaults to the contents of &pos (these are global "keyword" variables with dynamic scope managed by the binary ? pattern-matching operator). In either case, the ending index defaults to the length of the string plus one (the first index past the end of the string).procedure f(..., s, a, z)
/a := if / s then &pos else 1
/ s := &subject
/z := *s + 1
...
end
/sneed even within a code block)# match exactly N characters from cset cs
# usage: exactly(4, &digits)
procedure exactly(N, cs, s, a, z)
N >= 0 | fail
while N > 0 do {
a := any(cs, s, a, z) | fail
N -:= 1
}
return a
end
As others have given a usecase for that, I'll share one even more obscure: Common Lisp provides the ability to see if the parameter was provided a value, which allows one to distinguish between the case of an omitted parameter and a supplied parameter given the default value. I love Common Lisp for thinking of everything like this, but I've only ended up using it once. It looks like this:What usecase would there be for interdependant default args?
(lambda (&optional (symbol-name default-value supplied-p))
...)
While cool, I prefer slices for this manner of thing.The pattern is that the last three arguments are the string that is being searched, the index to start searching at, and the index to stop searching at.
Use the [plain][/plain] tags for that purpose. That previous sequence was written as [plain][plain][/plain][/plain] for example.(apologies for the space between the slash and the s, but otherwise it gets wordfiltered to/sneedeven within a code block)