64 points · by lmm · 12y ago · 106 comments
EDIT: If it gets changed, the submitted title is "Why Scala is the best language available today"
Hey man, that's like... your opinion
In my opinion types are a poor man's schema, my email is not a string, it's a email, and my longitude/latitude pair are not just ints they have specific ranges, saying that longitude is 500 is as wrong as saying it's "foo". I use schema libraries and asserts to both document the code and make sure you can't feed it wrong data. I even generate automatic html documentation out of my schema so my clients know what to send me, and this only in the places I need, no need to a schematize or assert every simple function with obvious parameters.
Maybe type annotation is more useful in OO languages, but as a clojure programmer, for me, data is just data, there's no behavior associated. If I really want type safety at compile time I can use core.typed only in the places I need it.
As a former long time java programmer (who tried scala for months) I welcome my new found freedom from type slavery, but that's just... my opinion.
What's the distinction you're drawing here?
> my email is not a string, it's a email, and my longitude/latitude pair are not just ints they have specific ranges, saying that longitude is 500 is as wrong as saying it's "foo"
I fully agree. Those sound like exactly the kind of thing I would enforce using types.
> and this only in the places I need, no need to a schematize or assert every simple function with obvious parameters.
How do you enforce that all code paths go via your schema? Just visual inspection?
Unfortunately dependent types are incredibly difficult to get working (Scala's type system is already turing complete (and can handle path-dependent types) and true dependent types would make reasoning about nigh-on impossible).
I would argue that you're dealing with a sub-typing problem here, Email <: String, LongLat <: (Int, Int)*
* I would say in Scala:
case class LongLat(longitude: Int, Latitude: Int)they are kinda cool, but also limited as hell.
presumably it just doesn't have a short syntax for them? if so, given what i know of the rest of scala, i'm surprised one can't be defined...
I really value strong typed languages in such projects.
With dynamic ones, it is always a guessing game.
Been on this game for quite some years now, the corporate world gives zero value to unit tests, regardless of what gets discussed and presented as success stories on conferences.
IME, strong (or, more to the point, static) typing doesn't eliminate the need for unit tests. Correct types don't guarantee correct values.
Here's the documentation for custom types in F#:
http://fsharpforfunandprofit.com/posts/conciseness-type-defi...
http://fsharpforfunandprofit.com/series/understanding-fsharp...
http://fsharpforfunandprofit.com/series/designing-with-types...
Types are a very good way to model your data strictly.
Err, you know that a type system could take care of all of those contraints, right?
Because you come across as types for you are restricted to be just the known scalar or barebones object types.
Having an email just as a string if far from the exhausting the specialization you can do using an "email" type.
Dependent types to the rescue!
Dependent types are nice, but much what the grandparent wants can be achieved fine with normal types. E.g. in Haskell, define the Longitude type and some helper functions
newtype Longitude = Longitude Double
fromDouble :: Double -> Maybe Longitude
...
And don't export the Longitude constructor to maintain invariants. Obviously, the same can be done in OO languages that allow you to hide members, C (via opaque pointers), etc.Use the right tool for the job, and there are jobs where Types are the right tool.
I don't think that's true. I think that the ritual incantations to the type system required in, particularly, C++/Java-style languages are a hindrances that outweighs the benefits of static typing on very small projects.
And the limitations of limited static type systems can also be a hindrance.
But when you have a richer type system and/or type inference that reduces the necessary incantation, the size of project on which static typing becomes a net positive drops.
Because you will screw up.
I'd personally say Python is best.. for general data manipulation. But it's slow.
Go is best.. for network and concurrent programming, but it's rough around the edges and comparably low level.
C is best.. for precise control of the hardware. No hand-holding here. But that's also it's weakness.
C++ is best.. has all the bells and whistles you can think of, and more. More of the later probably.
PHP is best for.. masochists and people used to it. It's also one of the quickest ways to create a web application by completely abstracting the low level stuff away.
C# is best.. for religious people and people who buy into the Microsoft ecosystem. Strong library selection.
Java is best.. for people who are looking for a job. As boring as enterprise is, they have money and look for Java devs.
VBA is best.. if you are on a locked down corporate environment, just because it's almost the only option.
<insert language> is best.. <advantages>, but <constraint>.
So, you want to tell me that Scala has all advantages and none of the disadvantages? I don't buy it..
Critically, never take a "best" statement at face value since these things can't be measured anyways.
I'm productive with Python, but it lacks many useful things and I'm no longer comfortable with the rampant mutation.
I like Haskell and the type system is extremely useful (typeclasses ftw), but I haven't managed to become productive using it.
Scala scares me like C++ does, through sheer size.
Rust is very interesting, but not yet mature enough. I'm not even certain that level of abstraction would generally be the one I want.
Clojure is perhaps the closest (especially with core.typed and ClojureScript), but the dependency on the JVM is unpleasant for me to say the least.
I also said not that Clojure and Haskell were vastly superior in every way, but that they individually represented their language niches better.
I'd also use Scala over Haskell in a lot of cases and I don't think Clojure necessarily represents FP better. Either way these arguments are still pointless.
That's cute; he seems to think the reason for managing configuration information in separate files is due to the inflexibility of Java. Let's hope that one day he has to deal with a non-trivial project and is enlightened.
Looks like GrǬǬvy, also begun in 2003, went the other way, making its language grammar larger but its core methods small.
Beginning with a clone of Java's grammar, they expanded it with lots of extras, see http://svn.codehaus.org/groovy/trunk/groovy/groovy-core/src/...
And for the core methods http://groovy.codehaus.org/api/org/codehaus/groovy/runtime/D... (note the methods marked "deprecated" still actually exist but were repackaged into other classes for Groovy 2.x).
EDIT: actors -> the actor model
In the sense in which it is accurate to say that "design patterns are merely patches for missing language features" -- that is, design patterns that are applied as code templates -- anything that can be implemented once as a library is not a design pattern in the language where that is possible.
Perl has an experimental Actor model library threads::lite - https://metacpan.org/pod/threads::lite
For distributed scenarios NServiceBus is a good option although it's a bit different kind of model.
Yes, you can use Akka from Java. Just to show that you don't need something like Scala to implement an actor system.
I confess I haven't used it before though...why use pulsar when I can get away with using akka?
A new programming language that hopes to achieve wide adoption is a big deal. A very big deal. C has been in widespread use for 40 years now, and Java for almost 20. You could switch a language every five years or so, but that means that you're not in "mainstream software development" but in some kind of Silicon Valley startup (a tiny minority among software developers). Mainstream software developers don't switch languages every five years, and in most case, not even every decade, so they'd better get the language right.
But what makes a programming language right? That is a big question. Obviously, adoption, which is also a result of marketing, is a major factor regardless of the language's intrinsic merits. Also, you must consider your domain. Ruby is great for short-lived projects; Java is great for big, complex projects with dozens or hundreds of developers.
But assuming you've taken all that into account, making a switch better be really justified. The problem with the article, I think, is it focuses on specific language features (effects, delegation, etc.), which is what got Scala into trouble (IMO) in the first place.
When thinking about a new programming language, especially one not intended for research but for widespread adoption, this is not the way to go. I believe we should start by thinking what are the big problems with software developments, and how we can address them with a new language – one that does not simply offer this or that convenient feature, but gives a really big advantage, one that merits a switch. Java has done it with a GC for a C++-like language, and to a lesser degree, with threads. Clojure and Erlang address the issue of state - Erlang because of fault-tolerance, and Clojure (mostly) because of concurrency.
On the other hand, some languages, like Ruby, focus on "developer productivity", which often means getting to working, useful code quickly, while maintaining good readability. This is, no doubt, important (for some domains much more so than others), but is this a major problem of software development today?
Also, the article talks a lot about type safety. But type safety is language feature which is a means to an end. That end can be project maintenance/manageability, and arguably more correct code. But are there other ways of achieving this goal? I'm not saying there are, I'm just saying we should start by studying the problem, not examining particular solutions. Every language feature must be a part of solving a big problem; big enough to justify switching languages. After all, that's is a big deal so we better get it right. So, what big problem are you trying to solve?
I also find it a bit irritating that you love the vague claims like in the last article, but don't like articles with a precise and to-the-point description of issues. It's almost like you want to love all negative articles on Scala, but have to hate even neutral or remotely positive ones, completely irregardless of the quality of the article and the issues raised in them.
It leads to this whole train-wreck of reasoning here which you seem to be forced to post in pretty much every post with the word “Scala” in it.
Nobody can prevent you from spending your time with things you hate, but from my experience, live is happier if you spend it on things you love.
I can't say it any better than dancapo said it here: https://news.ycombinator.com/item?id=6844600 Maybe you should really at least try to consider the points he raises.
Also, I try to form my opinions after a lot of consideration, and you can be certain that I read most arguments against them. Sometimes I remain unconvinced, as in the case of Scala. I am not prejudiced against Scala. I think Martin Odersky is a very smart PL researcher, and when Scala first came out many years ago, I actually strongly advocated adopting it in a very, very large organization. My opinion has changed over the years, partly because of the path Scala has taken, partly because of new options that are now available, and partly because I've gained more experience with large projects and large teams.
My own criticism of Scala is, I believe, well informed; the fact that you consider its lack of minute detail as lack of evidence demonstrates the Scala's community obsession for tiny details to the detriment of a grander vision.
The comment you referred me to demonstrates the same. I do not dispute that Scala's features are well integrated in the compiler. It's a very nice compiler. What I meant in my comments on those other threads is that Scala mixes concepts whose mix creates a negative synergy, whose only purpose is that sometimes you can use one concept and sometimes you can use another. It doesn't matter that case classes are implemented as classes. Conceptually, they are meant to be used differently; again, that's getting bogged down in detail. Scala never gives a compelling reason why it is so useful to mix different concepts in a single language and pay such a heavy price in complexity, other than "sometimes it's better to use one and sometimes another". That's not a hallmark of great design. What big software development problem (as opposed to a PL research problem) does Scala solve?
Sorry, but no it isn't and it's painfully clear to a lot of people.
> the fact that you consider its lack of minute detail as lack of evidence demonstrates the Scala's community obsession for tiny details to the detriment of a grander vision.
You have a lot of talent in interpreting things the way you want. If people would have said “there are minor inconsistencies, but Scala has a grand vision it focuses on and that's what counts” you would have turned around and argued that it's the lack of attention to detail which makes everything in Scala horrible.
Sorry, but I have seen how you do this more than I care to count already. It gets tiring and embarrassing to read.
People have tried to tell you that “making up facts to retroactively fit your opinions” is not a good thing and then you just do it again:
> I do not dispute that Scala's features are well integrated in the compiler.
Let's just ignore the way you try to derail the debate here and move the goalposts around for a minute, because probably everyone who has spent 5 minutes to look at the actual source code realizes how mind-boggling wrong this claim is.
The compiler goes to great lengths to catch all the weird corner cases and shield it's users from inconsistencies which e. g. sometimes arise when running on a JVM or having to deal with other languages running on that platform.
Please have a look at javac, fsharpc and others. None of them come even close to effort scalac does to present its users with a consistent, coherent behaviour. They just let the user deal with all those minor annoyances.
> Scala never gives a compelling reason why it is so useful to mix different concepts in a single language and pay such a heavy price in complexity, other than "sometimes it's better to use one and sometimes another". That's not a hallmark of great design.
Sorry, you mentioned it yourself already that your mainly interested in a language which dresses up Java's minor pain points. I can understand that when coming from that point of view trying to understand the reason why Scala does things in a certain way is not interesting. But you should at least differentiate between “there is no reason” and “I didn't care enough to look for the reason”.
> What big software development problem (as opposed to a PL research problem) does Scala solve?
- Abstraction and code maintenance: In all languages, you can arrive at a certain point where refactoring/abstracting things any further (to increase readability, maintainability, modularity) doesn't add more value than it costs. The difference is that in Scala you are the one who can make this decision, not the compiler. This is a huge advantage, which can't be understated, but is also hard to describe if you haven't seen it yourself. Dropping into an unknown code base and being able to be positive that changing/fixing/modifying one item involves touching one place, instead of possibly dozens or hundreds of pieces of code, is a considerable benefit. (Not really related to this, but implicit classes are an interesting example of how lots of code maintenance issues are made impossible by design, when compared to inferior approaches like extension methods.)
- Long-term evolution and extensibility: Scala gives you lots of options and tools to evolve your code in a way which minimizes the impact on the consumers of your code. Have a look at how Scala doesn't expose any public fields in classes, how easy ensuring binary compatibility is with tools like the Migration Manager, have a look how typeclasses enable you to design your code with extension points in mind right from the start, have a look how @deprecated and friends allow you to have meaningful transitions between old and new code if necessary. This reduces the amount of technical debt accumulated over a period of time and makes it easy to keep existing code bases up to the changing/growing requirements of the real world.
- Closing the decade-old gap between data inside and data outside of a language: Type providers go a huge step toward a state where developers can just stop worrying whether their data is in the source code of their language, inside a database, stored in an XML file, or wherever else. This will be a huge productivity boost to all developers.
"Even F# simply isn't powerful enough (never mind OCaml)" evidence, please?
I think this a statement which deserves some actual facts.
There's plenty in Scala that other languages do better, the author's claim is that no languages puts all of its features together better than Scala.