Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Steve Thompson Newsgroups: comp.lang.c Subject: Re: Let's talk about UFOs then Date: Sat, 07 Mar 2015 18:22:08 +0000 Organization: Friends of the Galactic Collective Lines: 67 Message-ID: References: <87twxzpk1a.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: mx02.eternal-september.org; posting-host="dfca600df3027c25a5e3889f25105c66"; logging-data="30790"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/FW+HrQjLk+1GJUFX4I3XP" User-Agent: NN 6.4.3 Cancel-Lock: sha1:xuohQLJM9aOV6SjtyyMrLwITuio= Xref: csiph.com comp.lang.c:57973 On Thu, Mar 05, 2015 at 09:27:16PM -0600, Robert Wessel wrote: > On Thu, 05 Mar 2015 17:59:43 +0000, Steve Thompson > wrote: > > > >This is a little like speculating on the development of energy > >technology. Without contemporary politics and capitalism, would we > >have had a better chance of developing renewable energy resources such > >as solar or nuclear in preference to petroleum? Clearly the fact that > >oil is easy to extract from the ground is a major factor in its rise > >to prominence as a dominant energy resource. > > > Ease of extraction is one factor, but don't forget just how good > short/medium chain hydrocarbons are as an energy storage/transport > mechanism. They're energy dense in both mass and volume, easy to > handle, fairly non-toxic, and other than that pesky greenhouse gas, > reacting them results in fairly harmless byproducts (CO2 and water > vapor). If we didn't have a hydrocarbon based economy, we'd probably > invent them to just serve the transportation sector. Good point, but tangential to the thrust of my argument. In relation to C, my query was a little more prosaic. For instance, C is defined in such a way that the size of basic types is left implementation dependent. In a parallel reality the standardization process might have specified exact type sizes for basic types. We can enumerate a list of C characteristics and identify various places where compromises were made, perhaps mainly because of existing practice, such as in this example. So if our hypothetical aliens were developing a C language, what could we suggest about its characteristics? (Whether or not our aliens would have a stored program computer anything like what we use today is a different and vexing question.) For my part this question is interesting in the abstract since I disagree with certain aspects of C, much as I enjoy using it. So in my own code I define my own integer types such that I always know their range when I use them. You will be unsurprised to learn their names: s8, u8, s16, u16, s32, u32, s64, and u64. I have an architecture-dependent header file which defines these types for the target machine. (I understand that many implementations define int32_t and such, but it seems to be something of an afterthought and not so much a part of the early language specification.) Obviously this is hugely advantageous for real-world code since I know where I am at risk of overflow/underflow conditions. Standard C types make it difficult to have certainty on this matter, and porting code which uses normal 'int' types requires a detailed review to avoid the many problems associated with varying type sizes. I have no idea why this practice is not standardized, but there you are. I like to think that aliens would recognize the importance of establishing the range of variables in their code and the importance of avoiding breakage when code is used on different architectures. Regards, Steve Thompson -- GOTO's are like guns. Safety is entirely contingent on the user.