Live data from Hacker News

Choosing Scala

teaching.software-carpentry.org

21–30 of 65 posts

Re: Choosing Scala

#21
post #2

C# and F# would also be decent choices former being further in and the latter farther from abstract C-like comfort zone.

I see more and more F# on my twitter feed, it seems a very very nice language, terse, expressive and pragmatic.

psedit: I can't resist one of my favorite f# article http://blogs.msdn.com/b/ashleyf/archive/2012/01/26/hp-35-mic...

also, arrayForth chip emulator : http://blogs.msdn.com/b/ashleyf/archive/2013/09/21/chuck-moo...

Re: Choosing Scala

#22

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, obv…

Are you aware of the follow-on course?

https://www.coursera.org/course/reactive

Re: Choosing Scala

#23
post #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?

The issue isn't what `print` does. It's what `"5"+5` does. Even Ruby and Python throw a ValueError there.

Re: Choosing Scala

#24
post #22

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, obv…

Are you aware of the follow-on course? https://www.coursera.org/course/reactive

Yes, I am following that course, thank you! Although due to crunch at work I am not doing assignments for this one.

Re: Choosing Scala

#25
post #11

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…

Even better: scala> println("5" + 5 + 5) 555

    scala> val pi = "pie!"
    pi: String = pie!

    scala> println(f"Care for some $pi%f?")
    :9: error: type mismatch;
     found   : String
     required: Double
                  println(f"Care for some $pi%f?")
                                           ^

    scala> val pi = Math.PI
    pi: Double = 3.141592653589793

    scala> println(f"Care for some $pi%f?")
    Care for some 3.141593?
ps:

- http://docs.scala-lang.org/overviews/core/string-interpolati...

- read: https://github.com/adriaanm/talks/blob/master/scala-2.10/sli...

- watch: http://www.youtube.com/watch?v=tcQgNEFAVjI

Re: Choosing Scala

#26

As a software engineer I find Scala to be a very powerful tool, but one which takes some time to learn. I could see it being a useful teaching tool if they stay away from obscure corners of the language. I'm glad that they didn't go with Java, but I'd only go with Scala if the students are a sharp bunch. Python would also have been a suitable choice.

> "I'm glad that they didn't go with Java"

That School (Aalto University) has used Java as a first year language for quite some time. Then they switched to Python (I think), and then to Scala. Before Java, it was Scheme. Before Scheme, I don't know.

Re: Choosing Scala

#27

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> "5" + 5 res0: java.lang.String = 55 Don't use print in the REPL... > Python gives me a TypeError. And so does Common Lisp. I was expecting the same from Scala scala> val i:Int = "5" + 5 :7: error: type mismatch; found : java.lang.String required: Int val i:Int = "5" + 5 ^ You can easily get a compiler error, if you enforce the type. The inheritance of Javas "I'll call .toString on anything" is definitely not s…

Isn't this something that type inference should catch though?

Re: Choosing Scala

#28

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…

Java compatibility. Slightly unfortunate, but less of a problem than it would be in python or lisp thanks to static typing - if you tried to pass "5" + 5 to a method that expected an int you'd get an error.

Re: Choosing Scala

#29

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 avai…

Thanks for joining the discussion. Just want to say I'm working through the the videos for your coursera course (https://www.coursera.org/course/progfun) and, in addition to being a great introduction to Scala, it's changing how I approach other functional languages like JavaScript and R

Re: Choosing Scala

#30
post #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.

The example is merely illustration and not the recommended practice for writing C++! (Can you imagine?)

I only meant to illustrate that even in C++ where types have a different meaning I will get a warning with a decent compiler.

In either case the expression in both languages garners a silly result. However Scala is happy with the result and reports nothing wrong with it (not even a warning). I was just surprised is all.

Post reply on HN