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.

Perl and Python are often compared to each other (let's not forget Ruby), and almost always those discussions will come to the conclusion pretty much anything you can do in one or the other.

Without going into that, I've noticed that Python however, is often used as an implementation language (uhmm, maybe the term here is incorrect technically - a language you use to, for example, enable some degree of scripting in a large application ... Tecplot, Rhinoceros etc.; these are from the scientific area; there are others surely) and Perl never (well, to my knowledge at least).

So I was wondering - what makes Python more suitable for something like that? What particulars make a language more suitable to be implemented as part of a larger app. for scripting in general? Is it only that that wasn't so common 10 years ago (scripting in applications), and Python is just at its peak at the moment, ... or something else?

share|improve this question
1  
My experience (probably out-of-date, ~10 years ago) suggests embedding Perl is not that easy, some details can get pretty hairy. Maybe Python is better in that regard? –  StasM Dec 18 '10 at 1:18
    
@StasM - I hear you. But, Python was not really that popular 10 years ago, so that also should be taken into account (it came on my radar, some, maybe 5 years ago, tops). But anyways, I would be interested in the technical side of things also. –  Rook Dec 18 '10 at 1:45

4 Answers 4

Python is pretty easy to embed and has good documentation on how to do it.

Also, Python has a pretty approachable syntax, even for new users. Perl tends to have obtuse syntax making it less approachable for new users.

Another common language for embedding is Lua. It is known to be fairly easy to embed and has low operating overhead.

Python is well known and used in the Scientific community thanks to SciPy and NumPy, which may influence your particular observations.

share|improve this answer
    
Python sucks at multi-threading. –  Job Dec 18 '10 at 5:01
2  
@Job I'm not really sure how CPython's lack of true multithreading has anything to do with this answer... And I say CPython specifically because it's the only Python implementation with the GIL. Jython and IronPython both have true multithreading. –  jsternberg Dec 18 '10 at 5:47
3  
How does python suck at multi-threading? If you are building a CPU-bound application in python, then you are doing it wrong. Although Beazley did show a pathological case with mixed CPU-bound and IO-bound threads. (The Gil only exists in cpython, btw) –  rox0r Dec 18 '10 at 6:56

The term you are after is "embedded language" or to be more verbose, "application scripting language" -

JavaScript and Python seem to be some of the most common of these, mainly due to the fact that there is a lot of support for embedding them, and their syntax is considered by many as simple and easy to learn.

share|improve this answer
    
I couldn't remember the correct term. (Also, I wasn't sure if "embeeded" goes only for ... running on dedicated hardware, or does it apply to ... within software). –  Rook Dec 18 '10 at 12:22
    
I believe the term "extension language" is also used. –  Tom Zych Apr 4 '11 at 21:18

If you're talking specifically about application scripting, it may simply be that Python is more approachable than Perl to a casual programmer, and thus the developer of the application decides Python would be a better experience for the application's users. Lets face it, Perl, while powerful, can be... cryptic... at times.

VBScript is also used a lot in Windows applications for this reason. Its something end users, not programmers, can cobble a small script together in without too much trouble.

share|improve this answer
    
That is surely one of the important reasons. Do you think the decision was based mostly on the ease on newcomers? –  Rook Dec 18 '10 at 12:16

Python is easy to embed in C programs and it is easy to add C modules to python. Python has a lot of inroads in scientific computing with sci.py and numpy, so it is a natural fit for scientific apps.

share|improve this answer
    
Although true, I don't know how much that matters practically. Usually all such needs are covered by the language in which the app was written in originally, so pyth. is used solely for scripting (handling of data mostly). Very rarely users use it to handle computations. But yes, that is also one advantage. –  Rook Dec 18 '10 at 12:19
    
@rook - Sure, it is possible to do anything in an equivalent Turing language. Manipulating a subset of the application doesn't require the low-level features of C. And by choosing a higher level language for scripting, user scripts can be cross-platform and the user doesn't need to worry about memory management. –  rox0r Dec 20 '10 at 15:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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