I've been thinking about switch statements lately which is what this article essentially talks about with regard to efficiently switching between behaviours based on syscall
If you think of virtual functions in C++ which are function tables and switch statements in interpreters and emulators and pattern matching in Rust as essentially jumping to code based on data or state is a fundamental part of computing.
Unfortunately it is slow.
I thought of the possibility of a language that has a switch statement that automatically turns into a compiler. A bit like a futumura projection. You use the dynamic switch and you get a compiler in return.
I think Pypy's Rpython is essentially a JIT compiler generator.
I want to define relationships between objects and send messages between them. Even though files, sockets, pipes, containers, processes are all objects, the interfaces between them are all different. You need to use a different API for each. I think REST is a step in the right direction. Imagine managing files and sockets and operating system resources with REST.
The ultimate destination of OOP is this idea we can wire up objects based on their relationships to other objects and instruct them to behave according to some pattern.
One of my ideas is to think of every object as a while True loop that handles messages to behave in different ways.
In object orientated programming, there is the observer pattern and there is reactive style.
But how do you group a set of objects and run the equivalent of epoll() or select() on it when the objects state changes?
I kind of want to group a set of objects together and define a relation between them and tell them to maintain some invariant.
For example, if I wanted to implement multithreading and associate a 500 sockets per kernel thread and multiplex 1000 clients to each thread. And recv for receive threads and send for send threads. And have a pipeline of steps to process incoming messages and outgoing messages. This is a lot of code.
If I could just create a thread object and associate it with a list of sockets and tell them to send messages to eachother when to run what. Then I could use OOP to manage files, sockets, containers. Kubernetes is not really OOP but it does manage objects.
I feel the abstraction doesn't exist yet. What comes to mind is the Knuth shell script versus a low level program.
IMHO the ioctl "generic data pipe" interface will always be needed for those use-cases where the more specialised ones don't fit.
Counting total binary size (not source lines or bytes, since those can easily change with formatting differences) is probably the best measure of software complexity, since it's what ultimately runs on the hardware.
Binary size doesn't quite work for the Plan 9 example because Plan 9's compilers are less optimizing than GCC/LLVM, leaving extra size that doesn't correspond to extra code complexity
If you think of virtual functions in C++ which are function tables and switch statements in interpreters and emulators and pattern matching in Rust as essentially jumping to code based on data or state is a fundamental part of computing.
Unfortunately it is slow.
I thought of the possibility of a language that has a switch statement that automatically turns into a compiler. A bit like a futumura projection. You use the dynamic switch and you get a compiler in return.
I think Pypy's Rpython is essentially a JIT compiler generator.
I want to define relationships between objects and send messages between them. Even though files, sockets, pipes, containers, processes are all objects, the interfaces between them are all different. You need to use a different API for each. I think REST is a step in the right direction. Imagine managing files and sockets and operating system resources with REST.
The ultimate destination of OOP is this idea we can wire up objects based on their relationships to other objects and instruct them to behave according to some pattern.
One of my ideas is to think of every object as a while True loop that handles messages to behave in different ways.