7 ms·
Could you explain the difference?
by linux2647 1y ago
Could you explain the difference?
- spicybright 1y agoI'm not the most knowledgeable, but a protocol talks to another process through a specific format. I personally think its more powerful than writing a new process to replace and existing. My favorite example is an X11 windows manager implementing in about 18 lines of python. Obviously there's dependencies to talk to the X server, but the power of a protocol comes from any program written in any la gage communicate with existing code.
- xorbax 1y ago> My favorite example is an X11 windows manager implementing in about 18 lines of python. Uh, do you happen to know where to find that project? Sounds pretty comprehensible for most people as an example.
- alpaca128 1y agoNot sure about that Python project, but years ago I found this very minimal WM in a few hundred lines of C helpful: https://github.com/dylanaraps/sowm https://github.com/dylanaraps/sowm Was a lot easier to understand for me than, say, dwm.
- deleted 1y ago[deleted]
- ChanderG 1y agoI created my own X11 window manager [1] at the start of this year in around 800 lines of C. I had been using dwm (4000 lines of C) for many years and wished to write my own for a long time, but what made me take the leap was really steveWM [2] and TinyWM [3] which are both super small. [1] - https://github.com/ChanderG/cellwm https://github.com/ChanderG/cellwm [2] - https://github.com/stodd1031/steveWM https://github.com/stodd1031/steveWM [3] - https://github.com/mackstann/tinywm https://github.com/mackstann/tinywm
- vidarh 1y agoTinyWM was the starting-point for my wm in Ruby as well. It really drives home just how little you need to get started.
- spicybright 1y agoSure! https://github.com/mackstann/tinywm https://github.com/mackstann/tinywm I've run it once a long time ago and worked perfectly fine for me.
- neuroelectron 1y agoA protocol is like the line at Subway where an api is a bar & restaurant.
- linux2647 1y agoSorry, I don’t understand this analogy
- neuroelectron 1y ago[flagged]
- anthk 1y agoProtocol = It defines the whole channe with data structures and commands. API = how do you connect against.
- packetlost 1y agoThey're both poorly defined, but what I think GP meant is they want something that you use something like a socket instead of FFI to interface with. You need an extra data description layer for a 'protocol' in this context because you can't rely on something like the C data model and calling convention as a given.
- fnordpiglet 1y agoA protocol defines a set of primitives and their interactions, along with prescriptions where necessary, but is otherwise pretty loose generally. Especially in a Postels law world. APIs tend to be highly prescriptive with a highly specific interface and a lot of black box. Think of the difference between an IETF RFC on say SMTP vs an email API - the RFC describes how clients and servers for mail routing interact through an almost dialog, while a typical email API has highly structured interfaces. Another wat to cut it is an API can be tested as it has inputs and return values dependent on those, while a protocol you can generally only assert compliance with the specification of the protocol. People often assert protocols have something to so with RPC of some sort but that’s not true. Many language support protocols, which can be very similar to interfaces, but don’t have anything to do with OOP, etc. In language protocols it’s slightly different than network/IPC protocols but the intent is similar.
- rewgs 1y agoA couple ways to look at it: - Protocols are descriptive, APIs are prescriptive - Protocols are implemented, APIs implement