On Sun, 27 Mar 2016 04:43 am, Rustom Mody wrote:

> On Saturday, March 26, 2016 at 4:09:41 PM UTC+5:30, Steven D'Aprano wrote:
>> On Sat, 26 Mar 2016 04:30 pm, Rustom Mody wrote:
>> 
>> > For one thing its good to remember that we wouldn't be here without
>> > python Python wouldn't be what it is without CPython
>> 
>> There is nothing about Python that relies on the C standard being as it
>> is.
> 
> Um lets see...
> There is this nice piece of OO called the exception hierarchy:
> https://docs.python.org/2/library/exceptions.html#exception-hierarchy
> 
> So we have
> BaseException ⊇ Exception ⊇ EnvironmentError ⊇ IOError
> At this point it would have been completely natural for IOError to
> continue subclassing to all the typical errors
> - File not found
> - No Space left on device
> etc etc

You cannot possibly be serious. Are you *really* trying to argue that it is
because of the C standard that the Python exception hierarchy isn't
sufficiently nuanced for your taste?

The air conditioner in my car struggles on hot days. The compressor of the
air condition was designed by an engineer using software running on a
computer running Windows. Windows is written in C or C++. Therefore the C
standard is responsible for my car being hot.

In any case, you might like to consider the Python 3 exception hierarchy
before trying to defend your proposition:

https://docs.python.org/3/library/exceptions.html#exception-hierarchy



> But instead we have an integer errno and we must inquire what that is to
> figure out what the exact IOError was
> Are you suggesting that python's errno module:
> https://docs.python.org/2/library/errno.html
> And C's http://man7.org/linux/man-pages/man3/errno.3.html
> are coincidentally related?

Of course it's not a coincidence. The documentation explicitly states that
the names and values of the constants are taken from the C header file
errno.h. So what? If I somehow convince Guido to add a list of standard Go
error codes into the standard library, does that mean that the Python
language is dependent on Go?


>> There are Python implementations that are not written in C or C++:
>> 
>> Jython (Java)
>> IronPython (C# for .Net or Mono)
>> CLPython (Lisp)
>> Berp (Haskell)
> 
> As best as I know
> - Java is written in C
> - Lisp is written in C
> - Haskell is written in C

To my knowledge, all four of Java, C#, Lisp and Haskell are self-hosted
languages. Even if a particular (say) Haskell compiler happens to have been
written in C, it could have been written using Rust, D, Ada, Forth, PL/I, 
Modula 2, Java, Pascal, assembly language, etc. without changing anything
about Haskell.

You could replace "C" with any systems language such as "Fortran", and the
Python language would be absolutely identical. You could even write the C
ABI using Fortran.

(CPython can call Fortran libraries even though it is written in C -- why
couldn't a Fortran implementation call C libraries? There's no reason it
couldn't -- Nim, for example, has a foreign function interface capable of
calling C code even though the compiler was written in Pascal.)

I'm not saying that the amount of effort required would be the same. I'm not
saying that there are no influences in the design and practice of the
Python interpreter due to C -- obviously that would be silly, Guido is a C
programmer, of course he has been influenced by C. But many of those
influences are "Don't do what C does!".

Clearly C is important in the real world, and for practical and historical
reasons Python was written in C. But those reasons aren't fundamental to
the Python language, in the way that compatibility with C is fundamental to
C++. If Donald Trump takes over the world and bans C, insisting that it be
replaced with a new language of his own design called "T", the
*implementation* of CPython would have to change, but the *interface*, the
language itself, won't have to change one iota.


> Notice a certain pattern?
> Yeah some of them may be self-hosting
> eg haskell (ghc) is written in ghc
> Where did the first bootstrap start from?

Where did the first C compiler start from?

C is not some magical language that exists at the very heart of all
programming. Programming existed before it, and even today there are
corners of the computing world which don't rely on C, not even indirectly.
The development of C started in 1969, and it is generally agreed to have
first been more-or-less complete in 1972. The famous K&R C book didn't come
out until 1978, and C wasn't standarized until 1989. There were many years
of high-level computing before C was even a concept in Dennis Richie's
mind. The first Fortran compiler wasn't written in C.

Due to the ubiquity of C in 2016, it may be *convenient* to write your first
compiler for a language in C, but it is not *necessary*. The first Nim
compiler was written in Pascal, and if Nim isn't self-hosting, that doesn't
mean it couldn't be.


[...]
> So... Ahem... C is unsafe... Right... Prefer C++ ??<wink>

No, of course not. C++ is exactly as unsafe as C, because it includes the
same concept of Undefined Behaviour (which, I stress, is not the same as
implementation-specific behaviour, or undocumented behaviour), and C++ is
(mostly) backwards compatible with C. If I were to get involved with modern
systems programming, I would start with D, or perhaps Rust.



-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to