News for hackers. Stuff that matters.
Re:Typesafe raises $14M to commercialize Scala by draegtun on Wednesday August 22, 2012 @10:56AM (#4417635)
They look fine to me and it also look good written in Perl :)

  use List::Util qw(sum max min);

  # 1
  map { $_ * 2 } 1..10;

  # 2
  sum 1..1000;

  # 3
  my @wordlist = ("scala", "akka", "play framework", "sbt", "typesafe");
  my $tweet = "This is an example tweet talking about scala and sbt.";
  grep { $tweet =~ m/\b$_\b/ } @wordlist;

  # 4
  my $file_text = do { local $/ = undef; open my $fh, '<', 'data.txt'; <$fh> };
  chomp( my @file_lines = do { open my $fh, '<', 'data.txt'; <$fh> } );

  # 5
  say "Happy Birthday " . ($_ == 3 ? "dear Barry" : "to You") for 1..4;

  # 6
  my ($passed, $failed) = do { 
    my @p; \@p, [map { $_ > 60 ? push(@p, $_) && () : $_ } (49,58,76,82,88,90)]
  };

  # 8
  min(14, 35, -7, 46, 98);
  max(14, 35, -7, 46, 98);
Re:Typesafe raises $14M to commercialize Scala by xyzzyz on Wednesday August 22, 2012 @11:20AM (#4417774)

  my $file_text = do { local $/ = undef; open my $fh, '<', 'data.txt'; <$fh> };
I have absolutely no idea what this line does. local? undef? '<'?, <$fh>? This is how you read a file in Perl?
Re:Typesafe raises $14M to commercialize Scala by draegtun on Wednesday August 22, 2012 @11:24AM (#4417803)
> This is how you read a file in Perl?

Nope. I use Path::Class from CPAN...

  use Path::Class 'file';
  my $file_text = file('data.txt')->slurp;
Re:Typesafe raises $14M to commercialize Scala by chromatic on Wednesday August 22, 2012 @12:49PM (#4418270)
I have absolutely no idea what this line does.

If you don't know Perl, why should you expect to? I didn't know that #(...) represented a lambda in Scala until a moment ago.

Re:Typesafe raises $14M to commercialize Scala by AnswerAndForget on Wednesday August 22, 2012 @01:11PM (#4418377)
'Knowing Perl' is a rather hard thing to do when the list of completely ad-hoc implicit variables and hidden context-sensitive surprises is seemingly endless.
Re:Typesafe raises $14M to commercialize Scala by chromatic on Wednesday August 22, 2012 @01:27PM (#4418457)
Your grasp of English seems to include subject-verb number agreement, and I suspect you can handle pronouns. You'd do just fine with Perl.

Yes, lots of tutorials explain it badly, and yes, lots of people say "Why should a programming language take cues from natural language?", but implicit variables and context are concepts that primary school children have mastered. They're not that difficult.

Re:Typesafe raises $14M to commercialize Scala by AnswerAndForget on Wednesday August 22, 2012 @02:40PM (#4418878)
Yeah, that was not my point. These aren't but idiosyncrasies of Perl's design, and to model itself on constructs which evolved without direction and which take years to master, just to save a keystroke or two once in a blue moon, is a rather questionable road to take.

Seriously, in what other language don't you ever finish discovering what's on the default namespace, what side-effects any given statement, or hell, expression has, or which syntactic forms are supported, and on and on?

Well, PHP, but we know what the connotations of that are.

And by the way, I'm doing rather 'fine' in Perl, if not for the ever-present worrying about type mismatches (particularly arrays), the frustration of how dirty many operations are (unless you are using a recent version, regex substitution must mutate a variable), the laboriousness of the stock error handling mechanisms (make your own stack trace!) and so on.

Re:Typesafe raises $14M to commercialize Scala by Inufu on Wednesday August 22, 2012 @01:29PM (#4418469)
It represents a lambda in Clojure.
Re:Typesafe raises $14M to commercialize Scala by chromatic on Wednesday August 22, 2012 @01:44PM (#4418559)
You're right. I typed Clojure the first time, then for some reason uncorrected it.