4 ms·
I don't think anyone really disagrees with you -- most people have problems with the syntax of Perl, C, and C++. Sure, they can get used to it, particularly wi
by chubot 9y ago
I don't think anyone really disagrees with you -- most people have problems with the syntax of Perl, C, and C++. Sure, they can get used to it, particularly with C because it's small, but the syntax isn't why they use the language.
Somewhat surprisingly, I think Perl's syntax is one of the reasons that Python became popular. Perl can do pretty much everything Python can, and it came significantly earlier. Yet people gravitated toward Python.
I wouldn't call Python "strongly restrictive", but I would call it "just right". It's terse without being unreadable.
JavaScript syntax is also pretty sane (but there are many horrible parts to the semantics.)
Ruby seems to be pretty nice in the common cases, but there are apparently gremlins lurking in corner cases. Python has only 1 or 2 syntactic gremlins I can think of (trailing comma, etc.)
- kibwen 9y ago> Perl can do pretty much everything Python can, and it came significantly earlier. Yet people gravitated toward Python. I don't think syntax is the main culprit here, and Perl is only four years older than Python. For about 15 years Python tried, unsuccessfully, to compete with Perl as the premier language for shell scripting and sysadmin tasks. It wasn't until around 2005 that Python finally caught on, its rise coinciding with Ruby. While I do personally find Python more readable than Perl, I attribute its ascent more to the combination of the Web 2.0 gold rush demanding dynamically-typed languages for quick prototyping, Perl's apparent mid-2000s limbo due to Perl 5 vs Perl 6, the then-declining reputation of PHP and the shared hosting services which first popularized it, and the quality of Python's standard library (which made up for CPAN).
- wainstead 9y agoI have long thought Perl can do anything Python can, and then some. I still use Perl one-liners to find/change strings in code bases: perl -pi -e 's/somestring/newstring/g' $(ag -l --python Foo) Does Python have an equivalent? I think the fabulous Python libraries for data science have really propelled the language to the top of the list, in terms of users.
- kibwen 9y agoAgreed that Python still isn't as good at Perl at command-line scripting (which isn't a denigration; Python is good at it, but Perl was born for it). Also agreed that Python's current trajectory is buoyed by data science (compare Ruby, whose ascent via the web went hand-in-hand with Python, but which never took off for other domains and faded as new languages entered the web space). But that's a separate phenomenon, and probably has even less to do with comparisons between Python's and Perl's syntax (for years the data science crowd has been demanding more syntax from Python, e.g. a dedicated operator for matrix multiplication).
- emodendroket 9y ago> I have long thought Perl can do anything Python can I mean, yes, they're both Turing-complete languages, so one can be used to do anything the other can. I guess the actual question is whether it makes those things easier to do, and I think the same properties that make Perl great for one-liners make it harder for long-lived, large projects.
- richardwhiuk 9y agoYou could have just used sed for that?
- throwaway7645 9y agoSo Perl was built because Sed/Awk had "whipupitude", but fell short of being a real application language like C which was great and fast to run, but slow to develop in. Perl was the middle ground which took the power of Sed/Awk/Bash and made it faster and more respectable and added a huge module repository. Of course take this with a grain of salt.
- gh02t 9y agoCPython doesn't really have a "stream mode" like `perl -pi`, but you could easily make a pretty trivial wrapper to do it if you found yourself wanting to duplicate that functionality. I'd much rather use sed or awk in your specific case and similar, but to each his own.
- rodgerd 9y ago> I don't think syntax is the main culprit here, It's more culture than syntax; Python culture tends to favour adhering to a common style, while Perl culture tends to valorise clever or even poetic implementation.
- crzwdjk 9y agoI think the main culprit was Perl's mess of an OO system. While technically it was the same at its core as the Python one, the almost complete lack of syntax to support OO and lack of standards (especially in those earlier days) for objects to interoperate made it needlessly complicated for most people and people moved to languages where they could just write "class Foo".
- gaius 9y agoThe "killer app" for Python was NumPy. Ruby and Perl have nothing even close.
- emodendroket 9y ago> Somewhat surprisingly, I think Perl's syntax is one of the reasons that Python became popular. Perl can do pretty much everything Python can, and it came significantly earlier. Yet people gravitated toward Python. Surely the ugliness of OO Perl and having to deal with references/dereferences/data structure flattening by default is the biggest reason. Otherwise, why would Ruby have become popular around the same time despite not necessarily being very readable? e: Also the Perl 6 debacle like the other guy said.