Live data from Hacker News

Choosing Scala

teaching.software-carpentry.org

1–10 of 65 posts

Re: Choosing Scala

#3
Coming from CS and computational math background, I used mostly C++ for production and Python for prototyping and data analysis. I wanted to learn some new language for JVM, Clojure and Scala being the main (if not the only) contenders. I may learn Clojure anyway, but what tipped the scale to learning Scala first was wonderful Coursera course in functional programming by Martin Odersky, using Scala as a language, obviously.

A very short summary of my impressions from Scala: * It is beautiful, I felt the half-forgotten beauty of functional programming once again

* Scala worksheets (quick scratch to evaluate whole code snippets with immediate feedback) are awesome. I love them even more than REPL (Then again, I love IPython notebook more than Python REPL too)

* Scala seems a bit heavy in terms of number of concepts

* Scala can be terse and very expressive, but pretty verbose if you need it to be

* Compilation of large programs is slow and eats gobs of memory

* tail-call optimize everything

Re: Choosing Scala

#4
I really want to understand what the fuss is about with Scala so I fired up a REPL and found a tutorial and went to work. Then I can across this:

    scala> print("5" + 5)
    55
And I stopped there (for now). At least my C++ compiler will warn about that (although it will still compile even if it doesn't print anything save for the newline):

    #include 
    using namespace std;

    int main(int argc, char *argv[]) {
        cout 
Python gives me a TypeError. And so does Common Lisp. I was expecting the same from Scala; a language which purports to be a multi-paradigm language with static type inference and a strong functional programming bias. Not even a warning.

What's the reasoning behind this in Scala?

Re: Choosing Scala

#5

I really want to understand what the fuss is about with Scala so I fired up a REPL and found a tutorial and went to work. Then I can across this: scala> print("5" + 5) 55 And I stopped there (for now). At least my C++ compiler will warn about that (although it will still compile even if it doesn't print anything save for the newline): #include using namespace std; int main(int argc, char *argv[]) { cout Python gives…

I am hoping reasoning is in a non-print application the type of the captured value will be compile time checked elsewhere. But if the language is willing to cast both ways between int and string then there is no safety (no idea if it does do that). Also I do agree with your points (explicit and implied) I don't see "hey free parsing" as a big enough advantage to infect the language with these sort of implicit conversions.

Re: Choosing Scala

#6

I really want to understand what the fuss is about with Scala so I fired up a REPL and found a tutorial and went to work. Then I can across this: scala> print("5" + 5) 55 And I stopped there (for now). At least my C++ compiler will warn about that (although it will still compile even if it doesn't print anything save for the newline): #include using namespace std; int main(int argc, char *argv[]) { cout Python gives…

This is handy for something like: scala> print("The result is " + iResult)

Re: Choosing Scala

#7

I really want to understand what the fuss is about with Scala so I fired up a REPL and found a tutorial and went to work. Then I can across this: scala> print("5" + 5) 55 And I stopped there (for now). At least my C++ compiler will warn about that (although it will still compile even if it doesn't print anything save for the newline): #include using namespace std; int main(int argc, char *argv[]) { cout Python gives…

It's inherited from Java, where adding something and a string will implicitly convert the something into a string.

The C++ behavior is notably worse, though: "5" + 5 in C++ is undefined behavior, and will give you a pointer to some mystery data.

Re: Choosing Scala

#8

I really want to understand what the fuss is about with Scala so I fired up a REPL and found a tutorial and went to work. Then I can across this: scala> print("5" + 5) 55 And I stopped there (for now). At least my C++ compiler will warn about that (although it will still compile even if it doesn't print anything save for the newline): #include using namespace std; int main(int argc, char *argv[]) { cout Python gives…

Since print() most likely expects a string, isn't the result exactly what you would expect? Why would you want a warning in this case?

Re: Choosing Scala

#9

I really want to understand what the fuss is about with Scala so I fired up a REPL and found a tutorial and went to work. Then I can across this: scala> print("5" + 5) 55 And I stopped there (for now). At least my C++ compiler will warn about that (although it will still compile even if it doesn't print anything save for the newline): #include using namespace std; int main(int argc, char *argv[]) { cout Python gives…

FYI, this works in Java too. System.out.println("5" + 5);

Re: Choosing Scala

#10

I really want to understand what the fuss is about with Scala so I fired up a REPL and found a tutorial and went to work. Then I can across this: scala> print("5" + 5) 55 And I stopped there (for now). At least my C++ compiler will warn about that (although it will still compile even if it doesn't print anything save for the newline): #include using namespace std; int main(int argc, char *argv[]) { cout Python gives…

Scala inherits essentially all its expression syntax from Java, including the string +. This was done because a lot of other things in Scala are new, so we did not want to rock the boat too much with changes that might seem arbitrary. That said, I believe string + is probably the most criticized feature in Scala's expression syntax. People are generally moving away from it, towards String interpolation, which is available from Scala 2.10.
Post reply on HN