78 points · by mulkave · 5y ago · 61 comments
Yes. I absolutely agree.
Start with a monolith. Use server-side rendering if possible. Use SQLite instead of [wretched nosql abomination]. API development is a waste of time. The business doesn't give a shit about any of this. Just make it work, then make it "webscale".
where's the line between from scratch and evolved?
Some people try to write game engines from scratch before actually creating their game. Some people learn & adopt complex frontend frameworks before finishing their project’s landing page. Some people start new projects by immediately building all the abstraction layers they think they’ll need during the project before implementing a single useful feature.
I’ve fallen for each of those at least once, and I’ve seen lots of people doing the same. You’re not going to need it. Wait until it makes sense to justify the hidden time & reliability costs. Wait until you actually know what you need.
Doesn't this lead to an unnecessary increase in complexity without any immediate benefit?
> API development is a waste of time.
Why do you think so? Doesn't a well developed API mitigate, if not eliminate entirely, needless increases in complexity?
Developing an API may also be a waste of time when your client-side application is the sole consumer of the server API. This is especially true when people try to build an API that does too much (often seen when building REST-style HTTP APIs) instead of a more usecase-based (or even view-centric) API.
That layer doesn't go away with server-side rendering. It is always there, even if you don't use a REST API. It just gets fused with views.
In fact, I'd argue that this perception that server-side rendering gets rid of that layer is a telltale sign that the project is already plagued with accidental complexity.
> It usually also implies that you don't have build your data model in two different languages ($BE_LANG + JS/TS);
Unless the front-end is written in pure HTML+CSS, this hypothetical simplification doesn't materialize. Also, you can't brush off or ignore the complexity added by templating engines.
> Developing an API may also be a waste of time when your client-side application is the sole consumer of the server API.
I don't get what point you're trying to make. Even if you are the only client for that API, don't you still need to put it together and maintain it?
> Developing an API may also be a waste of time when your client-side application is the sole consumer of the server API
i think this is assuming you'd never need a native (ios, android) client no?Controller queries DB, builds a Model then passes that Model to a View.
View uses that Model to render HTML which returned to the client.
With dedicated frontend it turns into:
Controller queries DB, builds an API response.
Frontend receives API response and renders it into HTML.
So basically Model is API.
Issue with SSR is that it's not popular nowadays and most frameworks are stagnating. At this point it's better to stick to separate backend/frontend unless you don't want to touch it.
You don't have to build JSON Schema, OpenAPI and whatnot. Just spew some JSON and consume it with JavaScript.
Why do you think using server-side rendering leads to an unnecessary increase in complexity without any immediate benefit?
> Doesn't a well developed API mitigate, if not eliminate entirely, needless increases in complexity?
It does when multiple clients consume that API. The point of GP is, I think, that you shouldn't start with the assumption that you will have at some point multiple clients and prepare for it.
Not necessarily. All the major JavaScript frameworks also support server-side rendering, which is used to improve load times and perceived performance.
While you can be careful about round trips with client side rendering, and graphql helps in that regard, it’s easy to create hidden bottlenecks.
Once you have reached at least junior level, start learning about how to split the system into subsystems and putting some additional thought into it.
The business doesn't give a shit about the implementation. Very true... that's why they hired you so that you fucking do. Just do your job.
If you want to work in finance, accounting, sales, investor relations, partnerships, business development or whatever, go do that. If you want to work creating software, start caring about how software is created, or at least don't ruin it for people that do.
If you decide to follow a business career path, you will find that they also have to care about their job, have attention to detail and care about good practices and compliance. In fact, that will also be the case for every occupation in every sector.
Like so many fads in our industry microservices solve a problem that giant, famous companies have and are aped by thousands of companies that don’t, and will never, have those problems.
We have to stay mediocre and keep the bar low, to lower the entry barrier to software and depress wages.
Before learning about how to split something into multiple parts, you should start by learning about why you would want to do that.
> If you want to work in finance, accounting, sales, investor relations, partnerships, business development or whatever, go do that. If you want to work creating software, start caring about how software is created, or at least don't ruin it for people that do.
Again, before that you should learn about the why. You are writing software for someone. Why? For most people, especially when doing "web stuff", the why is going to be way more important than the how. Carefully crafted software is useless if it doesn't fit what the business wants. Better than that is bad software that still fits the use case. Even better is carefully crafted software that fits the use case.
That is certainly a deliverable a company can use to grow a team of multiple developers and focus on making progress without being constantly interrupted by incidents, defects, downtime as customers roasting and demoralizing customer support representatives and leaving bad reviews online.
Those slow requests in your logs mean a human is looking at a spinning wheel asking why the fuck they bought your software. That is good for the business.
Your product being affected by a security breach is excellent for the business.
Your company infringing licenses because everyone is copying and pasting shit from the Internet is great for the business.
The mythical, romantic image about "business" is just the place where lazy developers run to when they want to stop caring about work.
Real business people want software that does not break everytime a sales person is giving a demo, want a good reputation and do not want to create opportunities for competitors to have a superior product.
Talking about business is not a valid replacement for doing the things that are actually favorable for the business.
How is explaining the way to build actual working shit "ruining it" for others? Do you want to live in some fantasy where Netflix's approach to engineering is applicable everywhere? I don't understand what some of you are trying to get out of this, but it sounds suspiciously like you want to have your cake while simultaneously having consumed it.
GQL notoriously performs weaker to REST in this regard.
>When a user navigates to a page on a web app or deep links into a Single Page Application (SPA) or a particular view in a mobile app, the frontend application needs to call the backend service to fetch the data needed to render the view. With RESTful APIs, it is unlikely that a single call will be able to get all the data. Typically, one call is made, then the frontend code iterates through the results of that call and makes more API calls per result item to get all the data needed.
>For example, I don’t want to navigate through multiple screens to review my travel itinerary; I want to see the summary (including flights, car rental, and hotel reservation) all on one screen before I commit to making the purchase.
I disagree.
Sure, sometimes more than one restful call is made for just one page, but the example given, when architectured properly is just a user foreign key relationship to all its children (reservations flights, rentals, etc), which is just a single sql query.
I don't think the author really understand the flexibility of REST and how much it can emulate what GQL has to offer.
If you want specificity in your query fetching, just add query params or put them in the request body
And if it is the case that you really do need resources from different endpoints, what is preventing you to build that single endpoint in REST?
Also, which properties of GQL make it inherently slower than REST ... ? Both are abstract concepts. (Also I'd argue that GQL is REST.)
That feature is not exclusive to GQL.
If we assume that REST serves more requests than GraphQL, but GraphQL is more flexible, that may be a trade off of dev time of the application vs a dev time of the infrastructure. Which would fit with more and more people using orchestration and things like that. That might be a very wrong assumption though.
As far as dev time excluding onboarding time, lets not forget why gql was created - facebook wanted to separate the data responses to their mobile and web platform
first of all, not all organizations are facebook
secondly, especially for smaller to medium sized startups, not all responses need to be separated, and "shaving" off data for an extra endpoint is not difficult in REST.
and I remember graphql's early website where they made the claim saying that you'll need to have some really huge number of endpoints in order to emulate what graphql has to offer, and since then they have taken that down because of how ridiculous that sounded.
In reality and practice, the number of endpoints that you need to "shave", again, especially for small to medium startups, is slim to none.
Performance is 99% about latency. And, when having this conversation, we are typically talking about I/O-bound latency.
Assume you have a trivial computer system that can only process 1 thing at a time. The number of things you can process per unit time is inversely proportional to the amount of time it takes to process each thing. Adding more threads/cores to the mix does not change this fundamental equation. Many practical business systems have a large component of processing that must occur in a serial fashion.
Think:
Multiple computers: Milliseconds, One computer: Nanoseconds
How much more work can you do if you can finish each unit in 100ns vs 5ms? How would this impact the user experience? Is the reason you cant finish in 100ns because you are doing global illumination on the CPU or because you are waiting for [hipster noSQL solution] to return some packets to your application server?
You haven't supported your position that GraphQL is weaker at all. Everything that I have read, seen and heard is exactly the opposite. GraphQL seems to be the "I will never go back to REST" experience for virtually everybody I know in the field who has used it.
The other issue is that you're fighting the nature of REST itself to make it do more. Sure, you can make any API call take in specific input and send out exactly the output that you need...but REST API guidelines tend to preach exactly the opposite approach. The call should return one thing and if you want more, you need to get it yourself.
I'm open to hearing your perspective on this, but if you're going to make a claim like that you really need to support it.
in some organisations the amount of meetings and overhead scales proportionally to the number of network connections in the architecture diagram, so that also suggests replacing external dependencies with in-process function calls wherever possible.
Isn't this true for all software systems? If anything, microservice architectures just make it easier to re-architect parts of the system, thus lower the bar to actually do the work.
With regards to stuff inside each service, microservices aren't really different from monoliths.
When service calls are involved, I'd argue that microservices make it even simpler to refactor/rewrite modules and entire services. Microservice architectures already impose boundaries between components that help limit the scope of any work, and teams are free to deploy and run in parallel, even in production, any service they wish to update/rewrite/launch. You can control which service is called with a load balancer, and don't bother much with the services you're developing.
Systems grow from toddlers to old men, so do the businesses. They just evolve and adapt, otherwise they die.
Your body is constantly "refactoring" itself via catabolic processes, and it's also getting of different forms of waste.
My main question was why implement GraphQL BFF layer on top of REST layer. How is this efficient, unless you have legacy REST service that you want expose as GraphQL service. If I am writing a service from scratch why would I create a REST service and then wrap it with GraphQL service?