Clojure China

5.27 Clojure meetup 分享内容

meetup
分享
clojurescript
clojure
#1

5.27 meetup

**地点:**深圳南山 · 高新园

**分享主题:**基于JVM底层的Functional programming- Clojure&Scala


Topic:

条件分支是程序中常见的流程控制的一种方式,但是分支过多会使函数变得复杂
本次分享Clojure中对条件分支的一些比较独特的处理方式。   

Clojure中的条件分支处理

Author:陈建业


  如何利用惰性求值,保证性能不受损失,同时简化编程、优化程序设计?

Clojure惰性求值——原理、坑、应用

Author:柳朕


Scala:从零到一支技术广告团队 - @凤凰木

Author:凤凰木


typeclass,adhoc-polymorphism and higher kinds - @雪川大虫

scala.Future陷阱 - @雪川大虫

protobuf and gRPC for scala microservices (optional) - @雪川大虫

Author:雪川大虫

3赞
#2

关于惰性求值我这里还有一点需要补充,也是在线上环境遇到的,类似:

出现这个问题后代码不是很好定位,需要对整个系统比较熟悉才能找到。这里有个分享也说到了 lazy 的一些问题,这里摘抄出来

Eric: Could you talk about what would be a good pull mechanism?

Zach: Sure. It’s not that if it’s a lazy-seq it’s bad, because lazy-seq is a very overloaded thing in Clojure, but actually just refers to pure operations you haven’t performed on the data structure yet, but where that actually represents effects.

Like the point that I made is that if you have a function and that function means effects, you’re not actually transforming things, and that’s carried out not from the push but the pull, if I go and I pass in a lazy sequence which is performing effects to go and yield data…

Eric: Like reading in the lines of a file.

Zach: Exactly. Something can go wrong there. There can be an IO exception on that disk that are not actually in the transform phase, because we can’t actually reason about this in isolation, because there is something that someone else can do to screw us up.

The reason that you don’t use lazy sequence is because it fundamentally shrinks it, so that the M&M is all candy-coated shell and sometimes there’s chocolate in it. That’s not good. That’s not what we want.

可能需要阅读原文才能理解上面的片段。最后,lazy 的官方文档也写了不少注意点: