Programming thread

  • Want to keep track of this thread?
    Accounts can bookmark posts, watch threads for updates, and jump back to where you stopped reading.
    Create account
Continuations are brain-melting though
that's why you wrap them up in nice hygienic macros and make them into whatever goofy high-level nonlocal control structure you want
or even use said macros from a regular old library if they happen to form an incredibly ubiquitous pattern

also returning multiple times from your functions is perfectly normal because we all know that returning from a function is really just calling a function with less steps
 
What does this even mean
well to implement the ability to call a function you need to provide it with some way to come back to the code that called it, and this is actually often done by arranging to pass it another function (a "continuation") which is then called when the function "returns"
and the joke is that the functions never actually return so they therefore have fewer steps than regular functions that do return
so any time you think of a function "returning" you can just think of it as calling its own continuation

many functional language compilers convert code into this style so that the continuations are explicit and then they can implement call/cc in like 3 lines of code by just picking out the current continuation and handing it back to the regular world where functions return after they're done
of course it's not the only way you can also just copy the stack like a fucking nigger as long as it's still semantically consistent (and it also avoids possible painful issues with managing all the continuations out in the user code that might get abused in weird ways)
 
I've learned about some pretty arcane stuff but so far I'm still drawing the line at continuations
oh continuations are pretty easy i am currently having a bit of trouble with monads
from what i know a monad is simply anything that acts like a monad which is not very helpful since i have trouble remembering the monad laws as they are usually expressed in completely incomprehensible haskell niggerscribbles
 
Python is probably the most "beginner friendly" though, which is where this conversation began, and it's decently widespread and well known.
I think it's one of the most beginner unfriendly languages out there, because it leads to really bad habits and taking shortcuts.
I've learned about some pretty arcane stuff but so far I'm still drawing the line at continuations
Continuations are quite fun to work with, though they can be a bitch to learn if you don't live and breathe FP.
from what i know a monad is simply anything that acts like a monad which is not very helpful since i have trouble remembering the monad laws as they are usually expressed in completely incomprehensible haskell niggerscribbles
for monads I usually refer to this video:
 
Last edited:
I think it's one of the most beginner unfriendly languages out there, because it leads to really bad habits and taking shortcuts.
yes it's absolutely not as readable or straightforward or elegant as its proponents frequently claimed back in the day
unfortunately it is a common myth that python is a great beginner language when it isn't very great
of course python and javascript (more so js, due to its very traditional c-like syntax and certain other advantages) could be good starter languages as long as you pay careful attention to what the student is doing and aggressively cuck them if they so much as think of doing something niggerlicious

javascript is actually quite unique among potential beginner languages because everybody already has a decent js repl installed even if they're a retarded windows peasant (if you doubt what i am talking about, please open the inspect element menu in the browser you are using to read this and look for the "console" tab. there it is!)
it is also actually pretty close to scheme if you ignore how weird and badly thought out a lot of its specifics are and be careful about not triggering the weird type conversion shit
it would be good to move beginners off of it the moment they write something more complicated than a breakout clone so they don't have to enjoy javascript edge case prison for the rest of their lives
and that would teach that changing languages is not some kind of impossible thing that takes years but in fact something basically every programmer does when they need to make a quick script to do some retarded shit and their main language would make it a bit too unwieldy (or there's a weird dsl that's a good idea for that specific task, see: man 1 make)

anyway the main point of a beginner language is to teach the student stuff like how variables and conditionals work and to give them a bit of flashy graphical power so they can have that "wow i could make any computer software i want if i worked toward it" feeling
 
from what i know a monad is simply anything that acts like a monad which is not very helpful since i have trouble remembering the monad laws as they are usually expressed in completely incomprehensible haskell niggerscribbles
oi mate.
Monads are easy once you start using them.

Other than that:
1. understand what monoid is. Which just means that you have set with associative binary operation and an identity element.
- set of integers and addition create monoid because 1 + 2 + 3 == (1 + 2) + 3 == 1 + (2 + 3) and 1 + 0 == 1
- So is string with concat becasue "abc" ++ "efg" ++ "hjk" == "abc" ++ ("efg" == 'hjk") and "abc" + "" == "abc"

2. understand what functor is. Which is just transformation of Category into another Category that preservers morphisms between.
Which is just fancy way of saying that you can fmap functions that would work on orginal Category. And for easiest functor it is just a container.
- Optional/Maybe is functor because fmap (+1) Just 5 == Just 6 Because Maybe Int preserves all operations that you can do on Int.
- So is List/Vector/Array because fmap (+2) [1, 2, 3] == [3,4,5] Because again List of Ints preserves all operations that you can do on Int. You use fmap to apply them.

3. Now you combine it into Monad. Bind has signature m a -> (a -> m b) -> m b .
- m a is a monad that transforms a the way functor would do.
- a -> m b is a function that takes not-transformed a and returns monad of b
- m b is monad of b which is returned value
What's important is the way that (a -> m b) work on m a is defined by monoid laws I.E if you have [1, 2, 3] and function that for number returns list of numbers length n so foo 1 == [1], foo 2 == [2,2], foo 3 == [3,3,3] etc.
Applying only fmap fmap foo [1,2,3] = [[1], [2,2], [3,3,3]] However bind does apply associative binary operation (which is concat for lists) and we are left with bind foo [1,2,3] == [1, 2, 2, 3, 3, 3]

It's very useful for operation that can fail and return Maybe/Optional. Because if you were only to use functor you will get nested optionals when you chain multiple operations. i.e talking string from db and converting it into number. Because if you were to get Just "123" from db using fmap toNumber (Just "123') == Just (Just 123) but using monad you get bind toNumber (Just "123") == Just 123 Which alows for chaining of operations.

There is also this site which has nice pictures explaining it: Functors, Applicatives and Monads.
And yes, I will autistically try to explain monads any time they will be brought up.
 
Could also be summarized as anything that is flatmap-able is a monad.
where flatmap does 2 parts: flattening and mapping
flattening meaning that nested structures such as lists of lists can be converted into non-nested ones. Or a tree of trees can be converted into a single tree. The exact way it gets flattened depends on the implementation though. For example the list of lists to list can be either concatenating the inner lists, or it could also be taking the sum of the inner lists and concatenating those values.
and mapping meaning that you can take the value within it and transform it without changing the structure of the container.

(different explanation which may help others who didn't vibe with yours)

note: fmap and flatmap are different.
 
javascript is actually quite unique among potential beginner languages because everybody already has a decent js repl installed even if they're a retarded windows peasant (if you doubt what i am talking about, please open the inspect element menu in the browser you are using to read this and look for the "console" tab. there it is!)
it is also actually pretty close to scheme if you ignore how weird and badly thought out a lot of its specifics are and be careful about not triggering the weird type conversion shit
it would be good to move beginners off of it the moment they write something more complicated than a breakout clone so they don't have to enjoy javascript edge case prison for the rest of their lives
and that would teach that changing languages is not some kind of impossible thing that takes years but in fact something basically every programmer does when they need to make a quick script to do some retarded shit and their main language would make it a bit too unwieldy (or there's a weird dsl that's a good idea for that specific task, see: man 1 make)
JS is a beautiful functional language used exclusively to write unholy abominations.

That's functors. Monads additionally have defined way of combining them with associative binary operation.
tbh, even as someone who has a degree in this shit, category theory terminology always makes my eyes glaze over when I read it.
 
tbh, even as someone who has a degree in this shit, category theory terminology always makes my eyes glaze over when I read it.
Category theory is sort of like Algol 68 to abstract algebra's Algol 60: It does something very similar but is adds a lot more complexity than seems justified by the gain in expressiveness, introduces entirely new terminology for things that we already had perfectly good names for, and everybody involved is (as near as I can tell) some sort of Commie scum (which explains the change in terminology, since Communism demands permanent revolution).
 
JS is a beautiful functional language used exclusively to write unholy abominations.


tbh, even as someone who has a degree in this shit, category theory terminology always makes my eyes glaze over when I read it.
Cat theory isn’t real it’s a scary story they tell math undergrads
 
Back
Top Bottom