Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compiler
#1
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?
Reply
#2
suggest you read: https://docs.python.org/3/distutils/builtdist.html
Reply
#3
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.
Reply
#4
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  When does Python need to use a compiler? JanOlvegg 5 3,043 Mar-09-2023, 04:24 PM
Last Post: snippsat
  f2py: no Fortran compiler found FMJS 2 5,414 May-25-2020, 02:51 PM
Last Post: FMJS
  pip 2.7 problem with compiler aster 2 2,772 Dec-25-2019, 06:16 PM
Last Post: aster
  how do i make a compiler? lol 2 2,443 Nov-29-2018, 05:43 PM
Last Post: Larz60+
  Compiler fault or some kind of weird referencing bug? Joseph_f2 11 9,183 May-09-2017, 08:50 PM
Last Post: volcano63

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020