【发布时间】:2015-04-30 08:38:30
【问题描述】:
我熟悉“Scala coding styles and conventions?”
我还阅读了this article,其中指出程序员每天只能生成这么多行代码,因此具有“更好”语法的语言只能在这个方向上有所帮助。
由于世界上没有完美的事物,Scala 的语法有其缺点(当然有人可以将这些视为纯粹的优点)。我说的是这样的东西:
def someMethod(someParameter: Int): Boolean = {
// import here in the middle of nowhere
import com.example.bad.VeryBad._
// semicolon here? maybe?
val two = 1+1;
// nested function here
def boo(a: Int) = a+1;
// now do something useful
println(boo(two))
// for God's sake don't use return!!!
two == 2
}
如果一个人有 Java 背景(甚至是 C++、C# 等),那么在函数中间有 import 语句、有嵌套函数并且我什至不会进入其他语言结构是有点奇怪的。
我对 Scala 带来的真正生产力提升持怀疑态度。你如何体验这一点?您是否应用了所有(尽可能多的)编码约定,这是真正的好处吗?有没有更好的方法来围绕这种代码风格?
附:也许这整个帖子可以转移到程序员或类似的...
【问题讨论】:
-
你可以看看scalariform
标签: java scala coding-style