Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is also known as event sourcing [0] and is a common pattern used inside of databases, in git, in lots of popular software.

I don't generally recommend it for every application as the tooling is not as well integrated as it is in an RDBMS and the data model doesn't fit every use-case.

However, if you have a system that needs to know "when" something happened in an on-going process, it can be a very handy architecture... although with data-retention laws it can get tricky quickly (among other reasons).

[0] https://martinfowler.com/eaaDev/EventSourcing.html



I saw other times Git being related to event sourcing, but the argument is wrong.

Most of the VCSs before Git (RCS, CVS, SVN) used to store deltas and to rebuild the state reapplying them.

The very reason why Git took them by the storm is exactly because, on the contrary, Git does not store deltas but snapshots. Each commit is not there collection of the occurred chances but a complete snapshot of the whole project. Git is very efficient in reusing the blob objects to save space, but it’s still a whole snapshot. The occurred changes are not stored, and they are calculated on demand.

The very opposite of event sourcing, where it’s the state to be calculated and the occurred changes / events to be stored.

Git is really the demonstration that for code versioning state sourcing is way more efficient than event sourcing.


Git is still event sourced, it’s just there is only one kind of event (a commit), and its payload is the whole state ¯\_(ツ)_/¯


Eh eh, this is an interesting point of view, but it’s really not like this.

Take the case of the event of “deleting a file”. There has been an interesting discussion between Linus and the orher developers, when Git was being d initially esigned: some of them wanted to capture and track this event. Linus firmly rejected the whole idea of track events, providing very solid arguments

http://web.archive.org/web/20200117061404/http://www.gelato....


jdkoeck is right.

Storing-events-and-calculating-state is the dual of storing-state-and-calculating-diffs. It's an implementation detail, and if it works well, who cares?

I personally use git as an event log.

When I commit something, I write out a description of what I changed, not the current state of the whole repository (even if that's what a git hash is supposed to represent).

When I pull or push, I send and receive only diffs, not the state of the multi-GB repo.

When I rebase, I grab the latest diffs that went into master and put them under my feature branch diffs.

When I run 'git show {commit}', I see a diff, not a state.

It doesn't matter which way it is in any case: the evergreen debate about fast-mutations vs slow-immutations is that it's easier and faster to just mutate someone's bank balance in-place, rather than the slow way of appending transactions, or just quickly delete a bad transaction rather than slowly append a refund event to the log.

Taking that debate over to git land, "it would be faster" to just mutate the state of the codebase in some single, central location rather than the "slow way of sending commits" back and forth - regardless of whether those commits are technically states or diffs.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: