Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am a 10 year PHP developer. Just recently I have taken a little bit of an interests in C# after seeing that you can build native Windows desktop programs as well as build sites like Stackoverflow. It's like the best of both worlds.

Now recently I started using a text editor many know of called SublimeText which is coded with C++ and has Python embedded so that the users can create almost anything in Python and use it as a plugin for this text editor, I never seen anything like that. This got me looking into Python, as I had always thought Python was just like another language similar to PHP ( a scripting language mainly for the web) but now I am seeing that you can create Desktop programs that work on any OS, make web apps like you can in PHP so it's almost like what you can do with C# but with the added benefit of being multi-platform

Now this is no way a One Language vs Another Language debate, I am simply trying to find out more about how these foreign languages to me compare:

  • PHP is scripting
  • Python I think is scripting
  • C# has to be compiled?

Python can be used to build anything C# can? Including fast desktop applicaions, can Python application be compiled into an EXE file or how does that work to use Python program on Windows?

Please help me understand I have been stuck in the PHP world for a long time I have never ventured out past Javascript, PHP web stuff

Also I am aware that PHP can be used to make GUIs but from what I have read, they are not that good or it is not that good for doing them, something like that.

share|improve this question

closed as not a real question by gnat, Glenn Nelson, Dynamic, Robert Harvey, psr Dec 21 '12 at 0:40

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

3  
Anything that is a script language can end up as a compiled language. The distinction is blurred at best. –  Oded Dec 18 '11 at 20:01
    
With PHP Desktop you could write your gui using PHP+HTML5+JS. –  Czarek Tomczak Jan 13 '13 at 4:16
add comment

4 Answers

up vote 9 down vote accepted

Compiled/interpreted is hardly a meaningful distinction nowadays; IDE's such as Eclipse completely hide away the compile step, interpreted languages are sometimes compiled transparently to improve performance. The really interesting metric is "how much time I need to start my program while developing", really. With today's processors, even compiled heavyweight Java + Tomcat starts in my box in less than two seconds, which hardly bothers me.

Again, most languages are Turing complete, meaning they are all "equivalent" wrt. to the capabilities of the programs you can make with them. What matters normally is:

  • Bindings/ability to use the libraries/framework you need. If you are developing a GUI app, you will need to be able to use a GUI library from the language you want. There are loads of GUI libraries (GTK, QT, the couple of Windows frameworks, Cocoa for OS X, etc.)- some are a platform's native GUI library, some are multiplatform- and they all support different sets of languages (and within that, there are often first-class citizens; Objective C is Cocoa's first-class citizen, for instance)
  • General language quality and suitability to the task at hand

The latter is more complicated, and fairly subjective.

I would say that PHP is ill-suited to GUI app development- the main GUI binding I know is PHP-GTK and it seems to be pretty much inactive. Also, PHP's programming model is fairly tied to the request-response/HTML generating nature of web applications, which doesn't really fit nicely with GUI development.

Python is generally OK to develop GUI apps. Bindings exist for a variety of toolkits, and while Python isn't a particularly fast language, that hardly matters for most desktop apps- unless your application does something particularly CPU-intensive, you're not gonna notice any performance difference between any languages.

In general, GUI applications are more chosen by your target platform. If you target a single platform, often the least-effort/best-results approach is choosing the first-class citizen in that platform. If you are coding an OS X app, Objective-C + Cocoa is probably the way to go. If you develop a Gnome/Linux app, GTK + (Python|Vala|C) are probably the best options, likewise C++/QT for KDE, and C# + one of the official Windows toolkits (I've lost track now). Funnily enough, the "official way" is muddled- what you want here is something with plenty of documentation and maintained by the same people who develop the platform- languages/bindings by third-parties often lag behind or miss features.

But if you can choose the native "first-class" toolkit/language combination, you'll normally be able to deliver an application which looks and behaves like the rest of applications in the platform and which provides the most natural experience.

If you want to develop cross-platform apps, it gets slightly more complicated. There exist cross-platform toolkits- GTK, QT, Java's Swing and SWT, etc.- but you must realize that often they do not provide as good an experience as native toolkits- maybe the widgets do not look like the native widgets, or stuff like that, but even the best cross-platform toolkit cannot fix that different platforms have different conventions (standard shortcuts, menu arrangement and naming, dialogs, etc.)- think of iTunes on Windows- it looks and behaves definitely foreign and different to regular Windows applications, although it looks perfectly at home at OS X: same application, different platforms; means no native experience.

You might be OK with this- or even you want one of those custom-looking applications which look like no regular apps.

If you aren't, prepare for a road of pain. Probably the best solution is to develop separate applications for each platform you target, and if you are lucky, you might be able to reuse a good chunk of code from platform to platform (particularly, if you can use a common language- for instance you might develop your core app in Python and develop several GUIs for different platforms using different toolkit bindings- if you are lucky and they exist). Another way would be to use a multiplatform toolkit and work hard to adapt your program to the different platforms you target, but that might be a lot of effort or maybe even outright impossible to achieve completely.

share|improve this answer
    
Thanks for the response, you helped put a different perspective of it all as I had always thought that the main Windows programs were just pure C++ code and more recent code like C#, I never thought of it as all just programming languages and the GUI side was just a GUI library for that language, that makes sense though so i'm glad you clarified that for me. So for example in MSVisualC# when working with C# you can create a Winforms project, is Winforms basicly the GUI library, because you can also choose other things like WPF or Console app. Also above when you mentioned...continue –  jasondavis Dec 18 '11 at 21:03
    
... "Python is generally OK to develop GUI apps." Does that mean Python was originally built for other purposes? I have a lot to think about now, I really like how Sublimetext has embedded Python into it's C++ code, that is powerful. 1 last question you might know the answer to, If a desktop application is built with Python and some GUI library for a windows app, does the use need to install Python for the app to work? Thanks for your help really awesome of you –  jasondavis Dec 18 '11 at 21:06
    
I really don't know what purpose Guido had in mind while designing Python, but other than JavaFX, I can't think of many languages designed for GUI work. I'd say Python is a dynamic-typed general purpose language. Concerning your other question, there is software out there which let you bundle Python apps so that they can run without Python installed (probably by bundling a Python runtime). –  alex Dec 18 '11 at 22:35
    
Well, as a historical note, it was originally conceived as a successor to the ABC language. But that doesn't matter, it's a general purpose language, not geared towards a specific purpose, and with more than enough support mechanisms for every common purpose (including GUI apps). +1, good answer. –  Yannis Rizos Dec 18 '11 at 23:46
    
Very comprehensive answer, thanks! –  cori Dec 19 '11 at 16:22
show 2 more comments

C# compiles on linux as well using the mono framework. However, it is not as robust or feature-rich as .NET.

Also, you should know that languages like C# and Java use a runtime. They are first compiled (to Microsoft Intermediate Language in case of C# and Bytecode in the case of Java). These compiled programmes are essentially platform independent, and is interpreted by platform dependant interpreters (.NET runtime or JVM).

Hence, if you are looking at speed, languages usually compiled to binary such as c is faster than intermediate languages like C# and Java which are faster than completely interpreted languages.

As for python, you should check out IronPython, which takes advantage of the .NET framework.

share|improve this answer
add comment

Python I think is scripting

I don't even think in terms of "scripting". Python is a programming language. As was mentioned, all Turing complete programming languages can in theory do anything any other one can. Python can be used to control devices (including tiny ones), run web sites, create desktop applications, etc.

Python can be used to build anything C# can? Including fast desktop applications,

Yes. But compiled languages like C# produce faster executables than interpreted languages like Python (or Ruby). But as was pointed out, the speed differences are often negligible with today's fast processors. If you have a CPU-intensive part of your application, you can write just that part in C/C++ to speed it up. (By the way, there are some attempts to make Python comparably fast as C++...like Shed Skin, PyPy, etc.)

can Python application be compiled into an EXE file or how does that work to use Python program on Windows?

It can be "bundled" into an .exe file using py2exe, but it still isn't compiled. What py2exe does is bundle up everything one needs to run your app in Python, which would include the Python interpreter, the GUI toolkit, and whatever other 3rd party libraries you use, all stored as a single file called YourAwesomeApp.exe (or whatever you name it). I think the desired effect--to distribute your desktop app easily to those who want it and don't have all the dependencies, including Python--works fine.

share|improve this answer
add comment

I can tell you, Python is a nice place to be right now, you can play with both worlds, desktop and web (big options for the web, django and flask are both worth looking), and PLUS is awesome for command line scripts and all the admin related stuff.

PHP is not a bad thing if you use it correctly (a good framework), but I find that using it outside web is like a fish in a desert. Try PyQt, PySide or WxWidgets (the gtk bindings are not so cool IMHO).

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.