Effective Scala Marius Eriksen, Twitter Inc. marius@twitter.com (@marius) [translated by Yuta Okamoto (@okapies) and Satoshi Kobayashi (@scova0731)] Table of Contents åºç« æ¸å¼: ãã¯ã¤ãã¹ãã¼ã¹, å½å, ã¤ã³ãã¼ã, ä¸ã«ãã³, ãã¿ã¼ã³ããã, ã³ã¡ã³ã åã¨ã¸ã§ããªã¯ã¹: æ»ãåã¢ããã¼ã·ã§ã³, å¤ä½, åã¨ã¤ãªã¢ã¹, æé» ã³ã¬ã¯ã·ã§ã³: é層, 使ã, ã¹ã¿ã¤ã«, æ§è½, Java ã³ã¬ã¯ã·ã§ã³ 並è¡æ§: Future, ã³ã¬ã¯ã·ã§ã³ å¶å¾¡æ§é : å帰, Return, forã«ã¼ãã¨å å , require 㨠assert é¢æ°åããã°ã©ãã³ã°: 代æ°çãã¼ã¿åã¨ãã¦ã®ã±ã¼ã¹ã¯ã©ã¹, Option, ãã¿ã¼ã³ã
ããã«ã¡ã¯ãæ±å£ã§ãã 2æ21æ¥(å)ã«ãå®æ¦ã§ã® Scala ã 6ã¤ã®äºä¾ããç¥ã Scala ã®åæãããã¹ãã¼ããã¥ã¼ã¹æ ªå¼ä¼ç¤¾ããã¨å ±åã§éå¬ãããã¾ããã®ã§ããã®æ§åã¨çºè¡¨å 容ãå ¬éãããè³æã¨ã¨ãã«ç°¡åã«ç´¹ä»ãã¾ãã å ´æã¯æ¸è°·ã«ããã¹ãã¼ããã¥ã¼ã¹ããã®æ°ãªãã£ã¹ã§è¡ããã¾ãããScalaã¸ã®æ³¨ç®åº¦ã®é«ãããã£ã¦ããå½æ¥ã¯åºãã¹ãã¼ã¹ã«ç¨æããã座å¸ãã»ã¼æºå¸ã¨ããçæ³å ·åã§ããã ããºãªã¼ãã®æ°ãµã¼ãã¹ãScalaã§ä½ã£ã¦ã¿ã ï½ãã¤ã¯ããµã¼ãã¹ã®è£å´ (æ ªå¼ä¼ç¤¾ããºãªã¼ã 竹添ãã) æåã«ãæ ªå¼ä¼ç¤¾ããºãªã¼ãã®ç«¹æ·»ãããããæ°ãµã¼ãã¹ã§ããã¹ã¿ã³ãã¤ã¨ããæ±äººæ¤ç´¢ã¨ã³ã¸ã³ã®éçºã«ã¤ãã¦ã®çºè¡¨ãè¡ããã¾ããã ãµã¼ãã¹å ¨ä½ã®ã¢ã¼ããã¯ãã£ã«ãã¤ã¯ããµã¼ãã¹ãæ¡ç¨ããåãµã¼ãã¹ã®å®è£ ã«ã¯Scalaãæ¡ç¨ããã¨ãããããªå 容ã§ããã Scalaãæ¡ç¨ããçç±ã¨ãã¦ã並åå¦
Scalaåå¦è ã®æ¹ãæ¸ãã³ã¼ãã«ã¯ããã°ãã°ä»¥ä¸ã®ãããªãã®ãæ£è¦ããã¾ãã list.map {x => x match { case A => case B => case _ => } } ç¡åé¢æ°ãä½ãããã®æ§æã§ãã{x => ...}ã¨exp match { case ... }ãå¥ã ã«èããã¨ãã®ãããªã³ã¼ãã«ãªãã®ã¯ç¡çã¯ããã¾ãããããããããã¯ãã£ã¨ç°¡æ½ã«æ¸ããã¨ãã§ãã¾ããæ¹è¯ããã®ã以ä¸ã®ã³ã¼ãã§ãã list.map { case A => case B => case _ => } åè ã®æ¸ãæ¹ã«æ¯ã¹ã¦æç¶ç°¡æ½ã§ãããç¹å¥ãªäºæ ããªãéããç¡åé¢æ°ã®å¼æ°ãå³åº§ã«ãã¿ã¼ã³ãããããå¿ è¦ãããå ´åãå¾è ã®æ¸ãæ¹ã使ãã¾ãããã ã¡ãªã¿ã«ããã®æ¸ãæ¹ãæããã¨çµæ§ã³ã£ãããããæ¹ãå¤ãããã§ããã®æ§æã¯PartialFunctionã®ããã®ãã®ã ã¨æã£ã¦ãããã¨ãã
åçªã«å§ã¾ã£ãScala Tipsã³ã¼ãã¼ãåå¦è ãé¥ããã¡ãªScalaã®ã³ã¼ããã¿ã¼ã³ãä¾ã«ãã¦ãããè¯ãæ¹æ³ã解説ãã¦ããã¾ãã第ä¸åã¯Optionã¯ã©ã¹ã®map()ã¡ã½ããã使ããã¨ãããã®ã§ããç¥ã£ã¦ã人ã«ã¯ä»æ´ã§ãããOption#map(f)ã¯ãã¬ã·ã¼ãã¼ã®å¤ãSome(v)ã®å ´åã¯ãfã«vã渡ããçµæã®Some(f(v))ããNoneã®å ´åã¯Noneãè¿ãã¾ãããããã£ã¦ããã¿ã¼ã³ãããã使ã£ã以ä¸ã®ãããªã³ã¼ã㯠val result = exp1 match { case Some(v1) => val vx = //expression using v1 Some(vx) case None => None } 常ã«ä»¥ä¸ã®ãããªå½¢ã«æ¸ãæãããã¨ãã§ãã¾ãã val result = exp1.map{v1 => val vx = //expression using
ã¿ãªããããã«ã¡ã¯ãæè¡é¨Webãã¼ã ãªã¼ãã¼ã®ç°ä¸ä½æ¨¹ã§ãã ã¿ããªããã¯ããªããã¨å¼ã°ãã¦ãã¾ããç«ã¨Vimã大好ãã§ãã ãã¦ãä»åã¯å æ¥éå¬ãã2æ³3æ¥ã®ChatWorkéçºå宿ã®å ¨è²ã«ã¤ãã¦ãç´¹ä»ãããã¨æãã¾ãã ãéçºå宿ããã£ã¦ã¿ãããã©ãã©ãããã°ããã®ãããããããªããã¨ããæ¹ã®åèã«ãªãã°å¬ããã§ãã ãªãéçºå宿ããããã¨ã«ãªã£ãã®ãï¼ ãã£ããã¯ã¼ã¯ã¯2011å¹´3æã®å ¬é以æ¥ãé 調ã«ã¦ã¼ã¶ã¼æ°ã伸ã°ã2014å¹´4ææç¹ã§ä¸ç170ã«å½42,000社ã®ä¼æ¥ã«å°å ¥ãããã¾ã§ã«æé·ãã¦ãã¾ãã ãããªä¸ãç¾å¨ãã£ããã¯ã¼ã¯ã®ããã¯ã¨ã³ãã§åãã¦ããããã°ã©ã ãä»å¾ã®éç¨ã«ããã¦æé©ã§ã¯ãªãã®ã§ã¯ã¨ããæ¸å¿µããããè¨èªã¨ãã¬ã¼ã ã¯ã¼ã¯ã®åé¸å®ããããã¨ãã声ãä¸ããã¾ããã ãã ããªããªãæ¥é ã®æ¥åã®ä¸ã§æéãåãã®ã¯é£ãããä»å¾ã®ãã£ããã¯ã¼ã¯ãå·¦å³ããé大ãªé¸æãªã®ã§
val is better than Java's final? JavaScript hoisting var r = double(1) + triple(1); function double(x) {return x * 2;} var triple = function(x) {return x * 3;} Throws: java.lang.NullPointerException at Vals.<init>(Vals.scala:2) Simplified class Vals { println(answer) private[this] val answer = 42 } Prints... 0 return in lambda def samples(xs: TraversableOnce[Int]) { xs map {x => return x * 10} for
2. èªå·±ç´¹ä» î åå : ä¸å® î ã¯ã¦ãª : id mollifier î twitter : @mollifier î ç¥æ¸ã®ããã°ã©ã 4. ããã°ã¨ã î ã¯ã¦ãªããã° http://mollifier.hatenablog.com/ î twitter http://twitter.com/mollifier î slideshare http://www.slideshare.net/mollifier î github https://github.com/mollifier
ã¯ããã« åãã¾ãã¦ã 2011å¹´åº¦å ¥ç¤¾ã®ã¤ã¡ã¯ãã¨ç³ãã¾ãã ã¢ã¡ã¼ãã®ã²ã¼ã é¨éã§ã¨ã³ã¸ãã¢ããã¦ãã¾ãã ä»åã¯ã¨ã³ã¸ãã¢ããã°ãæ¸ãæ©ä¼ãé ãã¾ããã®ã§ã大好ã㪠Scala ã«ã¤ãã¦æ¸ããã¦ããã ãã¾ããã ããã®ãããã¨ããã¨ããã©ããã®ãªã話ãããããããããã¼ããªã£ã¦ããã¾ããããäºæ¿ãã ããã¾ãã ã¨ããããã§ããããRuby ã¯ä½¿ã£ã¦ãã¦æ¥½ããã æ°æã¡ããããã¨èããã©ã Scala ã楽ãããæ°æã¡ãããã ãã¼ï¼ ã¨ããã®ãä¼ãããã§ããã ä¼ããã¨ããã§ããã (ãã®è¨äºã¯ç§ã Scala ã®æ¥½ããã¨æããé¨åã«çãçµã£ã¦æ¸ãã¦ãã¾ãã Scala ã«ã¯æ¥½ãããªãé¨åãããããããã¾ãããããã«é¢ãã¦ã¯ããã§ã¯è§¦ãã¾ããã Scala ããã¯ä¿ºã®å«) ããã£ã¨æ¸ãã¦ãããã¦ã¿ããã¨ãåºæ¥ãã® æ¬é¡ã«å ¥ãåã«ãã Ruby ã«ã¯ irb ã¨ããããã®å ´ã§ããã°ã©ã ã
Scala.js 1.16.0 Harness the Scala and JavaScript ecosystems together. Develop robust apps for browsers, Node.js, and serverless. Strong typing guarantees your code is free of silly mistakes; no more mixing up strings or numbers, forgetting what keys an object has, or worrying about typos in your method names. Scala.js takes care of all this tedious book-keeping for you, letting you focus on the ac
å¤ä¼ã¿åã®å°ãã¿ã第2å¼¾ã ä»æ¥ããããç®ã«ãããã¡ããè¦ã¦ã Rubyã§GUIã¢ããªãä½ããªãJRuby+JavaFX+Rawrã§æ±ºã¾ãï¼ http://blog.supermomonga.com/articles/jruby/javafx-rawr.html Scalaã¨Groovyã§ãJavaFXã使ã£ã¦åããããªãã¨ããã£ã¦ãã¾ããã ããæåã«æ³¨æäºé ã ScalaFXãGroovyFXã¯ããããJavaFXã触ã£ããã¨ãªã人ãæ¸ãã¦ã¾ã ããã¾ã§ããåãç»é¢ãåºãã¾ã§ãã®ã¨ããããã£ãã ãã§ãexeãã¡ã¤ã«åã¨ãã¯ä¸åãã¼ã¿ããã§ã ã¨ã¯ãããå°ãã ãJavaFXã«èå³ã¯ãã£ãã®ã§ãå¢ãã§ãããã¦ã¿ã¾ãããååãå ã«åºãã¡ããã¾ãããã©ãScalaFXã¨GroovyFXã§ã ScalaFX http://code.google.com/p/scalafx/ GroovyFX h
ã¢ãã´ã¡ã³ã¹ãã»ã½ããã»ã¨ã³ã¸ãã¢ãªã³ã°ï¼ASEï¼ã¯ãããã°ã©ãã³ã°è¨èªãScalaãã§ã®éçºãå¾æã¨ããã½ãããã¦ã¹ã ãããã¾ã§ã®Scalaã§ã®åè¨éçºã®å®ç¸¾ã¯ãå®å ¬åºãéèç³»ä¼æ¥ãWebãµã¼ãã¹ã®ä¼æ¥ãªã©5件以ä¸ã«ä¸ãã å社ã¯å¾æ¥ãJavaãRubyã§ã®ã·ã¹ãã éçºãä¸å¿ã«ææãã¦ãããã2010å¹´ã«ããéèç³»ä¼æ¥ããScalaã§ã®éçºãæ診ãããå©ç¨ãããã¨ããã£ããã«ããæè¡è ãScalaã¯é¢ç½ãã¨æ°ã«å ¥ããï¼å社æè¡éçºé¨é¨é·ã®è¤å·èç« æ°ï¼ã人æè²æãå¼·åããã以éãScalaã®ã¹ãã«ãæã£ã人æããããã¨ãä¼ç¤¾ã®å¼·ã¿ã¨ãã¦æã¡åºãããã«ãªã£ãã 以åã¯å¤§æãã³ãã¼ããã®äºæ¬¡è«ãã®æ¡ä»¶ãå¤ãã£ãããScalaã«åãçµã¿å§ãããã¨ãæ©ã«ãScalaã§ãã²éçºãã¦ã»ããã¨ãã¦ã¼ã¶ã¼ä¼æ¥ããç´æ¥å½ç¤¾ã«æåãå ¥ããæ¡ä»¶ãç²å¾ã§ããã±ã¼ã¹ãå¢ãã¦ãããï¼è¤å·æ°ï¼ã¨ãããç¾å¨é²è¡ä¸ã®æ¡ä»¶ã§
Twitter Engineer Talks About the Company's Migration from Ruby to Scala and Javaã翻訳ãã¾ããã â»ãGoogle翻訳ãã¼ã«ãããã®è©¦è¡ãå ¼ãã¦ãã¾ãã Twitterã¯Ruby on Rails ãæ´»ç¨ãã¦ãããã¨ã§æåã§ããããµã¼ãã¹ãæ¡å¤§ãã¦ããã«ã¤ãã¦ãã³ã¼ãã®ä¸é¨ãä»ã®æè¡ã«ç§»è¡ãã¦ãã¦ãã¾ããå社ã¯ããã¯ã¨ã³ãã®ã¡ãã»ã¼ã¸ãã¥ã¼ã®å®è£ ãScalaã«ç§»è¡ ãããã¨ããå§ããããã¯ã¨ã³ãã®æ¤ç´¢ãJavaã§åæ§ç¯ãããã¨ãç¶ç¶ããæè¿ã§ã¯æ¤ç´¢å¦çã®ããã³ãã¨ã³ãã Java ãµã¼ãã«ç½®ãæãã¾ãã ã InfoQã¯ãTwitterã®ã¨ã³ã¸ãã¢ãã¨ã´ã¡ã³ã»ã¦ã£ã¼ãã¼ã«ã¤ã³ã¿ãã¥ã¼ãè¡ãã¾ãããå½¼ã¯ããã®å¤é©ã«ã¤ãã¦ãã詳ãã説æãã¦ããã¦ãã¾ãã èå³æ·±ãã®ã¯ä»¥ä¸ã®ãã¤ã³ãã§ãã Twitterã§ãã使ãã
Scala.jsã¯Scala製ãScala Licenseã®ãªã¼ãã³ã½ã¼ã¹ã»ã½ããã¦ã§ã¢ã§ãã JavaScriptã¯ã¹ã¯ãªããè¨èªã§ãããã³ã³ãã¤ã«ç³»è¨èªã使ã£ã¦ããããã°ã©ãã¼ã«ã¨ã£ã¦ã¯ä½¿ãåæãæªãã¨æãã¦ãã¾ãããã§ããããããªããScalaã®ä½¿ãæã§ããã°ãScalaã§Webããã³ãã¨ã³ããéçºã§ããScala.jsã使ã£ã¦ã¿ã¾ãããã ãµã³ãã«ã§ããããã±ã¼ã¸ããªãã¸ã§ã¯ãã使ãã¾ããæ®éã«Scalaãè¨è¿°ã§ãã¾ããã³ã³ãã¤ã«ãå®è¡ãã¦JavaScriptãã¡ã¤ã«ãçæãã¾ãã ã½ã¼ã¹ãããã«å¯¾å¿ãã¦ãããã³ã³ã½ã¼ã«ããScalaã®ã½ã¼ã¹ã«é£ã¶ãã¨ãã§ãã¾ãã Webã¨ãã£ã¦DOMã®æä½ããã¡ããã§ãã¾ãã å ¥åãåãåã£ã¦å¦çãè¡ãã¾ãã å¼æ°ã¨ãã¦å ¥åå 容ãåãåã£ã¦å¦çãè¡ããã¨ãã§ãã¾ãã jQueryã¨ã®é£æºãã§ãã¾ãã jQueryã®ã¤ãã³ããå¼ã³åºããå¦çãè¡ãã¾
[注æ] ãã®æç« ãèªãã¨ãæ¢åã®Rubyã³ã¼ããScalaã§rewriteããããªãã Rubyã³ã¼ãã§åãã§ãã¯ãããã®ã鬱ã«ãªããRubyæ¡ä»¶ã§ããæ°ãåºãªããªãã ãªã©ã®å¹»è¦ãç°å¸¸è¡åãå ±åããã¦ãã¾ãã ç¾å¨é¢ãã£ã¦ããããã¸ã§ã¯ãã家æã®ãã¨ã常ã«æèãã æ°ãå¼·ãæã£ã¦å·éã«èªãã¨ããã§ãããã "ã³ã¼ãã£ã³ã°æéã®ååããã¹ãä½æã«è²»ãããªããã°ãªããªãã£ã"(p.3)"Railsã«ãã£ã¦å¾ãããçç£æ§ã®åä¸ã¯ããã¹ãä½æã®ä½æ¥ã«å¤±ããã¦ãã¾ãã¾ãã"(p.3) ã¾ãã«ããæ°å¹´ç§ãæ±ãã¦ãæ¼ ç¶ã¨ããã¹ãã¬ã¹ã®æ£ä½ããç確ã«æç« ã¨ãªã£ã¦ããããã ãããã¦ã»ã©ãªããããããã®æ©è½ãRubyã«æ¬²ãã㣠ãï¼ãã¨ããé©ãã¨å ±ã« Scala ãæ¬ç©ã§ãããã¨ã«æ°ä»ãããããã«èªã¿ç¶ãã¦ããã¨ããã®é©ãã®åæ°ã¯æ¸ãã©ããããæå¾ã«ã¯ããæ¯ã¸ã¨å¤ãã£ã¦ãã£ãã ã¯ã...ãããªãã¾ã§ã§ã
ãªãScalaããã«åããªã®ãã ã¼ãã®çµé¨ãå ã«ããã«åãè¨èªã¨éãã«åãè¨èªãæ¯è¼ããªããè¦ã¦è¡ãã¾ããã éãã«åãè¨èª C ããã°ã©ãã¼ã¨ãã¦æåã«æºãã£ãã®ãCè¨èªã§ãã ããã¯ä»¥ä¸ã®ãããªãã®ã§ããã ä½åãã®ãã¡ã¤ã«ã«ã¾ãããã°ãã¼ãã«å¤æ° ç·»å¯ãªå¶å¾¡ãå¿ è¦ã§ããã«ãé¢ããããç¡ç§©åºã«åå¾/éæ¾ãè¡ããã¦ããã¡ã¢ãªã¼ç®¡ç ãã®ãããªè¤éãªæ§é ããã¼ãã®ãããªãã±ã³ã³ä¸¦ã®å¦çè½åããæããªããã«ã«ææ¡å¯è½ã§ããããããã¡ããä¸å¯è½ã§ã ããã§ã次ã®ãããªã³ã¼ãã£ã³ã°ãå¿ããã¾ããã ã°ãã¼ãã«å¤æ°ã使ãããé¢æ°ã«å¼æ°ãå®ç¾©ãã¦æ¸¡ã ã¡ã¢ãªã¼ã®åå¾/解æ¾ãåä¸ãã¡ã¤ã«å ã«éå®ãã ããã§ãã¡ã¢ãªã¼ãå¤æ°åç §ã®å½±é¿ç¯å²ãéå®ããã¼ãã®ãããªãã«ã§ãç解ã§ããããã«ãªãã¾ãã ã§ããããããããããªäºããããªãã¦ãå ¨ã¦ãç解ã§ããã¨ãªã¼ãæ§éã¯ã ããªãå¼æ°ã§æ¸¡ããã ãã°ãã¼ãã«å¤æ°
Play Framework and Ruby on Rails are web application frameworks that help developers build web applications. Both frameworks provide tools and libraries for common tasks like routing, database access, templates and more. Some key similarities include using MVC patterns, supporting SQL/NoSQL databases via libraries, and including tools for unit testing and deployment. Some differences are Play uses
The document discusses DWANGO's use of Scala and the Play framework to build APIs for niconico's Android app. It summarizes the project's history and team structure, describes the core library, API server, and management server built using Scala, and outlines some pros and cons they experienced like case class limitations, Jenkins memory issues, and Akka exceptions in Play.Read less
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}