Compiler - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Compiler (/thread-29165.html) |
Compiler - wallgraffiti - Aug-20-2020 So. Say I'm making a compiled language in Python (compiled because it makes up for the slowness of an interpreted language like Python). How would I go about generating machine/bytecode that does what I want it to? Do I, myself, need to have a thorough understanding of machine/bytecode first? RE: Compiler - Larz60+ - Aug-20-2020 suggest you read: https://docs.python.org/3/distutils/builtdist.html RE: Compiler - jefsummers - Aug-20-2020 Before reinventing the wheel, look at: Jython - Python in Java bytecode Cython - C extension to Python to speed things up Pypy - a just-in-time compiler Now, writing a compiler in Python. Yes, you do need to begin with the end in mind, therefore you need to have an understanding of the machine code for the platform, or bytecode for a bytecode machine (like Java). Then, you need to understand the basics of compiler theory and design. This typically is a lexer, parser, optimizer, and code generator. None of these tasks is trivial.That you ask suggests you are not ready - no offense, but writing a compiler is a really big deal. RE: Compiler - Gribouillis - Aug-21-2020 Hundreds of excellent compiled languages already exist. Why not use one of them? Don't write your own language if you can't answer this question. Also remember that an essential part of a language's power come from a large collection of libraries. Suppose that you want to use regexes in your language, or sockets or databases, will you have to write all these libraries from scratch? |