|
> and you know exactly what I'm describing. I won't unless both you and I have a shared context which will tie each of these concept to a specific thing. You said "async function", and there's a lot of languages that don't have that concept. And what about the permissions of the s3 bucket, what's the initial time of the wait time? And what algorithm for the resizing? What if someone sent us a very big image (let say the maximum that the standard allows). These are still logic questions that have not been addressed. The thing is that general programming languages are general. We do have constructs like procedure/functions and class, that allows us for a more specialized notation, but that's a skill to acquire (like writing clear and informative text). So in pseudo lisp, the code would be like (defun fn (bytes)
(when-let\* ((png (byte2png bytes))
(valid (and (valid-png-p png)
(square-res-p png)))
(small-png (resize-image png))
(bucket (get-env "IMAGE_BUCKET"))
(filename (uuid)))
(do-retry :backoff 'exp
(s3-upload bucket small-png))))
And in pseudo prolog square(P) :- width(P, W), height(P, H), W is H.
validpng(P, X) :- a whole list of clauses that parses X and build up P, square(P).
resizepng(P) :- bigger(100,100, P), scale(100, 100, P).
smallpng(P, X) :- validpng(P, X), resizepng(P).
s3upload(P): env("IMAGE_BUCKET", B), s3_put(P, B, (exp_backoff(100))))
fn(X) :- smallpng(P, X), s3upload(P)
So what you've left is all the details. It's great if someone already have an library that already does the thing, and the functions has the same signature, but more often than not, there isn't something like that.Code can be as highlevel as you want and very close to natural language. Where people spend time is the implementation of the lower level and dealing with all the failure modes. |
The fact that you're able to confidently take what I wrote and stretch it into pseudocode with zero deviation from my intended meaning proves my point.