I'll bet that most of time that non-initialized values bite me is when I'm checking if a member variable is null or not. I frequently rely on the fact that Object, String, and most classes default to null, and then I do something like this:
if(this._myVar === null) { } I dread the day I need to go in and initialize a ton of variables that didn't need to be initialized before (across hundreds of classes). Even with this new option, if I port an open source library like Feathers, I'm not going to force everyone who uses it to add -js-default-initializers=true to their project's compiler options when they want to add my library's source code to their project. That would be a bad user experience. I've started trying to manually initialize to null when I add new member variables to Feathers with the idea that this might be required someday, but there's still a ton of existing code that will take a very long time for me to update. I wonder if there's some value in initializing only member variables, and not locals (which I don't usually declare without initializing them). That seems like it could be confusing, though. Or maybe null is worth considering as a special case that's always initialized too. It seems pretty very difficult to get the best of both worlds here. - Josh On Tue, Aug 1, 2017 at 3:31 PM, Harbs <harbs.li...@gmail.com> wrote: > I’d prefer if we could somehow get the best of both worlds. > > I don’t see a solution to that dilemma at the moment, but maybe we’ll come > up with something... > > Harbs > > > On Aug 2, 2017, at 1:24 AM, Josh Tynjala <joshtynj...@gmail.com> wrote: > > > > Don't get me wrong. If you see value in it, then we definitely shouldn't > > remove it as an option. However, for compatibility with the existing > > language, I'd prefer to see initialization be the default instead. > > > > - Josh > > > > On Tue, Aug 1, 2017 at 3:14 PM, Harbs <harbs.li...@gmail.com> wrote: > > > >> Any maybe vice versa... ;-p > >> > >> Alex was planning on looking into whether he can solve the boolean > >> problem, so let’s hold off until he does that. > >> > >> I think comparing two booleans is pretty rare although I have already > run > >> into if(myBool == false) not working. Changing it to if(!myBool) was > simple > >> enough, but I do agree with you that it’s currently broken. > >> > >> For now, we’re going to have to agree to disagree on initializing > values. > >> I’ve seen a lot of value in leaving them undefined. It makes it really > >> clear while debugging whether the value has been set or not. > >> > >> Harbs > >> > >>> On Aug 2, 2017, at 12:54 AM, Josh Tynjala <joshtynj...@gmail.com> > wrote: > >>> > >>> Maybe I'll convince others eventually. > >> > >> > >