Cloud Foundry: Design and Architecture
Derek Collison discusses the goals, the design premises and patterns employed in creating the architecture of Cloud Foundry, VMware’s open source PaaS, unveiling internal architectural details.
The content has been bookmarked!
There was an error bookmarking this content! Please retry.
Posted by Alex Blewitt on Jun 10, 2011
The lambda syntax is under discussion again at lambda-dev mail list, but this time, they're actively courting opinions.
The “strawman” syntax provided a temporary means to discuss the aspects of the implementation and details of how lambda and type inference would work in the Java language, but it was never intended as a permanent syntax. Now, four separate syntax variations have been proposed:
#(arglist)(expr) and #(arglist){statements}{ args -> statements }#{ args -> statements} (args) -> { statements }The poll also provides what using real-life expressions might be like with the above syntaxes:
Example of Strawman:
list.filter( #(Foo t)(t.length() > 3) )
.map( #(Foo t)(t.barCount) )
.max();
Example of BGGA:
list.filter( { Foo t -> t.length() > 3 } )
.map( { Foo t -> t.barCount } )
.max();
Example of SotL:
list.filter(#{ Foo t -> t.length() > 3 } )
.map(#{ Foo t -> t.barCount } )
.max();
Example of Redmond:
list.filter((Foo t) -> { t.length() > 3 } )
.map((Foo t) -> { t.barCount } )
.max();
Please see the original post at the lambda-dev mail list for more details on the proposals, and for how to respond to the survey.
Troubleshoot Java/.NET performance while getting full visibility in production
Early Access! Download JBoss Developer Studio 5.0 now, with packages for Mac, Windows or Linux!
RDBMS to NoSQL: Managing the Transition
Combining Inspections, Static Analysis, Testing to Achieve >95% Defect Removal Efficiency
Introducing SQLFire: a memory-optimized, high performance SQL database
VMware vFabric SQLFire - Test drive the data management system with memory speed, horizontal scalability and a familiar SQL interface
The post also has "voting rules" at the end, and people are asked to vote according to them.
You might make them a service by mentioning that in the article.
The survey was for *UP TO* 100 people. It is already closed :(
Personally I think BGGA is the best, with Redmond a close second. What does everyone else think?
but I just completed it 1 min before.
+1
Yeah, I voted the same.
Strawman and Redmond have too many parentheses. Besides that, they make the parameter declaration and the code block look like separate things. Specially Redmond, it looks like it is an operation between two expressions.
I like SotL more than BGGA, because the # makes it immediately clear that it is a block of executable code, not an expression. Also, the # sign could be consistent with a possible alternate 'method reference' syntax:
Istead of using
List<String> trimmedList = list.map(#{ String s -> StringUtils.trim(s) });
since StringUtils has the same signature as the lambda, one could instead write
List<String> trimmedList = list.map(StringUtils#trim);</string></string>
I keep w\ BGGA, usefull.
My favorite syntax is AS:
seperate syntax for expresion lambdas and statement lambdas :
1) Expression Lambdas:
1.1) if len(args) <= 1: optional parentheses
[(] arg0* [)] -> expr
sample1:
list.filter( t -> t.length() > 3 )
.map( t -> t.barCount )
.max();
sample2: empty args
doRun( -> out.println("lambda"))
1.2) if len(args) > 1: required parentheses
(args ) -> expr
Sample:
Sam2<Integer,Integer,Integer> func5 = (x, y) => x * y;
2) Statement lambdas:
2.1) if len(args) <= 1: optional parentheses
[(] arg0* [)] -> { statement* }
list.filter( t -> t.length() > 3 )
.map( t -> t.barCount )
.max();
doRun( -> { out.println("lambda"); })
2.2) if len(args) > 1: required parentheses
(args ) -> { statement* }
Sam2<Integer,Integer,Integer> func5 = (x, y) => { return x * y;};
Ali Ebrahimi</integer,integer,integer><></integer,integer,integer><>
SotL is the most redundant out of all four.
The arrow already tells us it's lambda, we don't need the hash sign for that.
The arrow is not much visible, since it uses a combination of common expression symbols.
The # symbol makes it easy to parse, not only by the compiler - which is pretty irrelevant - but by the reader (we always have to parse code mentally to understand it, no matter how close to english it looks).
this was not even an option. Although, it would have made a huge difference if
they told us that the required parentheses could be removed. Your example is the same
syntax as c# changing => to ->.
Sam2<Integer,Integer,Integer> func5 = (x, y) -> x * y;
Sam2<Integer,Integer,Integer> func5 = (x, y) -> { return x * y;};</integer,integer,integer></integer,integer,integer>
Yes, this is improve version of C#'s lambda syntax.
In C# for zero-len aguments parentheses is not optinal.
test( -> x * y ); //compile fails
Sam0<Integer> func = -> { return x * y }; //compile fails
</integer>
Don't forget about the argument types!
I like the idea of separating expression and block lambdas.
My try:
list.filter((String prizeDescription) {
return prizeDescription.length() > 3; // block syntax
}).map((String prize) -> Integer.valueOf(prize)) // expression syntax
.max();
From given options I would stick with BGGA.
Questions like optional brackets around whatever, fat vs thin arrow, etc, are left for later, like Brian wrote in the message.
And aside from optional brackets, your suggestion is pretty much Redmond style.
I suspect that most people would have identified with the syntax you propose. I have no idea
why the syntax you propose would not have been an option (there are alot of discussions behind closed doors).
Working with c# on a regular basis I can say with great confidence that the syntax is very easy
to read and would fit quite naturally in the Java lanaguage (would not look alien).
Its too late now but I would have voted for BGGA.
Sotl is ok but I don't like strawman or redmond
For heaven's sake, just make the lambda syntax identical to C#. I think most people in Enterprise Architecture have to learn both languages (and C# has stolen so much from Java). Why not pilfer something from C#?
another sample:
from(customers).
where( c -> c.orders.size() > 0 ).
orderBy( c -> s.name ).
select(c -> c.name); // select(c -> list(c.name,c.address));
I wouldn't mind if Java starting ripping off C# wholesale. Just copy everything that can fit in the JVM, then we can look into surpass C#. Really, what's the point of having the best VM if the language can't keep up?
For heaven's sake, just make the lambda syntax identical to C#. I think most people in Enterprise Architecture have to learn both languages (and C# has stolen so much from Java). Why not pilfer something from C#?
For heaven's sake, just make the lambda syntax identical to C#. I think most people in Enterprise Architecture have to learn both languages (and C# has stolen so much from Java). Why not pilfer something from C#?
Well Redmond is the same syntax as C#, of course, so it isn't as if the option is being considered. Also more-or-less the same as the syntax in Scala. BGGA is based on Groovy's syntax, and is, to my mind, slightly nicer to code in though I honestly don't think it makes much odds. The question really is do we have more C#/Scala people or more Groovy people coding in Java today.
On the other hand the strawman syntax has the advantage of being easier to read - the # screams "this is a Lambda" at you, which some people seem to like. As far as I can tell SotL is BGGA with a # glued on the front - I can't see why you would do this. Any Lambda expert care to comment.
A great answer from Neal, anyway (about the subject of how to poll different populations and how ...):
If you want to know how a car *will* handle in traffic, then ask the
physicists. If you already have the car (which we do not) then ask
the drivers.
And if your question is on how to design the car, certainly do not ask
the drivers.
No, Redmond is similiar, but not exact.
For instance, in the example above(Redmond):
list.filter((Foo t) -> { t.length() > 3 } )
.map((Foo t) -> { t.barCount } )
.max();
In C#, this would be:
list.filter((Foo t) => { t.length() > 3 } )
.map((Foo t) => { t.barCount } )
.max();
In general, however, if there is only one expression, you leave out the curly braces:
list.filter((Foo t) => t.length() > 3 )
.map((Foo t) => t.barCount )
.max();
with type inference with my proposed syntax would be:
list.filter( t -> t.length() > 3 )
.map( t -> t.barCount )
.max();
SotL: #{ args -> statements}
from my POV SotL is more readable than any other examples mentioned above, because it sticks out more clearly from (non-functional) surrounding code
because both "#" and "->" are new operators and thus easier to recognize
and because the curly braces make it clear that one deals with code executable later on (as in anonymous code blocks - thus more consistent with existing syntax)
Derek Collison discusses the goals, the design premises and patterns employed in creating the architecture of Cloud Foundry, VMware’s open source PaaS, unveiling internal architectural details.
Andrew Watson talks about the work of the OMG, where CORBA is alive and well (hint: in your car), UML and UML Profiles vs. custom Modeling languages, DDS and other middleware, and much more.
Sohil Shah discusses creating iPhone and Android enterprise mobile applications based on cloud services using the open source platform OpenMobster.
Paul Sanford presents the transformations supported by data throughout its life cycle, and how that can be better done with Splunk, an engine for monitoring and analyzing machine-generated data.
A common “best practice” for unit tests is to only write a one assertion in each test. I intend to question this advice by showing that multiple assertions per test are both necessary and beneficial.
John Rauser presents the architectural and technological evolution of Amazon retail websites starting with 1994 and ending with adopting Amazon Web Services.
Michael Stal discusses system architecture quality, how to avoid architectural erosion, how to deal with refactoring, and design principles for architecture evolution.
Every developer has had to integrate with another system, API or component. Tis article provides strategies to handle the change and for he separating system boundaries.
25 comments
Watch Thread Reply