Better HN
topnewbestaskshowjobs
Log inSign up

hakunin

2,515 karma · joined Mar 4, 2010 (16y ago) · 549 submissions

https://max.engineer, mastodon:ruby.social/@maxim, x.com/hakunin, bsky.app/profile/max.engineer

meet.hn/city/43.1009031,-75.2326641/City-of-Utica

---

Submissions

comment 3y ago · link · parent

Rails and Phoenix when it's up to me, custom Go+React stack at work.

I actually went 3 years building Phoenix projects (2015-2018) and went back to Ruby/Rails, because it's really hard to beat the ergonomics, low ceremony, and expressiveness of the stack.

Might swing back into Elixir world if the right project comes along.

comment 3y ago · link · parent

I agree that some claims about e2e are misleading. That said, you could interpret "mathematically impossible" very charitably as risk assessment math. It's mathematically impossible to improve investigability while also improving resistance to spying by adversaries. Their relationship must be inverse. I agree that most people would interpret "math" as cryptography, and that it's better to make a clearer distinction between cryptography and risk assessment maths.

However this goes both ways. People demanding a solution think that you could make something investigable while keeping it completely airtight to adversaries or abuse. There is no escaping the fact that this is mathematically impossible in terms of how risk works. You can compromise security in favor of investigability, or you can improve security at the cost of investigability. And it's also important for the lawmakers to understand that each compromise is not gradual. It's drastic. If you went from 1 party having a key, to 2 parties, you've probably doubled vulnerability surface. If it's 3 parties, and one of those parties is an organization with lots of employees, you've probably exponentially increased vulnerability surface by orders of magnitude. This math does apply here.

comment 3y ago · link · parent

Generally:

1. NPR Up First podcast while brushing teeth.

2. This site for tech and adjacent nerdy topics.

3. Macrumors, 9to5mac, and various blogs via RSS.

4. Apple News+ subscription (that I got as part of Apple One) — check regularly for more in-depth stories form a variety of sources, and for following big events.

comment 3y ago · link · parent

I gotta admit, perhaps a bit naive of me, that the concept of "tech charlatans" didn't click for me until now. It's true, they are out there, and I see it now. I mean, I know there are phone scammers, but they probably been there before tech. I know there are hackers writing viruses and exploits, but those are oftentimes talented people doing bad things. However, this comment, and a couple recent experiences really drove "tech charlatans" home.

One experience was a trip to a crypto conference. Many booths were making unsubstantiated, impossible claims. If you tried to ask how, they couldn't answer. Like, someone would say they made transactions instantaneous, and when I asked how they solved the problems of unpredictable networks, they'd have no answer. It got pretty frustrating. I had to dig through a few claims like these only to be convinced that they're selling snake oil.

Another (less recent) experience was looking through a spreadsheet of government approved innovation/research grants. I couldn't believe what I was reading. Many of the entries seemed to make absolutely no sense, purposefully using buzzwords to sound smart, but having no meaning when unpacked. Buzzword salads. These are funded projects. And to get more money on round 2, all the "innovators" had to do is show any activity, which is very easy to fake.

So yes, tech charlatans. I'm a bit on the old school side of tech, and this gives me cognitive dissonance. I'm used to thinking of software devs/engineers as honest/creative/driven, but I guess this was always inevitable. Our field is very exploitable, because many people put their livelihood in tech, while knowing very little about it.

comment 3y ago · link · parent

I considered that, but couldn't find a way to precisely control amount of RAM used when you read from it.

comment 3y ago · link · parent

Are you saying that the file would just entirely be loaded into a page cache eventually? I imagine, even if true, it still wouldn't result in OOM killing the server/worker daemons on account of this data?

comment 3y ago · link · parent

>the data was fragmented in such a way that efficient lookup was possible

Yeah, there's a build step that sorts and arranges data into "cells", making binary search possible.

Not sure about kernel/user space. I'm just calling `pread` from ruby, so only a few bytes are loaded per lookup.

comment 3y ago · link · parent

I'm no systems programmer, but I remember trying to research mmap approach. It's been 3 years, so I'm not sure what stopped me, but something didn't feel right. Perhaps it was the lack of control over how memory is used. I could clearly see how not use it, and didn't want any fluctuations.

Edit: oh and I think I did come across some article like the one linked in the neighbor comment. It's starting to come back.

comment 3y ago · link · parent

Not 100% what the article is about, just a short story.

In one of my old jobs we had megabytes of infrequently accessed static key-value data. If we simply loaded it into a const (i.e. a hash table), it would blow up the RAM so much, that we would need to upgrade to bigger VPSes. If we put it in database, it would make it annoying to keep these tables up to date, track changes in them.

I figured this was one of those in-between use cases, where the best solution is to have zero-RAM lookups from SSD. In my case, I wrote a little ruby library[1] that arranges data in equal cells in a file, and performs binary searches via `pread`. This was perfect for us, because we kept data in our repos, sacrificed no RAM at runtime, SSD lookups were fast enough, and we didn't have to support a more elaborate db.

[1]: https://github.com/maxim/wordmap

comment 3y ago · link · parent

To be frank, alcohol, most drugs, and fat are not the same. Every time I go to a place where smoking is not culturally frowned upon, I can't make a few steps without inhaling vomit-inducing smoke. If it wasn't for this, then I would agree with you.

comment 3y ago · link · parent

The truth is, this does happen, but you want it to happen less. Banks accept certain amount of risk due to logistical limitations, but always seek ways to reduce it.

comment 3y ago · link · parent

This is a good explanation for Bitcoin-type ledger, but as far as I understand, banks don't share a global ledger. In US they run settlements through FED, which is the closest thing to global ledger we got, but internally they keep their own separate ledgers. Fed sees settlements between banks, but allocation within a bank is done via internal transactions. If you wanted to give banks a transfer rail that allows them to communicate directly incurring liability, and later settle via FED, you would need to write a transaction in each bank's ledger.

comment 3y ago · link · parent

This is a checksum-like trick for manual record keeping, and isn't specifically relevant to the grandparent. It isn't required in digital world. The grandparent talks about having to write 2 separate transactions in 2 accounts in such a way that either both are successfully written, or none are written. This means that there must be transactionality between 2 services, regardless of balance being cached or not.

comment 3y ago · link · parent

In most cases microservices are an anti-pattern, because they are trying to solve problems that can be solved without incurring their complexity and sacrifices.

However, I remember that Sagas originally were proposed to deal with multiple 3rd party APIs. The example was "book flight, hotel, rental car". If you're dealing with necessarily separate systems, then there's probably a place for sagas.

comment 3y ago · link · parent

The difficulty is different. Front-end is very capricious, idiosyncratic, inconsistent. You have to deal with lots of annoyances, puzzles. You still might have some connectivity responsibilities, like restoring a web socket connection, managing local storage, integrating 3rd party SDKs.

But frontend doesn't need to deal with as many categories of failure modes as backend (imagine running out of file handles in *nix OS, or dealing with a deteriorating hard drive), doesn't need to worry about security to the same extent, and doesn't need to scale to many users. You know that you're running on a single machine, in (usually) a single thread. If you got it to work in all target devices, and handled low connectivity conditions, you're probably good.

On the backend, you might get it to work, but that's just step one. Now you have to make sure it's secure, make sure you handle all weird thread safety edge cases, db deadlocks from connection limits, and make it scale, which can take you very far from what you had when you just made it work. Running a feature at scale is an entirely different beast than making a feature work. Every backend function can turn into an iceberg of code, databases, queues, and other infrastructure to facilitate that feature.

comment 3y ago · link · parent

You're the reason I wrote "split _almost_ perfectly".

That said, looks like your history involves .NET -> Python/.NET. I went .NET -> PHP -> Ruby/Elixir/Go. It took me some time to withdraw from .NET before I started preferring not to have an IDE. If you're still split half/half between two worlds, I can understand why you're still hooked.

comment 3y ago · link · parent

What's missing here is the programming language.

There are incredibly flexible, concise, low-ceremony languages, with implicit types where placing an IDE between you and code kinda obfuscates them. These are the languages where I think the best representation of code is the code itself.

Then there are elaborate, verbose, high-ceremony languages with explicit types, where looking at code and keeping up with ceremony might be a bit overwhelming. For those languages you probably want a lot more automation and a variety of info representation that goes way beyond code.

I'd go out on a limb to say that everyone here who likes/dislikes IDEs will split almost perfectly among those two language categories.

comment 3y ago · link · parent

How do you use stream deck in a typical remote work setting?

comment 3y ago · link · parent

The first 3 sentences of the article are implying that the whole thing is written with "if you must" attitude.

That said, a lot of companies have front-end teams, and those front-end teams commit years to building React components. So even if you render server-side, this is how you'd put data into those components. I'm a backend dev. I don't like some of what frontend is doing, but you gotta work with people, right?

comment 3y ago · link · parent

Huge scale typically leads to the opposite: more backend generalization, not catering to a specific front-end. That's why Facebook built GraphQL — because they run on anything, like fridges, TVs. That's specifically an attempt to avoid tailoring a backend to a frontend. The article argues that at small scale you shouldn't try to build a generalized backend for any imagined frontend. It's exactly how you would get unnecessary performance and complexity bottlenecks, when you really just need to serve your data the 1 or 2 ways that your front demands.

comment 3y ago · link · parent

> you need to make a ticket for the backend work first and the front end work can only start once the backend work is finished

In practice, a lot of this can be done in parallel. Once the design is established, front-end can start working on the layout/UX without knowing the exact shape of supplied data. The back-end can start proposing the shape of data and populating writing SQL/other queries to populate it. The final sync will only require small adjustments.

> it gives the front-end team the freedom to develop on their own timeline

At the cost of backend having to support every single use case under the sun.

> still you have the problem of deciding to intelligently architect your data access layer to not have massive amounts of duplicated code.

All this involves, is passing the pages the data they need for their construction. The alternative is building and supporting a generic data access for infinite use cases that is hard to optimize.

I see this suggested often, and I don't think it's true that the way to reduce duplication is by providing all data forever. You can provide specific entities wrapped in pages, and reuse the backend logic used for their construction.

> it’s possible on the backend to just easily make restful crud for every single resource

This shifts all the complexity of combining data onto the front-end, and the front-end is a lot more distant from the data storage. See the note where I describe that "Reliable communication allows for simpler interfaces"[1].

[1]: https://notes.max.engineer/reliable-communication-allows-for...

comment 3y ago · link · parent

I'm suggesting to pass via JSON what we used to pass via HTML back when front-end was templates on the server. I still prefer those days, like I alluded to in the first paragraph of the article. It used to be: write your template by inserting database values into it. Now I'm saying: instead of a template, come up with a neat json structure that kinda represents that template, and insert your database values into it. Name the fields after what page needs, not what you have in the database (following standard practices of object construction). I'm not sure what I might be reinventing, or what it might've been called, because I'm just trying to explain a practice that saves time and reduces complexity in simple language. It's interesting if it already was a thing with a name, but doesn't really change the point.

comment 3y ago · link · parent

Have you looked at this from the angle of object constructor or function parameters? Let's say you build an object called Person. They have first_name, last_name, phone_number. That's what you probably will pass into a new Person. Now let's say you build an object called BusinessCard. Most people will be tempted to pass in BusinessCard.new(first_name: person.first_name, last_name: person.last_name, phone_number: person.phone_number) or simply BusinessCard.new(person). What I suggest is that you should pass in BusinessCard.new(main_text: person.first_name + ' ' + person.last_name, secondary_text: person.phone_number). This, but for webpage. Your front-end defines the constructor parameters for the page, and back-end passes them in.

> your backend will now do what was doing before AND also will need to handle UI elements and relation between them. So you have duplicate data architecture/knowledge in UI

I don't think it will need to handle any elements, it will only need to construct the page by passing in what the page needs, not what the backend has. Just like constructing any other object or calling any other function.

In a way yes, you can say that any caller that constructs any object couples itself to said object, because it passes the specific arguments needed for its construction. Instead, we could provide access to the entire database, and allow objects to construct themselves by fetching any data they like. I guess I can agree with your characterization, but this would be considered an unjustifiable anti-pattern in any other context, because it makes it easy to lose track of dependencies, and makes it hard to optimize things. "Let's have objects auto-construct themselves from global state."

> it will be like saying in a traditional simple HTML app that I should name tables and columns in DB as they are in the UI

This part seems incorrect. Just because you pass parameters to construct an object, doesn't make it like having said parameters live in a database in the same format as the object constructor that accepts them. The entire point is that they are not the same, and need to be adapted to construct various things (pages in the front-end among them).

comment 3y ago · link · parent

Redesign: I've responded to the redesign argument in another comment. It's easy to find if you search the page for "rare event".

Mobile app: this is addressed in the article.

Naming: Usually most naming for different parts of pages is handled by the design(er), but even if not, once you have an approximate naming convention for parts of the site, naming becomes easy. And the stakes for these names aren't that high, because you are only scoping everything down to a single page, so global consistency and precision in naming is not that imporant. It just needs to be enough for someone to understand what it most likely refers to on this page.

385.

Reliable communication allows for simpler interfaces(notes.max.engineer ↗)

2 points · by hakunin · 3y ago · discuss

comment 3y ago · link · parent

Author here. Here's an additional piece of wisdom that I picked up in over 20 years of doing this. Reliable communication allows for simpler, less coupled interfaces. Unreliable communication demands increasingly elaborate and coupled interfaces. I wrote a short note explaining this principle. https://notes.max.engineer/reliable-communication-allows-for...

> If you make backend create one API call for each page, you will NOT get FE focusing on UI and backend on something else. You will get FE focusing on UI and BE focusing on UI and something else.

You need your backend to focus on something, otherwise it would be focused on nothing/everything. You need to tie yourself down to use cases, otherwise every use case is your use case.

comment 3y ago · link · parent

For reads and offloading front-end work, I think the article's approach should be good for your use case. Just make sure that your backend code is cleanly written. Create proper domain objects to represent pages that you will be serving as json. Pass all dependencies into these objects to construct them.

For writes, a typical rest approach as described in the grandparent is good.

Using specific actions such as `update_status` vs. allowing any fields to be supplied is… I think both can work. But it's not easy to cleanly organize the latter. It might be important to split different groups of related fields into separate logical paths, as though they were indeed supplied via separate endpoints. In Ruby/Rails I had success doing this via modules included into the model. The advantage of letting any fields be updated in any combination is that this would allow you to build different interfaces (i.e. admin UI, user UI, using REPL console if your language supports it) with different combinations of fields, and expect them all to work. You don't have to do that if you don't anticipate this need yet, but it's also true that splitting this logic into different urls is not all that different from splitting its handling under the hood, while allowing all fields submitted at once.

comment 3y ago · link · parent

> showing the same data or exposing the same flows elsewhere in the application required nearly a total reimplementation on the backend. This created an explosion in size of the codebase and complexity.

I'm trying to understand how this is possible. Couldn't the backend logic that contributes this response fragment in one endpoint be extracted and reused to contribute the same response fragment in another endpoint?

Was backend not modularized and reused?

The way I understand your approach, you ended up building and maintaining CRUD resources similarly to how they would exist in a naive public API, but the difference is that you spent extra time to build more meaningful, rich, business-level resources than serving nearly raw database records.

This is probably a good compromise that isn't disagreeing with the article as much as you seem to be implying. The difference between your approach and the article's approach is a small side-step. You either let the front-end fetch your rich business-level resources separately, or you package them into pages and serve them in a nice single package. Or you can build pages as per the article, and extract these rich resources that you display in those pages into separate endpoints for some additional flexibility. Either way, you end up with rich use-case driven resources, packaged differently.

comment 3y ago · link · parent

The "page" becomes the resource for reads. You get great scalability, because you can use your database in the most efficient way possible to provide entire data for the page. You can maintain 100% back-end clarity on what each page depends on (instead of letting front-end request anything they want in any part of the view).

I personally prefer server-side frameworks. I also understand when a front-end team prefers to work a certain way, has a lot of knowledge and tooling built-up around a certain way, and is worth accommodating for that reason.

comment 3y ago · link · parent

Agree with this. Of course because front-end still gets to build business logic, and back-end still ultimately decides the basis on which to build it, the decision making is spread more equally between them. Perhaps calling it "a washed out view" is not strictly appropriate, but worth acknowledging that the front-end is at the mercy of what back-end decides to provide it.
1
121314
19