欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2, C++/F#/Lisp
Scala
小 (→REPL) |
小 (→版本) |
||
(未显示1个用户的41个中间版本) | |||
第8行: | 第8行: | ||
==新闻== | ==新闻== | ||
+ | [[文件:Scala-logo.png|right]] | ||
*[http://www.scala-lang.org/node/8579 欧盟研究委员会将在未来五年向Scala 开发团队资助230万欧元] | *[http://www.scala-lang.org/node/8579 欧盟研究委员会将在未来五年向Scala 开发团队资助230万欧元] | ||
<rss>http://www.scala-lang.org/rss.xml|short|date|max=10</rss> | <rss>http://www.scala-lang.org/rss.xml|short|date|max=10</rss> | ||
第25行: | 第26行: | ||
More Detail: http://www.infoq.com/cn/Scala | More Detail: http://www.infoq.com/cn/Scala | ||
+ | |||
+ | ==哲学== | ||
+ | 在Scala中,一切都是对象,即使是数值类型(一切值都是对象,一切函数都是值)。Scala更信奉万物皆应为对象。 | ||
==版本== | ==版本== | ||
− | *[http://docs.huihoo.com/scaladoc/scala/2. | + | [http://docs.huihoo.com/scala/language-specification/ Scala语言规范] |
− | *[http://docs.huihoo.com/scaladoc/scala/2.11 | + | *[https://scala-lang.org/blog/2021/05/14/scala3-is-here.html Scala 3 is here!] [https://docs.scala-lang.org/scala3/ Scala 3 Docs] |
− | *[http://docs.huihoo.com/scaladoc/scala/2.10 | + | *[https://scala-lang.org/blog/2020/09/15/scala-3-the-community-powered-release.html Scala 3 - A community powered release] |
+ | *[http://docs.huihoo.com/scaladoc/scala/2.13 2.13] | ||
+ | *[http://docs.huihoo.com/scaladoc/scala/2.12 2.12] | ||
+ | *[http://docs.huihoo.com/scaladoc/scala/2.11 2.11] | ||
+ | *[http://docs.huihoo.com/scaladoc/scala/2.10 2.10] | ||
+ | |||
+ | ==SIP/SPP== | ||
+ | *[https://docs.scala-lang.org/sips/index.html Scala改进过程(Scala Improvement Process),语言及编译器进展] | ||
+ | *[https://scalacenter.github.io/platform/ Scala平台进程(Scala Platform Process), 社区驱动代码库的进展] | ||
+ | |||
+ | ==JDK== | ||
+ | [http://docs.scala-lang.org/overviews/jdk-compatibility/overview.html JDK Compatibility] | ||
+ | |||
+ | ===JDK 9=== | ||
+ | [https://github.com/scala/bug/labels/jdk9 JDK9 Issues] | ||
+ | |||
+ | ===JDK 8=== | ||
==指南== | ==指南== | ||
===OS X=== | ===OS X=== | ||
+ | 使用[[sdkman]]安装Scala或 | ||
sudo port install scala2.10 | sudo port install scala2.10 | ||
ls /opt/local/bin/scala* | ls /opt/local/bin/scala* | ||
第40行: | 第61行: | ||
$ scala | $ scala | ||
scala> :help | scala> :help | ||
+ | scala> (1 to 10) filter (_ % 2 == 0) map (_ * 2) reduce (_ * _) | ||
+ | res0: Int = 122880 | ||
vim Hello.scala | vim Hello.scala | ||
object Hello { | object Hello { | ||
第63行: | 第86行: | ||
===Vim=== | ===Vim=== | ||
+ | *[[ENSIME]] | ||
*[https://github.com/derekwyatt/vim-scala vim-scala] | *[https://github.com/derekwyatt/vim-scala vim-scala] | ||
===Emacs=== | ===Emacs=== | ||
− | *[https://github.com/ensime/ensime-emacs ENSIME Emacs] | + | *[[ENSIME]] [https://github.com/ensime/ensime-emacs ENSIME Emacs] |
*[http://www.emacswiki.org/emacs/ScalaMode ScalaMode] | *[http://www.emacswiki.org/emacs/ScalaMode ScalaMode] | ||
==REPL== | ==REPL== | ||
− | $ scala | + | $ scala |
+ | scala> object HelloWorld extends App { | ||
+ | | println("Hello, world!") | ||
+ | | } | ||
+ | defined object HelloWorld | ||
+ | scala> HelloWorld.main(null) | ||
+ | File IO | ||
scala> import scala.io.Source | scala> import scala.io.Source | ||
scala> val source1 = Source.fromURL("http://huihoo.com", "UTF-8") | scala> val source1 = Source.fromURL("http://huihoo.com", "UTF-8") | ||
第116行: | 第146行: | ||
*Groovy与Scala若能走向统一, 将为Web开发者带来巨大的生产力 | *Groovy与Scala若能走向统一, 将为Web开发者带来巨大的生产力 | ||
− | == | + | ==项目== |
+ | [[scala ecosystem]] | ||
+ | *[[sbt]] | ||
+ | *[[Apache Kafka]] | ||
+ | *[[Apache Spark]] | ||
*[[Play framework]] | *[[Play framework]] | ||
*[[Akka]] | *[[Akka]] | ||
第125行: | 第159行: | ||
*[[Finagle]] | *[[Finagle]] | ||
*[[Norbert]] | *[[Norbert]] | ||
+ | *[https://github.com/scalate/scalate Scalate] 模版引擎 | ||
+ | *[http://json4s.org/ json4s] [[JSON]] for Scala | ||
+ | *[https://github.com/twitter?language=scala Twitter]开发了不少Scala开源项目,Scala是Twitter使用的主要编程语言之一,[http://twitter.github.io/effectivescala/index-cn.html Effective Scala]是Twitter大量工程实践的总结,强力推荐。 | ||
+ | *[http://slick.lightbend.com/ Slick] Functional Relational Mapping for Scala | ||
+ | *[http://squeryl.org/ Squeryl] Scala ORM and DSL | ||
+ | *[[Lagom]] | ||
==[[.NET]]== | ==[[.NET]]== | ||
第138行: | 第178行: | ||
==文档== | ==文档== | ||
+ | *[http://docs.huihoo.com/javaone/2015/CON5331-Scala-in-the-Wild.pptx Scala in the Wild] | ||
+ | *[http://docs.huihoo.com/javaone/2015/CON6923-Finatra-The-Fast-Testable-Scala-Services-Framework-That-Powers-Twitter.pdf Finatra: The Fast, Testable Scala Services Framework That Powers Twitter] | ||
*[http://docs.huihoo.com/scala/scala-2012.pdf Scala:让Java平台上的编程重现生机] | *[http://docs.huihoo.com/scala/scala-2012.pdf Scala:让Java平台上的编程重现生机] | ||
*[http://docs.huihoo.com/javaone/2014/BOF3024-Learning-Scala-A-Practical-Approach.pdf Learning Scala: A Practical Approach] | *[http://docs.huihoo.com/javaone/2014/BOF3024-Learning-Scala-A-Practical-Approach.pdf Learning Scala: A Practical Approach] | ||
*[http://docs.huihoo.com/infoq/qconbeijing/2015/day1/scala-v-clojure.pdf Scala v. Clojure] | *[http://docs.huihoo.com/infoq/qconbeijing/2015/day1/scala-v-clojure.pdf Scala v. Clojure] | ||
− | *[http://docs.huihoo.com/infoq/qconbeijing/2015/day2/scala-clojure-playing-nice.pptx Scala | + | *[http://docs.huihoo.com/infoq/qconbeijing/2015/day2/scala-clojure-playing-nice.pptx Scala and Clojure
Playing Nice] |
+ | *[http://docs.huihoo.com/cufp/2013/Enabling-Microservice-Architectures-with-Scala.pdf Enabling Microservice Architectures with Scala] | ||
==图集== | ==图集== | ||
第155行: | 第198行: | ||
Image:typesafe-console.png|Typesafe控制台 | Image:typesafe-console.png|Typesafe控制台 | ||
image:eclipse-scala-2.11.2.png|Eclipse插件 | image:eclipse-scala-2.11.2.png|Eclipse插件 | ||
+ | image:Spark-Streaming-Cassandra-Kafka-and-Akka.png|技术堆栈 | ||
+ | image:play-framework-components.png|Play框架组件 | ||
</gallery> | </gallery> | ||
==关注== | ==关注== | ||
− | [[image:java.png]] [[image:scala.png]] [[image:akka.png]] [[image:play.png]] [[image:spark.png]] [[image:slick.png]] [[image:lagom.png]] [[image:activator.png]] | + | [[image:java.png]] [[image:scala.png]] [[image:akka.png]] [[image:play.png]] [[image:spark.png]] [[image:slick.png]] [[image:lagom.png]] [[image:activator.png]] [[image:predictionio.png]] |
==链接== | ==链接== | ||
*http://www.scala-lang.org/ | *http://www.scala-lang.org/ | ||
*[http://docs.huihoo.com/scala/language-specification/2.11/ Scala Language Specification] | *[http://docs.huihoo.com/scala/language-specification/2.11/ Scala Language Specification] | ||
+ | *[http://docs.huihoo.com/scala/docs.scala-lang.org/zh-cn/ Scala中文文档] | ||
*[https://github.com/lauris/awesome-scala Awesome Scala] [[image:awesome.png]] | *[https://github.com/lauris/awesome-scala Awesome Scala] [[image:awesome.png]] | ||
*[http://qiujj.com/static/Scala-Handbook.htm Scala Handbook] | *[http://qiujj.com/static/Scala-Handbook.htm Scala Handbook] | ||
第186行: | 第232行: | ||
*[http://www.infoq.com/cn/articles/Scala-PatternMatching Scala模式匹配的亮点——Martin Odersky访谈(四)] | *[http://www.infoq.com/cn/articles/Scala-PatternMatching Scala模式匹配的亮点——Martin Odersky访谈(四)] | ||
*[https://rocketeer.be/articles/concurrency-in-erlang-scala/ Concurrency in Erlang & Scala: The Actor Model] | *[https://rocketeer.be/articles/concurrency-in-erlang-scala/ Concurrency in Erlang & Scala: The Actor Model] | ||
− | |||
− | |||
[[category:programming language]] | [[category:programming language]] | ||
[[category:functional programming]] | [[category:functional programming]] | ||
+ | [[category:lambda]] | ||
[[category:concurrent computing]] | [[category:concurrent computing]] | ||
[[category:actor model]] | [[category:actor model]] |
2021年8月11日 (三) 00:28的最后版本
您可以在Wikipedia上了解到此条目的英文信息 Scala Thanks, Wikipedia. |
Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages. It is also fully interoperable with Java. The Scala distribution is released under a BSD-like license.
目录 |
[编辑] 新闻
自http://www.scala-lang.org/rss.xml加载RSS失败或RSS源被墙
[编辑] 简介
Scala是一门现代的多范式编程语言,志在以简练、优雅及类型安全的方式来表达常用编程模式。它平滑地集成了面向对象和函数语言的特性。
- Scala是面向对象的:Scala是一个纯面向对象语言,在某种意义上来讲所有数值都是对象。对象的类型和行为是由class和trait来描述的。Class的抽象可由子类化和一种灵活的基于mixin的组合机制(它可作为多重继承的简单替代方案)来扩展。
- Scala是函数式的: Scala还是一个函数式语言,在某种意义上来讲所有函数都是数值。Scala为定义匿名函数提供了一种轻量级的语法,它支持高阶(higher- order)函数、允许函数嵌套、支持局部套用(currying)。Scala的case类及其内置支持的模式匹配模型代数类型在许多函数式编程语言中都被使用。
- Scala是静态类型的:Scala配备了一套富有表现力的类型系统,该抽象概念以一种安全的和一致的方式被使用。
- Scala是可扩展的:Scala的设计承认了实践事实,领域特定应用开发通常需要领域特定语言扩展。Scala提供了一个独特的语言组合机制,这可以更加容易地以类库的形式增加新的语言结构:
o 任何方式可以被用作中缀(infix)或后缀(postfix)操作符
o 闭包按照所期望的类型(目标类型)自动地被构造
两者结合使用可方便地定义新语句,无需扩展语法,也无需使用类似宏的元编程工具。
- Scala可与Java和.NET进行互操作:Scala 设计时就考虑了与流行编程环境良好交互,如Java 2运行时环境(JRE)和 .NET框架(CLR)。特别是与主流面向对象语言,如Java和C#尽量无缝交互。Scala有像Java和C#一样的编译模型(独立编译,动态装载类),允许访问成千上万的高质量类库。
More Detail: http://www.infoq.com/cn/Scala
[编辑] 哲学
在Scala中,一切都是对象,即使是数值类型(一切值都是对象,一切函数都是值)。Scala更信奉万物皆应为对象。
[编辑] 版本
[编辑] SIP/SPP
[编辑] JDK
[编辑] JDK 9
[编辑] JDK 8
[编辑] 指南
[编辑] OS X
使用sdkman安装Scala或
sudo port install scala2.10 ls /opt/local/bin/scala* sudo ln -s /opt/local/bin/scala-2.10 /opt/local/bin/scala vim /etc/paths , add /opt/local/bin $ scala scala> :help scala> (1 to 10) filter (_ % 2 == 0) map (_ * 2) reduce (_ * _) res0: Int = 122880
vim Hello.scala
object Hello { def main(args: Array[String]) { println("Hello, world!") } }
运行
scala Hello.scala 或 scala> :load Hello.scala
编译运行 scalac Hello.scala && scala Hello
[编辑] Eclipse
从 Eclipse Marketplace 中选择安装 The Scala IDE for Eclipse,来自 scala-ide.org。
从 Help > Install New Software ...
For Scala 2.11.2
http://download.scala-ide.org/sdk/helium/e38/scala211/stable/site
For Scala 2.10.4
http://download.scala-ide.org/sdk/helium/e38/scala210/stable/site
[编辑] Vim
[编辑] Emacs
[编辑] REPL
$ scala
scala> object HelloWorld extends App { | println("Hello, world!") | } defined object HelloWorld scala> HelloWorld.main(null)
File IO
scala> import scala.io.Source scala> val source1 = Source.fromURL("http://huihoo.com", "UTF-8") scala> val lines = source1.getLines.toArray scala> for (i <- 0 until lines.length) println(i + ": " + lines(i)) // 逐行打印
[编辑] 容器Collection
[编辑] 斐波那契数列
使用了Stream(流) 它与List类似,只不过其中的每一个元素都经过了一些简单的计算处理 #::
scala> def fibFrom(a: Int, b: Int): Stream[Int] = a #:: fibFrom(b, a + b) fibFrom: (a: Int, b: Int)Stream[Int] scala> val fibs = fibFrom(1, 1).take(10) fibs: scala.collection.immutable.Stream[Int] = Stream(1, ?) scala> fibs.toList res32: List[Int] = List(1, 1, 2, 3, 5, 8, 13, 21, 34, 55)
[编辑] 等价性
scala> List(1, 2, 3) == Vector(1, 2, 3) // true scala> HashSet(1, 2) == TreeSet(2, 1) // ture scala> Set(1, 2, 3) == List(1, 2, 3) // false
[编辑] 并行容器
Scala标准库中包含的并行容器通过免去并行化的底层细节,以方便用户并行编程。
val list = (1 to 10000).toList list.map(_ + 42) // 顺序处理 list.par.map(_ + 42) // 并行处理 res2: scala.collection.parallel.immutable.ParSeq[Int] = ParVector(43, 44, 45 ....
[编辑] 并行并发
[编辑] 元编程
[编辑] Groovy and Scala
- Scala和Groovy之间的核心区别在于前者是静态类型:静态类型是性能的关键,Scala的性能远高于Groovy
- Groovy的优势在于易用性以及与Java无缝衔接,Scala的优势在于性能和一些高级特性
- Groovy团队更注重实效思想而更Scala团队具有学术思想
- Groovy与Scala若能走向统一, 将为Web开发者带来巨大的生产力
[编辑] 项目
- sbt
- Apache Kafka
- Apache Spark
- Play framework
- Akka
- Scalatra
- Lift:Scala的Web框架
- Scala.js
- Dropwizard
- Finagle
- Norbert
- Scalate 模版引擎
- json4s JSON for Scala
- Twitter开发了不少Scala开源项目,Scala是Twitter使用的主要编程语言之一,Effective Scala是Twitter大量工程实践的总结,强力推荐。
- Slick Functional Relational Mapping for Scala
- Squeryl Scala ORM and DSL
- Lagom
[编辑] .NET
[编辑] 用户
Twitter,Fouresquare以及LinkedIn,它们的Scala应用程序每天都要处理数十亿的Web事务。
[编辑] 课程
[编辑] 文档
- Scala in the Wild
- Finatra: The Fast, Testable Scala Services Framework That Powers Twitter
- Scala:让Java平台上的编程重现生机
- Learning Scala: A Practical Approach
- Scala v. Clojure
- Scala and Clojure Playing Nice
- Enabling Microservice Architectures with Scala
[编辑] 图集
[编辑] 关注
[编辑] 链接
- http://www.scala-lang.org/
- Scala Language Specification
- Scala中文文档
- Awesome Scala
- Scala Handbook
- Scala 2.12将只支持Java 8
- Scala Improvement Process
- http://docs.huihoo.com/scala/
- Scala Style Guide
- http://download.huihoo.com/scala/
- Scala API
- Guardian.co.uk 从Java切换到Scala
- Scala与Spring:强强联合
- Scala School、Scala 课堂(中文)
- Effective Scala,Twitter的Scala最佳实践。
- Groovy创始人:Java面临终结 Scala将取而代之
- Why we love Scala at Coursera
- 在路上的Scala专题
- Scala Best Practices
- Java 下一代: Groovy、Scala 和 Clojure
- Awesome Scala: 搜罗了当下主要的基于Scala开发的框架与工具
- 在大规模系统中使用Scala——Martin Odersky访谈(一)
- Scala的设计目标——Martin Odersky访谈(二)
- Scala类型系统的目的——Martin Odersky访谈(三)
- Scala模式匹配的亮点——Martin Odersky访谈(四)
- Concurrency in Erlang & Scala: The Actor Model