You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@dubbo.apache.org by Kun Song <so...@gmail.com> on 2019/01/18 12:04:49 UTC

[DISCUSS] Should we encourage Optional in Dubbo or not?

Hi community,

    We will support Java 8 since Dubbo 2.7 according to Huxing’s comments here [1], one big improvement of Java 8 is `Optional`, which is introduced primarily to avoid `null` and `NullPointerException`. 

    `Optional` will make programs more readable and less bug prone, and some projects such as Apache Pulsar do use `Optional` a lot. However heavy use of `Optional` may produce many small objects and hence introduce some performance costs, my question is should we encourage `Optional` in Dubbo?

    Looking forward to hearing from you.

[1] https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757 <https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757>

Re: [DISCUSS] Should we encourage Optional in Dubbo or not?

Posted by Huxing Zhang <hu...@apache.org>.
Hi,

I think it depends on how much overhead it will brings.
Do you have some performance evaluation of using optional? (e.g. using JMH)



On Fri, Jan 18, 2019 at 8:05 PM Kun Song <so...@gmail.com> wrote:
>
> Hi community,
>
>     We will support Java 8 since Dubbo 2.7 according to Huxing’s comments here [1], one big improvement of Java 8 is `Optional`, which is introduced primarily to avoid `null` and `NullPointerException`.
>
>     `Optional` will make programs more readable and less bug prone, and some projects such as Apache Pulsar do use `Optional` a lot. However heavy use of `Optional` may produce many small objects and hence introduce some performance costs, my question is should we encourage `Optional` in Dubbo?
>
>     Looking forward to hearing from you.
>
> [1] https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757 <https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757>



-- 
Best Regards!
Huxing

Re: [DISCUSS] Should we encourage Optional in Dubbo or not?

Posted by Imteyaz Khan <kh...@gmail.com>.
Kun,
   I appreciate about your care about Dubbo and you consciousness about
things. As you mentioned, it has some additional overhead of having extra
object but those are not  as big. As Optional or like some other features
which gives better redability along with avoiding options where developer
could make mistakes and by removing boilerplate code. Along with this, it
also make easier for new reader from understanding point of view and
increase their confidence or understanding.

As your caring quality and consciousness has brought us this discussion, we
should also be keep countinuing of careness by imrpoving our code
redability.





On Fri, Jan 18, 2019 at 7:34 PM wts <we...@foxmail.com> wrote:

> I think we should because newer features of a language often have more
> good than harm.
>
>
> ------------------ Original ------------------
> From: Kun Song <so...@gmail.com>
> Date: Fri,Jan 18,2019 8:05 PM
> To: dev <de...@dubbo.apache.org>
> Subject: Re: [DISCUSS]  Should we encourage Optional in Dubbo or not?
>
>
>
> Hi community,
>
>     We will support Java 8 since Dubbo 2.7 according to Huxing’s comments
> here [1], one big improvement of Java 8 is `Optional`, which is introduced
> primarily to avoid `null` and `NullPointerException`.
>
>     `Optional` will make programs more readable and less bug prone, and
> some projects such as Apache Pulsar do use `Optional` a lot. However heavy
> use of `Optional` may produce many small objects and hence introduce some
> performance costs, my question is should we encourage `Optional` in Dubbo?
>
>     Looking forward to hearing from you.
>
> [1]
> https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757
> <
> https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757
> >

Re: [DISCUSS] Should we encourage Optional in Dubbo or not?

Posted by wts <we...@foxmail.com>.
I think we should because newer features of a language often have more good than harm.


------------------ Original ------------------
From: Kun Song <so...@gmail.com>
Date: Fri,Jan 18,2019 8:05 PM
To: dev <de...@dubbo.apache.org>
Subject: Re: [DISCUSS]  Should we encourage Optional in Dubbo or not?



Hi community,

    We will support Java 8 since Dubbo 2.7 according to Huxing’s comments here [1], one big improvement of Java 8 is `Optional`, which is introduced primarily to avoid `null` and `NullPointerException`. 

    `Optional` will make programs more readable and less bug prone, and some projects such as Apache Pulsar do use `Optional` a lot. However heavy use of `Optional` may produce many small objects and hence introduce some performance costs, my question is should we encourage `Optional` in Dubbo?

    Looking forward to hearing from you.

[1] https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757 <https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757>

Re: [DISCUSS] Should we encourage Optional in Dubbo or not?

Posted by Kun Song <so...@gmail.com>.
+1, seems right, although I did’t do the benchmark as Huxing said, I found some others’ result like [1], it shows that Optional’s performance is not bad, or even better.

And more importantly, it will improve readability much.

[1] https://stackoverflow.com/questions/34696884/performance-of-java-optional <https://stackoverflow.com/questions/34696884/performance-of-java-optional>

> 在 2019年1月21日,上午10:50,LiZhenNet <li...@gmail.com> 写道:
> 
> +1 ,
> Now ,Dubbo‘s source code language level is old ,We should use some new
> features of java to make the source code more concise and understandable.
> 
> 
> Ian Luo <ia...@gmail.com> 于2019年1月21日周一 上午10:45写道:
> 
>> The potential performance penalty should be trivial, and we should
>> encourage use Optional in Dubbbo. I believe the static optimization from
>> the compiler and the dynamic optimization from the JIT compiler will take
>> care of it.
>> 
>> Thanks,
>> -Ian.
>> 
>> 
>> On Fri, Jan 18, 2019 at 8:05 PM Kun Song <so...@gmail.com> wrote:
>> 
>>> Hi community,
>>> 
>>>    We will support Java 8 since Dubbo 2.7 according to Huxing’s comments
>>> here [1], one big improvement of Java 8 is `Optional`, which is
>> introduced
>>> primarily to avoid `null` and `NullPointerException`.
>>> 
>>>    `Optional` will make programs more readable and less bug prone, and
>>> some projects such as Apache Pulsar do use `Optional` a lot. However
>> heavy
>>> use of `Optional` may produce many small objects and hence introduce some
>>> performance costs, my question is should we encourage `Optional` in
>> Dubbo?
>>> 
>>>    Looking forward to hearing from you.
>>> 
>>> [1]
>>> 
>> https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757
>>> <
>>> 
>> https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757
>>>> 
>> 


Re: [DISCUSS] Should we encourage Optional in Dubbo or not?

Posted by LiZhenNet <li...@gmail.com>.
+1 ,
Now ,Dubbo‘s source code language level is old ,We should use some new
features of java to make the source code more concise and understandable.


Ian Luo <ia...@gmail.com> 于2019年1月21日周一 上午10:45写道:

> The potential performance penalty should be trivial, and we should
> encourage use Optional in Dubbbo. I believe the static optimization from
> the compiler and the dynamic optimization from the JIT compiler will take
> care of it.
>
> Thanks,
> -Ian.
>
>
> On Fri, Jan 18, 2019 at 8:05 PM Kun Song <so...@gmail.com> wrote:
>
> > Hi community,
> >
> >     We will support Java 8 since Dubbo 2.7 according to Huxing’s comments
> > here [1], one big improvement of Java 8 is `Optional`, which is
> introduced
> > primarily to avoid `null` and `NullPointerException`.
> >
> >     `Optional` will make programs more readable and less bug prone, and
> > some projects such as Apache Pulsar do use `Optional` a lot. However
> heavy
> > use of `Optional` may produce many small objects and hence introduce some
> > performance costs, my question is should we encourage `Optional` in
> Dubbo?
> >
> >     Looking forward to hearing from you.
> >
> > [1]
> >
> https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757
> > <
> >
> https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757
> > >
>

Re: [DISCUSS] Should we encourage Optional in Dubbo or not?

Posted by Ian Luo <ia...@gmail.com>.
The potential performance penalty should be trivial, and we should
encourage use Optional in Dubbbo. I believe the static optimization from
the compiler and the dynamic optimization from the JIT compiler will take
care of it.

Thanks,
-Ian.


On Fri, Jan 18, 2019 at 8:05 PM Kun Song <so...@gmail.com> wrote:

> Hi community,
>
>     We will support Java 8 since Dubbo 2.7 according to Huxing’s comments
> here [1], one big improvement of Java 8 is `Optional`, which is introduced
> primarily to avoid `null` and `NullPointerException`.
>
>     `Optional` will make programs more readable and less bug prone, and
> some projects such as Apache Pulsar do use `Optional` a lot. However heavy
> use of `Optional` may produce many small objects and hence introduce some
> performance costs, my question is should we encourage `Optional` in Dubbo?
>
>     Looking forward to hearing from you.
>
> [1]
> https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757
> <
> https://github.com/apache/incubator-dubbo/issues/3186#issuecomment-454236757
> >