Better HN
topnewbestaskshowjobs
Log inSign up

codebje

1,356 karma · joined Jun 19, 2017 (9y ago) · 591 submissions

Submissions

comment 7y ago · link · parent

I pay Australian GST on AliExpress imports, but it doesn't make local outfits more viable. I buy hobby electronic components primarily, local suppliers are often one to two orders of magnitude more expensive, not just a few percent more.

comment 7y ago · link · parent

There is a much smaller set of useful 100Mb text files than there is of total possible ones. If there's only 15 million such useful 100Mb text files we should be able to map them to 15Mb executables.

comment 7y ago · link · parent

The events are a scheduling mechanism, not the work done.

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

Well, a reason to care about effects systems is to have a way to specify what a program is doing in a way that lets you calculate and manipulate properties of it (from proofs to optimisations), which generally means static typing and purity.

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

This is spectacular revisionism.

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

All monadic computation can be accomplished with continuations, which offer a way to thread the monadic bind between sub-programs. But at some point this is equivalent to saying that all continuations can be implemented with machine language... True, but beside the point.

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

A published code base doesn't necessarily mean a full revision history, just something others can reproducibly build and run.

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

My experience with ML notebooks in particular has been poor. But most of the publications I read are not in the field of ML, and I tend to prefer ones that use an abstract definition of an algorithm rather than code in any case - whatever the language of the day is, it probably won't be compilable in fifteen years, but the algorithm will probably still be relevant.

comment 7y ago · link · parent

The irony here is that you appear to be unaware of the former work on algebraic effects, to the point that this one lightweight blog post forms your entire understanding of it and you mistake it for a limited and ill-defined language construct...

comment 7y ago · link · parent

Common Lisp's condition system was first described in '83 for the Lisp Machine in a technical report that's hard to get one's hands on these days. It was described in an MIT AI Labs working paper a few years later by Pitman (https://dspace.mit.edu/handle/1721.1/41474).

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

That paper has another paper on algebraic effects in its list of references, so it's highly unlikely to be the origin :-)

comment 7y ago · link · parent

Jupyter notebooks are risky business for reproducible work. No dependency data means they're highly prone to bit rot. Stored results and out-of-order execution means they're prone to subtle errors. Environmental leakage is relatively high.

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

This should be a type error, because there's no further information available to resolve which implementation of FromIterator<> should be used. (Also you'd need to use filterMap to ever arrive at Vec<string> since you can't simply discard the errors.)

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

The most common intersection, IMO, is inductive reasoning. If you can write a working recursive function, you are also writing an inductive proof. The only explanation I have for why people think there's either no link to math, or that they can program but can't do math, is a cultural sledgehammer smashed into our collective skulls while we're young that tells us we can't.

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

I'm not sure it's really true that the NES represents a single hardware target. There's two families of CPUs (2A03, 2A07) with different clock speeds depending on whether the device is NTSC or PAL, within each family there's a half dozen or more revisions, DRAM controller chips changed frequently causing many interesting variations in how and when the object attribute memory could be read (or not read, as the case may be).

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

There really are still games out there that aren't built on the freemium model, yes.

There really should be freemium games that advertise a monthly ceiling on possible spend as a feature to attract customers who are wary of pay-to-win gaming or exploitative models.

comment 7y ago · link · parent

That throws the baby out with the bathwater due to its coarse grained nature.

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

There's an interesting duality in that. Companies are choosing to maximise profits by tapping into addiction and gambling, and consumers are choosing to accept and reward that.

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

I've been trying to find such games for my kids (4 & 6) - there really are no search options to help.

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

Check the regulators on those cheap boards, they're often well under spec and cause brown-out reboots when the wifi gets working.

If you don't use the more power hungry board features they still work fine.

comment 7y ago · link · parent

I buy unlocked Nexus devices to avoid mftr and carrier bloatware and update delays.

Never again for a Samsung device, they churn through models absurdly quickly, delay updates for months, and shovel tons of crap on.

comment 7y ago · link · parent

Build systems tend to get very complex Turing complete scripts, such as gradle for Java or Make for C. Having something almost as powerful but reducible to a normal form is very helpful for CASE tools.

comment 7y ago · link · parent

Recursion is fine, as long as an argument gets smaller at every iteration, since that guarantees termination.

comment 7y ago · link · parent

Six or seven, or thereabouts.

comment 7y ago · link · parent

The OS thread model is lightweight processes - each OS thread is essentially a separate process sharing a common section of the process control block. Context switches are still relatively heavyweight involving a kernel mode switch, CPU state save and restore.

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

You're probably not going to need a separate function for a binary operator.

comment 7y ago · link · parent

I usually start with types. A signature saying I'm going from a pair of ints to one int doesn't say why I want to do that, I trust that the function name will, but it does help guide me to a function that's more likely correct than one without a type signature. More complex types offer more benefit, as they constrain the set of correct implementations further. Consider just the value of saying Int x Int -> Nat.

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

The IRR is also controlled by a few entities that would be vulnerable to government intervention, but that's the tool we currently rely on.

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

Here at the University of Queensland formal methods are in optional classes for computing degrees. I'm in the last six months of a part-time postgrad coursework degree, during which I did both a formal specification and a concurrency validation course. For my thesis I did a formal model using a proof assistant to describe event sourcing.

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

There's several fine replies already. Another aspect to consider is that inheritance is tied up with polymorphism. If your B class inherits from an A class, then anywhere that an A is expected, a B may be supplied instead.

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.

1
1617181920