All The World’s A VAX
by Fang on May.15, 2010, under Blog
vaxocentrism
/vak”soh-sen”trizm/ [analogy with "ethnocentrism"] A notional disease said to afflict C programmers who persist in coding according to certain assumptions that are valid (especially under Unix) on VAXen but false elsewhere. Among these are:
1. The assumption that dereferencing a null pointer is safe because it is all bits 0, and location 0 is readable and 0.
Problem: this may instead cause an illegal-address trap on non-VAXen, and even on VAXen under OSes other than BSD Unix. Usually this is an implicit assumption of sloppy code (forgetting to check the pointer before using it), rather than deliberate exploitation of a misfeature.
2. The assumption that characters are signed.
3. The assumption that a pointer to any one type can freely be cast into a pointer to any other type. A stronger form of this is the assumption that all pointers are the same size and format, which means you don’t have to worry about getting the casts or types correct in calls. Problem: this fails on word-oriented machines or others with multiple pointer formats.
4. The assumption that the parameters of a routine are stored in memory, on a stack, contiguously, and in strictly ascending or descending order. Problem: this fails on many RISC architectures.
5. The assumption that pointer and integer types are the same size, and that pointers can be stuffed into integer variables (and vice-versa) and drawn back out without being truncated or mangled. Problem: this fails on segmented architectures or word-oriented machines with funny pointer formats.
6. The assumption that a data type of any size may begin at any byte address in memory (for example, that you can freely construct and dereference a pointer to a word- or greater-sized object at an odd char address). Problem: this fails on many (especially RISC) architectures better optimised for HLL execution speed, and can cause an illegal address fault or bus error.
7. The (related) assumption that there is no padding at the end of types and that in an array you can thus step right from the last byte of a previous component to the first byte of the next one. This is not only machine-but compiler-dependent.
8. The assumption that memory address space is globally flat and that the array reference “foo[-1]” is necessarily valid.
Problem: this fails at 0, or other places on segment-addressed machines like Intel chips (yes, segmentation is universally considered a brain-damaged way to design machines (see moby), but that is a separate issue).
9. The assumption that objects can be arbitrarily large with no special considerations. Problem: this fails on segmented architectures and under non-virtual-addressing environments.
10. The assumption that the stack can be as large as memory. Problem: this fails on segmented architectures or almost anything else without virtual addressing and a paged stack.
11. The assumption that bits and addressable units within an object are ordered in the same way and that this order is a constant of nature. Problem: this fails on big-endian machines.
12. The assumption that it is meaningful to compare pointers to different objects not located within the same array, or to objects of different types. Problem: the former fails on segmented architectures, the latter on word-oriented machines or others with multiple pointer formats.
13. The assumption that an “int” is 32 bits, or (nearly equivalently) the assumption that “sizeof(int) == sizeof(long)”. Problem: this fails on PDP-11s, Intel 80286-based systems and even on Intel 80386 and Motorola 68000 systems under some compilers.
14. The assumption that “argv[]” is writable. Problem: this fails in many embedded-systems C environments and even under a few flavours of Unix.
Note that a programmer can validly be accused of vaxocentrism even if he or she has never seen a VAX. Some of these assumptions (especially 2–5) were valid on the PDP-11, the original C machine, and became endemic years before the VAX. The terms “vaxocentricity” and “all-the-world”s-a-VAX syndrome’ have been used synonymously.
The Ten Commandments for C Programmers by Henry Spencer
by Fang on May.15, 2010, under Blog
1 Thou shalt run lint frequently and study its pronouncements with care, for verily its perception and judgement oft exceed thine.
2 Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end.
3 Thou shalt cast all function arguments to the expected type if they are not of that type already, even when thou art convinced that this is unnecessary, lest they take cruel vengeance upon thee when thou least expect it.
4 If thy header files fail to declare the return types of thy library functions, thou shalt declare them thyself with the most meticulous care, lest grievous harm befall thy program.
5 Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest “foo” someone someday shall type “supercalifragilisticexpialidocious”.
6 If a function be advertised to return an error code in the event of difficulties, thou shalt check for that code, yea, even though the checks triple the size of thy code and produce aches in thy typing fingers, for if thou thinkest “it cannot happen to me”, the gods shall surely punish thee for thy arrogance.
7 Thou shalt study thy libraries and strive not to reinvent them without cause, that thy code may be short and readable and thy days pleasant and productive.
8 Thou shalt make thy program’s purpose and structure clear to thy fellow man by using the One True Brace Style, even if thou likest it not, for thy creativity is better used in solving problems than in creating beautiful new impediments to understanding.
9 Thy external identifiers shall be unique in the first six characters, though this harsh discipline be irksome and the years of its necessity stretch before thee seemingly without end, lest thou tear thy hair out and go mad on that fateful day when thou desirest to make thy program run on an old system.
10 Thou shalt foreswear, renounce, and abjure the vile heresy which claimeth that “All the world’s a VAX”, and have no commerce with the benighted heathens who cling to this barbarous belief, that the days of thy program may be long even though the days of thy current machine be short.
5 tunes that you have probably not heard before until now!
by Fang on Mar.28, 2010, under Blog
5. Dinka – Elements (EDX’s 5un5hine Remix)
The unmistakable style of EDX mixed into Dinka’s elements with dashes of vocals here and there. Definitely worth a listen if you are a fan of EDX.
4. Sergey Tkachev – Alien & Butterfly (Solid Sky Remix)
From the anjunadeep label, nice bass line, uplifting at times. Can’t go wrong with the guys over at anjuna.
3. Stefano Noferini – Burujava (Original Vibes Mix)
Powerful bass. Tribal vibe. This is going to sound absolutely rocking on a huge sound system.
2. Vitalic – Second Lives (The Bloody Beetroots Remix)
No idea why this is filed under Indie Dance. Is Indie Dance even a genre to begin with? An excellent electro house track none the less.
1. Way Out West – The Gift (Gui Boratto Remix)
Way Out West’s classic The Gift remixed by Gui Boratto. Pure genius.