Better HN
topnewbestaskshowjobs
Log inSign up

andersmurphy

1,011 karma · joined Feb 22, 2019 (7y ago) · 496 submissions

https://andersmurphy.com
Submissions

comment 1y ago · link · parent

Yes! This is the way.

Honestly, its the key to getting the most out of sqlite. It also allows for transaction batching and various other forms if batching that can massively improve write throughput.

302.

We Deleted Tokio from Our Payment System and Cut Cloud Costs by $127,000(medium.com ↗)

4 points · by andersmurphy · 1y ago · 1 comment

comment 1y ago · link · parent

Watching people with mastery show off is a great way to get insight. It can be quite an engaging way to learn.

comment 1y ago · link · parent

Awesome explainer of combinator logic, the writing style reminded me of this series of posts (which is always a good thing in my opinion):

https://aphyr.com/posts/353-rewriting-the-technical-intervie...

comment 1y ago · link · parent

I couldn't disagree more with this take. Frontend maximalism locks you out of so many wins. I'd never consider it outside of a solo offline app and at that point a native app is probably a better choice.

comment 1y ago · link · parent

Yeah the whole article is absurd. Functional programming is not even remotely mainstream. So not sure who is twisting?

comment 1y ago · link · parent

The part I really like about pegs in janet is it works on bytes.

comment 1y ago · link · parent

Yeah funny most proponents if static types don't even know the difference between static and strong types and often conflate the two. Show's how pervasive cargo culting is in this industry.

comment 1y ago · link · parent

Yup, generally less code is easier to maintain so if you can express yourself in an order of magnitude less code its easier to be sure your program obviously has no bugs, rather than it has no obvious bugs.

Also most types systems don't go far enough. reverse takes a list and returns a list. That type checks but is of little practical value.

comment 1y ago · link · parent

I agree with this. I value immutability much more than static types. I find it eliminates a much larger class of bugs without sacrificing expressiveness.

comment 1y ago · link · parent

Non sargability easy to solve with expression indexes. At least in sqlite.

comment 1y ago · link · parent

Yeah shared vCPU can be really bad.

comment 1y ago · link · parent

Feels surprisingly good to me.

comment 1y ago · link · parent

Not sure why this is getting downvoted. I'm literally showing an example of storing popup state in the database as per the parents question.

> You mean I should be storing the state of a popup menu in my database?

comment 1y ago · link · parent

Not if you care about state being consistent between all clients. Say you want a minimap, or a presence indicator, now the server needs to know these things. Same the minute you want backend analytics.

Millions of users hitting the same server at the same time is a very nice problem to have. I've handled 40000r/s (script kiddies are gonna script) with 500+ concurrent users in those demos on a 5$ VPS. With all the scroll position/tab state etc not just going to the server, but to a sqlite db.

Events up are fine if you batch them and 204 (i.e CQRS). In return you get a nice pushed based system that you can throttle/batch. You only push view data when the server decides to. In my case that's every 100ms (because it's a 5$ server), so all changes in that time get batched.

>Whenever your program has to interact with external entities, don't do things directly in reaction to external events. Instead, your program should run at its own pace. Not only does this make your program safer by keeping the control flow of your program under your control, it also improves performance for the same reason (you get to batch, instead of context switching on every event). Additionally, this makes it easier to maintain bounds on work done per time period.

- tiger style https://github.com/tigerbeetle/tigerbeetle/blob/main/docs/TI...

You don't need optimistic UI, a fast server with an in process DB and a decent backend language and you'll be fine for a lot of use cases. I like to add a pop animation on the client to register something has happened, but in a lot of situations you don't even need that.

comment 1y ago · link · parent

But what really defines client side state?

If the latency was good enough you'd store everything on the server. It doesn't force you to give them the same state when they re-open your app, you can key state by session and tabid if you want.

comment 1y ago · link · parent

Correct. That's literally what happens with the scroll position, and share modal in this demo (QR code is generated on the fly on the backend):

https://checkboxes.andersmurphy.com

comment 1y ago · link · parent

In my mind collaborative apps are a core feature of the web. Streaming hypermedia is a great way to keep all your state on the server and have a solid multiplayer/realtime experience, especially with large datasets.

Here's a basic google sheets clone that does just that:

https://cells.andersmurphy.com/

comment 1y ago · link · parent

Hypermedia can do all of that fine. You don't need to stick it all in the url. Using simple session and cookie/tab id state can be shared and or isolated between tabs. Then just do a lookup in your backend database.

Hypermedia is also way better for realtime and multiplayer.

If anything where HTMX falls short is it doesn't put enough state on the backend, if anything it's not radical enough.

comment 1y ago · link · parent

It's standard http so you don't have to build your own bad version of http on top of it. It's handles disconnects for you. You can use the browsers built in compression over the life of the connection. You have access to brotli/zstd without having to ship it to the browser first (and it's the C++ version).

In short it means you don't have to do any manual diffing, just let the compression do it for you, and have something on the client like morph to merge it in to the dom. It's way more bandwidth efficient as compression is at the byte/char level not at the semantic html level (and not per message but over the whole stream).

comment 1y ago · link · parent

You mean like this one? https://data-star.dev/

comment 1y ago · link · parent

Websockets are the wrong choice. SSE is the way to go. That or your own UDP protocol.

comment 1y ago · link · parent

Right. But, hypermedia systems doesn't go far enough. It can be even simpler then that.

In a video game the "server" doesn't figure out what's changed (that's too much work) it just redraws the frame. So rather than the complexity of working out what has changed you can just send down the whole page again whenever something changes.

This gives you view = f(state) over the wire and has great DX. It's called immediate mode in games.

comment 1y ago · link · parent

Yeah, I've had fun using macros to create optimised functions at runtime (inline caching effectively) and/or generate code that is more friendly to the JVM JIT.

Also, there's always plenty of use for doing work at compile time.

In some sense they can also be seen as a better code generation.

comment 1y ago · link · parent

Sure, but the browser is fast and rendering HTML so why stream anything else? Why stream javascript + json to build html. You're adding a bunch of marshalling that doesn't need to be there.

comment 1y ago · link · parent

Depends on the language. Java or Go you really don't need docker.

327.

UI = Fn(state) Done Right(yagni.club ↗)

3 points · by andersmurphy · 1y ago · discuss

comment 1y ago · link · parent

It's really good for streaming view updates to your users in realtime.

comment 1y ago · link · parent

Thanks for the heads up. I encountered similar issues so staying on 0.3.13 for now. But excited to give 0.5.x a go once the dust settles.

Livestream, sqlite and caddy are incredibly at making single box/vps ops a breeze.

1
101112
17