Any ideas for a new language inspired to Python?

Marco Sulla Marco.Sulla.Python at gmail.com
Sun Aug 9 12:44:20 EDT 2020


On Sun, 9 Aug 2020 at 10:31, Barry Scott <barry at barrys-emacs.org> wrote:
> By going to C you are really saying you want to use the native instructions of your CPU.
> Contrast that with bytecode that needs an interpreter.

This is also an answer for Grant Edwards: the idea was to generate
bytecode and compile it to machine code. See gcj, for example, that
translates the Java bytecode into machine code.
Even if it's not needed by the "mainstream" implementation, it could
be good if someone wants to implement its own interpreter.

Currently I don't care if this will slow down the compilation: things
can be accelerated or removed. My doubt is if the initial work is too
much and if I can, eventually, add this extra step later without many
troubles.

On Sun, 9 Aug 2020 at 10:31, Barry Scott <barry at barrys-emacs.org> wrote:
> Have a look at http://www.nuitka.net/ that compiles python into C.
> It can also spot optimisations that help, for example noticing that
> code is doing int math and write that as C avoiding the python objects.

This is another big problem: everything is an object?
It seems that in practice, using integers and floats as objects leads
to great slowdowns. And personally I never saw people that created
superclasses of int or float. Anyway, if they feel the urgence, they
can use `numbers` ABCs. It seems to me that the Java separation
between primitive types vs objects is quite practical.

On Sun, 9 Aug 2020 at 10:31, Barry Scott <barry at barrys-emacs.org> wrote:
> You need a compiler person to explain better than I can.
> But the steps that you need are:
> 1. Parse the source into an intermediate form (AST for example)
> 2. Check that the code is valid
> 3. Compile into runnable code

I know this is not trivial... I read also about lexers and parsers.
For example, it seems that Guido now uses a new parser, a PEG parser.
Don't know if it uses a lexer or not and why. And it seems they exist
generators of lexers and parsers. The more simple to use seems to be
ANTLR: https://github.com/antlr/antlr4 but it does not generate a PEG
parser.

Do you think py devs will be greatly bored if I link this discussion
in the python-dev mailing list?


More information about the Python-list mailing list