Live data from Hacker News

Scala Feels like EJB 2

blog.joda.org

81–90 of 119 posts

Re: Scala Feels like EJB 2

#81

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. val myList = "Jim" :: "Bob" :: Nil myList(println) what's hard about that?

Heh to a Java programmer, the answer would be - everything.

Here are my thoughts on it. - I get val myList is some sort of list... - Seems to be a list of Strings. But what is ::? - Nil means list is nullable. Wait is one of the parts of list 'myList(println)' (looks a bit like Smalltalk)? - Why is println the argument and not the method? Is that syntax correct?!

Compare same thing in Fantom. Note ; is only used as a separator and is equal in all respects to '\n'.

     myList := ["Jim", "Bob", null]; echo(myList)

Re: Scala Feels like EJB 2

#83
post #79

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…

After struggling through using sbt and Maven/Ivy I can say it is categorically worse than what I have used in other languages including ruby-gem python-pip clojure-leiningen (a jvm language) and node-npm. When I say worse I mean doing what the majority of developers want from a module system: easily install modules, not provide a complicated mess of configuration and versions. This isn't to say scala couldn't adopt a…

Did you ever try buildr? I've never used sbt, as, coming from a Ruby background, the fact that buildr sits atop of rake appealed to me more than sbt. It uses maven repositories underneath the hood, but then again, as I understand it, so does clojure-leiningen.

Part of me thinks you're conflating two separate things: build systems and package repository systems. Even people who hate Maven's build system (myself included) tend to agree that Maven's package management system is really good, and as you like clojure-leiningen, you must agree in some sense.

Re: Scala Feels like EJB 2

#84

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.…

“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.”

This is key. People sometimes look at the type signature of the map method (as above) and freak out. It's good to try and understand everything, mind you, and eventually you probably will. The key here is that the crazy signature of the map method simply means the map method will do what you expect. That's it! “But I would write X to do it in my language” is irrelevant, because you don't write the map method. It's provided. There's a paper that describes why the signature is how it is and everything, but you don't care, because it's complicated so that when you're actually using it, it just works.

Re: Scala Feels like EJB 2

#86
post #79

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…

Disclaimer I like Fantom and it is my language of choice. That said, I agree he (Stephen) for every fault he finds Scala finds a way to recommend Fantom. That strikes me as dubious.

Nevertheless I find this statement:

> 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!

Baseless at best. In what aspect is Scala lightyears ahead?

Also what are you implying by saying 'if it can't win on technical merit then best strategy involves negative blogging!'

First Stephen is just one guy. Second I think Stephen just likes Fantom for the same reasons he dislikes Scala and wanted to blog about it.

The authors and the community have overall been quite ambivalent to Scala. As witnessed by this blog from one of Fantom's authors: http://fantom.org/sidewalk/topic/675

Re: Scala Feels like EJB 2

#87
post #58
post #6

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. 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. But some problems benefit from powerful mathematical abstractions, and that's where Haskell…

> How useful is Scala if you don't need to do functional programming with a strong type system? Functional programming with a strong type system, IMO, has much wider applicability than just the esoteric mathematical abstractions (e.g. Haskell/scalaz) that you're asserting is a niche for Scala. I can think of many non-scalaz uses of Scala, but even for non-Scala uses, look at Jane Street's evangelism of OCaml (functio…

I think the issue is not that there aren't applications, it's that people just aren't used to looking for them. As an example, let's think of classical geometry. They figured out the area of circles, the volumes of cones, etc without any calculus. If you know the tricks you can figure it out too, or you can just apply a little calculus and it just falls out. I feel that people dismiss the math as unnecessary because they can get by without it, but in reality the math is always there and sometimes provides much simpler solutions.

I've found over the last few years that my thinking has morphed from primarily OO to primarily functional. It isn't for lack of writing OO code, which I do professionally. I find that my brain loves to think in terms of functional transformations on classes of data types.

Suddenly I find myself noticing when things should be expressed as a monad or monoid. I also find myself thinking in type signatures for dynamic languages and silently cursing the language designer who decided a function can return null without warning. I see patterns in my code and find myself wishing I could overload the semi-colon to implement monadic behavior.

Re: Scala Feels like EJB 2

#88
post #82
post #14

Having dipped my toes in Scala, and written some Clojure, it seems to me: If Java is CVS, then Scala is Subversion and Clojure is git.

And what people want is Mercurial -> ?.

Didn't Stephen already linked to Fantom :P (which is quite a coincidence since Fantom uses Hg as it's DVCS of choice).

Re: Scala Feels like EJB 2

#89
post #56

Earlier quoted context omitted.

The whole point of having an expressive type system is to encode useful properties in it. If a type of String isn't any use to you, give the value a more expressive type . Make a Name type, or a RegEx type, or whatever. Use unboxed types: http://www.chuusai.com/2011/06/09/scala-union-types-curry-howard/ if you don't want to pay an abstraction tax.

Indeed. I think many people seem to miss the fact that types are a language for describing the data in your program. I also think many people do not understand the benefits of type abstraction, perhaps because many languages do not even offer it without requiring boxing. Even if your RegEx type is a String, not revealing that to client code is wise engineering.

My favorite example is dealing with user input on the web. Everything from the data passed by the user's browser to the data stored in the database is just a string of bytes. You could go about representing this as a string, but really there are different types of strings, specifically there are sanitized and unsanitized strings. The database should only ever receive sanitized strings and all input from the user is an unsanitized string. Then you have two simple functions that map from one to the other, say, escapeString and unescapeString.

If you don't represent these as different data types it's very easy to accidentally lose track of if you sanitized a string or not. Did you sanitize it before you placed it in your model, or do you need to sanitize it before to display it? Did we unsanitize it when we pulled it from the DB? Should we be displaying it unsanitized in the HTML?

If you encode these differences in opaque types it suddenly becomes impossible to make a mistake. It suddenly becomes very easy to reason about a program. Based on the type you can immediately know what type of string you are dealing with and not have to every ask yourself if it has been sanitized yet.

For me, that reduces the complexity of the application and makes reasoning about the program easier. Wise application of types to semantic differences in data can really make a program easier to build.

Re: Scala Feels like EJB 2

#90
post #76
post #62

Earlier quoted context omitted.

Yes, you can do that by using types indexed by a number. See https://apocalisp.wordpress.com/2010/06/16/type-level-progra... for one take on this.

Scala, with its “type-level programming”, crazy operator overloads and weird DSLs, is at a similar precipice as C++ was back when people started doing insane stuff with template metaprogramming (around the time of Alexandrescu's “Modern C++ Design”, 2001 maybe?). Unfortunately, I don't think many Scala users were around at that time or in that community, so lessons of the past might be learned the hard way again. The…

Yes, I guess I answered the letter of his question... but I personally wouldn't use collection types indexed by a size unless (a) I really really needed to be sure about this particular invariant (b) there was a bit more sugar and automation. In most cases the added verbosity and complexity involved would not generally be a win over just using an assertion. However, it is nice to know you have the option of static enforcement should it be desirable.
Post reply on HN