Live data from Hacker News

Real world feedback from a Java dev using Scala

capecoder.wordpress.com

1–10 of 17 posts

Re: Real world feedback from a Java dev using Scala

#3
Api docs do tend to merely provide method signatures, which is great when you know what you are doing, but when you come upon a bunch of generics, implicit parameters, and thats in the docs for the first time, you end up combing through a lot of stuff. In many cases, a simple example use case embedded in the document with console output of the use case would admittedly be very helpful.

Re: Real world feedback from a Java dev using Scala

#4
I'm in the same shoes with OP. Here's how my Scala skill progresses:

In the beginning, I wrote Scala "the Java way", sans semi-colons. Then I omit dots and parenthesis whenever possible (foo.do(bar) -> foo do bar). Then I learn to use immutable declaration (var -> val) and learn that expressions like this:

  var i = 0
  if (something) {
    // Additional logic
    i = 1
  }
Can be made immutable like this:

  val i = {
    if (something) {
      // Additional logic
      1
    } else 0
  }
Then I try to make use its functional goodies like map and fold, and so on. I use IntelliJ with Scala and JRebel (free for Scala!) plugin. JRebel allows you to "hot reload" Scala classes to avoid server restarts.

I admit I'm a frequent lurker in SO when using Scala, as its API doc sucks, and I also dislike its integration with Java, although it's not Scala's fault. For API doc, I think it'd be better if it has examples, which reminds me of ActionScript API docs.

Re: Real world feedback from a Java dev using Scala

#5
Very interesting comment about the notation for package-level scoping. When I worked with Java, most of the devs I worked alongside also used package-level access for more complicated private methods in order to unit test, but I've never seen that pattern used in Scala.

How do you generally test private methods in Scala? Would an inner class work? Path-dependent types in Scala seem to make this approach more elegant than in Java.

Re: Real world feedback from a Java dev using Scala

#6

Very interesting comment about the notation for package-level scoping. When I worked with Java, most of the devs I worked alongside also used package-level access for more complicated private methods in order to unit test, but I've never seen that pattern used in Scala. How do you generally test private methods in Scala? Would an inner class work? Path-dependent types in Scala seem to make this approach more elegant…

perhaps you could elaborate on the inner class idea...

Re: Real world feedback from a Java dev using Scala

#8
post #2

Doc continues to be a challenge, but there's a lot of good stuff at http://docs.scala-lang.org/ including an in-depth guide to collections that the author might find helpful.

I think being able to community add to the API docs would be very helpful.

For beginners http://dcsobral.blogspot.com/2011/12/using-scala-api-documen... may be helpful in learning how to navigate the docs buuut what really helps are examples especially with scala's sometimes long and hard to parse type signatures.

In general I think a site for language docs where people can add comments/examples/content would be extremely useful. Like the php docs but for all languages in the same place. I never use php but comment-able docs are a win.

Re: Real world feedback from a Java dev using Scala

#9

That's quite similar to how it is with C# and F#. Writing C# code just feels _so_ verbose and cumbersome to do even the most trivial tasks. And yes, the F# compiler is around 1/8th the speed of the C# compiler, at best - possibly much worse.

Does F# have live compilation like C# right now? (If I type invalid C# code, then it tells me right away by underlining the invalid code.)

Re: Real world feedback from a Java dev using Scala

#10

Very interesting comment about the notation for package-level scoping. When I worked with Java, most of the devs I worked alongside also used package-level access for more complicated private methods in order to unit test, but I've never seen that pattern used in Scala. How do you generally test private methods in Scala? Would an inner class work? Path-dependent types in Scala seem to make this approach more elegant…

I use ScalaTest's PrivateMethodTester for testing private methods.
Post reply on HN