The Most Expensive One-byte Mistake

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

The Most Expensive One-byte Mistake

#1 Post by Flash »

http://queue.acm.org/detail.cfm?id=2010365
....The best candidate I have been able to come up with is the C/Unix/Posix use of NUL-terminated text strings. The choice was really simple: Should the C language represent strings as an address + length tuple or just as the address with a magic character (NUL) marking the end? This is a decision that the dynamic trio of Ken Thompson, Dennis Ritchie, and Brian Kernighan must have made one day in the early 1970s, and they had full freedom to choose either way. I have not found any record of the decision, which I admit is a weak point in its candidacy: I do not have proof that it was a conscious decision.

As far as I can determine from my research, however, the address + length format was preferred by the majority of programming languages at the time, whereas the address + magic_marker format was used mostly in assembly programs. As the C language was a development from assembly to a portable high-level language, I have a hard time believing that Ken, Dennis, and Brian gave it no thought at all.

Using an address + length format would cost one more byte of overhead than an address + magic_marker format, and their PDP computer had limited core memory. In other words, this could have been a perfectly typical and rational IT or CS decision, like the many similar decisions we all make every day; but this one had quite atypical economic consequences......

.......To a lot of people, C is a dead language, and ${lang} is the language of the future, for ever-changing transient values of ${lang}. The reality of the situation is that all other languages today directly or indirectly sit on top of the Posix API and the NUL-terminated string of C.

When your Java, Python, Ruby, or Haskell program opens a file, its runtime environment passes the filename as a NUL-terminated string to open(3), and when it resolves queue.acm.org to an IP number, it passes the host name as a NUL-terminated string to getaddrinfo(3). As long as you keep doing that, you retain all the advantages when running your programs on a PDP/11, and all of the disadvantages if you run them on anything else.

I could write a straw man API proposal here, suggest representations, operations, and error-handling strategies, and I am quite certain that it would be a perfectly good waste of a nice afternoon. Experience shows that such proposals go nowhere because backwards compatibility with the PDP/11 and the finite number of programs written are much more important than the ability to write the potentially infinite number of programs in the future in an efficient and secure way.

Thus, the costs of the Ken, Dennis, and Brian decision will keep accumulating, like the dust that over the centuries has almost buried the monuments of ancient Rome.

User avatar
Dave_G
Posts: 453
Joined: Thu 21 Jul 2011, 13:53

#2 Post by Dave_G »

And just think of how many nul bytes were used for your post about nul bytes :-)

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#3 Post by nooby »

Flash so that fact then open up the vulnerabilities that the other way would not do?
I use Google Search on Puppy Forum
not an ideal solution though

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#4 Post by sunburnt »

This is typical of the way things go in general...
The worst method is invariably the one that`s used, over and over.

Example:
The cost of roads in any country is enormous. Enough to bankrupt Rome.
After WWII most countries should have built a rail transit system, not roads.
If the nations of the world could cooperate... Build a "World Class" rail system.

But it`s this way because people who make the decisions want things this way.
It benefits them and they won`t allow it to be changed. Follow the money.!
Examine most any inequity at all, and you`ll find that someone`s profiting from it.

rokytnji
Posts: 2262
Joined: Tue 20 Jan 2009, 15:54

#5 Post by rokytnji »

After WWII most countries should have built a rail transit system, not roads.
Derailment of thread :wink:

Being a Biker. I am partial to roads. :)

LinuxFan2010
Posts: 15
Joined: Sat 28 Aug 2010, 14:37

#6 Post by LinuxFan2010 »

@sunburnt

A rail-road transit system spanning the whole of Europe would have lead to a monopoly, most likely. So what's the sense in that?

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#7 Post by seaside »

Maybe they should have considered the Null terminator issue in a more philosophical manner...

"Would you like to know ahead of time exactly when the end comes?"

-or-

"Would you rather just run into it unexpectly?"

Aren't Programs just standins for people...

Cheers,
s

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#8 Post by sunburnt »

Good points... With improvements must come changes to the way things are done.
A rail system would make commerce and product delivery "hands free".
Meaning that the semi truck drivers would all loose their jobs in a capitalist economy.
It doesn`t have to be that way, but we all know the reality of it is not good for average citizens.

Simply stated... In an advanced rational society the people are taken care of.
They`re not cogs in the industrialist`s machinery or lab rats to experiment on.
A few nations do a fairly good job of providing for the welfare of it`s people.
All the other nations of the world it`s easily said are run by self serving monsters.
NOTE: Elected officials are not[/n] the ones running the show, they`re puppets.

It`s not speculation, it`s not an opinion, it`s not propaganda, it`s the truth!

Post Reply