Better HN
topnewbestaskshowjobs
Log inSign up

codebje

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

Submissions

comment 7y ago · link · parent

All validation is only performed up to an assumed platform.

There's usually little value in worrying too much about how a real platform won't correspond precisely to that assumed platform, since the goal of validation is to remove a class of errors, not all errors.

comment 7y ago · link · parent

> Did the event happen yet? Did it succeed?

Events have already happened when you see them in the event log. It's happened, it succeeded.

> I didn't like having an event ledger say "comment created," where my application is then meant to consume this, handle validation, potentially fail on the db operation, etc.

You don't validate the past, you just accept it. Failing on the dB operation means your application is in error - if it's a transient error, retry with whatever backoff strategy you have. If it's a permanent error, you have a serious mistake somewhere in your code.

In your example, I believe you've broken one event into two parts. The second part essentially only says "the command was accepted." The first part says why there was a change made.

The first event is essentially "a user submitted a request to create a comment." The second event is essentially "a user's request resulted in a database change." The second event is not semantically interesting without the request's information, and the first event is of little interest outside of processing the request. Your application receives the _command_ to post a comment, validates the command, and records the outcome as an event.

A complete system would record errors as events as well as successes. This might seem very noisy, but down the line you might need to answer questions like "was this user doing lots of failed comments leading up to their successful hack of our system?" Or "how many comments are failing because the spam filter rejected them?" And you can't answer those if you haven't recorded the error outcome.

(And there's no harm in logging commands separately, too, but I'd log them explicitly as _commands_, not events. Commands are imperative tense, they're an order or request for the system to take some action. Events are past tense, they're what the system actually did.)

comment 7y ago · link · parent

If you took event sourcing out of the picture, how would you solve it?

This is a problem to do with distributed transactions, not event sourcing. If you don't need distributed transactions, don't use them. If you do need distributed transactions, redesign your system so you don't need distributed transactions. If you _still_ need distributed transactions, use one of the available mechanisms for making them occasionally work, like three-phase commit, or clocking, or blind luck, all of which work just as well with events as without.

If you'd be perfectly happy using a single database server doing a more typical ORM solution with tons of database locking without event sourcing, you can use a single database server with tons of database locking with event sourcing: just serialise all (or maybe most) events.

My domain has a lot of unpredictable coupling between events, such that there's not really a sensible aggregate model to divide up the information model (remember: an aggregate is the unit level of consistency in your system). But it's also low update volume, so we quite happily just serialise all events - which is what we did before event sourcing, using table locks.

comment 7y ago · link · parent

Basic event sourcing is quite simple to implement. All the bells and whistles people sell alongside event sourcing are hard - whether you do event sourcing or not.

Your typical application presents a user interface based on data in a set of database tables (or equivalent), the user takes some action, the database tables get updated.

The equivalent event-sourced application presents a user interface based on data in a set of database tables (or equivalent), the user takes some action, the outcome of that action is written to one table, the other database tables get updated.

For git, where "or equivalent" is the working copy. You could easily imagine a source code management system similar to git, but without storing history - every commit and pull is a merge resulting in only the working copy, every push replaces the remote working copy with your working copy.

But man, wouldn't it suck to be limited to only understanding the most recent state of your source code…

comment 7y ago · link · parent

Most problems are pretty quick to solve, maybe 30-60 minutes. Scheduling that time every day can be tough. Some problems are pretty tricky.

I still haven't solved all of 2017's, "some offset delay" indeed. I might not have solved all of 2016's for that matter - the closer it gets to Christmas, the less likely I am to touch a computer at all.

comment 8y ago · link · parent

    try {
      MyType x{args, args};
      x.DoSomething();
    } catch (SomeException &e) {
      ...
    }
You can't do much with the x if it didn't construct correctly, so you either need a strategy for a safe default value for x, or you need to bail entirely if an exception occurs.

comment 8y ago · link · parent

> > As for sequential, we're in the age of multiple cores and GPUs..

> What point are you trying to make? Obviously what I mean by sequential code here is that you can easily reason "if control flow reaches point A, then B will be executed, too".

That goes out the door with any parallelism whatsoever, because control flow may reach point A in thread 1, but then thread 2 kills thread 1, and point B is never reached.

It's increasingly hard to bury ones head in the sand and pretend every machine is a single-CPU single-task system with no interrupts.

comment 8y ago · link · parent

Less code should not mean either less readable code, or cleverer code. It should just mean ... less code.

Using abstractions, removing dead code, refactoring to share common code paths, etc, all reduce the amount of code you have, and all typically increase the readability of your code.

This doesn't seem at odds with your bullet list for maintainable code.

A useful maxim is: working software is an asset, source code is a liability. More code means more maintenance cost, so accomplishing business outcomes with less code is good, to a point.

comment 8y ago · link · parent

The Events here give up on the naming, granularity, and semantics problem: they're extremely low level fine-grained changes to fields in a database.

Events themselves are no longer interesting or semantically meaningful, because they're a single atomic change to a database field. A change in the way state is represented means a different set of events is produced. Subscribing to meaningful occurrences in this model is difficult, and probably will eventually result in the creation of a "meta-event" for each action that contains the semantic intent of the outcome.

Events are IMO most useful for analytics and processing when they correspond to meaningful business outcomes: steps in a workflow, consequences of user actions, and the like - despite this having the problem of making extraordinary and rare business outcomes more difficult to accomodate.

comment 8y ago · link · parent

The massive rise of carrier grade NATs perhaps.

comment 8y ago · link · parent

SPIN and TLA+ aren't proof assistants at all - they're model checkers, that is, they simulate a model some number of times and check that the desired properties hold in all explored states. Obviously this means they're not providing a guarantee that the properties hold for all states: there's no proof, only evidence. This doesn't mean they're useless, but it does mean they're not proof assistants.

ACL2 is a proof assistant, at least, but it's not based in type theory, so that's probably why they didn't use or improve it. ACL2 looks like it's specifically intended to aid in proving theorems about models of software systems, as well, which probably makes its logic system a bit clunky to use when expressing theorems about mathematical structures.

comment 8y ago · link · parent

If actions are fully deterministic, a list of actions is isomorphic to a list of events: you can always determine what happened by looking at what was requested.

A list of all past states avoids the determinism problem, but the consequence of each action is only implicit in the difference between two states.

For event sourcing, "the state" is the list of events, and what you're calling "the state" is just another selector/projection.

comment 8y ago · link · parent

You can't have DNSSEC outages if no-one is validating DNSSEC. So either there are outages, but a little extra security, or no extra security, but no outages, either.

comment 8y ago · link · parent

My network link is asymmetrical - I have very little upload bandwidth compared to download. This is not uncommon.

BitTorrent is abysmal for me. It quickly saturates my uplink bandwidth, destroying downlink performance. Or I cap it, or it discovers a cap, and my upload rate is slow enough that I'm labelled a leech in the BitTorrent network and get a slow download rate.

World of Warcraft's updater was absolute trash for me. I always got far better transfer rates turning off P2P and sucking up the congestion on the direct download option.

BitTorrent simply doesn't work for most of the world's commercially available home links.

comment 8y ago · link · parent

I'm pretty sure they'd have had to backdate that, since git didn't exist until 2005. :-)

Or a CVS importer applied the appropriate date, perhaps.

comment 8y ago · link · parent

I misused the term, yes: it should be "mutual recursion" not "corecursion", sorry.

comment 8y ago · link · parent

The first returns a callable that's the value assigned to the key argument. The second is a callable that's the value assigned to the key argument. They're the same thing.

comment 8y ago · link · parent

That's co-recursion, rather than strict recursion.

It's plausible that a compiler might catch the tail recursion case but ignore non-recursive and co-recursive tail calls.

Consider:

    def even(x, useless, arguments);
        return x == 0 or odd(abs(x) - 1)

    def odd(x):
        return x == 1 or even(abs(x) - 1, 6, 9)
There are two more formal parameters to even(), which means the stack frame when calling even from odd() includes two more actual parameters.

If the compiler follows the usual stack management approach of having the caller allocate and release space for actual parameters, this means the caller has to be aware that the stack space for odd's actual parameters is larger than the size needed for its formal parameters.

If odd() is tail calling odd(), there's no difference in actual parameter space, and so the caller can be ignorant of it.

It's a minor enough difference that any compiler implementing TCO should handle it anyway (just keep track of the maximum parameter size required in a function's tail call tree, and have the caller allocate and free enough space, or have the cleanup of actual parameters performed by callee) but big enough that a toy or experimental compiler, or one in which TCO is being slowly added, might just do the simple case only.

comment 8y ago · link · parent

There's no difference.

When you exit a function, you must clean up local stack allocations. It doesn't matter if you exit with a return or a jump. It doesn't matter where you jump. If you leave the stack with temporary allocations in place, they'll leak space.

(A compiler pipeline may, at some point, observe that releasing stack space, jumping, then claiming the same amount of stack space could be optimised to just a jump, but it may equally observe that releasing, jumping, and claiming a different amount could be optimised to either releasing or claiming the difference, then jumping, too - there's still no difference between recursive, co-recursive, and non-recursive tail calls.)

comment 8y ago · link · parent

There are viable forms of tutoring available for honest students who want to make some income, already, either University funded positions or private tutoring.

Your friend may lack the soft skills for tutoring, and definitely lacks the ethics to earn money honestly.

comment 8y ago · link · parent

If I were an AI or uploaded brain, I'd copy myself over the communications link, fully expecting to diverge into two distinct individuals.

comment 8y ago · link · parent

100 years doesn't seem like a long time to me because of the age of our civilisation or species, it seems like a long time to me because of the lifespan of our species. I certainly can't communicate at all on a 200 year RTT, as I'll be dead and forgotten before I get an answer.

If it's communication, that implies a two-way exchange of ideas. The galactic equivalent of blogging would be like all such communications: typically of more interest to the sender than the receiver.

If we assume a long-lived species that can receive a response within its lifetime, we must also assume that during the intervening time little enough of the context has changed that the answer is still relevant. That means a species and a civilisation that has extremely little change over hundreds of years.

This is what I mean by an extraordinarily static civilisation.

(But if it's so static, what could possibly be said that has material bearing on anything? :-)

comment 8y ago · link · parent

"Perception" in the context of autonomous agents means a mapping from sensors to a model of the world; how effectively can the agent establish a reliable model given its sensor readings?

What GP means by perception being a solved problem is that existing sensors and algorithms produce high quality and reliable models in a wide range of environment conditions.

A webcam is a sensor device, the human observing the webcam feed most likely cannot construct a good model of the car and its surrounds, as they can't do things like shoulder checking or looking in the rear view mirror, which a good driver does frequently to maintain a model of where other cars are.

But then "reasonably well" for a human driving a car remotely via webcam feed is likely to be a far lower standard than we're holding self-driving cars to.

comment 8y ago · link · parent

The problem with communicating across even a few hundred light years is that everybody's bored and gone to do something else before the response arrives.

You'd need a spectacularly static civilisation to engage in any meaningful communication over the timespans involved.

comment 8y ago · link · parent

His argument begs the question.

If you pre-suppose that describing types and finding appropriate abstractions aren't "writing applications", that is, they offer no value in the process, then spending time doing them is of course solving neat little puzzles to no benefit.

On the other hand, if you pre-suppose that types and abstractions offer some value to the process of writing an application, then solving those puzzles is adding value.

Calling types and abstractions a "neat little puzzle" is a diminution we could apply to other aspects of writing an application: implementing an algorithm to correctly process some data is a neat little puzzle presented by our test cases.

Rich Hickey would need to demonstrate the lack of value of types and abstractions for producing applications to make a solid argument here, and that I believe is a steep uphill battle, because Clojure would be a pretty terrible language if you took out the ISeq abstraction, and there's an awful lot of effort spent shifting the puzzle of "is this function being used right" from the type system game engine to the test harness game engine.

comment 8y ago · link · parent

Not normalise, just set the rules you want to apply. Internationalised domain names suffer this issue, so cribbing their fix probably would work for you - pick a script, restrict allowable characters to it.

You probably never want to allow unrestricted use of any character set for a username, even ASCII - otherwise I could take the username 'bjt2n3904 '.

comment 8y ago · link · parent

Have a look at f.lux, which alters your display's colour temperature as the time of day changes, shifting away from blues into the evening.

comment 8y ago · link · parent

Did you think of the mailman?

I get postal mail for someone living a few blocks away because they're technically in another suburb with a slightly worse reputation, and their real estate agent sold them on the idea they were in my suburb instead.

The post office, however, isn't paying attention to marketing or non-profit interest groups, it's paying attention to council zoning and regulation.

So every so often, I get mail addressed to a street name similar to mine, but in the next suburb over.

Names change over time, but when there's a central registry of names with a democratically founded process for managing those names, and the names are a public utility for locating things, it's best we don't just shit all over it and make up whatever we like because it suits us at the time.

comment 8y ago · link · parent

Blockchains aren't better than what we have today for property.

At least the victim in your deed fraud article was able to recover their property, albeit at significant cost. How are people going recovering funds from the Mt. Gox theft?

Let alone the oracle problem, people keeping a digital asset secure and safe for decades, the chance of the software being 100% bug free first time, the total lack of incentive to run a blockchain node on a registry chain, or the complexity of rolling crypto when the current algorithm becomes too weak in 10-15 years…

Nope. This is yet another problem blockchains are hopelessly ill-suited to tackling.

comment 8y ago · link · parent

Java is "a language like C" if you squint? ;-)

Thanks to you and others for the clarification on C's (lack of) behaviour!

1
1617181920