408 karma · joined June 19, 2017
Combine, reuse, rewrite as needed.
Eliminate control flow.
I don’t know about you, but I definitely wouldn’t hit either of those buttons taking up most of my screen, and I definitely wouldn’t give out specific information on the second screen.
Depending on what people consider “going online,” this isn’t necessarily a problem.
Being glued to an endless feed of clickbait and advertisements is probably unhealthy.
Having a desktop running SETI in the background for the entire day probably isn’t.
I wonder what people mean when they say “going online.”
Many of them seem to be about what I, the developer, can use.
Let me reframe it — what if you thought of FP techniques as something you could expose to a user of your API?
What if you viewed all your work in a language as a language. Borrowing concepts like affine types (aha, rust!), dependent types (hello, Agda!), composition (from pipes to combinators, this one is everywhere!) is important.
Strictly procedural or OO concepts might be useful in an implementation, but it rarely helps the user.
Some people writing security vulnerabilities in C are feeling put off by a programming language with sanity checks.
The only difference between “modern, clean” C++ and the author’s switch is probably a concept that requires some type attributes.
The example is contrived, and the realization of “clean” code through runtime polymorphism is both dangerous and odd. The whole point of not using polymorphism is to catch runtime crashes at compile time, reduce overhead and improve readability. I know many people who wouldn’t use an object here anyway. Free functions would do nicely, and are infinitely compositional.
Programming is a form of expression between a human and a system. We should finally start treating it that way.
Write something beautiful.
Never use objects with behavior. (Ban OOP.)
Prefer monadic types.
Functions should only take or return moved values or const references. (These form linear types when you need state and ensure immutable values for stateless types.)
Never use a template without a concept.
Prefer the stack and ban mutable memory.
You end up with a functional language which resembles Haskell and competes with C. Not even rust has that level of generality.
The computation I’m talking about is whether you’re for more of a von neumann target or a lambda calc target.
This property becomes more useful when you’re trying to prove something about a function’s behavior over a bunch of well-defined types.
Languages like Haskell and Agda have these properties.
Rust also has some of these properties by default. It has an affine type system (the borrow checker) enforces some guardrails on ad-hoc state manipulation. C++ has linear-esque types in its pointers and higher-kinded types in the concepts and constraints features.
Edit: eh, that comment didn’t really say much. What I meant was that there are classes of algorithms that are stateless. Maybe the most useful are proofs.
Look, I’m a C++ dev. I live and breathe state. Weird, mostly-working gadgets are the real humans of the world.
But that doesn’t mean I don’t use linear types and write unit tests for my function composition. Sure, I’ll let closures capture their context, and I’ll allow pass-by-reference in my APIs, but that doesn’t mean I encourage it.
I do it regularly. They compose well (and you can pass them state for context).
I could see a monad being defined as a list of (typed) states with a functor. But they’re still stateless.
I could also see immutable data structures being implemented in a stateful way (they usually are in non-FP languages).
Oh, wrong universe.
Edit:
I use state, too. I get it. I just dislike it. It doesn’t usually compose and is rarely safe.
- Pattern theory
- Abductive logic
- Machine learning
Do they converge?
Functional F# syntax or bust.
“We can only be great at one thing. The rest we can only be good at.”
This doesn’t quite answer the question, but I think it’s related.
Anyway, the whole OSI has problems. If it were up to me, I’d redo IP to include named ports and see what follows.
Often, you have to both null-delimit your string and store its length somewhere. That’s the dangerous part. Messing either of those up, or passing your string to an API that messes that up, is not safe.
C strings are pointers to memory, either the stack or the heap, and follow exactly the same rules as everything else in that chaotic space: Not many.
I moved to a minimal std::filesystem-based watcher and optimized it from there.
There hasn’t been a formal head-to-head test between the two. That should be about halfway down my todo list. It’s worth revisiting more formally.
My response to this question should help here: https://news.ycombinator.com/item?id=33247155#33251437
In short, there’s no secret sauce. There’s an efficiency spread in (what I consider) edge-cases.
Every potential gain over other naive watchers implemented with kqueue is likely algorithmic. I store events in a historical map, compare differences to the current state of the file tree, prune them, and send events when they change. That’s the whole implementation: scan paths, record their attributes, check for differences in the map, and send events when they happen. I haven’t given much thought to exactly why it beats kqueue, nor are there any good tests showing by how much. (Again, this is worth doing.)