What is the difference between a Library and a Language extension? Specifically in Scala.
What is the difference between a Library and a Language extension? Specifically in Scala.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is valid both for Scala and for Java, a library could be defined as:
It means that (I know, I simplify a lot) a library is a collection of routines you’ll use in your code to implement an algorithm. They save you to write the same code again and again (for example you do not need to reinvent the wheel every time you have to print a string to console).
A language extension is not code that you’ll call (or use) directly from your code but something that will change how you write your programs. It may change (and usually it does) the syntax of the language itself and often it’s a plug-in for the compiler. Many of the features added to the Java language are extension (generics, for example).
For example Session-Scala is an extensions made of both:
For an example take a look to this page.
That said, often with Scala a language extension isn’t really needed (even if it’s so easy to write, more than for .NET languages, for example) because of its syntax. First thing that comes to my mind are infix operators but in general all its syntax for methods invocation makes everything simple to use it as DSL without a DSL.