Need advice about which tool to choose?Ask the StackShare community!
Erlang vs Perl: What are the differences?
Introduction
Erlang and Perl are both popular programming languages, but they have distinct differences in terms of design philosophy, syntax, and purpose. This article will highlight the key differences between Erlang and Perl.
Concurrency and Parallelism: Erlang is designed for building highly concurrent and fault-tolerant systems, utilizing lightweight processes (also known as "actors") and message passing. It excels in handling massive concurrency and can handle millions of processes simultaneously. In contrast, Perl does not have built-in concurrency mechanisms like Erlang and is generally used for scripting and text processing tasks, where parallelism is not a primary concern.
Syntax and Expressiveness: Erlang has a unique, functional programming-based syntax that emphasizes pattern matching and immutability. It has a simple and consistent syntax, which makes it easy to learn and read. Perl, on the other hand, has a more traditional syntax influenced by C and other scripting languages. Perl's syntax allows for more flexibility and expressiveness, enabling developers to write concise, powerful scripts.
Regular Expressions: Perl is famous for its extensive support for regular expressions. It provides powerful built-in features for pattern matching and text manipulation, making it well-suited for tasks that involve complex string processing. While Erlang also supports regular expressions, it does not have the same level of built-in functionality as Perl.
Scalability: Erlang is known for its ability to scale horizontally, making it ideal for distributed systems and telecommunication applications. It provides built-in features for distribution and fault tolerance, such as automatic process migration and hot code reloading. Perl, on the other hand, is not specifically designed for massive scalability and may not be the best choice for building large-scale distributed systems.
Community and Libraries: Perl has a large and active community that has developed a vast array of libraries and modules. These libraries provide extensive functionality and cover a wide range of domains, making Perl a versatile language for various tasks. While Erlang also has a community and ecosystem of libraries, it may not have the same level of breadth and maturity as Perl's.
Industry Adoption: Perl has had a long history and is widely adopted in various domains, particularly in the field of system administration and web development. It has a significant codebase and is supported by a large number of developers. Erlang, on the other hand, has gained popularity in specific niches, such as the telecommunication industry and the development of highly available and fault-tolerant systems.
In summary, Erlang and Perl differ in their approach to concurrency, syntax, regular expression support, scalability, community and library ecosystems, and industry adoption. While Erlang excels in highly concurrent and fault-tolerant systems, Perl is renowned for its text processing capabilities and extensive community support.
I intend to use a programming language which I'll use as AWS runtime and write a script that will comb through tons of files in a directory and its subdirectories and search for simple text regular expressions and process and write the matches in a file as output. I have heard that Perl is good for regex based search but I also want the performance to be good as it will have to go through tons of files for IO. In this post: https://filia-aleks.medium.com/aws-lambda-battle-2021-performance-comparison-for-all-languages-c1b441005fd1, I see that Rust works well as AWS Lambda runtime with very good performance. Which one should I choose as my AWS lambda runtime for this problem? Golang is also an option as it is fast as per the above link.
I used to work in a Perl shop and must admit that the language is very simple for tasks like these, but as you mentioned it's not fast at execution time. I'm now a Go programmer professionally but I taught myself the language while in college purely out of interest and eventually found my way to the job, not the other way around. I've recently been learning a little rust because of how much that language comes up in conversations around Go. I find the concept of the borrow checker nice but I have to admit I feel lost like I am in most flavors of new fancy framework js. That's not to say Rust is really anything like js, but the learning appears the same to me as someone who's convinced they could learn just about any programming language if it was necessary (over time I've seen procedural, OOP, declarative and functional stuff but never programming logic outside of the prolog code I wrote in school).
Go isn't made for your specific task at hand but it's a very easy language to pick up and it has good directory traversal standard library code and good regex (even though with time perl's has been optimized to be faster and I think it's written in C++) but more than anything Go is "cloud native" programming in that an awful lot of new microservice tech stacks are centered around it, docker and kubernetes are written in it, and there's a thriving community whose focus is generally web-first and performance-oriented. This means for your use case there might already be a large cohort of gophers that have asked the stackoverflow questions for you
I personally would push you towards the NYT Profiler for Perl before I would towards Rest, but that's because I know you wouldn't waste any time being able to get to the task at hand and then make it go faster, and I expect all but a few rustaceans would be able to do so with the same speed.
Whatever you pick I wish you the very best of luck!
Pros of Erlang
- Real time, distributed applications62
- Concurrency Support62
- Fault tolerance58
- Soft real-time36
- Open source32
- Message passing22
- Functional programming22
- Immutable data16
- Works as expected14
- Facebook chat uses it at backend6
- Practical5
- Knowledgeable community5
- Bullets included4
- WhatsApp uses it at backend1
Pros of Perl
- Lots of libraries72
- Open source66
- Text processing61
- Powerful54
- Unix-style49
- Regex47
- Stable37
- Concise syntax32
- Hackerish29
- Easy to use22
- Swiss army chainsaw16
- Code Less Do More13
- CPAN12
- Freedom9
- All purpose8
- Readability5
- Familiar5
- Many ways to do it5
- Community5
- Object-Oriented4
- Modular4
- Smart (does alot for you)4
- Postmodern3
- It's the best one-off task language3
- For a man2
- Good man pages2
- Auto case variables1
- Single Source Library (CPAN)1
- Multi-threaded support1
- Multiparadigm1
- C-style1
- Hashes1
Sign up to add or upvote prosMake informed product decisions
Cons of Erlang
- Languange is not popular demand1
Cons of Perl
- Messy $/@/% syntax4
- No exception handling3
- Bad OO support2
- "1;"2
- No OS threads2
- Variables are global by default1
- Copy-on-create for interpreter-based threads1
- Barewords1
- Errors/warnings are ignored by default1