General > General Technical Chat

How many people code in C these days, and if so, why?

<< < (94/99) > >>

bd139:
Yeah aware of that. TBH you're probably expecting a bit much out of JSON there. It's pretty loosely typed and so is python so there is no serialization contract. Everything is runtime inferred. You get the same problem using python's pickle stuff as well.

This is one reason I use protobufs / gRPC for communication these days. Explicitly define the contract and generate the serializers etc. That gives strong contracts, strong type inference, portability of wire and disk formats and contract versioning.

tl;dr: JSON is fucking shit. Avoid it like the plague.

paulca:

--- Quote from: bd139 on May 19, 2020, 03:11:18 pm ---Yeah aware of that. TBH you're probably expecting a bit much out of JSON there. It's pretty loosely typed and so is python so there is no serialization contract. Everything is runtime inferred. You get the same problem using python's pickle stuff as well.

This is one reason I use protobufs / gRPC for communication these days. Explicitly define the contract and generate the serializers etc. That gives strong contracts, strong type inference, portability of wire and disk formats and contract versioning.

tl;dr: JSON is fucking shit. Avoid it like the plague.

--- End quote ---

Horses for courses, but JSON is both machine consumable and human consumable.  It's very loosely typed, or barely typed at all, but XML is far, far, heavier.

When a service goes tits up at 3am and it used JSON (say REST) you can poke it with a stick in a terminal without needing header files and a compiler or a suite of utility clients.  It's also, like XML standardised and fully standalone/introspectable.

I'm old enough to remember people starting to run scared from binary format and old enough to remember why.  So when I see proto-buf and RPC returning, get the popcorn and listen to Cherly bassy - history repeating.

Nominal Animal:

--- Quote from: paulca on May 19, 2020, 03:01:36 pm ---Have you tried to use the json package?
--- End quote ---
Only to and from dicts, server-side talking to ajax.  And when I do that stuff, my mind is already bifurcated into two antagonists (one trying to implement the thing, another trying to misuse it), so I tend to not notice developer un/friendliness, unless the language/library actively fights me.  :-//

It is interesting to note, however, that JS objects best correspond to Python dicts (orderedDicts prior to version 3.8 ), and not to Python objects per se.
In fact, the two even have the same syntax in the two languages... which might explain why using JSON on Python objects is not comfortable/intuitive: the way those who use a lot of JSON in Python envisioned the json module to be used, would be mainly with dict/orderedDict objects.

This is exactly the paradigm difference I've mentioned in other posts, and others have called "writing X in Y" (with X and Y both programming languages).  It is not necessary for "object" to correspond to "object" in another programming language.  Here, it just happens that the general equivalent of JS objects is not a Python object, but a Python dict, behaviour-vise.

Note that this is a pitfall anyone with any amount of experience can fall into, because we humans are instinctive extrapolators, and are particularly susceptible of missing these unless we are aware of this pitfall.  Me myself, I've had to climb out of these often enough, and instead of asking "what in Y is like Z in X" (with Y a class or function name, and X and Y prohramming languages) I've had to learn to look at behaviour and features instead of assume analogous behaviour based on name or hierarchy!

In theory, that should be annoying (because it means the definition of "object" is now highly dependent on the context, and not like you were taught in school/course/book).  Me myself, I don't mind, because I am aware of my limitations, and finding those different approaches allow me to overcome and exceed my own built-in limitations; to grow.  You know, knowing how and why others see a different thing when looking at the same thing I am, tells me a lot about what my own limitations are, and how to overcome them.  I like that a lot.

2N3055:

--- Quote from: bd139 on May 19, 2020, 03:11:18 pm ---Yeah aware of that. TBH you're probably expecting a bit much out of JSON there. It's pretty loosely typed and so is python so there is no serialization contract. Everything is runtime inferred. You get the same problem using python's pickle stuff as well.

This is one reason I use protobufs / gRPC for communication these days. Explicitly define the contract and generate the serializers etc. That gives strong contracts, strong type inference, portability of wire and disk formats and contract versioning.

tl;dr: JSON is fucking shit. Avoid it like the plague.

--- End quote ---

proto3 I presume ??

bd139:
Correct

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod