open, close, dup, dup2, lseek, read, write, fileno, etc.

Steven Schveighoffer schveiguy at yahoo.com
Mon Feb 11 10:14:32 PST 2008


"David Wilson"wrote
> On 2/9/08, Bruce Adams wrote:
>
>> Unfortunately this is so. A long time ago the POSIX standard was invented
>> (or rather brought together from some early Unixes) and though low-level
>> (not OO for a start) it is solid and reliable.
>> The idea being if you want to write portable code you write it using only
>> POSIX
>> functionality.
>> M$ in their finite wisdom chose to tear up the standard and invent their
>> own
>> and then pretend they supported it. The result is it is practically
>> impossible
>> to write portable code without having another wrapper layer inbetween.
>
> ANSI C (including the standard library) wasn't standardised until
> 1990. The first versions of MS-DOS appeared in 1982. POSIX didn't
> appear until 1988. Which standard are you referring to, or is this
> just more of the same uninformed Microsoft bashing?

According to Wikipedia, Windows NT was released in 1993, which is the first 
OS (I believe) that contained CreateFile, etc.  Those functions were 
different from DOS which had no names for the functions, just interrupts 
(there was a DOS3Call in windows 3.x which wrapped the interrupt call).

It would have been very easy for Microsoft to implement unix-like system 
calls in NT instead of what they have, but I believe they did so either 
because they did not want to restrict themselves to a standard API out of 
their control, or they just didn't consider it at the time.  It could be 
'not invented here' syndrome.  CreateFile and friends have a lot more 
arguments and flexibility than the POSIX counter parts.

These are just choices that a company made at the time.  Were they right or 
wrong?  I'd say they were both right and wrong.  But you can't change it now 
:)

And I don't think there is any problem with using POSIX functions on 
Windows, it isn't any different than using D classes that wrap those 
functions.  I don't think there is any purposefully bad implementation in 
the unix-like calls, what makes D or phobos so much better in their wrapper 
implementation that one should prefer the D wrapper over the C call?  The 
logical choice if you want to use D is to use the D wrappers as they fit 
with the rest of the standard library, but if you want to use the C calls, 
there really should be no significant performance hit IMO.

-Steve 





More information about the Digitalmars-d mailing list