views:

588

answers:

7

Hi guys, I hope I'm not repeating questions here.

Beforehand, please no flamewar. My intention is to consult to someone that has been using python longer than me. I'm currently in the process of switching career into Python programmer.

After been doing research and Googling about Python from the internet, I can see that Python can do almost anything.

I know that we can do GUI programming with Python. And I know that there is a Python framework for making mobile application with Python for S60. I know Google and NASA is a heavy Python user. And of course there is alot of Python webframework available out there.

Now the big question: Is there anything that we can't programmed with Python?

Please forgive me for my lack of knowledge and thanks in advance for all of your advise.

+2  A: 

If you need to access system interfaces for which no Python module exists yet (such as a relational database with only a C API), you cannot directly use that in Python.

Of course, you can create a wrapper (in C) to make it available in Python.

Assuming you have interfaces to all hardware and functionality: yes, Python is turing-complete, so you can solve any problem in Python (assuming enough time and memory). Resource limitations may be a reason not to solve the problem in Python, though.

Martin v. Löwis
Being turing complete does not mean you can "do anything" with it. For example, try writing a video game on tape-based Turing machine.
anon
@Neil: that's why I said you need interfaces to all hardware and software components you want to use.
Martin v. Löwis
I think it might still be a little slow - paper tape tends to tear if you drive it faster than a few feet per second.
anon
Ah, so you are assuming that the tape is made of paper. That's old technology - today, we use Virtual Tape (tm).
Martin v. Löwis
Even using virtual tape, I doubt you could manage Space Invaders, even if the tape were virtualised on a super computer. And actually, I always liked paper tape - as an archive mediom it is certainly more reliable than floppy disks, and you can use the chads as confetti.
anon
+1  A: 

Python is Turing-complete. In other words, you can do anything in it that a computer could do. (oh, and obligatory xkcd reference)

Piskvor
+1  A: 

In the sense that Python is a Turing complete language, no, there's nothing that cannot be written in Python.

In the sense that some programs would be require extensive use of third-party tools, would be incredibly difficult to write, or would run unacceptably slow, yes, some things cannot or should not be written in Python.

Imagist
+27  A: 

Primarily, any kind of system programming won't be possible with python. Things like device drivers or operating systems. These people saying that python is turing complete therefore anything is possible are missing a rather important thing. Being turing complete means that you can compute every turing-computable function, not that you can do everything in the environment you're running in that's possible. You would have to have special runtime support for python built in to the system to allow that.

IRBMe
+1 for clearly stating what turing complete actually means
anon
I have seen several filesystem drivers, and at least one operating system in Python. And although I don't know if anyone has actually done that, I have a very clear idea on how one could write a device driver in Python. I mean, if it can be done in Lisp and Smalltalk, why wouldn't it work in Python?
Jörg W Mittag
Granted you could maybe write user-mode drivers (UMDF in Windows), but I doubt it's possible to write kernel-mode drivers in Python. How would you write interrupt handlers, access hardware using port IO, use things like DMA (direct memory access) and so on? At the very least, you would need a special Python compiler that can compile your python code to native code or a kernel-mode python interpreter (but that's covered under "special runtime support" in my answer).
IRBMe
There are also special assembly instructions that some platforms require to do things like switch processor modes, enable and disable interrupts, read and write from ports to access hardware, load and store descriptor tables and interrupt tables (in the case of x86) and more. So you would also need the ability to write inline assembly, or at least be able to compile your python files to object files that can be linked with those produced by your assembler. It's also possible, but can be extremely hairy, to lay out required processor structures (in x86 you have a GDT, IDT etc.) using Python.
IRBMe
+1  A: 

Time travel would be rather tricky ;-).

But I assume you mean with anything, anything that can be done with other computer languages.

Gamecat
+1  A: 

Prefixing that with the statement that "possible" is not at all the same as "useful", "easy", "simple" or "general good practice", I'd state, you can do a huge lot with Python.

And I'd even question Rich Seller saying systrem programming isn't possible with python. One possible meaning of "system programming" - system manegement tools and scripts for system administration are more and more written in python. And about the OS and driver thing - defintely, you'd choose C when you're about to write a Linux device driver. On the other hand, I don't think it's impossible to do that in Python - if you really want to for some reason (and may it be only to prove it's possible).

I'm more into java usually, and I know there even exists an (definitely experimental and not production ready) OS written in Java. I don't see why that shouldn't be possible in Python, too.

In the end, you always have machine code to be run on your CPU - be it an OS kernel, a web application or a shell script - and all environments produce this type of code sooner or later, more or less directly.

So, no, I don't think there are too many real limits - while there always might be reasons to choose another language for something - for technical or other reasons (you shouldn't expect a team of experienced Java developers write a sophisticated Python high performance application from one day to another).

For your career, I think it's good to concentrate on one language and get very good at it and know each and every tweak - but it's also considered good practice for developers to learn one new language per year.

Henning
Thanks for the advice :-)
jpartogi
A: 

there are very powerful general purpose programming frameworks like .NET/Mono, Java or Qt and they all have python bindings. that means that you can access from python all of the functionalities of the provided frameworks.

i personally recommend PyQt4 python bindings for Qt framework. it's GNU GPL, very powerful, crossplatform (windows, mac, linux/x11, embedded linux, windows ce and S60), the best what c++ can do. recently bought by nokia and chosen as their main development platform so it seems that if will be covered up with enough of resources in a long term. it is very well documented.

i really recommend the book "Rapid GUI Develompent with Python and Qt" by Mark Summerfield.

the links: http://www.riverbankcomputing.co.uk/software/pyqt/intro http://www.qtsoftware.com/ http://www.qtrac.eu/pyqtbook.html

marcell