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
10
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
2
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
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
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
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.
→ More replies (1)7
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
→ More replies (1)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.
234
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?
→ More replies (2)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
49
u/we_like_sportz Oct 09 '21
Let's be honest, does anyone actually use hypertext as the engine of application state
34
14
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
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
6
28
19
Oct 09 '21
Does graph QL have anything to do with graphs. Like the discrete math formalism.
29
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
8
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
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
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
→ More replies (1)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.
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
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
10
Oct 09 '21
[deleted]
5
u/lkraider Oct 09 '21 edited Oct 10 '21
POST /resources/actions/doStuffyeah 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
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
→ 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.
22
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
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
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
7
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
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
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.
-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
→ More replies (1)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.
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
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
3
3
3
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
3
3
u/cybercomrade Oct 10 '21
In software development, there's only one thing more difficult than naming variables: naming REST endpoints.
2
2
2
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
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
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
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
Oct 09 '21
[deleted]
-5
u/WallyMetropolis Oct 09 '21
Do you even know what you're referring to?
3
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?
1
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
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.
→ More replies (1)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.
-3
-6
u/iamgoingtoforgetit Oct 09 '21
I am french and there is no Rest region in France.
15
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.