TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Scala Feels like EJB 2

141 pointsby thebootstrapperover 13 years ago

19 comments

ekiddover 13 years ago
Scala's great, if you have a gorgeous Haskell program and you want to port it to the JVM. Unfortunately, by itself, that may be a niche market.<p>If you want a dynamic language, you have lots of great choices. If you want powerful syntactic abstractions, you have Clojure, Lisp or Racket. You can win big with any of these tools.<p>But some problems benefit from powerful <i>mathematical</i> abstractions, and that's where Haskell and Scala start to shine. For example, if you need to do Bayesian filtering, you can bury all the math in a monad, and make Bayes' rule as easy as an 'if' statement. (I've got a blog post for the curious: <a href="http://www.randomhacks.net/articles/2007/02/22/bayes-rule-and-drug-tests" rel="nofollow">http://www.randomhacks.net/articles/2007/02/22/bayes-rule-an...</a> ) And when your library designs start involving generalizations of linear algebra, even Ruby-lovers may learn to appreciate a strong type system.<p>But this raises the real question: How useful is Scala if you <i>don't</i> need to do functional programming with a strong type system? Most people don't, at least today, and the jury's still out on whether it will ever be mainstream. Certainly, some smaller companies will use Scala and win big in specialized domains. But if Java hackers want to claim that Scala's an inappropriate tool for their jobs, who am I to argue? I write far more Ruby than Haskell, because I encounter lots of work that's well-suited to Ruby. (Of course, there's also Akka and a lot of other useful Scala features, which may appeal to people who don't need FP.)<p>So if Scala becomes seriously popular, I'll be delighted. But a large fraction of Scala's complexity is devoted to niche use cases, and that may make some people unhappy if they're merely looking for a "better Java".
评论 #3265801 未加载
评论 #3266042 未加载
评论 #3265171 未加载
评论 #3265175 未加载
dkhenryover 13 years ago
A few things about this post.<p>firstly it is never good when you start out a discussion by saying now I know people will disagree but thats because their bigoted zelots. Its kind of disingenuous to attempt to post a technical dissent filled with personal opinion and preface it with that kind of clause inevitability allowing you to label any dissent as "See those scala zelots are at it again"<p>That being said this is an article that attempts to raise technical problems with scala but really just list a few of the authors own personal gripes with the language. In order here are his complaints<p>1. Scala doesn't have a rigid versioned module system 2. The functional way of doing concurrency isn't how I like to do concurrency 3. The scala community isn't helpful enough for me 4. The type system is too powerfull 5. The syntax is too flexable 6. There aren't enough tests in the compiler test suite<p>Its alot of the same thing I have seen when people try to list "The" problems with the language and not "Their" problems with the language. Technically there is only one argument that could even hold water thats about the module system . Which if he really needs a module system for his work then that is a technical limitation of the language and he might consider using a better tool for his job. The rest of it however is just nonsense and personal opinion pretending to be technical dissent.
评论 #3265069 未加载
nirvdrumover 13 years ago
I've been picking up Scala on-and-off for the past few months. "Programming in Scala: Second Edition" is one of the best tech books I've ever read. The authors assume you already know how to program, offer mutable &#38; immutable approaches to nearly everything, anticipate esoteric questions in the footnotes, and even have a good sense of humor.<p>The book also weighs in at 883 pages and I was astonished how much of it I needed to read to even get started. Once I did, I very much like what I saw. But I was a big fan of ML back in grad school.<p>I do share some of the blog author's gripes though. Most of the popular Scala libraries are just a mess of DSL operators that have no real world association. I'm constantly having to look up what an operator means. I still have no clue how to use the Dispatch library, since the concepts it encapsulates are about 400 pages deeper into the book than I'm currently at. This, just to issue an HTTP GET request. I really thought there might be something on the lines of Ruby's rest-client library.<p>Additionally, my issues with versioning occur at a much simpler level. The release notes of any given Scala release are devoid of anything useful. Usually it's just a list of JIRA issue numbers (not the issue titles). And then there was this whole debacle around 2.9.0.1 and how SBT called the version. That took me 4 hours longer to work than was really necessary.<p>So, anyway, I do have some Scala projects. Incidentally they're all Java interop because I just can't wrap my head around how to use most of the Scala-specific libraries. But I've found it works really well in those situations. Deep down I really do like the language. The Scala ecosystem leaves a lot to be desired, but fortunately I can pull in stuff from elsewhere on the JVM.
评论 #3265668 未加载
codelionover 13 years ago
Most of the comments here talk about how whatever useful can be done in Scala can be done in some other language. That is not the point, Scala is a good language because<p>- Compatible with JVM<p>- Strong type system<p><pre><code> - Linear Typing - Substructal Types - Local Type inference </code></pre> - Concurrency constructs built in as actors (Akka)<p>- Integration of OO and functional paradigms<p>- Supports Higher Order Programming<p>- defn-site Variance based Parametric Polymorphism<p>- Mixin Class Composition for finer grain reuse<p>- Traits provide stackable behaviors (aspect-oriented style)<p>- Embedded Polymorphic Domain Specific Language (DSL) using dependent path types<p>Every language design is a trade off, but Scala is more expressive and concise than Java. Sometimes that may look to you as code which is unreadable. Other languages like clojure make some other trade offs. But Scala tries to bring some of the benefits of functional programming (in say Haskell) to Java.
评论 #3265377 未加载
评论 #3265587 未加载
srequeover 13 years ago
It's unfortunate that there a number of very smart people from the Haskell community that are trying to mold Scala in Haskell's image that also appear to be very prominent and active in the community. Other than having some negative effect on Scala's public image, however, there's nothing wrong with what they are doing. People work on open source projects that interest them, and it is an interesting exercise for some to find out how different Haskell constructs can be encoded in Scala.<p>However, the rest of us lesser mortals use Scala very differently, and we far outnumber these people. If you pay attention to Martin Odersky, the creator of the language, you'll notice that he is more interested in serving our needs than those of the Haskellites. He's outright refused to make IO monads a core part of the language, for instance, even though they have pushed for it. He's also said that scalaz is on another planet entirely, and he's asked publicly that people stop using symbolic method names in their libraries unless they have external meaning beyond the library. This guy gets it. He really has created a language that is powerful, but also practical, an excellent language for writing code that is readable, maintainable, efficient, and concise.<p>The author of this article admits that Scala doesn't feel right to him. He then proceeds to try to justify that feeling in his mind with some very weak arguments. For instance, his module argument oh so coincidentally happens to play into fantom's strengths alone, as No other JVM language is trying to tackle this problem right now. He is right about the lack of tests and binary incompatibility, but these are known issues that already have been addressed to some extent and are continuing to be addressed. They are not core issues with the language itself.<p>Scala is lightyears ahead of Fantom and Fantom will probably never catch up. If Fantom can't win on technical merit, then apparently the next best strategy involves negative blogging!
评论 #3266796 未加载
评论 #3266532 未加载
评论 #3267126 未加载
nessus42over 13 years ago
Where I worked, we switched from Java to Scala a few months ago, and we're all loving it. I really don't understand Stephen Colebourne's criticisms. Well, actually, sure I understand every one of his criticisms, but I could make equally damning or more damning criticisms of just about every programming language. No programming language is perfect. On the other hand, we find Scala to be much more expressive than Java. In Scala, I can write code in a natural way, rather than the way that Java wants to force me to write it. The result is cleaner, more elegant code, that is significantly shorter with much less boilerplate and code repetition, and easier to understand.<p>Sure the type system is complicated, but I don't really have to understand all its nuances in order to get my program to compile and work. When you use Scala, after a short while you just develop an intuition for it.<p>The comparison to EJB 2 is a bit nutty, if you ask me, since writing code in Scala tends to be the antithesis of all the terrible Java monster enterprise library crap. The libraries that people use in Scala tend to be much simpler and more straight-forward.<p>I do agree that there's a contingent of the Scala community who seem to want to rub their fluency with category theory in your face. This is hardly representative of the entire community, however, and I'm sure they must exist in the communities for almost every functional programming language these days. The solution for this is for people to come up with more intuitive explanations for the powerful tools that category-theory inspired abstractions provide. I know that this can be done, and it <i>will</i> be done, when functional programming become mainstream enough that it attracts better writers.<p>(I, myself, have been thinking of writing up a little essay called "The Mapcat is the state monad of Massachusetts" to try to explain monads in a better way than comparing them to space suits, or whatever. Okay, okay... mapcat isn't a <i>state</i> monad, but I think the title's funny anyway.)
评论 #3266710 未加载
bad_userover 13 years ago
Consider this method signature:<p><i>def map[B, That](f: A =&#62; B)(implicit bf: CanBuildFrom[Repr, B, That]): That</i><p>All this complexity to allow for automatic conversions (the following will return a Set[String]) ...<p><i>BitSet(1, 2, 3).map { _.toString + "!" }</i><p>In a dynamic language, the signature of map is simply this: (a → b) → [a] → [b]<p>The big difference is that the language doesn't care about types "a" and "b" until runtime. You're the one that cares about it, only on a need-to-know basis. Hence the implicit conversions become explicit (although conversions are less necessary) and code correctness is guarded by unit tests, which you need with Scala anyway. Also, the implementation of "map" in a dynamic language is something that a junior developer can come up with.<p>So the biggest problems I have with Scala:<p><pre><code> 1) it is not readable 2) it separates developers in two camps: library designers and users 3) it does not provide clear benefits over dynamic languages (Haskell does)</code></pre>
评论 #3265285 未加载
jzoidbergover 13 years ago
The article seems very fear driven, many of his arguments simply do not gel with my experience.<p>We have been using Scala for 4 months now and have the first cut of our product released:<p>The Scala community have been great - we have had insightful answers on the Lift, Akka, Dispatch and Scala users list and on stack exchange.<p>We have used parallel collections and Akka actors to get good scalability without the usual pain. We do have some mutable data structures where it makes sense - we appreciate the flexibility to do that. The distinction between mutable and immutable data structures is pretty easy to read in the code.<p>Our code base is very concise, and i think readable for the breath of functionality we have implemented. We have not used type level programming, simple Scala constructs like pattern matching, collections and closures make a huge difference. You can write obtuse code in Scala - we choose not to.<p>In short we see Scala as a competitive advantage going forward.
michaelcampbellover 13 years ago
Everything's unreadable until one learns to read it. This is a classic non-argument that people buy into for reasons I can't comprehend. Is Scala <i>harder</i> to read than other languages? Perhaps, but then just say that.<p>As Rich Hickey pointed out recently, "I can't read German; does that mean it's unreadable?"
评论 #3265478 未加载
krookooover 13 years ago
There are those who say scala is complicated, and there are those who actually learn it and once they do they love it more than anything out there. So yeah, I love scala.
评论 #3265133 未加载
jongraehlover 13 years ago
For the past few years, I've used Scala every time I need to do something on JVM (which isn't too often). Otherwise I use Python or C++. I don't blog about it.<p>Scala is clearly an improvement over Java (although I wish they'd kept a C-style for loop). I happen to slightly prefer it to Clojure (which is also better than Java for my purposes).<p>In the non-Java JVM ecosystem, there are always these angry bucket-of-crabs posts from enthusiasts. Ignore them.
codelionover 13 years ago
Odersky says Scala is PlayFramework not EJB2 <a href="https://twitter.com/#!/odersky/status/138950022703222784" rel="nofollow">https://twitter.com/#!/odersky/status/138950022703222784</a>
twpover 13 years ago
Having dipped my toes in Scala, and written some Clojure, it seems to me:<p>If Java is CVS, then Scala is Subversion and Clojure is git.
评论 #3266684 未加载
timfover 13 years ago
Chris Marshall has a notable response in the comments: <a href="http://blog.joda.org/2011/11/scala-feels-like-ejb-2-and-other.html?showComment=1322001467368#c3731872064551816780" rel="nofollow">http://blog.joda.org/2011/11/scala-feels-like-ejb-2-and-othe...</a>
beagledudeover 13 years ago
Scala is awesome, when combined with AKKA it's even better. We're much more efficient then we ever were in Java. Also, ops doesn't know it's not java since they can use all the same jvm tools.<p>val myList = "Jim" :: "Bob" :: Nil myList(println)<p>what's hard about that?
评论 #3266682 未加载
评论 #3267871 未加载
评论 #3267404 未加载
ajucover 13 years ago
So Scala is to Java what C++ was to C
评论 #3267695 未加载
Maven911over 13 years ago
Could someone explain to me what are entreprise javabeans and how they are used - in easy to understand language
评论 #3267506 未加载
adabsurdoover 13 years ago
i used scala for a few months. it sounded very promising, java without the verbosity. but in the end i decided to stop using it.<p>The biggest problem for me was readabilty. Scala is the first language that i've learned where at first i couldn't just read code and immediately guess what it does.<p>I think the prime reason for this is that scala permits operator overloading; more than that, in fact, almost every character can be an identifier. This results in often very cryptic code and libraries, because you can't guess what that function does without reading its definition. quick, what's the difference between +++ and ::: ? what's /: and /:\ ? You can't even google it!<p>The other big problem for me was the type system. At first it sounded really great, and in fact the amount of compile-time code verification that you can achieve is indeed impressive. But in practice, i found myself fighting with the type system a lot, for example when trying to reuse a function with generic type restrictions that I had't written: some time these can get very long and your only choice is to copy-paste them from the original definition.<p>Also, how do you test that your type constraints are correct? you can't, by definition, write compilable code that would invalidate them.<p>Finally, it turns out that a lot of the bad stuff that's in java ends up in scala also, because of runtime compatibility concerns. in particular, scala's generics are an extension of java's. so, for example, almost all generic type information is lost at runtime, except for some extra metadata that scala stores in the object. this results in pretty ugly code when you have a dynamic object and you need to use it with a generic method.
评论 #3267553 未加载
Runarover 13 years ago
This post feels like utter bollocks.