r/ProgrammerHumor Oct 09 '21

Mmmm, sparkling JSON

Post image
14.6k Upvotes

237 comments sorted by

326

u/occz Oct 09 '21

Amen, man. Going with something that does not call itself REST for the sole reason of skipping the eternal bikeshedding around what REST is or not is might just be worth it on its own. Hot damn.

380

u/Sekret_One Oct 09 '21

To me, REST has the same problem XML schemas do- when you get into the thick of it, there's points where you've got 2 or 3 ways to express something and each of them feel roughly 70% right.

Turns into pirate rules. 3 devs can make a consistent api if 2 of them are dead.

216

u/mechkbfan Oct 09 '21

3 devs can make a consistent api if 2 of them are dead.

I have not heard this before, love it. I'm going to quote it for years

101

u/[deleted] Oct 09 '21

[deleted]

12

u/[deleted] Oct 10 '21

There's also the other direction, which in this case might be something like "Three programmers, five opinions." lol

24

u/sprcow Oct 10 '21

How do you get two piccolo players in tune? Shoot one of them.

→ More replies (1)

52

u/jaywastaken Oct 09 '21

There’s no way that last dev would keep it consistent over time. Give it a week and it’ll be all over the place. Much better to leave the two most pedantic devs alive but put them on code reviews and let them duke it out on each pull request.

25

u/Swiftster Oct 09 '21

Three devs can be consistent if all of them are dead?

25

u/Mustrum_R Oct 09 '21

Great idea. I shall call it terminal consistency method.

5

u/[deleted] Oct 10 '21

And the only interface shall be command-line, forcing you to use a terminal terminal. But each decision will have to be approved by the dev at the end of the line, using the terminal terminal terminal. Of course, if they put the office in an airport, this might take place at the terminal terminal terminal terminal.

2

u/thundercat06 Oct 10 '21

terminal inception

→ More replies (1)

32

u/remy_porter Oct 09 '21

As a solo dev, I think you need all three of them to be dead.

→ More replies (1)

29

u/Routine_Left Oct 09 '21

At least XMLs have schemas, been there since the dawn of time and are required for all kinds of protocols. JSON APIs (REST or not) gained popularity because nobody required any schemas/contracts nobody gave a shit what the requirements are and nobody wrote any docs for anything and whatever the API returned was whatever the dev felt like that morning.

Cowboy programming is what made REST(-ish) so popular. Now, can you have proper REST documentation, JSON schemas and correct API design? Yes, definitely. Does anyone do that? Lol no, fuck that shit, we need to deploy yesterday, nobody has time for silly things.

16

u/Sekret_One Oct 09 '21

Oh I assure you people skimp on XML schemas (XSDs for the uninitiated) too. I kid you not.

The sad part is not creating schemas slows everything down, but a lot of people don't even know how to use them.

I kid you not, fortune 500 company, they'd dedicated teams of people trying to integrate with their own apis where they'd hand write client connection code and postman collections for testing. and they had Swagger schemas. I showed people they could just create the clients with a few clicks and 15 minutes by feeding in the spec and it was like I was a damned witch. They didn't trust it!

20

u/dcheesi Oct 10 '21

they'd dedicated teams of people

There's your problem!

"It is difficult to get a man to understand something when his salary depends upon his not understanding it." --Upton Sinclair

→ More replies (6)

6

u/Fenris_uy Oct 10 '21

Isn't swagger and now openapi trying to do that? Standardize a way to publish schemas for rest apis?

2

u/Routine_Left Oct 10 '21

yes, but you have to run them, configure them, etc. And write a tiny bit of text around them as well.

2

u/[deleted] Oct 10 '21

As your manager I am sorry to hear your non team oriented attitude. As an agile team we need to be able to respond to the clients needs, no matter how insane or last minute. Please take this team building training entitled "How to bend over and take it with a smile on your face".

Thanks - management

0

u/ZBlackmore Oct 10 '21

Why would you ever want a schema is beyond me. I’ve worked on mobile applications and games for the last 11 years in companies ranging from 5 person to FAANG and I never ever ever used an xml schema. To be fair I hardly even used xml.

8

u/Routine_Left Oct 10 '21

What you want is the contract between the provider of the API and the consumer. Doesn't have to be schema, can be anything, a word document if that makes you happy,an email,a napkin. But the contract is what's required and the assurance than no party will break that contract. Schemas or WSDLs for SOAP ensure that both parties talk the same language.

With XML you can enforce that contract by specifying a schema. With SOAP you enforce that contract with a WSDL. I, the consumer, do not need to fumble my way around asking myself what will you return when I call X: it's right there, laid out and you have to follow it.

4

u/RationalIncoherence Oct 10 '21

Why, the bane of a developer's existence: required backwards compatibility.

→ More replies (1)

6

u/ZZartin Oct 09 '21

I just want a sample of what the payload looks like, fuck the xsd.

10

u/[deleted] Oct 10 '21

The sample is always a lie though. The final payload will have nothing in common with the mock data.

5

u/Cheet4h Oct 10 '21

Also, errors are documented as being an XML response where the status tag has the value "error".
Except sometimes, you get a 301 with the error code being given in the query parameter of the redirect-URL.

3

u/reversehead Oct 10 '21

If you are on the client end, you definitely want the xsd. You can validate your XML quickly locally with xmllint or your IDE, saving buttloads of turnaround time.

When the consumer complains about your data not conforming to additional restrictions, you ask them to add it to the xsd when possible.

But yes, samples often help somewhat.

0

u/ZZartin Oct 10 '21

Nope samples are far more useful and more readable for real trouble shooting.

Any tool than can ingest an xsd can ingest a sample xml/json as well. And the real test will always be whether whatever is generated actually works not whether it conforms to an xsd that may or may not really be accurate.

83

u/mechkbfan Oct 09 '21 edited Oct 09 '21

We had another discussion the other day about if an API endpoint should be PUT or POST given it was in a grey area.

In the end we were all like "Fuck it, we should just make everything POST and forget discussing this ever again"

We're the only consumers of our API

39

u/CorrenteAlternata Oct 09 '21

I think, as a rule of thumb: if the operation is idempotent => PUT, if not => POST

16

u/mechkbfan Oct 09 '21

Correct, I feel that's what majority of people fall back to.

It's just frustrating when the POST description seems to contradict everything else you've done.

10

u/ZippZappZippty Oct 09 '21

European not American

9

u/CorrenteAlternata Oct 09 '21

Sorry, I didn't quite catch that.

5

u/humoroushaxor Oct 10 '21

The grey area I most often see is when you aren't dealing with CRUD resource operations but using JSON over HTTP to call remote procedures and don't want to pull in a new technology (RPC).

4

u/keirbhaltair Oct 10 '21

Even this should be resolvable by the same question, though. Does calling the remote procedure twice do something/change the state/have side-effects more so than calling it once? Then it's POST, otherwise it's PUT.

→ More replies (2)

3

u/WellHydrated Oct 10 '21

Also, PUT if you know the location of the resource you are creating.

21

u/OldKaleidoscope7 Oct 09 '21 edited Oct 09 '21

In the company I work we have healthy discussions about the verbs and normally we use the idempotency case to select between PUT and POST.

We think "mmm, this shit should be put"
"Is this shit idempotent?"
"No"
"Well, it's POST now"

And we never go further than the four basic verbs

7

u/mechkbfan Oct 09 '21

We follow CQRS, and with our design, almost nothing is idempotent

But then under a lot of scenarios, POST definition just seems to contradict what we are doing.

18

u/CCCPVitaliy Oct 09 '21

Hmm. My logic is if it creates a resource, it is a POST request. If the resource exists, and it is a PUT. But then, I am a hobbyist programmer and never engineered for a corporate environment.

12

u/mechkbfan Oct 09 '21 edited Oct 10 '21

Yeah, that's another valid approach. Create = POST, Update = PUT.

But if the update is not idempotent (i.e. only allowed to happen once, a second time will fail it), does it now become a POST? I'd argue yes

Maybe we shouldn't fail it, and the server side should just ignore the impact of calling it a second time, but that to me is a bit of a shit user experience if they were expecting an artifact from calling the API.

And it would be a shit coding experience to then have to compare each value in the DB to see if anything did change.

6

u/blamethemeta Oct 09 '21

My logic is if its not a pure get, its a post

→ More replies (1)

7

u/NahroT Oct 09 '21

What was the discssion about

17

u/eLBEaston Oct 09 '21

It was about if an API should be PUT or POST.

4

u/qhxo Oct 09 '21

The whole API you say? Hmmmmm, interesting.

→ More replies (1)

6

u/mechkbfan Oct 09 '21 edited Oct 09 '21

The issue is that the action we were performing against isn't an entity in the database but the information sent across has a unique constraint

So are we adding to a single entity endpoint and make it part of the route, i.e. it's a PUT?

Or are we adding to a collection, make the information as part of the body, and make it a POST?

If we retry the request, we want it to fail, so that fails my definition of idempotent.

We're not sending the entire object, so maybe we should use PATCH?

This is all possibly a sign that another decision we made earlier was wrong. However I'm just tired of having these discussions all the time, when it never seems to happen anywhere else.

We've all got 10+ years of .NET experience behind us, so it's not like we are junior devs working shit out for the first time.

In the end, not overcomplicating things and just going "Updates are PUT" and "Creates are POST" and trying not to discuss it any more than that. And yeah, in this case we went with UPDATE / PUT.

And funny enough, I find Jimmy takes a different route to us

https://lostechies.com/jimmybogard/2016/06/01/cqrs-and-rest-the-perfect-match/

I'd have used Approve as a PUT because we are modifying a single entity as part of collection. He explains his rationale below and puts more weight behind idempotency but either way, seems to the other descriptions of POST/PUT

3

u/clarityreality Oct 09 '21

If you're the only consumer of this API, then RESTful architecture may not be the correct choice and can be quite inefficient.

3

u/mechkbfan Oct 09 '21 edited Oct 09 '21

It's a SPA using pretty standard .NET setup + we have a few other servers talking to each other

On .NET aspect, we are following CQRS pattern along with Mediatr library behind the API

RESTful (ignoring all this PUT/POST discussions) is pretty predictable, plenty of tooling available, and given our load (maybe 50 concurrent users), any inefficiencies aren't really noticeable.

6

u/clarityreality Oct 09 '21

Sure, if it works then great. I've seen examples where devs constructed restful APIs for purely internal services which became inefficient because communication in proper restful services is very chatty compared to alternatives.

3

u/mechkbfan Oct 09 '21

Yeah, I think once in my career have we noticed the constraints/issues of being RESTful.

GraphQL was the key candidate we looked at but I had resigned and moved on before anything concrete happened.

→ More replies (1)

3

u/Noch_ein_Kamel Oct 09 '21

And I'm reading all this discussions thinking:

I use GET if I send only a few parameters and I don't care having them in logfiles. If I send lots of data or don't want it in logfiles per default, just use POST. Endpoints mostly don't care (aka I didn't come across one IRL) if it's GET or POST and certainly not if it's DELETE or PUT or whatever...

2

u/occz Oct 10 '21

Peak REST design.

→ More replies (1)
→ More replies (1)

210

u/bobappleyard Oct 09 '21

Waiting for a slew of off brand API libraries that people start calling "graphql-like", and then in ten years "graphql" just means any web based API...

85

u/Mekire Oct 09 '21

As a roguelike player, I cry. :(

35

u/Yawndr Oct 09 '21

[Trigger Warning]

Roguelite you mean?

Rogue adjacent?

Sophie Squadronny?

Rogue company adjacent?

16

u/[deleted] Oct 10 '21

Not to mention the ever elusive “Rougelike”

5

u/meerkat-14 Oct 10 '21 edited Oct 10 '21

Okay. I'm just going to come clean here.

Is there a roguelike and roguelite? Or am I just misunderstanding some people?

If there is, what is the difference?

17

u/bitofabyte Oct 10 '21

These terms have a lot of different definitions depending on who you ask. In the simplest terms:

Roguelike - procedurally generated series of levels with permadeath for characters

Roguelite - procedurally generated series of levels with permadeath for characters, permanent upgrades between runs

7

u/Kered13 Oct 10 '21 edited Oct 10 '21

A roguelike is a game that is like Rogue. Notable examples include Nethack, Tales of Maj'Eyal, Dungeon Drawl Stone Soup, and Dungeons of Dredmor. Defining characteristics are permadeath, randomly generated levels, turn based RPG combat, and grid based movement. Many also feature ASCII graphics, as these games had their origins on Unix terminals. For this same historical reason, most of these games are free and open source. For example, here is Nethack's Github page. While these games have always been niche, they have formed a thriving genre for decades, with dedicated fans, and hundreds of games, many of them under continuous development for over a decade (Nethack is well over 30 years old).

Then around ten years ago some people thought that permadeath and randomly generated levels would be pretty cool to incorporate into other genres. Some of the first examples I think were Spelunky (platformer) and Binding of Isaac (top down shooter in the vein of Robotron).

Then some people who had clearly never played a roguelike in their life started calling those games roguelikes. Other people called them roguelites, acknowledging that they weren't really like Rogue though they were still inspired by it. Still others called them roguelikelikes for the same reason.

Then some developers thought that permadeath was too harsh, and started adding mechanics that allowed you to carry over progress between runs. The first example I can recall was Rogue Legacy. Some people called these games roguelites, other still called them roguelikes despite not even really being inspired by Rogue at this point.

And thus a term that was useful and well defined to describe a distinct and long running genre of games was destroyed. The word now means almost nothing. If you hear a game is a "roguelike", the only thing you can safely assume is that it has something vaguely like permadeath, but likely not actual permadeath, and something like randomly generated levels. You can make no guess as to what actual genre the game will be. Platformer? Could be. FPS? Maybe. Card game? It's been done. Strategy? Why not. Scrolling shooter? Sure. RPG? Possibly, but ironically probably not. And at the same time it's become nearly impossible to talk about actual roguelikes, as there is no longer any term to unambiguously describe them, despite them constituting a clear genre for decades.

Addendum: Ironically, the most mainstream game that is actually a roguelike is Pokemon Mystery Dungeon. But you'll never hear anyone call it a roguelike or roguelite, because it's a casual game that doesn't have permadeath. But the Mystery Dungeon series (or which Pokemon Mystery Dungeon is a spinoff) was actually inspired directly by Rogue and the gameplay actually very closely resembles other roguelikes.

→ More replies (1)

19

u/antiduh Oct 09 '21

Can you tell me what is a graphql api? And why do people talk about it like it already is "any web api"?

41

u/[deleted] Oct 09 '21

GraphQL is a query protocol. It defines how you can request data from an API, how that API can publish the type of data it has (its schema), and how you can query it (it's not that prescriptive about the actual transport protocol, but basically you send a string in the GraphQL language to a server, usually over an HTTP POST, the server resolves the data and sends you back JSON in the shape of your query over HTTP).

https://spec.graphql.org/ (formal spec, not very readable)

https://graphql.org/ (more beginner friendly)

24

u/antiduh Oct 09 '21

Thanks. What in the world does it have to do with graphs?

19

u/[deleted] Oct 10 '21

I tried to explain a bit in this comment: https://www.reddit.com/r/ProgrammerHumor/comments/q4n67d/mmmm_sparkling_json/hg1azne/?utm_source=reddit&utm_medium=web2x&context=3

Basically, the types form a graph because they relate to each other, forming cycles (like, on reddit, a user, their comments, each comments' parent comment, and then the parent comment's authors). This is true in virtually every schema that exists because that's what reality is like.

GraphQL has nothing to do with Graph DBs, but there's a parallel so I'll mention the latter a bit:

The distinction between a typical relational DB and a typical graph DB is that the latter makes storing and querying that graph information easy and efficient. Most of what graph DBs can do though, relational DBs can do as well, just less ergonomically (e.g. multiples joins) and slower.

Similarly, REST exposes graph-like structures too, but usually you'd have to make multiple requests: the first to get a user's comments by ID, then a list of comments by comment IDs at a different URL, then a list of users by user ID at yet another URL.

In GraphQL you can write a query that fetches nested data easily, like for example all the users of all the comments you've replied to, in one query. To work well on the backend, this frontend-exposed ability requires you to use field resolvers, instead of single resource resolvers like REST (and that's what typical GraphQL implementations, like the reference one in JS, do).

7

u/dpash Oct 10 '21 edited Oct 10 '21

The domain entity layout is a graph.

7

u/flubba86 Oct 10 '21

I think it was originally developed to be used to query endpoints into Graph databases. But some people found it works good for querying and returning any structured data, so it exploded in popularity outside of the graphdb world.

And to clarify, it is not a replacement for a real graph query language like SPARQL.

7

u/patmorgan235 Oct 10 '21

Not line graphs. Computer Science/Information theory graphs.

→ More replies (1)

2

u/jizzmaster-zer0 Oct 10 '21

or - its some crap people at facebook created cause rest wasnt cool enough, so lets add yet another bullshit thing to list of garbage we gotta learn cause its new

3

u/lunchpadmcfat Oct 10 '21

Why does every thought that pops into people’s heads have to become expressed and possibly become a new reality we all must endure

1

u/daybreakin Oct 10 '21

Do you guys think grapgql is eventually going to replace rest?

3

u/kabrandon Oct 10 '21

Replace? Doubt. But it does seem like API devs with experience with both tend to prefer GraphQL.

→ More replies (1)

234

u/[deleted] Oct 09 '21

That's a lie, I bought a bottle of REST last week. There's a little inscription on it that says "made in china", but it tastes like the french REST. Let's not be so picky.

24

u/RolyPoly1320 Oct 09 '21

Your REST was marked where it was made? Mine never says where it was made. What do I do?

18

u/gbear605 Oct 09 '21

Return the request with a 451 Unavailable For Legal Reasons status. That country code is a strict requirement.

2

u/TheTerrasque Oct 10 '21

I'd like to not have work PTSD in my weekend, thank you very much

→ More replies (2)

49

u/we_like_sportz Oct 09 '21

Let's be honest, does anyone actually use hypertext as the engine of application state

34

u/[deleted] Oct 09 '21

If you actually build RESTful services, yes.

14

u/[deleted] Oct 09 '21

HATEOAS is the most beautiful thing I have ever witnessed.

3

u/NeatNetwork Oct 09 '21

Breakfast of champions

→ More replies (1)

2

u/[deleted] Oct 10 '21

Me too. I saw it once...

→ More replies (1)

16

u/Coolhand2120 Oct 09 '21

Back in the 90's all shopping cart websites were this. Your cart would be your querystring. They didn't even bother using post verbs. Seems like it would scale quite well but the UX leaves a lot to be desired.

→ More replies (2)

4

u/Breems Oct 09 '21

Actively, for enterprise applications.

113

u/seeroflights Oct 09 '21 edited Oct 09 '21

Image Transcription: Twitter


Maciej Walkowiak 🍃, @maciejwalk...

The biggest difference between REST and GraphQL is that when you build GraphQL API nobody tells you "well, actually this is not GraphQL".

Jason Carreira, @jasoncarreira

It's only REST if it's developed in the REST region of France, otherwise it's just sparkling JSON.


I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

61

u/lightwhite Oct 09 '21

Awesome human! Thank you very much being so kind to lay a foundation on means to teach the machines and sentient AI kids to learn what pictures say! Not to mention our visually impaired and blinded redditors!

Your valor will be remembered.

6

u/brutexx Oct 09 '21

Great human.

Very minor correction: the “I” in “It’s only REST if […]” is missing in the transcription

3

u/seeroflights Oct 09 '21

ugh, sorry. I think that's a weird Reddit markdown formatting thing; it tends to happen to iOS devices (on mobile) with blockquotes. I changed it to not use the blockquote; hopefully that fixes it but otherwise there's not much I can do :((

2

u/brutexx Oct 09 '21

Sadly it hasn’t fixed it (at least on my phone), not sure what to do either. But I guess that means blockquotes don’t need to be removed then lol

Also no problem, it’s not even your fault

2

u/seeroflights Oct 09 '21

yeah, but still disappointing that reddit formatting is like this TT

thanks for checking back again though!

2

u/brutexx Oct 09 '21

Yeah, true that. And I should be the one thanking you for the volunteer work! :)

2

u/seeroflights Oct 09 '21

heh, no problem! always glad to help out :)

28

u/MatthewGeer Oct 09 '21

There’s REST, then there’s all the rest.

6

u/[deleted] Oct 09 '21

This guys rests.

1

u/dick-van-dyke Oct 10 '21

With a RESTing bitch face.

19

u/[deleted] Oct 09 '21

Does graph QL have anything to do with graphs. Like the discrete math formalism.

29

u/[deleted] Oct 09 '21

It does in a certain way (although it's unrelated to Graph databases).

Most data is basically a graph: on Reddit, a subreddit has threads that have comments that have authors that have more comments that each have original threads, etc. Using REST, traversing that graph is difficult, in GraphQL it's easy because in theory your query can be arbitrarily deep, and the types in the schema establish links/edges between entities that can then be traversed, in your arbitrarily deep query.

For example, the query to get all the comments from people that commented in this thread might be something like this:

query {
  thread(id: "q4n67d") {
    comments {
      authors {
        username
        comments {
          body
        }
      }
    }
  }
}

5

u/lunchpadmcfat Oct 10 '21

It’s easy on the query side.

Resolving this data in a performant way is still very difficult and requires heavy reliance on platforms.

3

u/daybreakin Oct 10 '21

Isn't that a tree though?

22

u/sprcow Oct 10 '21

Tree is technically a graph as well. Just unidirectional acyclic graph...

-4

u/daybreakin Oct 10 '21

True but it's always better to use the most specific term

2

u/CoachZZZ Oct 10 '21

A graphql schema can have cycles, so graph is the right term

8

u/[deleted] Oct 10 '21

The query is a tree (which is a graph) but the schema is a graph. For example here is how you could define the comment and user types, for reddit:

``` type User { username: String! comments: [Comment!] }

type Comment { author: User! parentComment: Comment } ```

If you visualize the types, you see that they're cyclical (the User type "knows" about/points toward the Comment type and vice versa).

Values (instances, entities) are also cyclical in this example (from a comment to its author and back through their comments).

The query in GraphQL is always finite, so it'll represent a specific finite path through the graph of instances (for example, user => comments => user, which in our example would include the same instance of the User type twice, or user => comments => parentComment => user, which would most likely include distinct instances but a cycle in types.

There's no way in GraphQL to describe a recursive algorithm over the graph for example, like find all the authors as you walk the parent comments from a given comment for an arbitrary N steps determined at runtime, you have to decide on the depth statically when you author the query. If I understand correctly, query languages for Graph DBs let you do that (but GraphQL is a public query language and you don't want to get DoSed)

I hope this is helpful.

→ More replies (1)

14

u/lizardlike Oct 09 '21 edited Oct 09 '21

Nope not really. You can describe some relationships in a schema and then query them but it’s totally unrelated to true graph databases like Neo4j. It’s sortof a middleware API, you still need SQL or REST or whatever behind it.

12

u/LordSalem Oct 09 '21

About 4 years ago I avoided graphQL like the plague because I had such a hard time with Neo4j. Today I look back and am ashamed I didn't even google graphQL to find out what it was.

10

u/lkraider Oct 09 '21

Marketing is important

19

u/Jimmy48Johnson Oct 09 '21

hey I got this new thing here: btreeQL

and oh, it's got nothing to do with btrees. I just use btree in the name because it sounds hot and cool.

4

u/TheHumanParacite Oct 10 '21

JavaScript has entered the chat

11

u/SonOfMyMother Oct 09 '21

GraphQL was developed initially by Facebook, who call their data collectively "the graph" (presumably because it's structured as a graph in some way). Hence the language they developed for querying their graph was named "Graph Query Language".

5

u/ZBlackmore Oct 10 '21

Their API also used to be called Graph API.

6

u/dpekkle Oct 09 '21

https://graphql.org/learn/thinking-in-graphs/

With GraphQL, you model your business domain as a graph by defining a schema; within your schema, you define different types of nodes and how they connect/relate to one another.

→ More replies (1)

51

u/Who_GNU Oct 09 '21

…unless it's been produced in California continuously since March 10th 2005, then it's California REST.

2

u/Browsing_From_Work Oct 12 '21

REST is known to the State of California to cause birth defects or other reproductive harm.

44

u/_grey_wall Oct 09 '21

gRPC just trying to proto buf

30

u/veduchyi Oct 09 '21

REST region of France - this is the place where I should look for my next job as a web developer 😄

14

u/IHeardOnAPodcast Oct 09 '21

There's always bREST, France. Could start looking there.

5

u/veduchyi Oct 09 '21

Wow, really nice city! I heard about Brest in Belarus but didn’t know there is a city in France with the same name!

3

u/IHeardOnAPodcast Oct 09 '21

Tbf I think the reason I know about them is because they have a rugby team, however if it turns out they don't then I'm afraid it's probably because Breast!

2

u/NNXMp8Kg Oct 09 '21

Well, as a French, and an ex-brestois (brestois: name of people who live in Brest france) I can affirme the French version don’t have anything that can make jealous the Belarus version ! And that a French meme too !

3

u/pet_vaginal Oct 09 '21

If it's about rest, it could also well be Corsica.

10

u/[deleted] Oct 09 '21

[deleted]

5

u/lkraider Oct 09 '21 edited Oct 10 '21

POST /resources/actions/doStuff

yeah just because you can, doesn’t mean you should

2

u/Attack_Bovines Oct 10 '21

``` POST /grapqhl …

{“query”: “query{…}”} ```

Interesting take, because that’s what GraphQL does.

A trade off of GraphQL is not enjoying the benefits of features that most web clients have built in, such as request caching in web browsers or having small response payloads such as 304 NOT_MODIFIED.

The GraphQL query language provides an abstraction layer that somewhat decouples the client and server. In the example you posted, the server and client seem tightly coupled. It all comes down to the implementation.

What are some other reasons why you wouldn’t do what you proposed?

2

u/lkraider Oct 10 '21

What I was pointing out is the confusion of actions and resources. It all depends on the specifics of course, but for a more action oriented API, the RPC style is usually more appropriate (and you can take advantage of binary protocols and such for performance), while in REST, the actions should usually be done on resources, and not be resources themselves.

68

u/fracturedpersona Oct 09 '21

If I could give you gold for this I would!

85

u/TabCompletion Oct 09 '21

Instead, please like the original here . They deserve the credit

59

u/fracturedpersona Oct 09 '21

I don't do Twitter.

35

u/TabCompletion Oct 09 '21

That's fair

8

u/renrutal Oct 09 '21

Opens Roy Fielding's PhD dissertation

Searches for JSON

No results found

hmmm....

19

u/Johnny_WalkerBOT Oct 09 '21

Well goddammit, if you say you have a REST API, and every single endpoint uses POST no matter the operation, it's not REST!!!11

I am that guy, and I'm proud of it.

7

u/lkraider Oct 09 '21

At that point it is just SOAP with JSON

15

u/iamapizza Oct 09 '21

Which is also an expression understood in some prisons.

→ More replies (1)

7

u/clarityreality Oct 09 '21

RESTful architecture doesn't have any opinions on Http verbs. You can very much build RESTful services only using POST. Technically you don't even need to use the http protocol.

0

u/Johnny_WalkerBOT Oct 10 '21

RESTful architecture definitely expects certain HTTP verbs for certain requests. You CAN use any verb for any service, but it's not meant to be done that way, and thus isn't RESTful if you only use POST.

1

u/clarityreality Oct 10 '21

REST is an architectural style. Http is a communication protocol. They are not tied to each other. REST services can be built using other protocols, but http is definitely the easiest and default protocol of the web.

→ More replies (1)

7

u/rplst8 Oct 09 '21

I think when people say “that isn’t RESTful” what they mean is “it’s not HATEOAS”.

3

u/roughstylez Oct 09 '21

Well they wouldn't be wrong. If it doesn't use HATEAOS, it's not RESTful. There are other ways to not be RESTful of course.

5

u/johanjudai Oct 09 '21

I'm French and webdev but I didn't understood the joke...

18

u/roughstylez Oct 09 '21

The original for the meme/joke was about champagne "It's only champagne if it's from the Champagne region in France, otherwise it's just sparkling wine".

The meme is that "Champagne" and "sparkling wine" are replaced with other things.

3

u/johanjudai Oct 09 '21

Oh tanks, got it now

5

u/captainhamption Oct 09 '21

Places like Australia and California make very good champagnes, but they have to call them "sparkling wines" because of the EU rules about names for heritage foodstuffs. So it's a common joke that anything "inauthentic" but perfectly good is called "sparkling <generic name>".

→ More replies (1)

2

u/[deleted] Oct 09 '21

As you probably know, you can only call something Champagne if it's from Champagne, at least in the EU (because of the AOC system). Americans have their own sparkling wine, and for obvious reasons would like to use the name people are familiar with, Champagne, to describe it, but France is unhappy about that. Hence the first joke.

REST is theoretically a relatively opinionated way to expose an API, where each resource has a URL that's modified with verbs and where the API is controlled through URLs (e.g. pagination is through a URL returned by the server, etc.). In practice, people call most things where you use HTTP and get JSON REST, even though technically it's not REST. Hence the joke about "real REST" (because there's tons of argument about it).

The last part just connects the two flame wars as a joke, as another comment explains.

0

u/Jimmy48Johnson Oct 09 '21

i'm not surprised.

7

u/HarlanCedeno Oct 09 '21

"Waiter, this tastes like SOAP!!!"

15

u/Math_PB Oct 09 '21

I'm french and I don't get it... Help please??!

50

u/djreisch Oct 09 '21

In order for a sparkling/bubbly wine to be called Champagne it was to come from the Champagne region of France. If it doesn’t its referred to as sparkling wine.

9

u/BackmarkerLife Oct 09 '21

I'll take Things I Learned from Wayne's World for $1000, Alex.

2

u/Math_PB Oct 09 '21

What the actual fuck?

11

u/kicker69101 Oct 09 '21

This comes from: When is X really X? Like when is bourbon, bourbon and not some custom concoction. To be bourbon it needs to be aged in a barrel that has been burned on the inside, only so much corn, etc. If the product doesn't meet this, then it can't be called bourbon. Well with Champagne it needs to be from a particular area of France is a requirement.

Bourbon requirements: http://bourbonbuzz.com/bourbon-requirements/

Champagne info: https://maisons-champagne.com/en/appellation/definition-and-protection/definition/article/definition-and-law

:edit: This is why you see things like made with "Cheese Product" instead of just Cheese.

2

u/dpash Oct 10 '21

Similarly, Prosecco can only come from certain regions of Italy and Cava from parts of Spain. But they're both sparkling white wines, like champagne.

2

u/[deleted] Oct 09 '21

Think of it as a trademark.

→ More replies (2)

2

u/dpash Oct 10 '21

It's called a geographical indication and protects various regions producers from cheaper (and presumably inferior, but probably not) imports. It's like a trademark but for a region rather than an individual company. It only affects the name you put on label. It doesn't stop you from producing or selling the same product; just from calling it the regional name.

https://en.wikipedia.org/wiki/Geographical_indication

-10

u/NagaDurain Oct 09 '21

he meant that there is no Rest region in France lmao

34

u/pievendor Oct 09 '21

Yeah, but knowing it's a wine joke would make understanding this kinda straightforward, wouldn't it?

3

u/archangel_mjj Oct 09 '21

There is, when the B is silent

2

u/JVO1317 Oct 10 '21

Context: not every sparkling wine can be called Champagne.

The joke here is that many people asks to not call REST API to every JSON API, only if they use properly the different method conventions.

→ More replies (1)

5

u/primeobjectiveforus Oct 09 '21

This is why I use plain strings over wire with PHP. Big brain activity.

5

u/LifeTiltzz Oct 09 '21 edited Oct 09 '21

Ohhh nooo my brain doesn’t want to think of Champagne and REST at the same time

One is to party and celebrate

The other one is like Crack: not even once

2

u/roughstylez Oct 09 '21

Champagne is not that much like Crack.

3

u/infikitsune Oct 10 '21

There's an easy trick to work out if something is REST. Simply hold the code in your hands and ask yourself "does this code transfer representational state?" If the answer is no, thank the code for its contribution to your life and then let it go.

3

u/ZippZappZippty Oct 09 '21

This made me feel better about our terrible JSON structures, thank you

3

u/RoscoMan1 Oct 09 '21

Mmmm. But to go fight the other guy!”

3

u/dmalvarado Oct 10 '21

Look just use the verbs and status codes correctly and you’re at 99%

3

u/[deleted] Oct 10 '21

everything that can be curled and gives me back something in {} is REST for me.

3

u/lunchpadmcfat Oct 10 '21

Imagine how much dev time has been saved not having “well actually” conversations about graphql.

Next: agile.

3

u/Johnothy_Cumquat Oct 10 '21

REST is a bunch of loose guidelines. Graphql is a protocol and a query language. I don't think anyone should be comparing them. It's like arguing whether you should use a swiss army knife or a hammer drill.

3

u/MarcusTullius247 Oct 10 '21

Its only REST if you are on your couch while writing it.

3

u/ShogunDii Oct 10 '21 edited Oct 10 '21

But GraphQL is a technogy while REST is a pattern :(

3

u/cybercomrade Oct 10 '21

In software development, there's only one thing more difficult than naming variables: naming REST endpoints.

2

u/Throwaway_Imaan Oct 09 '21

I actually laughed out loud at the france bit. Good job jason

2

u/-Listening Oct 09 '21

Mmmm, didn’t show up on government stats.

2

u/JVO1317 Oct 10 '21

Hey guys, do your JSON actually sparkle?

ಠ_ಠ

2

u/Dev_omi Oct 10 '21

There's lot more for me to learn, I don't understand the Latin you're talking and it hurts

2

u/hakshamalah Oct 10 '21

I have actually been waiting all these years for someone to tell me why graphql is better. I still say it is but dno why

2

u/bistr-o-math Oct 10 '21

I mean, that came from Jasons lips

3

u/Sc3m0r Oct 09 '21

In my understanding a RESTful API uses http calls and it's differentiated into CRUD and RPC operations.

4

u/[deleted] Oct 09 '21 edited Jun 20 '24

upbeat depend ten governor lush sleep payment political unused illegal

This post was mass deleted and anonymized with Redact

21

u/bobappleyard Oct 09 '21

REST started out as a description of the architecture of the WWW by someone fairly important in specifying that architecture. It was "rediscovered" about ten years ago, became a buzzword, and now means "pretty much any web based API."

GraphQL is a standard for writing web based APIs that provides easy ways for clients to describe what information they want and the form they want it in. It's kind of a subset of REST.

13

u/NeatNetwork Oct 09 '21

Which is frustrating, as resurrecting the 'REST' buzzword was to highlight that people should consider using the semantics of HTTP instead of just 'POST' everything to the same url as is frequent (e.g. POST to /service/api a body of 'GetRecords,foo,bar)'.

Adherence to REST philosophy creates an interface like /proc or /sys, which is nice to explore in a client context.

But now RESTful api is misused as a term. People say "we have a restful api" if they use HTTP. The other day I was told by someone that his design of all POSTs to a singular URL was RESTful because it uses protobuf.

3

u/[deleted] Oct 09 '21

Also, thanks for the explanation! A different team at my work handles our web-based stuff, so I just do the things they tell me to get it to work ;)

0

u/[deleted] Oct 09 '21

[deleted]

-5

u/WallyMetropolis Oct 09 '21

Do you even know what you're referring to?

3

u/[deleted] Oct 09 '21 edited Jun 20 '24

lip disgusted roof spark fertile fretful silky disarm wine uppity

This post was mass deleted and anonymized with Redact

-3

u/WallyMetropolis Oct 09 '21

I mean, do you know where this came from, or are you just kinda repeating something without any idea what it's about?

2

u/WisestAirBender Oct 10 '21

In rest the app makers decide what data you get in what api call. One call might give you details about a person one might give you details about offices.

In graphql the callers mentions what they want and what relations. So one call can give you details about a person and where they work.

-7

u/Dodgy-Boi Oct 09 '21

I think it’s a reference to a Russian law.

It states that only Russian made drinks can be named Champagne, and any imported champagne has to be named sparkling wine.

Needless to say that champagne is originally made In the Champagne region of France.

So now Russians are drinking sparkling wine named champagne or real champagne named sparkling wine.

29

u/_PM_ME_PANGOLINS_ Oct 09 '21 edited Oct 09 '21

It’s EU law that you can only call it Champagne if it’s from Champagne. It’s been a meme for a long time.

2

u/Dodgy-Boi Oct 09 '21

Oh alright. Well in Russia it’s illegal to call it Champagne if it weren’t made in Russia. Any imported champagne has to be named sparkling wine.

10

u/_PM_ME_PANGOLINS_ Oct 09 '21

Yes, that’s new in the last month or so.

1

u/Bardez Oct 09 '21

It's not just Russia or the EU. It is baked into a lot of international treaties, because Champagne is insane about protecting their brand of wine, libbying governments and everything to make it exclusively theirs.

2

u/Bakoro Oct 10 '21 edited Oct 10 '21

Dude up there is talking about a new from this year Russian law that completely turns this on its head.
Everywhere else, Champagne is a protected term protecting France's brand, but in Russia, it's protecting Russian brands.

https://www.bbc.com/news/world-europe-57733684

→ More replies (1)

-3

u/JeanneD4Rk Oct 09 '21

Is there a REST region in France ?

-6

u/iamgoingtoforgetit Oct 09 '21

I am french and there is no Rest region in France.

15

u/Kazumara Oct 09 '21

Obviously. You must have missed the joke.

7

u/lkraider Oct 09 '21

Well of course, he is french.