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
Maybe it's just me, but choosing react/typescript for a tui seems like such a bad choice. I feel like the only proper way to do something like this is using something like c, c++, go, rust etc. Using those doesn't mean you will automatically have good performance, but all of the best performing tui's I use are written in a C like language.
a while back we had electron powered terminals that ran on typescript and that .... kinda made sense even if it was extremely heavy. But writing a tui itself in typescript unless its meant to be used as an integrated node package for some complicated setup is beyond stupid.
 
I got invited to a vibe coding training session for work.

It sounds super gay, but it seems to be company wide. I'll join the video chat and leave it running to go smoke weed on my roof instead.
 
I got invited to a vibe coding training session for work.

It sounds super gay, but it seems to be company wide. I'll join the video chat and leave it running to go smoke weed on my roof instead.
Dear lord. I never considered the idea of untrained professionals "vibe coding" as a replacement for professionals using it to enhance their work.

This is the end state of middle management, isn't it? Is this what I dismissed that we were being warned about the whole time? I dread the thought.
 
This is the end state of middle management, isn't it? Is this what I dismissed that we were being warned about the whole time? I dread the thought.
"middle management" but construed very, very liberally. If you're following what's going on with institutional fraud in, eg. Minnesota, the reality is that there are a lot of jobs that aren't complete scams like the Quality Learing one, but basically exist because management doesn't want to fire Karen, so she gets some dumb busywork dead-end that isn't management or anything, it's ostensibly useful, but could be replaced "with a very small shell script" by an experienced dev. And when I say "a lot of jobs", it's looking more and more like "most of them".
 
"middle management" but construed very, very liberally. If you're following what's going on with institutional fraud in, eg. Minnesota, the reality is that there are a lot of jobs that aren't complete scams like the Quality Learing one, but basically exist because management doesn't want to fire Karen, so she gets some dumb busywork dead-end that isn't management or anything, it's ostensibly useful, but could be replaced "with a very small shell script" by an experienced dev. And when I say "a lot of jobs", it's looking more and more like "most of them".
I don't want to turn this into a full-on politics thread, but that's almost the entire economy. "Service economy", means that we all pretend to work and pretend to get paid when nothing is meaningfully being produced and our dollar is worth less year after year, while finance-bros enrich themselves through speculation. We should, by all means, be in some form of fully automated luxury gay space communism if the world was a logical, well-ordered place, and for the beneficiaries of fraud, it practically is, while the working white taxpayer is financially raped to support quality learing centers across the country.

On topic tax: Does anyone have any resources on "functional reactive programming"? I read about it as a buzzword while looking a bit at Elm but I have no idea what it means.
 
"functional reactive programming"? I read about it as a buzzword while looking a bit at Elm but I have no idea what it means.
Functional programming adores having no program state and composing programs from pure functions whose values depend only on their inputs. This results in a problem, because a useable program almost always requires state, and the functions become impure because they need to interact with that state and create side-effects. Further, in the case of an interactive program or a service, the inputs aren't actually known at the time when the main function is run.

Reactive functional programming solves this problem by outsourcing all the impure things to an external component (not considered part of the functional program), which waits for events and then calls functions in the functional program. So the functions remain pure and white, and it is the dirty nigger event loop component on the wrong side of the tracks where the return values cause side-effects (called "switching" for some reason).

If you ever wrote a one-off node service that has event handlers and no main program, you've kinda already done reactive functional.
 
This is the end state of middle management, isn't it? Is this what I dismissed that we were being warned about the whole time? I dread the thought.
Don't dread it, there's going to be a lot of well-paid consulting positions in a few years when all that shit has to be fixed rewritten from scratch.
 
Functional programming adores having no program state and composing programs from pure functions whose values depend only on their inputs. This results in a problem, because a useable program almost always requires state, and the functions become impure because they need to interact with that state and create side-effects. Further, in the case of an interactive program or a service, the inputs aren't actually known at the time when the main function is run.

Reactive functional programming solves this problem by outsourcing all the impure things to an external component (not considered part of the functional program), which waits for events and then calls functions in the functional program. So the functions remain pure and white, and it is the dirty nigger event loop component on the wrong side of the tracks where the return values cause side-effects (called "switching" for some reason).

If you ever wrote a one-off node service that has event handlers and no main program, you've kinda already done reactive functional.
this is part of why i dislike the functional programming meme.
"no side effects makes functions pure" but without side effects you can't have software that does anything more than return some value based on whatever command line arguments you pass in. this sucks.

also the "no state" paradigm clashes with how computers actually work at the hardware level. registers, cache, memory and storage all exist because holding and managing state is one of the most important things that all software needs to do. all the assembly instructions that your code compiles to (or that your interpreter consists of) are manipulating state. trying to abstract it all away to achieve mathematics-like elegance just feels wrong to me. i code to control actual real machines so they do what i want, not to jack myself off about how cool category theory is.
 
this is part of why i dislike the functional programming meme.
"no side effects makes functions pure" but without side effects you can't have software that does anything more than return some value based on whatever command line arguments you pass in. this sucks
But that is all that a command line program, stated most simply, is. Bytes go in, bytes come out. Even interactivity can be simplified down to (and, in theoretical scenarios, often is) input at certain points in time. A compiler, for example, "just" takes a program written in a high-level programming language as input and then outputs the corresponding program in a low-level language. In many ways, programming is about specifying how exactly one input should be transformed into another.
also the "no state" paradigm clashes with how computers actually work at the hardware level. registers, cache, memory and storage all exist because holding and managing state is one of the most important things that all software needs to do. all the assembly instructions that your code compiles to (or that your interpreter consists of) are manipulating state. trying to abstract it all away to achieve mathematics-like elegance just feels wrong to me. i code to control actual real machines so they do what i want, not to jack myself off about how cool category theory is.
The objective of controlling the machine is to make it calculate something in the end, no? To take some numbers in through one end and then spit out some different numbers through another. Functional programming is simply realizing this and trying to be as direct as possible in specifying what you want to do.
 
The objective of controlling the machine is to make it calculate something in the end, no?
the objective usually consists of establishing I/O behavior that interacts with and depends on various external systems (local OS, file system, local io devices, network stuff, some database) which means side effects are a necessity

even your example (compiler) needs to read and write files on disk (side effects) and the process of compilation involves constructing and manipulating a truckload of internal state (build abstract syntax tree based on the parsed source code then run code generation on the AST node by node)
and with all the crazy optimisations modern compilers are expected to do, this stuff gets very very complicated and involves a ton of interconnected subsystems, all of which need to do some internal (and sometimes global) state management.

can you organize parts of the work being done here into pure functions? yes it's doable, and it can have benefits like making parallelisation easier in some situations (if there is no shared mutable state then you don't need to worry about race conditions, don't need to introduce mutexes to avoid race conditions, don't need to worry about whether your mutexes can deadlock your program)
but i am doubtful about whether these benefits are worth the downsides of having to create and maintain code that is generally more complicated to write and design, more difficult to read and understand, and probably less performant than what you would end up with if you had gone with regular imperative/procedural code instead.
 
Even interactivity can be simplified down to (and, in theoretical scenarios, often is) input at certain points in time
In a deterministic clockwork universe, we're all just a series of inputs that have already been decided, waiting to punch them in at the nearest teletype.
 
but i am doubtful about whether these benefits are worth the downsides of having to create and maintain code that is generally more complicated to write and design, more difficult to read and understand, and probably less performant than what you would end up with if you had gone with regular imperative/procedural code instead.
In my experience, it is much easier to read, write and understand a bunch of pure data transformers with some I/O shims on top than a big state machine where half the state is implicit. At the end of the day, functional programming just forces you to separate concerns you should be separating anyways and exposes a lot of seemingly essential state as inessential caching. You can then deliberately choose which parts you actually want to cache for performance reasons.
 
can you organize parts of the work being done here into pure functions? yes it's doable, and it can have benefits like making parallelisation easier in some situations (if there is no shared mutable state then you don't need to worry about race conditions, don't need to introduce mutexes to avoid race conditions, don't need to worry about whether your mutexes can deadlock your program)
but i am doubtful about whether these benefits are worth the downsides of having to create and maintain code that is generally more complicated to write and design, more difficult to read and understand, and probably less performant than what you would end up with if you had gone with regular imperative/procedural code instead.
There are actually fewer differences between functional and procedural programming than you'd expect. The main difference is that procedural programming involves operating on implicit states. The state of a CPU is very much implicit - only upon actually sending signals to various other devices, as you mentioned, does it reveal its internal state to the user. The idea behind functional programming is to represent that internal state itself as an explicit input so that the program is easier to reason about and prove certain properties about. In fact, this sometimes allows rather performant code to be written (e.g. Erlang, occasionally Haskell) more easily than in a procedural language (C/C++). The difficulty in reading and understanding it mainly stems from being introduced to programming by procedural languages, in my opinion, rather than the functional paradigm itself.
the objective usually consists of establishing I/O behavior that interacts with and depends on various external systems (local OS, file system, local io devices, network stuff, some database) which means side effects are a necessity
In many cases, this is not actually the purpose of the program - these are incidental ways of gaining input for the core logic of the program (its actual purpose). A program could very well be structured as a core, functional loop that siphons data from several sources and outputs it to several sinks. The other programs connecting the core to the sources and sinks would indeed be procedural but that does not mean the core logic has to be.
 
The difficulty in reading and understanding it mainly stems from being introduced to programming by procedural languages, in my opinion, rather than the functional paradigm itself.
that is definitely true. if my first language had been something like haskell instead of BASIC i would probably find functional stuff more intuitive and easier to understand than i do now.
 
I love things like strong type systems or functional programming because I don't trust my coworkers to not do stupid shit like cast things that shouldn't be casted or to stash important state in places it shouldn't be stashed.

Hell, I don't entirely trust myself with code Marvin-two-weeks-ago wrote. I'm sure whatever bad practices that Marvin-two-weeks-ago made an exception for was totally justified. But still, I still need to carefully understand the semantics of what I did to avoid fucking it up today. That slows me down if I am going to do it properly. And if I'm in a rush, I am sorely tempted to just say "fuck it, I'm sure I didn't do anything too crazy" and assume because some branches of the logic completed, that's good enough.

Curl got 200 from the endpoint for the most common use case, didn't shit the bed, sounds legit.

If it's 4:45pm on a Friday, I kinda want to be able to fuck off for the weekend (and work on my personal passion projects in stupid obscure programming languages versus corporate python slop). If I can run a compiler that enforces way more stringent checks than, say, Python might enforce, that's super helpful.

Type issues seem to cause like 80% of the headaches I get from my coworkers. "this might fail and return null, so you have to check it"

A type system that bakes failure into its model is instantly way more productive of a language.

Edit: Oh great, apparently empty arrays are false in Python. Neat.
 
Last edited:
Does anyone have any resources on "functional reactive programming"?
"Reactive" basically just means "uses async in Javascript or equivalent".

https://www.reddit.com/r/scheme/comments/zue0pd/async_await_in_scheme/ - dude who wrote an async implementation for IronScheme chats about it on Reddit here.

So "functional reactive programming" in JavaScript means, practically, something like using apply and async a lot.

Another way to look at it is like continuations and/or coroutines. You could make an async implementation effortlessly with call-with-current-continuation in Scheme.
 
I stumbled on this web book last night called Algorithmica while looking up some optimization techniques, found it really interesting and I wanted to recommend it.
 
A type system that bakes failure into its model is instantly way more productive of a language.
Fairly unrelated, but once upon a time I messed around with creating a scripting language that used ternary Kleene-Priest logic for all of its control structures, rather than the binary Boolean logic that we’re used to using. I did this on a whim because I saw that Fortran used to have three-way if statements and something in me just thought that would be really cool.
As I was developing it, I thought about how to make this system actually useful, and it occurred to me that this was a very natural place to put type checking. This was a dynamically typed language, and so normally to impliment that kind of stuff you’d use assertions or exeptions or reflection. The problem with each of those paradigms is that they’re something extra the programmer has to remember to insert, but if your type checking mechanism was baked into your logic system and control flow, then it would become ubiquitous.
It looked a little like this:
Code:
if x > 5:
    then: // Explicit true block
        return x - 5
    else: // Explicit false block
        return x
    err: // Explicit unknown block
        print("Looks like X isn't a number!")
        return unknown
Where unknown is the name of the third logical constant. The comparison operator does a type check, and instead of throwing an exeption or returning false if X is the wrong type, it returns unknown, and the if statement upon seeing the unknown jumps to the block labelled “err”. Thinking about it now, it would be great to combine this with an errors as values scheme. Imagine the previous statement but returning error(“value is not a number!”) in the err block.
This wouldn’t have the advantage that errors as values has in statically typed languages, that is explicitly flagging which functions can fail, but the thing about dynamically typed languages is that (theoretically) every function could fail, so it balances out.

I thought it was a neat idea.
 
Back
Top Bottom