Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

scala vs perl (5 and 6)

by david2008 (Scribe)
on Jun 02, 2013 at 07:57 UTC ( #1036556=perlquestion: print w/ replies, xml ) Need Help??
david2008 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I wanted to hear what do you think about the scala language against the perl 5 and 6 languages.
I am reading a book about scala and it looks like a very strong language.
On the one hand it is static typed which enhances code stability and the code is more documented. On the other hand the type inference makes it possible not to write Boilerplate code.
Additionally the functional properties of the language makes it very similar to perl in term of expressiveness.

My question is where perl5/6 shines against scala.
Where are the strong points of perl / weak points of scala where perl wins?

Thanks,
David

Comment on scala vs perl (5 and 6)
Re: scala vs perl (5 and 6)
by Anonymous Monk on Jun 02, 2013 at 09:05 UTC

    I wanted to hear what do you think about the scala language against the perl 5 and 6 languages.

    I know perl 5 :) I think the other two are "languages"

    Bye

Re: scala vs perl (5 and 6)
by moritz (Cardinal) on Jun 02, 2013 at 10:16 UTC

    I haven't written any Scala code myself, so the following is only hearsay.

    Scala is supposed to be a rather nice language, and its features often appeal to Perl programmers. The downsides are usually cited as the following:

    • High startup time due to JVM usage
    • While nice functional features like iterators, map etc. are available, they often make code slower
    • Heavy reliance on Java libraries

    The last point needs a bit explaining. On the one hand it's nice to have access to the rich of java libraries. On the other hand, those libraries are designed for java, and the limitations that java has. For example Java doesn't you allow to pass callback functions (because it has no functions, and no references to methods), so whenever you need to pass a callback to a library, you have to implement an interface instead with a method that the library calls for you, which is much more boilerplate. Likewise container libraries written in Java are limited by Java's type erasure.

    That said, I would like to encourage you to simply try it out, and see if you like it. Programming languages very much cater to personal preferences, and while some are nearly universally hated (or do you know somebody who does COBOL for fun?), most have their loyal followers who are very productive with their language of choice.

    Knowing other programming languages typically also makes you a better Perl programmer.

      For an example (albeit on a much smaller scale) of this problem look at C# and the .Net framework. While the language supports generic types and lambdas for quite some time, there's still a helluvalot of APIs designed for the older versions. Whole frameworks with tens of custom collections each one slightly different and neither supporting type inference in enumeration and LINQ, APIs forcing you do implement over-complicated interfaces and wrapper classes where a simple lambda would do, APIs designed so that they in effect turn the whole type system off, because before the introduction of generics there was no other way, ...

      Some of those APIs are deprecated, some of them should be (eg. the whole of ASP.Net Web Forms and the insane mess that's LLBLBLBLBBLLBLLGen), some are still being used, all are painful.

      In either case if you feel like trying Scala, do.

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

Re: scala vs perl (5 and 6)
by Grimy (Pilgrim) on Jun 02, 2013 at 15:08 UTC

    Hi,

    I'm a huge fan of both Perl5 and Scala. They are both strong language that fill different niches. In my opinion—and I know many won't agree—, when building complex class hierarchies, static typing is a must have. Thus I only use Perl for simple tasks: command-line one-shots, file manipulation, an audio player… and keep Scala for more complex things.

    Scala is basically Java on steroids.
    • Since both compile to the same .class, they are entirely interoperable (Java code calling Scala functions sometimes requires boilerplate, but the other way round is trivial). This is a huge advantage, considering the vast amount of Java library available.
    • Scala's syntax is great and flexible. You can define your own operators; define objects that can be called as functions (this is a common pattern in Scala, even array accesses are written array(index)); use OO, functional, procedural or mix everything… Yup, in Scala too, TMTOWTDI.
    • There is no performance hit for using Scala rather than Java. On the contrary, using functional idioms is usually faster in Scala, because they are specifically optimized (e.g. tail recursion).
    • The only thing I don't like about Scala are the compilation times. It's getting better, but they where really silly (about 10s for 1000 lines on my machine).
    I hope this was helpful (:
Re: scala vs perl (5 and 6)
by sundialsvc4 (Monsignor) on Jun 02, 2013 at 16:39 UTC

    Languages have always been a subject of special interest for me, because all of them are both Tools and reflections of a particular group’s point-of-view about programming.   Further, if a language catches-on, then pragmatism takes hold, and the language takes on even more of a human element as other people try to paint over the “warts formerly known as fee-churs,” and to make the old dog do new tricks.   (Moose anyone?)   The best way to understand an actual professional discipline is to observe the tools that they build for themselves ...

    “Versus” really doesn’t count for much, so don’t be holding your breath waiting for any flame-wars here.   (Whew.)   Languages almost never replace another, because there are millions of dollars’ worth of production code written in the one.   Most of us quite-routinely shift from one programming language to another, and back again, during the course of a day or week (and I’m not just talking about JavaScript).   Yes, I have done COBOL recently, and the pay was surely sweet.   But anyhow, a new language is always of interest ... as will surely be Perl-6, if when it actually materializes production-ready.

    As an aside ...   Something else that is of particular interest to me lately is haXe, which is a cross-platform, strongly typed language that works as a source-code translator, much as the original c++ implementation did.   In one notable project, I used it to generate JavaScript and Flash and Android and iOS from a single code base ... all with the full benefit of meaningful compile-time error checking ... and by Jolly, it actually worked well.   My team could not have attempted such a task without it.   So, do put that one “on your radar.”   I have often Meditated as to whether such a technique could be applicable to Perl in some useful way.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1036556]
Approved by LanX
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2014-09-19 12:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (137 votes), past polls