Skip to content

Commit bc00710

Browse files
authored
Merge pull request #264 from Logofile/sync
Documentation update
2 parents 951fee0 + 6b137f9 commit bc00710

22 files changed

+1117
-397
lines changed

content/best-practices/1-1-1.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ dependencies that may only be used by another message defined in the same file.
3434

3535
There are cases where the 1-1-1 ideal is not possible (circular dependencies),
3636
not ideal (extremely conceptually coupled messages which have readability
37-
benefits by being co-located), or where the some of the downsides don't apply
38-
(when a .proto file has no imports, then there are no technical concerns about
39-
the size of transitive dependencies). As with any best practice, use good
40-
judgment for when to diverge from the guideline.
37+
benefits by being co-located), or where some of the downsides don't apply (when
38+
a .proto file has no imports, then there are no technical concerns about the
39+
size of transitive dependencies). As with any best practice, use good judgment
40+
for when to diverge from the guideline.
4141

4242
One place that modularity of proto schema files is important is when creating
4343
gRPC

content/best-practices/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ topics:
1212
* [Proto Best Practices](/best-practices/dos-donts)
1313
* [API Best Practices](/best-practices/api)
1414
* [1-1-1 Rule](/best-practices/1-1-1)
15+
* [Avoid Cargo Culting](/best-practices/no-cargo-cults)

content/best-practices/api.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ type = "docs"
66
aliases = "/programming-guides/api"
77
+++
88

9-
Updated for proto3. Patches welcome!
10-
119
This doc is a complement to
1210
[Proto Best Practices](/best-practices/dos-donts). It's
1311
not a prescription for Java/C++/Go and other APIs.
1412

15-
If you see a proto straying from these guidelines in a code review, point the
16-
author to this topic and help spread the word.
17-
1813
{{% alert title="Note" color="note" %}}
1914
These guidelines are just that and many have documented exceptions. For example,
2015
if you're writing a performance-critical backend, you might want to sacrifice

content/news/2025-06-27.md

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
+++
2+
title = "Changes Announced on June 27, 2025"
3+
linkTitle = "June 27, 2025"
4+
toc_hide = "true"
5+
description = "Changes announced for Protocol Buffers on June 27, 2025."
6+
type = "docs"
7+
+++
8+
9+
## Edition 2024
10+
11+
We are planning to release Protobuf Editions in 32.x in Q3 2025.
12+
13+
These describe changes as we anticipate them being implemented, but due to the
14+
flexible nature of software some of these changes may not land or may vary from
15+
how they are described in this topic.
16+
17+
More documentation on Edition 2024 will be published in
18+
[Feature Settings for Editions](/editions/features),
19+
including information on migrating from Edition 2023.
20+
21+
## Changes to Existing Features {#changes}
22+
23+
This section details any existing features whose default settings will change in
24+
Edition 2024.
25+
26+
### C++ string_type {#string_type}
27+
28+
The default for `string_type` feature, originally released in Edition 2023, will
29+
change from `STRING` to `VIEW` in Edition 2024.
30+
31+
See
32+
[`features.(pb.cpp).string_type`](/editions/features#string_type)
33+
and [String View APIs](/reference/cpp/string-view) for
34+
more information on this feature and its feature values.
35+
36+
## New Features {#new-features}
37+
38+
This section details any new features that will be introduced in Edition 2024.
39+
40+
### `enforce_naming_style` {#enforce_naming}
41+
42+
[`feature.enforce_naming_style`](/editions/features#enforce_naming)
43+
enables strict naming style enforcement to ensure protos are round-trippable by
44+
default with a feature value to opt-out to use legacy naming style.
45+
46+
### `default_symbol_visibility` {#default_symbol}
47+
48+
This feature controls whether the default symbol visibility of importable
49+
symbols (such as messages and enums) is either:
50+
51+
* `export`: referenceable from other protos via import statements
52+
* `local`: un-referenceable outside of current file
53+
54+
The default feature value `EXPORT_TOP_LEVEL` in Edition 2024 ensures top-level
55+
symbols are export by default, whereas nested symbols are local by default.
56+
57+
This can be used along with the [`export` and `local` keywords](#export-local)
58+
to explicitly annotate symbol visibility, also added in Edition 2024.
59+
60+
Symbol visibility only controls which symbols can be imported from other proto
61+
files, but does not affect code-generation.
62+
63+
### C++: `enum_name_uses_string_view` {#enum_name}
64+
65+
Previously, all generated enum types provide the following function to obtain
66+
the label out of an enum value, which has significant overhead to construct the
67+
`std::string` instances at runtime:
68+
69+
```cpp
70+
const std::string& Foo_Name(int);
71+
```
72+
73+
The default feature value in Edition 2024 instead migrates this signature to
74+
return `absl::string_view` to allow for better storage decoupling and potential
75+
memory/CPU savings.
76+
77+
```cpp
78+
absl::string_view Foo_Name(int);
79+
```
80+
81+
Users should migrate their code to handle the new return-type following
82+
[the migration guide](/support/migration#string_view-return-type).
83+
84+
See [String View APIs](/reference/cpp/string-view) for
85+
more information.
86+
87+
### Java: `nest_in_file_class` {#nest_in}
88+
89+
This feature controls whether the Java generator will nest the generated class
90+
in the Java generated file class.
91+
92+
The default value in Edition 2024 generates classes in their own files by
93+
default, which is also the default behavior of the previous
94+
`java_multiple_files = true` file option. This replaces `java_multiple_files`
95+
which is removed in Edition 2024.
96+
97+
The default outer classname is also updated to always be the camel-cased
98+
`.proto` filename suffixed with Proto by default (for example,
99+
`foo/bar_baz.proto -> BarBazProto`). You can override this using the
100+
`java_outer_classname` file option and replace the pre-Edition 2024 default of
101+
`BarBaz` or `BarBazOuterClass` depending on the presence of conflicts.
102+
103+
### Java: `large_enum` {#large_enum}
104+
105+
This feature allows creation of large Java enums, extending beyond the enum
106+
limit due to standard constant limits imposed by the Java language.
107+
108+
Creation of large enums is not enabled by default, but you can explicitly enable
109+
it using this feature. Note that this feature replicates enum-like behavior but
110+
has some notable differences (for example, switch statements are not supported).
111+
112+
## Grammar Changes {#grammar-changes}
113+
114+
### `import option` {#import-option}
115+
116+
Edition 2024 adds support for option imports using the syntax `import option`.
117+
118+
Unlike normal `import` statements, option imports import only custom options
119+
defined in a `.proto` file, without importing other symbols.
120+
121+
This means that messages and enums are excluded from the option import. In the
122+
following example, the `Bar` message cannot be used as a field type in
123+
`foo.proto`, but options with type `Bar` can still be set.
124+
125+
Option imports must also come after any other import statements.
126+
127+
Example:
128+
129+
```proto
130+
// bar.proto
131+
edition = "2024";
132+
133+
import "google/protobuf/descriptor.proto";
134+
135+
message Bar {
136+
bool bar = 1;
137+
}
138+
139+
extend proto2.FileOptions {
140+
bool file_opt1 = 5000;
141+
Bar file_opt2 = 5001;
142+
}
143+
```
144+
145+
```proto
146+
// foo.proto:
147+
edition = "2024";
148+
149+
import option "bar.proto";
150+
151+
option (file_opt1) = true;
152+
option (file_opt2) = {bar: true};
153+
154+
message Foo {
155+
// Bar bar = 1; // This is not allowed
156+
}
157+
```
158+
159+
Option imports do not require generated code for its symbols and thus must be
160+
provided as `option_deps` in `proto_library` instead of `deps`. This avoids
161+
generating unreachable code.
162+
163+
```build
164+
proto_library(
165+
name = "foo",
166+
srcs = ["foo.proto"],
167+
option_deps = [":custom_option"]
168+
)
169+
```
170+
171+
Option imports and `option_deps` are strongly recommended when importing
172+
protobuf language features and other custom options to avoid generating
173+
unnecessary code.
174+
175+
`option_deps` requires Bazel 8 or later since the `native.proto_library` in
176+
Bazel 7 does not support this.
177+
178+
This also replaces `import weak`, which is removed in Edition 2024.
179+
180+
### `export` / `local` Keywords {#export-local}
181+
182+
`export` and `local` keywords are added in Edition 2024 as modifiers for the
183+
symbol visibility of importable symbols, from the default behavior specified by
184+
the
185+
[`default_symbol_visibility` feature](/editions/features#symbol-vis).
186+
187+
This controls which symbols can be imported from other proto files, but does not
188+
affect code-generation.
189+
190+
In Edition 2024, these can be set on all message and enum symbols by default.
191+
However, some values of the `default_symbol_visibility` feature further restrict
192+
which symbols are exportable.
193+
194+
Example:
195+
196+
```proto
197+
// Top-level symbols are exported by default in Edition 2024
198+
local message LocalMessage {
199+
// Nested symbols are local by default in Edition 2024
200+
export enum ExportedNestedEnum {
201+
UNKNOWN_EXPORTED_NESTED_ENUM_VALUE = 0;
202+
}
203+
}
204+
```
205+
206+
### "import weak" and `weak` Field Option {#import-weak}
207+
208+
Weak imports are no longer allowed as of Edition 2024.
209+
210+
Most users previously relying on `import weak` to declare a “weak dependency” to
211+
import custom options without generated code for C++ and Go should instead
212+
migrate to use
213+
[`import option`](/editions/overview#import-option)
214+
instead.
215+
216+
### `ctype` Field Option {#ctype}
217+
218+
`ctype` field option is no longer allowed as of Edition 2024. Use the
219+
[`features.(pb.cpp).string_type`](/editions/features#string_type)
220+
feature, instead.
221+
222+
### `java_multiple_files` File Option {#java_multiple}
223+
224+
The `java_multiple_files` file option is removed in Edition 2024 in favor of the
225+
new
226+
[`features.nest_in_file_class`](/editions/features#java-nest_in_file)
227+
Java feature.

content/news/_index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ New news topics will also be published to the
2020
The following news topics provide information in the reverse order in which it
2121
was released.
2222

23+
* [June 27, 2025](/news/2025-06-27) - Edition 2024
2324
* [March 18, 2025](/news/2025-03-18) - Dropping support
2425
for Ruby 3.0
2526
* [January 23, 2025](/news/2025-01-23) - Poison Java
@@ -96,6 +97,8 @@ release notes will be more complete. Also, not everything from the chronological
9697
listing will be in these topics, as some content is not specific to a particular
9798
release.
9899

100+
* [Version 32.x](/news/v32)
101+
* [Version 31.x](/news/v31)
99102
* [Version 30.x](/news/v30)
100103
* [Version 29.x](/news/v29)
101104
* [Version 26.x](/news/v26)

0 commit comments

Comments
 (0)