Any ideas for a new language inspired to Python?

Barry Scott barry at barrys-emacs.org
Sun Aug 9 04:31:04 EDT 2020



> On 8 Aug 2020, at 18:18, Marco Sulla <Marco.Sulla.Python at gmail.com> wrote:
> 
> On Sat, 8 Aug 2020 at 14:10, Barry <barry at barrys-emacs.org> wrote:
>>>> On 7 Aug 2020, at 23:28, Marco Sulla <Marco.Sulla.Python at gmail.com> wrote:
>>> My idea seems to be very simple (so probably it's not simple at all):
>>> a language similar to Python, but statically compiled.
>> 
>> Have a look at Apple’s Swift. It reminds me of python as I read it.
> 
> Thank you, some features are interesting, even if I prefer the Python syntax.
> 
> What about the compiler? Is it better to "compile" to C or to
> bytecode?

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.

> How can I generate a bytecode that can be compileed by gcc?

Have a look at http://www.nuitka.net/ <http://www.nuitka.net/> that compiles python into C.
One part of its speed up is that the bytecode evel code is not needed.
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.

> Can I skip the AST generation for now, or it will be a great problem
> later?

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

Barry


More information about the Python-list mailing list