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
1  
Just to add to your knowledge: Perl is a cornerstone in the DNA sequencing community. See How Perl saved human genome –  mouviciel Dec 4 at 8:17
    
For history, I can tell you that (a) python 1.5.2 final was released in 1999 and (b) python 1.5.2 compatability was a big issue for a long time because 1.5.2 was used in a bunch of distro-internal stuff in Redhat for a long time. At least I saw a lot of second hand mentions of the latter a while back. .... For Perl, I have heard people compare it to line noise and call it a write only language, but I know it gets used a ton and I haven't gone there so hard to say. I do remember thinking it was like INFORM (interactive-fiction lang) which I also felt was line noise, at first glance >.>. (#TADS) –  StarWeaver Dec 4 at 8:39

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
3  
@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
6  
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 one of the following, they are (relatively fungible)

  • Embedded language
  • Application scripting language
  • Extension language

Lua, 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 quite easy to learn.

A few other notable examples of extension languages, Java, used in Eclipse and JetBrains IntelliJ based IDEs. VimL / VimScript in Vim. Emacs Lisp in GNU/Emacs. (GNU also promote Guile, a Scheme variant as it's extension language of choice.)

At the moment, it's hard to say which language is most commonly used as Extension language, but Lua is extraordinarily easy to embed, JS and Python are relatively difficult (by comparison) but still not especially hard. MRuby has been developed specifically to be embeddable, however it drops a large part of the standard library as a result.

Within the Microsoft ecosystem, (since the introduction of .Net) CLR languages are all able to extend popular MS apps, VS, MS Office etc.

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
1  
I believe the term "extension language" is also used. –  Tom Zych Apr 4 '11 at 21:18
    
Sorry @TomZych I should've upvoted and included this in the answer body long ago. –  Slomojo Dec 4 at 5:56

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.