Giter VIP home page Giter VIP logo

Comments (3)

goderbauer avatar goderbauer commented on July 20, 2024 1

Performance

In a very contrived benchmark (#148261) const ness was giving us a speed-up in build times of 13-16% on a Moto G4. However, the benchmark was very artificial and we should test it with something that's closer to a real world app. I am going to create a version of the flutter_gallery that doesn't use any const instantiations outside of the framework and see how a run of the transition benchmark compares to a constified flutter_gallery. I will run this on a mid-range Android phone with route snapshotting disabled.

Naginess

From playing around with this a bit with the flutter_gallery app, the biggest offenders here are prefer_const_constructors and prefer_const_literals_to_create_immutables. These constantly fire as you're iterating on your build method. And they are also often flip-flopping, what makes them even more annoying: You make a thing const because the lint told you so, then you iterate in a way that it cannot be const anymore and the analyzer yells at you again for that.

The prefer_const_constructors_in_immutables is the least annoying lint in the group. In fact, it is hardly annoying at all because it is fairly stable and as your code evolves you don't have to go back and forth on this one. Even if we disable the other lints, this one may be good to keep because it keeps the door open for developers to decide on a case by case basis if they want to be more strict and enable the other const lints. If we stop enforcing prefer_const_constructors_in_immutables they may no longer have the option to const-construct a widget because the widget may not offer a const constructor.

The prefer_const_declarations lint is in a bit of a grey area. It does not feel particularly annoying. But it also doesn't feel super-useful on its own without prefer_const_literals_to_create_immutables and prefer_const_constructors. So, if we end up disabling those I am leaning towards disabling this one as well.

Summary

Do more performance testing with a benchmark that's closer aligned with the real world. If constness doesn't make a huge difference (threshold TBD) recommend removing prefer_const_constructors, prefer_const_literals_to_create_immutables, and prefer_const_declarations from package:flutter_lints, but likely keep prefer_const_constructors_in_immutables. If constness makes a difference, we'll work with the language/analyzer team to figure out if we can make this less annoying (e.g. by introducing better quick fixes in the analyzer or by looking into introducing something like autoconst to the language).

from flutter.

goderbauer avatar goderbauer commented on July 20, 2024

FYI @mit-mit @jonahwilliams @johnpryan @srawlins

from flutter.

goderbauer avatar goderbauer commented on July 20, 2024

Related: dart-lang/sdk#53744

from flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.