Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add page to explain Dart modes #4436

Open
polina-c opened this issue Dec 13, 2022 · 16 comments
Open

Add page to explain Dart modes #4436

polina-c opened this issue Dec 13, 2022 · 16 comments
Labels
a.language Relates to the Dart language tour e1-hours Can complete in < 8 hours of normal, not dedicated, work p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. st.triage.ltw Indicates Lead Tech Writer has triaged t.cli-tools Relates to the dart command line tools

Comments

@polina-c
Copy link
Contributor

Page URL

https://dart.dev/guides/

Page source

https://github.com/dart-lang/site-www/tree/main/src/_guides/index.md

Describe the problem

development mode and productive mode mentioned in this post are important aspects of the dart language, but they are not explained in dart documentation:

https://www.geeksforgeeks.org/assert-statements-in-dart/

Expected fix

No response

Additional context

No response

@polina-c polina-c changed the title [PAGE ISSUE]: 'Dart documentation' [PAGE ISSUE]: Dart development and productive modes are not explained Dec 13, 2022
@parlough
Copy link
Member

parlough commented Dec 14, 2022

Could you provide some more context on what documentation you are looking to see. As far as I can tell, the language specification doesn't really cover a "production" or "development" mode, it only specifies that program execution can occur with asserts enabled or disabled.

From a quick look, it seems like we cover that where relevant. We cover enabling asserts and other debugging options/modes in the dart run documentation as well as in discussion about dart compile js. We also talk about asserts, how to enable them, and how production code ignores them in the language tour.

@parlough parlough added a.language Relates to the Dart language tour p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. t.cli-tools Relates to the dart command line tools act.wait-for-customer Needs response from customer e1-hours Can complete in < 8 hours of normal, not dedicated, work labels Dec 14, 2022
@polina-c
Copy link
Contributor Author

@a-siva , can you comment?

Is it intention not to explain compilation mode for Dart applications and only explain asserts?
How about vm service availability, debuggability and other differences?

@polina-c
Copy link
Contributor Author

polina-c commented Dec 15, 2022

I faced this issue when I wanted to explain leak_tracker availability in different modes for Dart and Flutter. I wanted to reference the modes. I found the modes explanation for Flutter, but not for Dart.

For now I just linked this bug for Dart: https://github.com/dart-lang/leak_tracker/blob/04ad7a9e0b15ea4dac281ddd5522d496429b4fb1/README.md#by-build-mode

@parlough
Copy link
Member

parlough commented Dec 16, 2022

Thanks for the clarification!

I guess it's a bit challenging on the Dart side compared to Flutter. Flutter has a standardized platform combined into one tool, so there are standard build modes, but in terms of Dart, each platform and compiler/tool has its own configuration. So there are no standards modes as far as I know, at least like Flutter has with the build modes, and enabling the vm service and debugging looks different depending on the tool.

For the VM, the current documentation of enabling debugging is in dart run and for web it is in Debugging Dart web apps. We also have some shorter documentation about enabling both on the Dart DevTools page.

While we have sort of consolidated a concept for a "development" vs "production" web compiler on the website recently, that is separate from debugging. At least on the site, there does not seem to be a general concept of modes for VM apps, outside of JIT vs AOT and passing in --observe and --enable-asserts or not.

For your case of documenting leak_tracker, until we have a better consolidated picture, perhaps you could document in terms of the tools? Perhaps mentioning dart run --observe for VM apps and webdev serve --debug for web apps (if web apps are supported by leak_tracker).

\cc @mit-mit Is there is a bigger idea of modes or "production" vs "development" we should be documenting for VM apps or all Dart apps in general?

@mit-mit
Copy link
Member

mit-mit commented Dec 16, 2022

I'm a but confused about the term "productive mode". Do you mean "production mode" @polina-c? If so, please update your readme.

We have an overview that introduces those terms for each of native and web here: https://dart.dev/overview#platform

We should probably detail here which are development mode and which are production mode: https://dart.dev/tools/dart-compile

@polina-c
Copy link
Contributor Author

polina-c commented Dec 16, 2022

@mit-mit , I was not sure what term to use. I took 'productive' from the article I linked, because I did not find anything else.

Your link helps a lot. Updated README. Thank you!

Yes, it seems clarification of compilation modes on this page will help: https://dart.dev/tools/dart-compile

@polina-c polina-c changed the title [PAGE ISSUE]: Dart development and productive modes are not explained [PAGE ISSUE]: Dart development and production modes are not explained Dec 16, 2022
@parlough
Copy link
Member

parlough commented Dec 16, 2022

Ah, I forgot about that picture, thanks! Might be nice to be a bit more explicit in text so it's easier to search for.

Sounds like we potentially have a good step forward with improvements to the compile page.

@parlough parlough removed the act.wait-for-customer Needs response from customer label Dec 16, 2022
@a-siva
Copy link

a-siva commented Dec 19, 2022

I believe the key concept that @polina-c wants to capture here is that
dart compile exe bin/myapp.dart -o /tmp/myapp
produces an executable /tmp/myapp which does not have vm service in it.

@polina-c
Copy link
Contributor Author

polina-c commented Apr 20, 2023

if you go to dart sdk folder and run command tools/build.py --help, there will be line:

  --mode [all,debug,release,product], -m [all,debug,release,product]
                        Build variants (comma-separated). (default: debug)

The modes are different from what is explained here; https://dart.dev/tools/dart-compile

This instruction works just for debug and release modes: https://github.com/dart-lang/sdk/blob/main/runtime/tools/heapsnapshot/README.md

The limitation is hard to document well as the modes are not documented: dart-lang/sdk#52114

@polina-c
Copy link
Contributor Author

@atsansone
@mkustermann

@mit-mit
Copy link
Member

mit-mit commented Apr 24, 2023

The instructions for tools/build.py --help are irrelevant to the vast majority of Dart developers who do not ever build the SDK, or run it's python scripts. Terms like "product mode" I believe only make sense to those that work on implementing the SDK. I think they are different for historical reasons.

@polina-c polina-c changed the title [PAGE ISSUE]: Dart development and production modes are not explained [PAGE ISSUE]: Dart modes are not explained Apr 27, 2023
@polina-c
Copy link
Contributor Author

@mit-mit , per my understanding, the modes are for applications. And the modes define what features are available for the applications.

@a-siva and @mkustermann , can you comment on this? What should we say in documentation for, for example, NativeRuntime.writeHeapSnapshotToFile?

@a-siva
Copy link

a-siva commented Apr 27, 2023

@a-siva and @mkustermann , can you comment on this? What should we say in documentation for, for example, NativeRuntime.writeHeapSnapshotToFile?

Maybe the documentation of NativeRuntime.writeHeapSnapshotToFile can state that this function will not work in a self contained dart executable produced using the dart compile exe command.
I presume for Flutter apps it is not confusing when we refer to the modes debug, profile and release and state that this functionality will not work for Flutter apps in release mode.

@polina-c
Copy link
Contributor Author

There are may features like this. For example, leak tracker. Why do not we give names and explain Dart modes in a central place, that can be easily referenced in all other docs?

@atsansone atsansone changed the title [PAGE ISSUE]: Dart modes are not explained Add page to explain Dart modes Apr 29, 2023
@atsansone atsansone added the st.triage.ltw Indicates Lead Tech Writer has triaged label Apr 29, 2023
@mkustermann
Copy link
Member

Terms like "product mode" I believe only make sense to those that work on implementing the SDK. I think they are different for historical reasons.

The name "product" does leak into users code via an environment define: Users that want to exclude certain code in production mode (e.g. for dart compile exe) - will guard such code e.g. via if (!const bool.fromEnvironment("dart.vm.product")) { ... }.

Flutter specifically provides a kReleaseMode constant that is implemented using this. So flutter users can use that more appropriate name instead. Though non-Flutter Dart users are currently required to use bool.fromEnvironment("dart.vm.product") directly.

@mit-mit Would it make sense that we expose kReleaseMode as a constant as part of a dart:* library instead?

@atsansone
Copy link
Contributor

@polina-c , @mkustermann , @mit-mit : This is beginning to read like a code change before a documentation change. If that's the case, I can move this back into dart-lang/sdk for resolution. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a.language Relates to the Dart language tour e1-hours Can complete in < 8 hours of normal, not dedicated, work p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. st.triage.ltw Indicates Lead Tech Writer has triaged t.cli-tools Relates to the dart command line tools
Projects
None yet
Development

No branches or pull requests

6 participants