Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You mentioned an important point which Scala lacks a bit: the documentation.</p> <p>The REPL is a fantastic tool, but it is not as fantastic at it can be. There are too much missing features and features which can be improved - some of them are mentioned in your post. Scaladoc is a nice tool, too, but is far away to be perfect. Furthermore lots of code in the API is not yet or too less documented and code examples are often missing. The IDEs are full ob bugs and compared to the possibilities Java IDEs show us they look like some kindergarten toys.</p> <p>Nevertheless there is a gigantic difference of Scalas current tools compared to the tools available as I started to learn Scala 2-3 years ago. At that time IDEs compiled permanently some trash in the background, the compiler crashed every few minutes and some documentation was absolutely nonexistent. Frequently I got rage attacks and wished death and corruption to Scala authors.</p> <p>And now? I do not have any of these rage attacks any more. Because the tools we currently have are great although the are not perfect!</p> <p>There is <a href="http://docs.scala-lang.org" rel="nofollow noreferrer">docs.scala-lang.org</a>, which summarizes a lot of great documentation. There are Tutorials, Cheat-sheets, Glossaries, Guides and a lot of more great stuff. Another great tools is <a href="http://scalex.org/" rel="nofollow noreferrer">Scalex</a>, which can find even the weirdest operator one can think of. It is Scalas <a href="http://www.haskell.org/hoogle/" rel="nofollow noreferrer">Hoogle</a> and even though it is not yet as good as his great ideal, it is very useful.</p> <p>Great improvements are coming with Scala2.10 in form of Scalas own Reflection library:</p> <pre><code>// needs Scala2.10M4 scala&gt; import scala.reflect.runtime.{universe =&gt; u} import scala.reflect.runtime.{universe=&gt;u} scala&gt; val t = u.typeOf[List[_]] t: reflect.runtime.universe.Type = List[Any] scala&gt; t.declarations res10: Iterable[reflect.runtime.universe.Symbol] = SynchronizedOps(constructor List, method companion, method isEmpty, method head, method tail, method ::, method :::, method reverse_:::, method mapConserve, method ++, method +:, method toList, method take, method drop, method slice, method takeRight, method splitAt, method takeWhile, method dropWhile, method span, method reverse, method stringPrefix, method toStream, method removeDuplicates) </code></pre> <p>Documentation for the new Reflection library is still missing, but in progress. It allows one to use scalac in an easy way inside of the REPL:</p> <pre><code>scala&gt; u reify { List(1,2,3) map (_+1) } res14: reflect.runtime.universe.Expr[List[Int]] = Expr[List[Int]](immutable.this.List.apply(1, 2, 3).map(((x$1) =&gt; x$1.$plus(1)))(immutable.this.List.canBuildFrom)) scala&gt; import scala.tools.reflect.ToolBox import scala.tools.reflect.ToolBox scala&gt; import scala.reflect.runtime.{currentMirror =&gt; m} import scala.reflect.runtime.{currentMirror=&gt;m} scala&gt; val tb = m.mkToolBox() tb: scala.tools.reflect.ToolBox[reflect.runtime.universe.type] = scala.tools.reflect.ToolBoxFactory$ToolBoxImpl@32f7fa37 scala&gt; tb.parseExpr("List(1,2,3) map (_+1)") res16: tb.u.Tree = List(1, 2, 3).map(((x$1) =&gt; x$1.$plus(1))) scala&gt; tb.runExpr(res16) res18: Any = List(2, 3, 4) </code></pre> <p>This is even greater when we want to know how Scala code is translated internally. Formerly wen need to type <code>scala -Xprint:typer -e "List(1,2,3) map (_+1)" </code> to get the internally representation. Furthermore some small improvements found there way to the new release, for example:</p> <pre><code>scala&gt; :type Predef scala.Predef.type </code></pre> <p>Scaladoc will gain some <a href="https://scala-webapps.epfl.ch/jenkins/view/scaladoc/job/scaladoc-diagram-nightly/ws/build/scaladoc/library/index.html#scala.collection.immutable.List" rel="nofollow noreferrer">type-hierarchy graph</a> (click on type-hierarchy).</p> <p>With Macros it is possible now, to improve error messages in a great way. There is a library called <a href="https://github.com/pniederw/expecty" rel="nofollow noreferrer">expecty</a>, which does this:</p> <pre><code>// copied from GitHub page import org.expecty.Expecty case class Person(name: String = "Fred", age: Int = 42) { def say(words: String*) = words.mkString(" ") } val person = Person() val expect = new Expecty() // Passing expectations expect { person.name == "Fred" person.age * 2 == 84 person.say("Hi", "from", "Expecty!") == "Hi from Expecty!" } // Failing expectation val word1 = "ping" val word2 = "pong" expect { person.say(word1, word2) == "pong pong" } /* Output: java.lang.AssertionError: person.say(word1, word2) == "pong pong" | | | | | | | ping pong false | ping pong Person(Fred,42) */ </code></pre> <p>There is a tool which allows one to find libraries hosted on GitHub, called <a href="http://ls.implicit.ly/" rel="nofollow noreferrer">ls.implicit.ly</a>.</p> <p>The IDEs now have some semantic highlighting, to show if a member is a object/type/method/whatever. The semantic highlighting feature of <a href="http://scala-ide.org/docs/helium/features/semantic-highlighting/index.html" rel="nofollow noreferrer">ScalaIDE</a>.</p> <p>The javap feature of the REPL is only a call to the native javap, therefore it is not a very featue-rich tool. You have to fully qualify the name of a module:</p> <pre><code>scala&gt; :javap scala.collection.immutable.List Compiled from "List.scala" public abstract class scala.collection.immutable.List extends scala.collection.AbstractSeq implements scala.collection.immutable.LinearSeq,scala.Product,scala.collection.LinearSeqOptimized{ ... </code></pre> <p>Some time ago I have written a <a href="https://stackoverflow.com/questions/9350528/how-to-work-with-javap-for-scala-java-interop">summary of how Scala code is compiled to Bytecode</a>, which offers a lot of things to know.</p> <p>And the best: This is all done in the last few months!</p> <p>So, how to use all of these things inside of the REPL? Well, it is not possible ... not yet. ;)</p> <p>But I can tell you that one day we will have such a REPL. A REPL which shows us documentation if we want to see it. A REPL which let us communicate with it (maybe like <a href="http://www.haskell.org/haskellwiki/Lambdabot" rel="nofollow noreferrer">lambdabot</a>). A REPL which let us do cool things we still cannot imagine. I don't know when this will be the case, but I know that a lot of stuff was done in the last years and I know even greater stuff will be done in the next years.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload