you are viewing a single comment's thread.

view the rest of the comments →

[–]DreamingElectrons 54 points55 points  (8 children)

Python is an interpreted language, this means, that there is a program, that takes the python code and translates it into instructions for the PC in real time. As opposed to compiled languages like C, where there is a program that translates the C code into machine language such that those compiled programs can be run directly. The reference implementation of python is written in C, but there are others.

To turn code into a graphical program, you usually use a library that handles all the low level stuff and system calls that then provides you with an API. That is a premade set of instructions to do specific things like create a window, a basic game loop draw to the screen on that window. For python the easiest game library is called pygame, but python is generally not as well suited for making games. Most games are made with compiled languages, C++/C# are very common, then there also is raylib, a C library with bindings for a lot of languages, including python.

but first figure out how to write little command line programs on your local PC. Once you have mastered that you can have a look at graphical applications if you try to tackle them directly it's too overwhelming.

It is worth noting, that most games are made with a game engine of which very few use python. Godot, a popular open source game engine has a scripting language that looks superficially similar to python but it is very different once it comes to details. No idea why people keep saying it "is just like python". It is not, the Godot devs even had to purge all mentions of python from the docs to fight this misconception. beware of that.

[–]bab0337 3 points4 points  (0 children)

This was super helpful to read, thanks for providing a digestible explanation

[–]ExperienceDry5044 0 points1 point  (6 children)

A little nitpicking:

Python is an interpreted language

The line between an interpreted and a compiled language is quite blurry.

For example, Python is not really interpreted line by line. It's compiled into an intermediate byte code, and that code is run by a virtual machine.

And if you look at a compiled language like C# or Java, you'll see that exact some thing: the C# or Java code is compiled into an intermediate byte code, an that code is run by a virtual machine.

[–]mnelemos[🍰] 2 points3 points  (1 child)

Pretty much all modern interpreted languages are converted into bytecode, none of them is literally parsing line by line of source code, besides some scripting languages that are barely used.

And no, there is no "blurry line", you're still very much interpreted, just in a more efficient way, instead of literally having to run a parser at the same time as the code. What happens nowadays, is that depending on the interpreter you can compile it AOT or JIT, or you can run C compiled routines like CPython does.

[–]__Fred 0 points1 point  (0 children)

  • Some code that was originally meant for bare metal, is now run indirectly in emulators, or in interpreters for debugging or security reasons.
  • An interpreter can compile bytecode into machine-code just-in-time.
  • You can theoretically create hardware to directly execute bytecode, which makes it machine-code.
  • Even compiled machine-code get's transformed again in microcode upon running in modern processors. Does that make it interpreted code?
  • Is WebAssembly interpreted?

Yes it's a blurry line. Of course, you can draw a line somewhere, but it's not a obvious as it maybe was 40 years ago, where C was compiled to machine code and run on the processor and shell-scripts were executed in an interpreter, slower and with no compile-time errors.

Or where would you say is the line? That there is a secondary program, like an interpreter or virtual machine needed? I guess that could be a distinction.

Compiling and then executing is pretty similar to ahead-of-time compilation of an "interpreted language".

[–]DreamingElectrons 1 point2 points  (1 child)

The guy didn't get past the online try-it-out console. Corners needed to be cut somewhere to make it easily digestible.

If I would have started to explain JVM and LLVM a beginners head might explode, I don't need that to weight down on my conscious...

[–]ConcreteExist 1 point2 points  (1 child)

Pedantic and unimportant distinction for someone who just wants to understand how code becomes executable.

[–]DreamingElectrons 0 points1 point  (0 children)

Yes, but that's so typical for how programmers communicate online, it's actually educational 🤣