Top products from r/shittyprogramming

We found 5 product mentions on r/shittyprogramming. We ranked the 5 resulting products by number of redditors who mentioned them. Here are the top 20.

Next page

Top comments that mention products on r/shittyprogramming:

u/Intrexa · 2 pointsr/shittyprogramming

Because unlike what the OP said, IP's that are actively being used to route information are ints in memory. When I ping Facebook.com, the program doesn't get 173.252.120.6 back, it gets 2919004166 back (which is identical to getting 0xADFC7806 back, because it's just a bit order, there's no way to differentiate the decimal and the hex. It's just a display thing). It has to convert that number to the 4 octets that make sense to humans.

Same thing in reverse. When I go to http://173.252.120.6, it can't just start sending data out to 173.252.120.6, it has to convert it to 0xADFC7806 first. This is true of any program that does networking. Why is that? It saves space in an area where space is most important. So you see, it's not like the program is doing an extra step to allow this, it's actually doing 1 less step. What's more, I bet Mozilla (I use firefox, this is probably true of all browsers) didn't implement a specific "convert IP to int" function, this is default functionality of networking libraries, libraries that would routinely be handling both octet notation and ints, because most programs dealing with this would already dealing with low level ints. So not only are they doing 1 less step, Mozilla would have to go out of their way to specifically disallow this.

And again, for completeness sake, an IP address that is traversing a network is stored in a big endian int, meaning the bit order you see here (1010 1101 1111 1100 0111 1000 0000 0110) isn't actually the bit order a network switch will receive when it needs to route the packet. Also, it's technically not an int, it's a structure that only contains a single int.

/ Internet address. /
struct in_addr {
uint32_t s_addr; / address in network byte order /
};

If you want to learn about low-level hardware and what is actually happening behind the scenes, I strongly recommend Computer Systems a Programmers Perspective. It's a hard book, no doubt, but it will show you everything that happens that you don't see when you compile a program and then run it, including memory management, cache fetching, how hard drives store data, how processor pipelining works, all to the level of detail in my posts.