{"id":3123,"date":"2016-02-10T00:21:12","date_gmt":"2016-02-10T00:21:12","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3123"},"modified":"2016-02-10T00:21:12","modified_gmt":"2016-02-10T00:21:12","slug":"scala-example-hello-world-app","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/scala-example-hello-world-app\/","title":{"rendered":"Scala example &#8220;Hello World&#8221;"},"content":{"rendered":"<p>The scala programming language has become a popular replacement for Java. <\/p>\n<p>Once you <a href=\"http:\/\/www.scala-lang.org\/download\/\">download scala<\/a>, you can access it from the command line:<\/p>\n<pre lang=\"bash\">\nscala> Garys-MBP:search gary$ scala\nWelcome to Scala version 2.11.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_25).\nType in expressions to have them evaluated.\nType :help for more information.\n<\/pre>\n<p>This is an excellent place to explore the language. For example, you can print to the screen:<\/p>\n<pre lang=\"scala\">\nscala> println(\"Hello World!\")\nHello World!\n<\/pre>\n<p>To exit, press ctrl-C.<\/p>\n<p>Now, let&#8217;s put some code in a file named hello.scala (you can also run this in the scala command line interpreter):<\/p>\n<pre lang=\"scala\">\nobject HelloWorld { \n  def main(args: Array[String]) { \n    println(\"Hello, world!\")\n  } \n} \n<\/pre>\n<p>On the command line, you can run this with the scala interpreter:<\/p>\n<pre lang=\"bash\">\nscala hello.scala \nHello, world!\n<\/pre>\n<p>One of the benefits of using scala is the libraries that ship with the language.<\/p>\n<p>For instance, let&#8217;s go back into the scala interpreter and make a list:<\/p>\n<pre lang=\"scala\">\nscala> val x = List(1, 2, 3)\nx: List[Int] = List(1, 2, 3)\n<\/pre>\n<p>Now, type &#8220;x.&#8221; at the command line, and press tab twice: this will show you functions you can call on the list.<\/p>\n<pre lang=\"scala\">\nscala> x.\n++             canEqual        drop        foreach           isDefinedAt          mapConserve    product             reverseMap      sorted         toIndexedSeq    unzip3         \n++:            collect         dropRight   genericBuilder    isEmpty              max            productArity        reverse_:::     span           toIterable      updated        \n+:             collectFirst    dropWhile   groupBy           isInstanceOf         maxBy          productElement      runWith         splitAt        toIterator      view           \n\/:             combinations    endsWith    grouped           isTraversableAgain   min            productIterator     sameElements    startsWith     toList          withFilter     \n:+             companion       exists      hasDefiniteSize   iterator             minBy          productPrefix       scan            stringPrefix   toMap           zip            \n::             compose         filter      head              last                 mkString       reduce              scanLeft        sum            toSeq           zipAll         \n:::            contains        filterNot   headOption        lastIndexOf          nonEmpty       reduceLeft          scanRight       tail           toSet           zipWithIndex   \n:\\             containsSlice   find        indexOf           lastIndexOfSlice     orElse         reduceLeftOption    segmentLength   tails          toStream                       \naddString      copyToArray     flatMap     indexOfSlice      lastIndexWhere       padTo          reduceOption        seq             take           toString                       \naggregate      copyToBuffer    flatten     indexWhere        lastOption           par            reduceRight         size            takeRight      toTraversable                  \nandThen        corresponds     fold        indices           length               partition      reduceRightOption   slice           takeWhile      toVector                       \napply          count           foldLeft    init              lengthCompare        patch          repr                sliding         to             transpose                      \napplyOrElse    diff            foldRight   inits             lift                 permutations   reverse             sortBy          toArray        union                          \nasInstanceOf   distinct        forall      intersect         map                  prefixLength   reverseIterator     sortWith        toBuffer       unzip                          \n<\/pre>\n<p>Using these techniques you can start exploring the available APIs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The scala programming language has become a popular replacement for Java. Once you download scala, you can access it from the command line: scala> Garys-MBP:search gary$ scala Welcome to Scala version 2.11.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_25). Type in expressions to have them evaluated. Type :help for more information. This is an excellent &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/scala-example-hello-world-app\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Scala example &#8220;Hello World&#8221;&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[480,485],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3123"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=3123"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3123\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}