1,356 karma · joined Jun 19, 2017 (9y ago) · 591 submissions
comment 7y ago · link · parent
Performance probably relates more to the ratio of time spent selecting the next event to time spent executing code between yields than anything else: a thread waiting on an event joins a queue, a thread requesting an event joins the same queue but also flags it as ready, and a thread blocking an event flags the queue as not ready. When a queue is selected, it's drained completely before a new queue is selected.
The run cost of the scheduler would depend mostly on the structure used to maintain the ready set, but a basic double ended linked list would provide linear time operations for ready/blocked management. Whole program compilation could provide lookups or perfect hashes for event queueing, or partial compilation could rely on imperfect hashing.
Optimising during compilation might work best by trying to fuse events such that the scheduler is invoked less often.
Things that are not apparent from a lightweight article like this include state transfer (how do I know details of the card inserted?) and the likelihood that I'd keep the code to each b-thread and hack on those to make new ones...
comment 7y ago · link · parent
The curry-howard equivalence is only as useful as the strength of the type system. We ideally want proof irrelevance, that is, any program satisfying the types is sufficient, but while some things remain outside the type system this is only true up to a point (think: time and space costs). Putting effects into types helps this along.
comment 7y ago · link · parent
Conditions arose out of MIT's AI labs, a place full of entrepreneurial enthusiasm and practical work, conditions were described in the early 80s.
Algebraic effects come out of Endinborough, a place full of academic research focusing on abstract algebraic models of computing.
Algebraic effects builds on theoretical work by Wadler, Spivey, and Moggi on monadic computation, not on Lisp. Similarly, Lisp around that era built primarily on the previous work on Lisp out of MIT, not on models of computing from around the other side of the globe.
These labs had different focuses, goals, and approaches. Lisp is one of a dozen languages of the time that found clever ways to express control flow and exceptional flow, but none of them were trying to find a model for defining semantics.
Years later, we discover that many of those old constructions are almost equivalent to models derived by PL research. That's not surprising, as the models are meant to help us describe programming in general, and the problems were already there to be solved. Using the models usually (not always) gives a better end result than the ad-hoc approaches.
Or sometimes we keep ignoring the models because we've always done it some other way.
comment 7y ago · link · parent
The main purpose of ideas like algebraic effects is to build on a firm understanding of a model of computation. Implementing algebraic effects (whether with call/cc or otherwise) lets one specify a program's behaviour more precisely.
Whether this seems useful or not is probably closely aligned with whether you think static types and purity are useful or not, perhaps.
comment 7y ago · link · parent
If your claims don't depend on specific behaviours of some body of code, you wouldn't need it - eg, an article claiming some asymptotic performance of an algorithm should describe the algorithm in the abstract s.t. the performance bound can be proven, not some specific language's implementation of the algorithm.
comment 7y ago · link · parent
comment 7y ago · link · parent
Algebraic effects were introduced by Plotkin in 2001 (https://link.springer.com/chapter/10.1007/3-540-45315-6_1) as an extension of Moggi's 1991 work on monads (https://www.sciencedirect.com/science/article/pii/0890540191...), which in turn built on work from the 70s and 80s on understanding computing from the perspective of category theory.
The chief difference, IMO, is that Pitman defined terminology for a language feature in some LISP dialects, while Plotkin showed operational semantics for algebraic effects that are compatible with the denotational semantics (ie, adequacy). Pitman wrote his paper using the AI Labs' practical experience with LISP for the benefit of other LISP practitioners. Plotkin wrote his paper using previous work on lambda calculus and category theory for the benefit of programming language theorists.
Plotkin may have been unaware of CL's conditions system, but since conditions do not have formal semantics, and their behaviour is not particularly useful for probablistic non-determinism (the main thrust of Plotkin's effects article), I doubt that being aware of it would have made him any less motivated or likely to do the work he did.
Dolan et al (https://link.springer.com/chapter/10.1007/978-3-319-89719-6_...) discuss algebraic effects for concurrency in the setting of a dialect of OCaml, and reference CL conditions (amongst other things) as related work. It's a very brief mention observing only that conditions fail to convey the full continuation as a value to handlers, making them unsuited to the use case at hand.
TL;DR: no, conditions aren't the same thing, and if they were, they lack the rigour to be useful without the work that went into algebraic effects.
comment 7y ago · link · parent
Literate programming suffers from this in general because you don't want to clutter up your document with noise about versions and so forth - even as appendices, including package information and build instructions is a lot of noise.
Requiring that papers making claims about some code base publish that code base simultaneously with the paper via the peer review process should be sufficient to improve the overall state of affairs.
Don't underestimate the value of demos and competitions with companion papers either, those tend to get a lot more notice.
comment 7y ago · link · parent
Using magic language syntax like checked exceptions in lieu of type system expressiveness is not great, which is why Java's checked exceptions are a bit on the unpleasant side. You can't have one map() that handles functions with and without exceptions, because exceptions aren't part of the type system.
In Rust, exceptions are part of the type system, so you only need one map(). If you also add syntactic sugar for the types such as:
1: fn foo(i: i32) -> string throws IOException
2: throw SomeIOException
3: try a catch IOException b
To mean, respectively and approximately: 1: fn foo(i: i32) -> Result<string, IOException>
2: return Err(SomeIOException)
3: match a {
None => b
Some(_) => {}
}
... you can keep the simpler program code of exceptions and keep the ability to express exceptions first class in the type system.The Rust implementation (syntax I use might vary from reality) of async/await is just this sort of syntactic sugar over a type: "async fn foo() -> X" is sugar for "fn foo() -> Future<X>", and "await!foo()" is (kind of) sugar for "foo().then(rest of the function)".
The only really kind of disappointing thing about this is that exceptions and futures don't get unified: we get ? for exceptions and await! for futures. Both of them ultimately are continuations: exceptions bypass the continuation and return an error immediately, futures call the continuation only when their value becomes available. The value of using a unified interface to continuations (or monads, if you prefer) is that you can use ones that don't have a magic blessed syntax: parsers with automatic backtracking written as simple imperative blocks, non-determinism via iterators where the continuation is a flatten operation, etc.
comment 7y ago · link · parent
This is a shame, because we spend a lot of effort in deliberately avoiding common abstractions in case it scares programmers away, but really we're just making it harder for everyone to learn all these things. We either eventually recognise the underlying pattern through our brain's capacity to extrapolate from examples (hard, slow), or learn the pattern explicitly and recognise it, or often never learn the pattern and have to learn each new language's way of doing things one by one.
And of course when we either don't know or deliberately avoid effective abstractions we make or propagate mistakes. See Java's first crack at Future, for example, which was practically useless since the only thing you could do with a Future was wait for it to be the present.
comment 7y ago · link · parent
And that's just the NES devices! The Famicoms were different again, there were at least two licensed clones, and dozens of unlicensed clones (if you, eg, wanted your game to sell in Russia, you'd care about being compatible with the Dendy as well as the genuine NES).
comment 7y ago · link · parent
I'm fine with having a free game using an IAP to unlock full functionality, or to have a small! series of IAPs for it.
I think there's also a viable model for subscription gaming, mobile MMOs are plausible.
Requiring that all apps indicate their (enforced) maximum monthly and lifetime spend limits would work very well for me. An app with a $20 lifetime limit is a try-before-you-buy app, and one with a $20 monthly limit is a subscription app. One with "Unlimited" for monthly is a freemium casino, and is much more easily avoided.
comment 7y ago · link · parent
I don't agree though that there's only up-front payment or freemium options on the table, nor do I agree that consumers wouldn't accept up-front payment if that was really on the table.
Consumers paid up front for games on the Gameboy and other handheld devices, and they paid enough to keep that industry alive right up until mobile games took over.
Any expectations consumers have right now that mobile games should be free is on the publishers, not the consumers - and while consumers are enabling and supporting the freemium casino model, I don't think that us humans in aggregate have as much freedom of choice as we like to believe.
Regulation is the only way out of this bind, but with the continued rise of neoliberalism that's just not going to happen.
comment 7y ago · link · parent
Indiscriminate third party advertising and freemium games are going to cause significant long-term harm to mobile gaming, and possibly also to society as a whole.
There's still some games out there that use IAP in small doses (<10 total) to sell reasonably sized chunks of content, but they don't make the money that freemium games do.
(My own device operates on the same rules as my kids - no third party advertising, no freemium IAP stuff. There's really nothing to miss in that space anyway…)
comment 7y ago · link · parent
Application threads are a part of the application runtime environment. Thread scheduling is little more than a function call and doesn't involve a syscall invocation, and can be hooked into runtime environment trigger mechanisms.
Kernels have to be one size fits all, application threads can be tuned more precisely, with greater visibility over the application's state.
comment 7y ago · link · parent
But mostly I like Haskell's type system for the high degree of confidence it gives me while refactoring. Type Tetris is a side benefit on that, IMO.
comment 7y ago · link · parent
RPKI roots trust at the RIRs, and that is a vulnerability, but any government intervention would end that trust and end the use of the RIRs as trust anchors. It's pretty unlikely to ever be used that way.
Disclaimer: I co-authored some of the drafts for RPKI and helped implement RPKI systems at an RIR.
comment 7y ago · link · parent
Neither formal methods class was particularly full, but neither was OS architecture, advanced algorithms, compiler design... machine learning and AI were both packed to the rafters though.
Kids entering university are picking based on current trends, and formal methods are not trending.
(Proof assistants are fun, though.)
comment 7y ago · link · parent
If another body of code entirely was written and tested using As, without knowing that Bs exist, it may not work if given a B, unless that B happened to perform exactly the same as an A in whatever (unknown, unknowable) ways matter to that other body of code.
An object's interface is its specification. But most objects are woefully underspecified, with types (if you're lucky) and perhaps a bit of prose explaining what it's supposed to do. Preconditions and postconditions are rare, laws and properties are rarer still. Languages that are able to test those things hold are even rarer.
My own recommendation is to inherit only from abstract parents, and if your language supports it, to make any concrete class final. If you need some behaviour to be overridable at time of use, apply the Strategy pattern. There's a cost to this: you need to implement Strategy, and you will not think of all cases where behaviour should be overridable. But the cost of random errors that crop up at run time is IMO likely to be higher.