Skip to content

Instantly share code, notes, and snippets.

@hoganlong
Created April 17, 2023 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoganlong/c359301ddb72e17fc8777b623ee58ae1 to your computer and use it in GitHub Desktop.
Save hoganlong/c359301ddb72e17fc8777b623ee58ae1 to your computer and use it in GitHub Desktop.

In programming we are constantly applying different layers of abstraction. At the root level data is just 1 and 0 and moving between memory cells and registers. Most people have no concern for that when they program. They have an object oriented or strongly typed language that adds a layer of abstraction over the internal machine code, instructions, and bytes.

Worrying about the endian of integers is a case of not looking at problems form the correct level of abstraction, in almost all cases. It is very rare a programmer will ever have to worry about the details of how the hardware stores the number in memory -- unless you are writing in machine language or doing hardware level data transfer it won't matter.

The compiler (yes even low level compilers like C) will take care of it for you. It just won't matter as long as you use the abstract typing of compiler.

Lets say you need to create a transport protocol -- in this case it may or may not matter depending on the protocol. If the protocol is in JSON or some other standard, then there is no worry -- the libraries you use will work just fine and resolve these issues.

If you have a binary "byte-stream" protocol then you would have to worry about the order of the integers. But this is only case I can think of, in this case you would have the order defined in the protocol and make sure your serialization code work to that standard. The likelyhood you would "byte-swap" to create such a protocol is basically zero.

This is why the article says you should not be worried about byte swapping and it is a clear indication a user does not understand programming.

Programming is about abstraction and using the tools to leverage that abstraction to solve complex problems.

@hoganlong
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment