News for hackers. Stuff that matters.
Re:Write libraries instead of services, where possible by NBJack on Thursday November 23, 2023 @10:40AM (#38393925)
It's all fun and games until you hit version n+1 or n+2, and often realize how slow many customers are to upgrade the library. Then there are the potential conflicts in your own dependencies. And let's not forget the occasional breaking change you introduced.

You are now sacrificing the money saved by not hosting to maintain what will likely be a growing matrix of possible versions, underlying assumptions, and my personal favorite: weird customer deployment scenarios that break your library functionality. Bonus points if you are developing in a language without strong typing, or need to integrate with a dependency manager.

Plus, if there was anything about your service that leveraged unique algorithmic improvements or some other proprietary tech, it is now at the mercy of anyone with a decompiler and sufficient time.

I suspect the author may change their mind if exposed to scaled up solutions and technologies.

Re:Write libraries instead of services, where possible by gjadi on Thursday November 23, 2023 @10:49AM (#38394038)
> It's all fun and games until you hit version n+1 or n+2, and often realize how slow many customers are to upgrade the library.

How is that different with services? I don't develop services, but I can imagine that before breaking the services, you have to poll with your biggest customers and you don't break until they are ready to move to the new version. The alternative I can imagine is to keep providing the old services with a grace period (e.g. /v1 will be available until dec next year).

What am I missing?

Re:Write libraries instead of services, where possible by materielle on Thursday November 23, 2023 @11:38AM (#38394587)
The idea is to link a thin client library into the user’s code.

Then the thick client is controlled server side by the devs.

If you design the thin and thick client intelligently, you can make a lot of changes to the system by merely modifying the thick client (which you control), without needing to update the thin client.

Problems tends to come in a few flavors, namely that this increases complexity and that some changes will always require modifying the thin client.

The biggest pitfall, though, is that you have to actually put thought into the thin client design. “Thin” is an emergent property of a well thought out client. You can’t just “touch thin_client.java” and think because you named it “thin” that it’s inherently decoupled from the service. You have to actually put thought into it.

Your example is exactly right. The service can support either v1 or v2 depending on the version of the thin client.

The main other technique is to have the thin client communicate in a relatively abstract and generic manner. For instead a “write()” endpoint that accepts an “options” dictionary.

“write()” is so generic that it probably won’t have to change, and changes in behavior can be modified by shoving stuff into dict, perhaps with a “version” field to instruct the server how to interpret the call.

When you add a new feature, you can bump the thin client to v2 and shove new options in the dict. Then the server can support v1 and v2. But also, you can modify the server to handle v1 differently. E.g the absence of a “disable_new_feature” key automatically opts v1 callers into the new feature.

I think the details are are really coupled into what you are engineering and what you want to roll out. There’s no magic bullet, and this increases the complexity of your code. Good engineering in my opinion is deciding when these approaches are worth it and how they should be implemented.

Re:Write libraries instead of services, where possible by gjadi on Thursday November 23, 2023 @12:06PM (#38394908)
I don't quite understand what you are saying.

As per the article, the advantage of a library over a service is that you don't have the burden of maintaining the said service. How having a thin client and a server helps?

I also don't see how "shoving new options in the dict" can help. From my POV, if the client needs to be updated to benefit from the new features, then there is no way around it, work has to be done. From there, I much prefer having sensible name, parameters, etc. from a library that can be leveraged by static typing rather than a documentation for a JSON API (I know API-as-specs exist but I've never used, maybe that's why I think that).

Re:Write libraries instead of services, where possible by chii on Thursday November 23, 2023 @08:22PM (#38399786)
> From my POV, if the client needs to be updated to benefit from the new features, then there is no way around it, work has to be done.

But the point is they don't have to update even if there's changes. They can update at their leisure.

Re:Write libraries instead of services, where possible by gjadi on Friday November 24, 2023 @04:06AM (#38401921)
Same as not linking with the new lib?

I understand it may be different if the software is distributed through the package manager of linux distribution because you have to follow what's provided by the distribution. But for a commercial software you can probably bundle your own libraries in executable or compile it statically.

But I am not familiar with the difficulties of the above process so I am probably missing something.

Re:Write libraries instead of services, where possible by sokoloff on Thursday November 23, 2023 @10:56AM (#38394131)
Many changes are believed to be non-breaking and so you can be running only one version in prod. (Most of the changes believed to be non-breaking are non-breaking.)

With a library, you end up with many different minor or point versions running without control over it.

Re:Write libraries instead of services, where possible by gjadi on Thursday November 23, 2023 @11:58AM (#38394805)
Ok so the benefits here are transparent upgrade. Thanks.
Re:Write libraries instead of services, where possible by genman on Thursday November 23, 2023 @02:08PM (#38396271)
Emphasis on "are believed". This actually puts clients into risk of having breaking changes out of their control.
Re:Write libraries instead of services, where possible by zja on Thursday November 23, 2023 @01:42PM (#38396008)
You have the same problem with services and libraries when you’re introducing a breaking change. With services you can make non-breaking changes like security patches on the server side, without needing to coordinate with a customer.
Re:Write libraries instead of services, where possible by LtWorf on Thursday November 23, 2023 @04:52PM (#38397973)
And with libraries you can't make breaking changes?

The fact that I don't need to recompile everything whenever libcurl or libssl has a security fix proves otherwise.

Re:Write libraries instead of services, where possible by fl0ki on Thursday November 23, 2023 @08:13PM (#38399725)
That's not a great example given OpenSSL versions are famously backwards-incompatible. Older versions get ABI-compatible security patches because people put in the time to backport all of them to every version still supported, in many cases by distro package maintainers. It's exactly the situation libraries should generally avoid, because there are maintainance costs for older versions of the library as well as migration costs for all of its users.

https://wiki.openssl.org/index.php/Versioning

Re:Write libraries instead of services, where possible by LtWorf on Sunday November 26, 2023 @09:47AM (#38421956)
Well given that i upgrade but not downgrade… what's your point?
Re:Write libraries instead of services, where possible by fl0ki on Thursday November 30, 2023 @10:12AM (#38474431)
The point is that someone is paying the cost of maintaining the library's ABI surface area even if it's not you. In a thread specifically for developers considering how to offer an interface to their software, I think it's only fair to recognize the costs of those different approaches. In that regard, OpenSSL is an extremely bad example, or an extremely good example of what not to do.
Re:Write libraries instead of services, where possible by grogenaut on Thursday November 23, 2023 @03:28PM (#38397166)
Simple answer is YOU control the deploy of a server in miroservices, so YOU decide when it goes live. You aren't playing spreadsheet telephone at scale to get everyone even im an internal org to update. If you're smart you have your callers send version information and you usually just add fields, only removals or renames cause version issues. If you're having everyone use a library they control when they update the logic and you have less telemetry when some wierd corner of your company is using out of date logic.
Re:Write libraries instead of services, where possible by osigurdson on Friday November 24, 2023 @08:32PM (#38410268)
Such an odd technical solution to a political problem.
Re:Write libraries instead of services, where possible by mooreds on Thursday November 23, 2023 @10:48AM (#38394021)
I thought the author addressed that point:

"But this assumes that slow-to-upgrade users can have negative effects on everyone else. If one user can't have a negative impact on other users, then you don't care if some users are slow to upgrade; they're only hurting themselves."

There's still the support issue, I agree. If a customer paid you money and they are on version n-10, they still expect support.

> Plus, if there was anything about your service that leveraged unique algorithmic improvements or some other proprietary tech, it is now at the mercy of anyone with a decompiler and sufficient time.

This is a valid point. My answer would be: it's all tradeoffs, but if your secret sauce is so valuable that it would be worth decompiling and can't be protected with decent pricing, license terms and lawyers, run a service.

There are plenty of technologies that are not worth decompiling for your average business customers.

Re:Write libraries instead of services, where possible by jampekka on Thursday November 23, 2023 @02:22PM (#38396433)
In my experience the more they try to hide the sauce the worse it is.

Quite logical though if the secret is that your secret sauce is bland and off-flavor copy of a canned soup. Which it usually is.

Re:Write libraries instead of services, where possible by LtWorf on Thursday November 23, 2023 @04:53PM (#38397984)
If your updates don't break every single time, your customers will be more likely to do them.
Re:Write libraries instead of services, where possible by noah91734 on Thursday November 23, 2023 @01:14PM (#38395708)
> It's all fun and games until you hit version n+1 or n+2, and often realize how slow many customers are to upgrade the library.

Given how frequently needless breaking changes are made, or features are removed and paywalled, I would consider this a feature rather than a bug. Sometimes I have higher priorities than working to support someone else's breaking changes.

Two years ago, I was using an official library for interfacing with a video chat service, and they decided to break the underlying API without updating their library, so I had to rewrite the library myself.

Re:Write libraries instead of services, where possible by kuchenbecker on Thursday November 23, 2023 @01:46PM (#38396067)
Write a library, deploy it as a service if necessary.
Re:Write libraries instead of services, where possible by crabbone on Thursday November 23, 2023 @03:19PM (#38397076)
This is a completely broken model.

You are wrong by pushing your changes on "slow to update" customers. Customers know when to update much better than you do. If you are trying to update before they want to, you are doing them a disservice.

This attitude is inspired by the desire to sell more, and often times, it means to sell more unwanted crap, where customers are trapped by the "package deal", where they are either forced to update to gain useless features and the headache resulted from various inconsistencies and defects coming from the last update, or they are unable to get the product at all (because the provider cancels support or wouldn't sell older versions etc.)

In other words, you with straight face describe some really shady practice and you don't even realize how bad it sounds.

Re:Write libraries instead of services, where possible by actionfromafar on Thursday November 23, 2023 @05:56PM (#38398629)
It can be that, but it doesn't have to be. It depends on the business model and it's quite orthogonal to library vs service.
Re:Write libraries instead of services, where possible by stefan_ on Thursday November 23, 2023 @06:43PM (#38399066)
Unless they have a specific problem or missing feature, customers want to update never.
Re:Write libraries instead of services, where possible by mrmanner on Friday November 24, 2023 @06:08AM (#38402731)
> This attitude is inspired by the desire to sell more, and often times, it means to sell more unwanted crap, where customers are trapped by the "package deal", where they are either forced to update to gain useless features and the headache resulted from various inconsistencies and defects coming from the last update, or they are unable to get the product at all (because the provider cancels support or wouldn't sell older versions etc.)

Selling more is how service providers are able to sell their generic service at a lower price than the cost you would incur by building it in-house. In other words, being forced to upgrade to accommodate features that other users want is the price you pay for sharing the development cost with those other users. That's not shady.

Re:Write libraries instead of services, where possible by NBJack on Friday November 24, 2023 @02:20PM (#38407210)
You assume I wanted to make the update in the first place.

I invite you to review roll outs of security updates. These are rarely about pushing new features, and may have nothing to do with my own code at all. It might just be a version bump to my dependencies config (if a dep manager with shared libraries is involved), or just a refresh of my flatpak equivalent. But, either way, shit breaks in weird and wonderful ways, and there is little I can do but wave my arms frantically at customers.

Re:Write libraries instead of services, where possible by fsloth on Thursday November 23, 2023 @03:24PM (#38397125)
Yes you need to have n versions you support in parallel in the wild. One per released incompatible binary API (so in semver 1.x, 2.x etc). We support about 30 libraries with 5 ppl spread around a fortune 1000 org here and there. It’s quite tenable, we are just super strict regarding ticket policy and release notes, so we always know what’s released where. Just have a system. Stick to it. Keep things organized. Works like a charm. If someone wants a service out of those someone just packages them to docker and puts them to backemd somewhere. We can focus on pure business logic, someone else maintains services etc. Really nice setup.