I mostly agree with you, but for fun I'll play Devil's Advocate. Explicit interfaces give a single place to look for an explicitly, formally specified contract, telling you what a type is supposed to do. This can be important when you're not the only developer on a project.
Furthermore, these explicit interfaces can be implemented more efficiently than duck typing. A virtual function call has barely more overhead than a normal function call, except that it can't be inlined. Duck typing has substantial overhead. C++-style structural typing (using templates) can generate huge amounts of object file bloat (since each instantiation is independent at the object file level) and doesn't work when you need polymorphism at runtime, not compile time.
Bottom line: I agree that Java-style inheritance and polymorphism can be a PITA and alternatives should be used more often, but it still has its advantages.
When I work with HTML, PHP, etc., I simply write code, put it inside .html or .php file and double click this file. Then my code runs.
But how does Python work?
Exactly the same way.
Double-click a .py
file and your code runs.
I'm working inside Eclipse or Python command line and I can run this code, but what if I want make website with Python for example?
You usually use Apache to host a web site. You usually use mod_wsgi
to run Python inside Apache. This is exactly like using mod_php
to run PHP inside Apache.
Exactly the same.
I don't think it's like I put .py file on my server,
False. You do put .py files on your server. How else could it possibly work?
so what I need to do? I understand I need to install Python on my webserver through some server command line (I've never used it, but I will find some tutorials day I will need it) but what's next?
You need mod_php
to run PHP. You need mod_wsgi
to run Python.
So if I made some website with Python, then my user will see my index.py file when he comes to my server?
You could do that. It would be fairly silly, however.
Usually, you set up mod_wsgi
so that it executes your .py file, and your .py file creates the HTML page.
This parallels the way mod_php
executes the .php file to create an HTML page.
Or can I use Python code inside html like with php wrapped inside <?php ?>
?
No. You put the HTML inside the Python.
Best Answer
Python is a great language, but Computer Graphics are heavy and need performance. Because of this, commonly people use C or C++ in games. At most, C# and Java. XNA, for example, is a framework for C# that allows the user to make 3D games, but internally it has a lot of code written in C++.
Python is reserved for scripts, but the core engines are commonly made in C or C++. Panda 3D, for example, allows you to make games in Python. But internally, it uses C++.
But you CAN make basic Computer Graphics with Python, if it's for learning purposes. There is a Python binding to OpenGL. If the book uses OpenGL for making the graphics, you can use Python without a lot of effort.
But I think it's worth to learn C or C++ and learn how computer graphics works, given everything I explained.