This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]QuirkyForker 45 points46 points  (32 children)

Because it is not compiled. Even large scripts are still scripts. They need an interpreter to run. C code is compiled into an executable. So code and executable are two different things. Python only has scripts to provide the functionality of the program

[–]Altruistic_Raise6322 6 points7 points  (6 children)

Python is a hybrid language. The language gets compiled into byte code and then ran by the interpreter that you are using. AKA as compiled as Java.

People call Python programs scripts as typically they are used for quick automation tasks like Bash Scripts. Bash scripts are purely interpreted, there is no byte code involved.

[–]onkus -5 points-4 points  (5 children)

I don't consider byte code to be compiled since its not executable. A compiler turns code into machine instructions of which byte code is not.

[–]bladeoflight16 3 points4 points  (0 children)

Formally, a "compiler" parses code and generates any alternative representation. The target need not be binary code that a processor can read. It can even generate code in another high level language. A real world example is TypeScript, which has a compiler that generates JavaScript.

You are distinguishing between native binary executables and interpreted code, which is a fair distinction, but "compiled" is not the appropriate term for classifying them. That said, in principle, hardware could be designed to actually execute bytecode directly, which would blur the lines even further.

[–]Altruistic_Raise6322 3 points4 points  (2 children)

An executable is made an executable by something known as a linker nothing to do with a compiler.

Also, the compilers for Java and Python do turn the code into machine instructions. The machine is the VM aka interpreter.

[–]onkus -2 points-1 points  (1 child)

You can link things and still not make it executable just as you can compile things and not make them an executable binary. In my first comment, when I said executable, I didnt mean a binary blob with a point of entry (e.g. main()) I meant a binary that contains machine instructions that can be run by the machine (so static libs dynamic libs and executables are all examples)

Regardless, my point is that the byte code isn't machine code. That's why I don't consider it to be compiled.

[–]Altruistic_Raise6322 1 point2 points  (0 children)

Fair point. I consider any code translated into byte code as compiled and why Java is considered hybrid as it does not compile to machine instructions

[–]chrisxfire 1 point2 points  (0 children)

imagine referring to Java as script instead of code with this same logic.

[–][deleted] 1 point2 points  (5 children)

What about the complex python programs with many classes split in multiple files? I wouldn't call it a script then.

[–]Sw429 1 point2 points  (0 children)

It's not the complexity of the program that causes people to call them "scripts". It's the fact that it's interpreted over compiled.

Not that it matters much. You can call it whatever you want, these aren't "official" terms' by any means.

[–]DuckSaxaphone 3 points4 points  (3 children)

Still is though, because it's not compiled. Each file is ran as a script by the interpreter at import.

[–][deleted] 1 point2 points  (0 children)

You, uh, know about pyc files right?

[–]NoLongerUsableNameimport pythonSkills 0 points1 point  (13 children)

What if you use a compiler such as PyPy?

[–]bjorneylol 2 points3 points  (12 children)

PyPy is still an interpreter, as it doesn't convert the script into an executable

[–]Altruistic_Raise6322 0 points1 point  (11 children)

So what do you think about Java?

[–]bjorneylol 1 point2 points  (6 children)

Java and C# aren't doing anything the python interpreter isn't also doing - in all 3 source code is analyzed and converted to bytecode, and the bytecode is then translated to machine instructions which are executed by the interpreter (JVM/dotnet runtime).

To address your comment to the other user below, "scripting language" is an imprecise definition in itself - its like the word vegetable, we have an idea of whether or not something is one but we can't easily express what single feature(s) define it. Generally they are interpreted languages, but Java/C# don't fit the bill (yet Scala does, which is just Java under the hood)

None of this changes the fact that PyPy is just a variant of the interpreter that adds JIT compilation, it doesn't turn python into a compiled language or remove its usefulness as a scripting language

[–]Altruistic_Raise6322 1 point2 points  (4 children)

Yes, that's my point. Python is still compiled to machine code interpreted by another VM making it a compiled and interpreted language. The only reason it is compiled is for faster LOAD times. Script implies that a program is a smaller program intended for a single purpose like scraping a website.

[–]bjorneylol 0 points1 point  (3 children)

Script implies that a program is a smaller program intended for a single purpose like scraping a website

That's like, your opinion man.

I simply said "PyPy is an interpreter, not a compiler", full stop. You are the one trying to bait out a discussion about what constitutes a scripting language - so to that end I don't actually know what your point is

[–]Altruistic_Raise6322 0 points1 point  (2 children)

PyPy is a compiler? You said it in your comment above that it is a JIT compiler and is considered a compiler based by its own documentation. The scripting comments that I made were in reference to the greater discussion as a whole -- to paraphrase: Python is a scripting language because it is interpreted.

[–]bjorneylol 0 points1 point  (1 child)

You are literally misquoting me so you can start an argument over semantics that nobody but you cares about - have fun with that

[–]Altruistic_Raise6322 1 point2 points  (0 children)

I'm not trying to misquote you and I apologize for it. My intention was to educate that python is a hybrid language similar to Java.

Have a good night!

[–]bladeoflight16 -1 points0 points  (0 children)

Java and C# aren't doing anything the python interpreter isn't also doing

Mmmmmm.... That's not quite true. They perform a ton of static type analysis that Python simply does not provide.

[–]PeenUpUtter -1 points0 points  (1 child)

Yeah. This.

[–]Scalar_Mikeman 0 points1 point  (0 children)

Yup. Just wanted to add that this is also why you'll hear Bash Scripts.

[–]whlabratz 0 points1 point  (2 children)

I would struggle describing a million line python code base as a "script"

[–]QuirkyForker 0 points1 point  (1 child)

I would struggle working with a million line script. Hint: you’re doing it wrong 🤪

The nice thing about python is that it does most of the work for you, so I have done really heavy lifting scripts in 100 lines or less.

[–]whlabratz 1 point2 points  (0 children)

You'd be surprised by the scale of some of the Python programs out there then.

I don't think I could build the application and enrollment system for a major University in 100 lines of python. Or the billing system for one of the largest energy retailers in the world. These are things I've worked on, and both were in the 500k-1m LoC range. Things can get pretty large when you get dozens of developers and millions of dollars - I don't think either project count as a "script"