d******e 发帖数: 2265 | 1 开始试水 akka-slick-spray-play 技术stack. 大吃一惊。
先看fsm.
case class Supplier(id: Option[Int],name: String,desc: String)
case class SimpleSupplier(name: String,desc: String)
trait Suppliers extends Profile{
import profile.api._
class Suppliers(tag: Tag) extends Table[Supplier](tag, "SUPPLIERS") {
def id = column[Int]("id", O.PrimaryKey, O.AutoInc)
def name = column[String]("userID")
def desc = column[String]("last_name")
def * = (id.?, name, desc) <> (Supplier.tupled, Supplier.unapply)
}
val suppliers = TableQuery[Suppliers]
}
对比 sqlachelamy的大python的metaprogramming
lass QueryItem(Base):
__tablename__ = 'query_items'
mqi_id = Column(BIGINT(display_width=20), primary_key=True, nullable =
False, autoincrement=True)
mqi_item_id = Column(BIGINT(display_width=20), nullable = False)
mqi_site_id = Column(INTEGER(display_width=11), nullable = False)
感觉到scala的零零碎碎。第一没有用到2.10之后的 namedpara和default para.代码难
懂一些,第二,木有meta-programming,只好零碎的写个case class。
下面是提神的srpay json.
import spray.json.DefaultJsonProtocol
object JsonProtocol extends DefaultJsonProtocol {
implicit val supplierFormat = jsonFormat3(Supplier)
implicit val simpleSupplierFormat = jsonFormat2(SimpleSupplier)
}
这个jsonFormat 2,3 5也许是为了性能,但是及时比起haskell这个json实现也是太水
了。毕竟大家用 scala主要还是要语法糖的。归根到底还是没有默认的map 造成的。
scala这个语言是2005年的产物。各种观念严重的过时,特别是还有一种装逼文化,大
家都要写自己的轮子。而且像最难用看齐。结果是系统用那个轮子都头疼。 | l**********n 发帖数: 8443 | 2 python也很烂吧。
【在 d******e 的大作中提到】 : 开始试水 akka-slick-spray-play 技术stack. 大吃一惊。 : 先看fsm. : case class Supplier(id: Option[Int],name: String,desc: String) : case class SimpleSupplier(name: String,desc: String) : trait Suppliers extends Profile{ : import profile.api._ : class Suppliers(tag: Tag) extends Table[Supplier](tag, "SUPPLIERS") { : def id = column[Int]("id", O.PrimaryKey, O.AutoInc) : def name = column[String]("userID") : def desc = column[String]("last_name")
| p*****2 发帖数: 21240 | 3
所以vert.x在JVM的世界还是有市场的。Scala搞的太复杂了,也就是spark上玩玩算了
。
【在 d******e 的大作中提到】 : 开始试水 akka-slick-spray-play 技术stack. 大吃一惊。 : 先看fsm. : case class Supplier(id: Option[Int],name: String,desc: String) : case class SimpleSupplier(name: String,desc: String) : trait Suppliers extends Profile{ : import profile.api._ : class Suppliers(tag: Tag) extends Table[Supplier](tag, "SUPPLIERS") { : def id = column[Int]("id", O.PrimaryKey, O.AutoInc) : def name = column[String]("userID") : def desc = column[String]("last_name")
| l**********n 发帖数: 8443 | 4 我不觉得scala有多复杂。
【在 p*****2 的大作中提到】 : : 所以vert.x在JVM的世界还是有市场的。Scala搞的太复杂了,也就是spark上玩玩算了 : 。
| l**********n 发帖数: 8443 | 5 case class是scala的algebraic data types
example:
sealed trait Order {
def execute: Unit // ignore that Unit return type is not a great idea...
}
case class MarketOrder extends Order {
def execute {
println "executing market order"
}
}
case class LimitOrder extends Order {
def execute {
println "executing limit order"
}
}
An order is either a market or limit order not both. This is what is called
as a Sum type and MarketOrder and LimitOrder are value constructors for the
type Order. | p*****2 发帖数: 21240 | 6 oo+fp还不复杂?
【在 l**********n 的大作中提到】 : 我不觉得scala有多复杂。
| l**********n 发帖数: 8443 | 7 oo和fp是王八对绿豆,互相看不顺眼
【在 p*****2 的大作中提到】 : oo+fp还不复杂?
|
|