views:

200

answers:

3

Regarding first-class functions in Scala, it is written in the book Programming by Scala:

A function literal is compiled into a class that when instantiated at run-time is a function value.

When there will be many first-class functions used in a program, will this affect the JVM's PermGen space? because instead of simple functions the compiler is generating classes for each variation of the function value (e.g. in the case of varied definitions of partially applied functions).

+2  A: 

I don't have substantiation for this, but my feeling is that if you're writing any non-trivial program, the amount of space taken up for your program's "real" data will vastly dwarf the amount of space taken up by a few extra function-as-class definitions.

In other words, I wouldn't worry about it.

Carl Smotricz
+1  A: 

It is a proven mathematical fact that the number of classes you generate with first-class functions will be able to asymptotically approach, but never surpass, the number of compiled classes in the full Spring distribution. Don't worry, those pioneers will deal with the permgen issues first!

Mitch Blevins
Are you talking about the load time weaving done in Spring?
Monis Iqbal
I can't upvote it in good conscience, but it _was_ funny! :-)
Daniel
Just a joke. Please don't take seriously.
Mitch Blevins
haha, good one! I got it now :-)worth posting on some place like http://www.geekherocomic.com/
Monis Iqbal
+3  A: 

The memory profile is certainly going to be different than that of normal Java programs, though you can tune pretty much any memory parameter on the JVM.

All I can say, however, is that in one year of deep involvement in the Scala community, I have never seen anyone complain about this.

Daniel
take your word on it for now :)and btw totally inspired by your blog.
Monis Iqbal
Thanks. I should update it more often... it's not for a lack of material.
Daniel