Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 989345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:46:42+00:00 2026-05-16T05:46:42+00:00

Some people say that every programming language has its complexity budget which it can

  • 0

Some people say that every programming language has its “complexity budget” which it can use to accomplish its purpose. But if the complexity budget is depleted, every minor change becomes increasingly complicated and hard to implement in a backward-compatible way.

After reading the current provisional syntax for Lambda (≙ Lambda expressions, exception transparency, defender methods and method references) from August 2010 I wonder if people at Oracle completely ignored Java’s complexity budget when considering such changes.

These are the questions I’m thinking about – some of them more about language design in general:

  • Are the proposed additions comparable in complexity to approaches other languages chose?
  • Is it generally possible to add such additions to a language and protecting the developer from the complexity of the implementation ?
  • Are these additions a sign of reaching the end of the evolution of Java-as-a-language or is this expected when changing a language with a huge history?
  • Have other languages taken a totally different approach at this point of language evolution?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:46:43+00:00Added an answer on May 16, 2026 at 5:46 am

    I have not followed the process and evolution of the Java 7 lambda
    proposal, I am not even sure of what the latest proposal wording is.
    Consider this as a rant/opinion rather than statements of truth. Also,
    I have not used Java for ages, so the syntax might be rusty and
    incorrect at places.

    First, what are lambdas to the Java language? Syntactic sugar. While
    in general lambdas enable code to create small function objects in
    place, that support was already preset –to some extent– in the Java
    language through the use of inner classes.

    So how much better is the syntax of lambdas? Where does it outperform
    previous language constructs? Where could it be better?

    For starters, I dislike the fact that there are two available syntax
    for lambda functions (but this goes in the line of C#, so I guess my
    opinion is not widespread. I guess if we want to sugar coat, then
    #(int x)(x*x) is sweeter than #(int x){ return x*x; } even if the
    double syntax does not add anything else. I would have preferred the
    second syntax, more generic at the extra cost of writting return and
    ; in the short versions.

    To be really useful, lambdas can take variables from the scope in
    where they are defined and from a closure. Being consistent with
    Inner classes, lambdas are restricted to capturing ‘effectively
    final’ variables. Consistency with the previous features of the
    language is a nice feature, but for sweetness, it would be nice to be
    able to capture variables that can be reassigned. For that purpose,
    they are considering that variables present in the context and
    annotated with @Shared will be captured by-reference, allowing
    assignments. To me this seems weird as how a lambda can use a variable
    is determined at the place of declaration of the variable rather than
    where the lambda is defined. A single variable could be used in more
    than one lambda and this forces the same behavior in all of them.

    Lambdas try to simulate actual function objects, but the proposal does
    not get completely there: to keep the parser simple, since up to now
    an identifier denotes either an object or a method that has been kept
    consistent and calling a lambda requires using a ! after the lambda
    name: #(int x)(x*x)!(5) will return 25. This brings a new syntax
    to use for lambdas that differ from the rest of the language, where
    ! stands somehow as a synonim for .execute on a virtual generic
    interface Lambda<Result,Args...> but, why not make it complete?

    A new generic (virtual) interface Lambda could be created. It would
    have to be virtual as the interface is not a real interface, but a
    family of such: Lambda<Return>, Lambda<Return,Arg1>,
    Lambda<Return,Arg1,Arg2>… They could define a single execution
    method, which I would like to be like C++ operator(), but if that is
    a burden then any other name would be fine, embracing the ! as a
    shortcut for the method execution:

     interface Lambda<R> {
        R exec();
     }
     interface Lambda<R,A> {
        R exec( A a );
     }
    

    Then the compiler need only translate identifier!(args) to
    identifier.exec( args ), which is simple. The translation of the
    lambda syntax would require the compiler to identify the proper
    interface being implemented and could be matched as:

     #( int x )(x *x)
     // translated to
     new Lambda<int,int>{ int exec( int x ) { return x*x; } }
    

    This would also allow users to define Inner classes that can be used
    as lambdas, in more complex situations. For example, if lambda
    function needed to capture a variable annotated as @Shared in a
    read-only manner, or maintain the state of the captured object at the
    place of capture, manual implementation of the Lambda would be
    available:

     new Lambda<int,int>{ int value = context_value;
         int exec( int x ) { return x * context_value; }
     };
    

    In a manner similar to what the current Inner classes definition is,
    and thus being natural to current Java users. This could be used,
    for example, in a loop to generate multiplier lambdas:

     Lambda<int,int> array[10] = new Lambda<int,int>[10]();
     for (int i = 0; i < 10; ++i ) {
        array[i] = new Lambda<int,int>{ final int multiplier = i;
           int exec( int x ) { return x * multiplier; }
        };
     }
     // note this is disallowed in the current proposal, as `i` is
     // not effectively final and as such cannot be 'captured'. Also
     // if `i` was marked @Shared, then all the lambdas would share
     // the same `i` as the loop and thus would produce the same
     // result: multiply by 10 --probably quite unexpectedly.
     //
     // I am aware that this can be rewritten as:
     // for (int ii = 0; ii < 10; ++ii ) { final int i = ii; ...
     //
     // but that is not simplifying the system, just pushing the
     // complexity outside of the lambda.
    

    This would allow usage of lambdas and methods that accept lambdas both
    with the new simple syntax: #(int x){ return x*x; } or with the more
    complex manual approach for specific cases where the sugar coating
    interferes with the intended semantics.

    Overall, I believe that the lambda proposal can be improved in
    different directions, that the way it adds syntactic sugar is a
    leaking abstraction (you have deal externally with issues that are
    particular to the lambda) and that by not providing a lower level
    interface it makes user code less readable in use cases that do not
    perfectly fit the simple use case.
    :

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some people say that it is better to use dependency injection. Why is that?
I had this doubt for sometime now, some people say that there's no such
I have seen some instances where people will say you have to use JS
My web-app has this secret place only some people are allowed to use. When
I'm asking because some people say that Zend Framework is not very effective when
Say I'm building a UDF class called StaticLookupUDF that has to load some static
I have seen some people in SO commenting that Singleton Pattern is an anti-pattern.
I know of some people who use git pull --rebase by default and others
I have a common scenario that I am looking for some guidance from people
We occasionally have bugs that appear once in every X runs. Before people check

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.