Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

FamDav posted:

do your events never span multiple objects?

EDIT: and you're pushing confliction detection/resolution down to your materializer instead of making sure garbage didn't make it into your events in the first place. now youre event store isnt the one source of truth, its the one true source of some data which has to be interpreted by your application specific one true materializer.

your event payloads should include all relevant information, but not necessarily the entire object. and conflict detection / resolution *is* best handled at the materializer level, because that's where the various event streams get funnelled into a single queue regardless of how out-of-whack their sources are

say an app user on a 2G tablet in Madagascar orders a widget. the event payload will be something like [ BUYERID; 11252; ITEMID: 110291; QUANTITY: 1; PRICE: $35 ]

but, between the last time he queried product data from the server and the time he submitted the sale (event), somebody at the NYC headquarters: a) changed the product description of widgets b) increased the price of widgets c) decreased the price of widgets d) blocked all sales of widgets.

if you want to be thorough and have the time to code it, each of these cases should be handled differently (a) do nothing, as the property isn't relevant to the payload; b) apply the price in the event payload; c) apply the new, lower price and notify the user; d) block the sale and notify the user. or you could keep it simple/naive and just pause the sale because the product has changed, doesn't matter. either way, some code somewhere needs to notice the conflict and act upon it

you could require the app to sync its widget product data and handle the conflict before submitting the purchase, which is what i think you're suggesting by 'not letting garbage in your event store' - but you can't assume there won't be further changes after that, short of doing some locking silliness. plus you now have to have conflict resolution code in every client app. or, you can let the event be submitted as-is and have the materializer handle the conflict server-side. the UX of both approaches is basically the same, but the latter is simpler and more robust.

having events based on stale data in your event store isn't garbage; it is truthful, in that it represents what the user saw and what decisions he made on that basis.

Adbot
ADBOT LOVES YOU

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

Lutha Mahtin posted:

ty for teaching me a new word :D

everyone will think you're a douche for using it but gently caress the haters, math forever

FamDav
Mar 29, 2008

NihilCredo posted:

your event payloads should include all relevant information, but not necessarily the entire object. and conflict detection / resolution *is* best handled at the materializer level, because that's where the various event streams get funnelled into a single queue regardless of how out-of-whack their sources are

say an app user on a 2G tablet in Madagascar orders a widget. the event payload will be something like [ BUYERID; 11252; ITEMID: 110291; QUANTITY: 1; PRICE: $35 ]

but, between the last time he queried product data from the server and the time he submitted the sale (event), somebody at the NYC headquarters: a) changed the product description of widgets b) increased the price of widgets c) decreased the price of widgets d) blocked all sales of widgets.

Disregarding the weirdness of letting an application on an untrusted device send an arbitrary price, here's a concrete version of your story.

Its March 3rd and the Nintendo Switch launches. You are hammering refresh when the buy box finally appears, and you click buy it right now. You head off to work happy that you didn't have to head off to Target/Walmart/Gamestop/etc. and chase down one. At lunch you get an e-mail saying sorry! you didn't actually buy a Nintendo Switch after all, you just thought you did. Would you say that this is a reasonable customer experience?

quote:

if you want to be thorough and have the time to code it, each of these cases should be handled differently (a) do nothing, as the property isn't relevant to the payload; b) apply the price in the event payload; c) apply the new, lower price and notify the user; d) block the sale and notify the user. or you could keep it simple/naive and just pause the sale because the product has changed, doesn't matter. either way, some code somewhere needs to notice the conflict and act upon it

you could require the app to sync its widget product data and handle the conflict before submitting the purchase, which is what i think you're suggesting by 'not letting garbage in your event store' - but you can't assume there won't be further changes after that, short of doing some locking silliness. plus you now have to have conflict resolution code in every client app. or, you can let the event be submitted as-is and have the materializer handle the conflict server-side. the UX of both approaches is basically the same, but the latter is simpler and more robust.

why would you ever have the client application do anything like that? your client application should have as minimal functionality as is viable, and leave the rest to all of those servers that are actually under your control. you should never blindly trust any data that is coming to you from a client application, nor should you push that kind of application defining logic to something you can't easily update.

so when the app is telling the backend that the customer wants to order something, you have the ability to validate the request before you ever submit it to your event bus. If its an invalid event, you tell the customer right then and there that you are out of stock or that the price has changed, as opposed to minutes/hours later outside of the context of the order.

like, there exist event sourced datastores that handle submission of events as transactions in an application-invariant way. i use one every day at work that runs a lot of stuff a lot of people in this thread use. one that is publicly available is datomic http://www.datomic.com/get-datomic.html

quote:

having events based on stale data in your event store isn't garbage; it is truthful, in that it represents what the user saw and what decisions he made on that basis.

all information is out of date the moment it leaves the machine and so your customer (or some other computer) is always making decisions on out of date information. In almost all situations consumers desire and expect transactionality when they perform a mutating operation like ordering a video game console or spinning up some virtual machines, and they (like you should) consider reneging on that promise to be a failure of the system.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug
tracking causality: it's hard

AWWNAW
Dec 30, 2008

I wish kinesis had infinite retention

floatman
Mar 17, 2009
I am a poo poo programmer. Can I just use an event sourcing datastore thing in my project in a idiot proof way like if I wanted to use MySQL/postgres/mongo?
Is that diatomic thing it?

Arcsech
Aug 5, 2008

floatman posted:

I am a poo poo programmer. Can I just use an event sourcing datastore thing in my project in a idiot proof way like if I wanted to use MySQL/postgres/mongo?
Is that diatomic thing it?

datomic is the only event-sourcing-ish thing I've seen that comes anywhere close to just working out of the box without having to gently caress with it endlessly.

that said, I'd only bother with it if you're working in some language on the jvm. you can work with it from other platforms but they're 1000% second class citizens

Arcsech fucked around with this message at 08:25 on May 7, 2017

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

FamDav posted:

Its March 3rd and the Nintendo Switch launches. You are hammering refresh when the buy box finally appears, and you click buy it right now. You head off to work happy that you didn't have to head off to Target/Walmart/Gamestop/etc. and chase down one. At lunch you get an e-mail saying sorry! you didn't actually buy a Nintendo Switch after all, you just thought you did. Would you say that this is a reasonable customer experience?

quote:

all information is out of date the moment it leaves the machine and so your customer (or some other computer) is always making decisions on out of date information. In almost all situations consumers desire and expect transactionality when they perform a mutating operation like ordering a video game console or spinning up some virtual machines, and they (like you should) consider reneging on that promise to be a failure of the system.

i think we're talking about slightly different things

when I said "notify the user", I didn't necessarily mean "send a cancellation email later", but that the order confirmation and feedback cannot be any sort of 'pre-validation', it must originate from the event projection processor saying 'yea, sold, keep going' or 'nay, can't sell, reason: $X', because the processor is the only piece of code that is in a position to say so authoritatively.

for most use scenarios (certainly for mine) that means just waiting a few seconds for a HTTP response in the same session. but if you work on a much larger scale and the projection is too slow to make the client wait for it - or heck, if you have a random connection timeout - I guess the client should display a "your order is being processed, we'll send you a confirmation email when it's clear" message

(which is what I've seen a few e-commerce sites do, although most likely not for any event sourcing-related reasons, but in any case it was a perfectly acceptable UX)

because, what is the alternative?

quote:

so when the app is telling the backend that the customer wants to order something, you have the ability to validate the request before you ever submit it to your event bus. If its an invalid event, you tell the customer right then and there that you are out of stock or that the price has changed, as opposed to minutes/hours later outside of the context of the order.

that's great, but how exactly did you determine that his request is invalid, without submitting it to the event bus?

you need to figure out what the state of the system is or will be after every single one of the preceding events have been projected. you need to know that there are still Switches in stock and that the price hasn't changed. otherwise you could oversell because another customer sent his sale 3ms earlier than you but it's still in the queue

if you don't want to wait for the event projection processor to handle all the events ahead of you in the queue (which is what I'm suggesting), then you have to look at the queue yourself to figure out if the last one got snagged or not. but that's just running the projection in the first place, isn't it?

zokie
Feb 13, 2006

Out of many, Sweden
Lmao event sourcing, or anything else, isn't gonna solve the classic over sell ecommerce problem.

It's a business decision to fix, either you try to make sure you absolutely don't sell too many. Then your gonna be slower. Or you just accept the orders and accept a few over sells stopping the sale of the product when you notice and hope you can source additional examples to cover all sales.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

floatman posted:

I am a poo poo programmer. Can I just use an event sourcing datastore thing in my project in a idiot proof way like if I wanted to use MySQL/postgres/mongo?
Is that diatomic thing it?

datomic is great, but it's more than an event sourcing db - it's an immutable database that gives you transaction histories out of the box; you can use it for event sourcing, by designing your facts in an event style, but it's not required (and since you get immutability + transaction history anyway, you could argue that you have less reason to do that). also I'd go further and say that you really want to be speaking clojure to work with datomic

if you just want to mess around, i'd suggest downloading eventstore. it's kinda janky and i wouldn't trust it in production, but it has nice APIs (.net or js) and it's explicitly about event sourcing in a way other, tougher products aren't. look up some sample projects too

from what i've seen, most real-world event sourcing designs just use whatever no/sql datastore fits best with their stack, architecture, and scale (and bigger ones split the architecture into multiple components, eg distributed messaging system + dumb kv store for events + acid store for aggregates). the legwork really comes in the application code

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


reading up on java 9 modules and i want them so bad.

https://www.slideshare.net/scolebourne/java-se-9-modules-jpms-an-introduction

FamDav
Mar 29, 2008

NihilCredo posted:

i think we're talking about slightly different things

when I said "notify the user", I didn't necessarily mean "send a cancellation email later", but that the order confirmation and feedback cannot be any sort of 'pre-validation', it must originate from the event projection processor saying 'yea, sold, keep going' or 'nay, can't sell, reason: $X', because the processor is the only piece of code that is in a position to say so authoritatively.

for most use scenarios (certainly for mine) that means just waiting a few seconds for a HTTP response in the same session. but if you work on a much larger scale and the projection is too slow to make the client wait for it - or heck, if you have a random connection timeout - I guess the client should display a "your order is being processed, we'll send you a confirmation email when it's clear" message

(which is what I've seen a few e-commerce sites do, although most likely not for any event sourcing-related reasons, but in any case it was a perfectly acceptable UX)

because, what is the alternative?


that's great, but how exactly did you determine that his request is invalid, without submitting it to the event bus?

you need to figure out what the state of the system is or will be after every single one of the preceding events have been projected. you need to know that there are still Switches in stock and that the price hasn't changed. otherwise you could oversell because another customer sent his sale 3ms earlier than you but it's still in the queue

if you don't want to wait for the event projection processor to handle all the events ahead of you in the queue (which is what I'm suggesting), then you have to look at the queue yourself to figure out if the last one got snagged or not. but that's just running the projection in the first place, isn't it?

yeah maybe we're talking past each other? I'm saying that you can perform a transaction to submit to the event bus without the event bus knowing what the whole materialized view looks like. you submit enough data about the transaction, and the service that handles submissions can verify that your transaction viewed a consistent state of the world. your materializers will see the events a few milliseconds later, and will be able to process them in an application invariant way because the only application specific code here was creating the transaction to submit in the first place.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

zokie posted:

Lmao event sourcing, or anything else, isn't gonna solve the classic over sell ecommerce problem.

It's a business decision to fix, either you try to make sure you absolutely don't sell too many. Then your gonna be slower. Or you just accept the orders and accept a few over sells stopping the sale of the product when you notice and hope you can source additional examples to cover all sales.

Yep, you either lock the stock count and then accept the speed cost, or figure out another business process centered way to approach the problem, accepting the reality of the technical limitation.

FamDav
Mar 29, 2008

Maluco Marinero posted:

Yep, you either lock the stock count and then accept the speed cost, or figure out another business process centered way to approach the problem, accepting the reality of the technical limitation.

what do you actually think the speed cost is here? and why do you think "lock the stock" is the only means to achieving that?

cinci zoo sniper
Mar 15, 2013





owns. im glad that java is my spare time coding activity, i'll be able to hop right in

brap
Aug 23, 2004

Grimey Drawer

NihilCredo posted:

datomic is great, but it's more than an event sourcing db - it's an immutable database that gives you transaction histories out of the box; you can use it for event sourcing, by designing your facts in an event style, but it's not required (and since you get immutability + transaction history anyway, you could argue that you have less reason to do that). also I'd go further and say that you really want to be speaking clojure to work with datomic

if you just want to mess around, i'd suggest downloading eventstore. it's kinda janky and i wouldn't trust it in production, but it has nice APIs (.net or js) and it's explicitly about event sourcing in a way other, tougher products aren't. look up some sample projects too

from what i've seen, most real-world event sourcing designs just use whatever no/sql datastore fits best with their stack, architecture, and scale (and bigger ones split the architecture into multiple components, eg distributed messaging system + dumb kv store for events + acid store for aggregates). the legwork really comes in the application code

does datomic still prohibit benchmarking in their license agreement

CPColin
Sep 9, 2003

Big ol' smile.

Ha ha why would they introduce new "requires," "transitive," and "exports" keywords for the module descriptors, then reuse "static" for optional dependencies, instead of just saying "requires optional"? Good ol' Java.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

java 9 modules are neat but they're a big obstacle to supporting our products on java 9 since we went all-in on osgi lmao

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
https://vimeo.com/216330850

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


carry on then posted:

java 9 modules are neat but they're a big obstacle to supporting our products on java 9 since we went all-in on osgi lmao

apparently you can still use osgi on java 9, there's the classpath and the module path now and osgi would still use the classpath i'd think

the slides claim you can use osgi with java 9 at least

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod



i hope scala supports jpms in language soon. i'd imagine you could get sbt supporting it and make the module descriptors in src/main/java/fart/clownpenis, but i'd rather it be supported in the scala language

Arcsech
Aug 5, 2008

fleshweasel posted:

does datomic still prohibit benchmarking in their license agreement

yes. although there's no restriction on benching their free version, which runs on h2 (think java sqlite)

this is stupid as gently caress but also doesn't mean its slow. it doesn't have a query planner so if you order your clauses wrong you can make a fast query run very slow but all you need to do is make it so your first clause is a restrictive one

that is, if you do something like this:
code:
[?personId :person/name ?name]
[?personId :person/email "lowtax@deadgayforum.com"]
it'll do a full table scan but if you do

code:
[?personId :person/email "lowtax@deadgayforum.com"]
[?personId :person/name ?name]
it'll just do a single lookup (assuming you have :person/email indexed)

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

FamDav posted:

what do you actually think the speed cost is here? and why do you think "lock the stock" is the only means to achieving that?



I'd love to hear another way of approaching the problem but at the end of the day surely there must be a single source of truth that must be referred to in order to get that stock count? if multiple requests come in, you must handle each one sequentially at some sort of bottleneck to guarantee there is in fact stock remaining and that it's okay to charge the user.

the amount of things that happen inside that bottleneck could move around yes, you could reserve the order, then try payment with the processor, and then unhold the order of it fails, but there is always going to be some sort of single funnel you need to go through the process the sale with an exact stock count.

Sapozhnik
Jan 2, 2005

Nap Ghost
I kinda want to play around with an event sourcing sort of architecture, and I was wondering if there is anything a lil less heavyweight than Kafka out there

Luigi Thirty
Apr 30, 2006

Emergency confection port.

all the IIgs system documentation and examples are in Pascal i don't know Pascal help

at least Orca's C compiler and assembler both come with translations of the apple example desktop program into C and assembly

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


datomic is using a subset of prolog as a db language (called datalog) right?

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
Pascal is just like C but instead of { and } you have begin and end

hope this helps

but in all seriousness Pascal as used for systems programming like on the Apple II, III, Lisa, Macintosh, and IIgs is almost exactly equivalent to C, with just slightly different syntax

like instead of int *x; you have var x: Integer^; and instead of x = &y; you have x := @y; and instead of z = *x; you have z := x^;, it's almost 1:1 equivalent and you can actually do source-to-source translation from Pascal to C that results in highly readable code, unlike most other languages

the biggest differences were actually under the hood: typically Apple's Pascal calling conventions pushed arguments in the opposite order from C's calling conventions, so they added a pascal keyword for function prototypes to indicate this in a declaration of a Toolbox or operating system function

there are a couple of other notable syntactic differences that affect how a program reads: Pascal has sets as part of the language where C would typically use bitwise operations on integers, Pascal historically used prefix-counted instead of NUL-terminated strings (e.g. Str31, Str255, which is why Apple C dialects support \p to indicate a string literal is length-prefixed), Pascal had a with construct for simplified record access, and it had a concept of "variant records" that act kind of like a crude inheritance

overall though that should be enough to know to be able to read Pascal easily

you could also always get Orca/Pascal or TML Pascal…

wasn't there an "Apple Programmer's Workshop" too, like MPW but for the IIgs?

Arcsech
Aug 5, 2008

Condiv posted:

datomic is using a subset of prolog as a db language (called datalog) right?

correct

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

eschaton posted:

Pascal is just like C but instead of { and } you have begin and end

hope this helps

but in all seriousness Pascal as used for systems programming like on the Apple II, III, Lisa, Macintosh, and IIgs is almost exactly equivalent to C, with just slightly different syntax

like instead of int *x; you have var x: Integer^; and instead of x = &y; you have x := @y; and instead of z = *x; you have z := x^;, it's almost 1:1 equivalent and you can actually do source-to-source translation from Pascal to C that results in highly readable code, unlike most other languages

the biggest differences were actually under the hood: typically Apple's Pascal calling conventions pushed arguments in the opposite order from C's calling conventions, so they added a pascal keyword for function prototypes to indicate this in a declaration of a Toolbox or operating system function

there are a couple of other notable syntactic differences that affect how a program reads: Pascal has sets as part of the language where C would typically use bitwise operations on integers, Pascal historically used prefix-counted instead of NUL-terminated strings (e.g. Str31, Str255, which is why Apple C dialects support \p to indicate a string literal is length-prefixed), Pascal had a with construct for simplified record access, and it had a concept of "variant records" that act kind of like a crude inheritance

overall though that should be enough to know to be able to read Pascal easily

you could also always get Orca/Pascal or TML Pascal…

wasn't there an "Apple Programmer's Workshop" too, like MPW but for the IIgs?

pascal was the fire language i ever learned. to this day i typo assignments as := if im not paying attention

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


i like ada and wish i had more reasons to use it

i've never programmed pascal, but i hear ada is kinda pascalish. i like its syntax

Luigi Thirty
Apr 30, 2006

Emergency confection port.

the Apple Programmer's Workshop was a licensed version of Orca :v:

I ordered a compactflash card for the GS anyway since it's a pain to try to run these compilers off floppies, I paid :10bux: for the ByteWorks software collection (every compiler and tool they made plus PDFs of all the manuals, courses, and documents) so once it gets here I'll be set for Apple action

C, Pascal, Modula-2, integer BASIC, 65816 assembly, and shell scripts all in one IDE

fritz
Jul 26, 2003

my undergrad switched to pascal (from modula-2) my second quarter in the sequence, i remember it as "fine" except arrays of different sizes were different types

jesus WEP
Oct 17, 2004


cis autodrag posted:

pascal was the fire language i ever learned. to this day i typo assignments as := if im not paying attention

i kind of like = for equality and := for assignment

hosed up but true

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


St Evan Echoes posted:

i kind of like = for equality and := for assignment

hosed up but true

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

St Evan Echoes posted:

i kind of like = for equality and := for assignment

hosed up but true

= is the match operator hth

gonadic io
Feb 16, 2011

>>=

St Evan Echoes posted:

i kind of like = for equality and := for assignment

hosed up but true

i agree that they need to be different operators anyway. assignment is the more dangerous one, so maybe it should be harder to type

none of that for (int i = 0; i = n; i++) bullshit thanks

ultravoices
May 10, 2004

You are about to embark on a great journey. Are you ready, my friend?

St Evan Echoes posted:

i kind of like = for equality and := for assignment

hosed up but true

:= reminds me of BNF, which makes more sense as an assignment operator than trying to remember which sequence of = means equality and which means assignment.

ultravoices
May 10, 2004

You are about to embark on a great journey. Are you ready, my friend?

cis autodrag posted:

pascal was the fire language i ever learned. to this day i typo assignments as := if im not paying attention

did pascal just die because of that considered harmful essay, because it was the language for a decade plus

Elias_Maluco
Aug 23, 2007
I need to sleep
pascal is still alive in delphi, inst it?

is delphi alive, by the way?

Adbot
ADBOT LOVES YOU

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

gonadic io posted:

none of that for (int i = 0; i = n; i++) bullshit thanks

clang gives you warnings on this type of poo poo, you should be using -Werror, and also write them as yoda comparisons

  • Locked thread