Live data from Hacker News

Scala Feels like EJB 2

blog.joda.org

111–119 of 119 posts

Re: Scala Feels like EJB 2

#111

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?

I think you mean:

; println(myList)

i.e. reorder those and add a semicolon or put it on the next line

and I agree with pivo that "Jim" :: "Bob" :: Nil should be List("Jim", "Bob"). I'm not sure if these are the same as _Y_'s Fantom code, but both of these print out "List(Jim, Bob)" in Scala.

Re: Scala Feels like EJB 2

#112
post #95

Earlier quoted context omitted.

Data from the database is just as unsafe as data from URL parameters which is why escaping of data must be done in the presentation layer. This is basically the same thing as SQL queries. You have a template like this (most of the HTML omitted). "> Where username and user_type are variables containing data fetched from the database. This template is then compiled to something like the blow. Strings literals of the HT…

This makes sense. You're totally right about the database. I've run into that issue before, but I had forgotten. Your example is similar to the approach that Yesod, a Haskell web-framework, takes. The templating language, Hamlet, will accept many types, such as Text or String, but ultimately everything gets translated into RepHTML before being rendered to a real HTML string that is sent to the client. Whenever you gi…

Yeah, that is how I expect a templating system to work. The one in Rails (modified ERB)works in the same way. It has a SafeBuffer (name taken from memory) class which is a subclass of String. Strings can be converted into the safe class either by escaping or through unsafe conversion which emans that we say the string is safe.

Re: Scala Feels like EJB 2

#113
post #103

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. 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. I think the prime reason for this is that scala permits operator overloading; more than that, in fact, almost every character…

>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. I've been toying with the idea of trying scala for a serious project for a few months, and this part scares me. It's so obviously a bad idea it makes me wonder what other dumb things are in there.

Scala doesn't permit operator overloading, it doesn't even have operators.

Re: Scala Feels like EJB 2

#114
post #113
post #103

Earlier quoted context omitted.

>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. I've been toying with the idea of trying scala for a serious project for a few months, and this part scares me. It's so obviously a bad idea it makes me wonder what other dumb things are in there.

Scala doesn't permit operator overloading, it doesn't even have operators.

Well, that's true, technically. But can't you name your functions things like "++"?

Re: Scala Feels like EJB 2

#115
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.

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

In the non-Java JVM ecosystem, there are always these angry bucket-of-crabs posts from enthusiasts. Ignore them.

Re: Scala Feels like EJB 2

#116
post #15
post #10

Earlier quoted context omitted.

I don't see how Haskell or Scala are better in mathematical abstractions. I guess it would be equally easier (or even much easier) to abstract away this kind of thing in clojure, you could generate all the checking that you would get in Haskell/Scala. The only real diffrence I see is the compiletime checking, right?

Yeah, the big advantage of Haskell (and Scala) for abstract mathematical code is the compile-time type checking. Normally, I'm extremely happy with dynamic languages, because I make maybe 2 type bugs a year. I mean, it's not that hard to remember whether a variable contains an Employee or a String, and that's all you need for some programs. But when you're designing a library, and a variable contains the free module…

I am curious, what kind of programming problem, aside from a math theorem prover, requires free module in a variable?

Re: Scala Feels like EJB 2

#117
post #114
post #113

Earlier quoted context omitted.

Scala doesn't permit operator overloading, it doesn't even have operators.

Well, that's true, technically. But can't you name your functions things like "++"?

Yes. Because Scala doesn't make up random rules about how you name your methods.

If you name your method addAll or ++ is pretty much the same. The same rules apply to both. Both can be called the same way:

    coll1.addAll(coll2)        coll1.++(coll2)
    coll1 addAll coll2         coll1 ++ coll2

Re: Scala Feels like EJB 2

#118
post #112

Earlier quoted context omitted.

This makes sense. You're totally right about the database. I've run into that issue before, but I had forgotten. Your example is similar to the approach that Yesod, a Haskell web-framework, takes. The templating language, Hamlet, will accept many types, such as Text or String, but ultimately everything gets translated into RepHTML before being rendered to a real HTML string that is sent to the client. Whenever you gi…

Yeah, that is how I expect a templating system to work. The one in Rails (modified ERB)works in the same way. It has a SafeBuffer (name taken from memory) class which is a subclass of String. Strings can be converted into the safe class either by escaping or through unsafe conversion which emans that we say the string is safe.

It's tricky. Note activity this week around getting XSS protection right

http://weblog.rubyonrails.org/

I'm not that familiar with lift and Yesod, but it seems like they're both able to use compile-time checks as additional layers of protection.

https://github.com/dpp/liftweb/wiki/lifts-security

Re: Scala Feels like EJB 2

#119
post #117
post #114

Earlier quoted context omitted.

Well, that's true, technically. But can't you name your functions things like "++"?

Yes. Because Scala doesn't make up random rules about how you name your methods. If you name your method addAll or ++ is pretty much the same. The same rules apply to both. Both can be called the same way: coll1.addAll(coll2) coll1.++(coll2) coll1 addAll coll2 coll1 ++ coll2

Those "random rules" make the code base much easier to read. This kind of thing is a big step backwards for people working on large projects, especially people who need to come up to speed on a large code base.
Post reply on HN