-
-
Notifications
You must be signed in to change notification settings - Fork 36
Drop restriction on using keywords in the syntax #286
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
Comments
I still think that guidance is reasonable to not use keywords like I would prefer the syntax to represent the fact that a message is data that is the input to a formatting API, and my concern is that At the least, this feels like another divergence point that should be better handled as not a blocker. |
Let me try to provide some context about this.
My take:
When we did this exercise, we realized that by using keywords we think we can improve the discoverability and the readability of the syntax significantly. The syntax becomes explicit and self-explanatory, which helpfully means that developers don't really have to spend anytime learning it. #287 is one potential incarnation of this idea. The idea of being able to induce the rules of the syntax from just looking at it comes from another design goal:
@echeran Are your concerns about which specific keywords were proposed in #287, or more generally about the idea of using keywords in the first place? |
One observation: one of our goals is to provide e.g. an XLIFF binding for MFv2. This is how we can (help) separate code elements such as keywords from being exposed to translation and is a better way of ensuring that sort of protection. Unless we make our syntax utterly mysterious we will always have "language-like" words that are part of the syntax to the benefit of developers who need to write the source pattern. The problem historically has been that translators see I think we should avoid adding additional keywords except-and-unless they add value. But I don't object to having keywords if the consensus is that we need them. |
@stasm My concerns are about the general idea of using keywords if they're not significantly useful. And they don't seem necessary to me in order to achieve a reasonably readable syntax, as #266 demonstrates. Even though the words 'readable', 'useful', 'significant', 'value', etc. can have a bit of subjectivity in these discussions, mixing in these keywords into the syntax feels reminiscent of programming languages. With this MF syntax, what we're talking about is the syntax of the serialization of the data that is the input to the API. In general, data does not need a PL in order to exist. But PLs need data along with control flow constructs, etc., and they use keywords for such constructs. When I see the Funny enough, I think my argument against introducing keywords is the same reasoning that was the origin of this idea in the first place -- this issue+PR seems to be a way to have a workaround that is compatible with the desire to have The lesser nitpicky concerns come in when you notice that I don't know if there is a better way to accommodate |
@echeran I don't think there's an equivalence between having keywords and looking like a PL, is there? For instance, Jsonnet is a syntax for describing data, and yet it comes with the Before we get to discussing particular choices for keywords, I'd like to reach an agreement on whether we're OK with allowing keywords as a general rule, assuming we come to a conclusion that they are necessary or that they improve the syntax significantly. |
Agreed. I think the issue of separating translatable from non-translatable parts of the message is largerly solvable for translators, as you say. This is why we're suggestig to remove the explicit design restriction forbidding us from using keywords in the syntax, if needed.
I'd extend this to developers, as well. Even if developers don't translate, they also need to be able to understand what's going on, in order to be able to make change to the source code. If the I'm happy with the current syntax for placeholders precisely because I think it makes it easier for the reader to identify the functions of words inside them. I imagine that there's a budget of special characters that we can use for prefixes and delimiters. We've used part of it to make the placeholder syntax more clear. If we agree that keywords are OK (when designed well), then I think we can avoid going over the budget for the syntax around patterns. #287 is one attempt, but first we need to agree that keywords are acceptable as a general rule. Hence this issue.
+1. |
In order to get some user input on this topic, at the end of my presentation on "The Road to Intl.MessageFormat" at React Norway earlier today, I asked my audience for their preferences between two options: Option A
Option B
Option A is lifted directly from here; Option B applies the changes of #287 on that base, keeping the This was an audience of front-end developers that is completely unfamiliar with the details of the syntax, but did just get a general explanation of the sort of of work we're doing. The talk itself barely touches or presents the MF2 syntax; the only example I use is:
Based on a quick count of hands, about 20 people preferred Option A and about 50 people preferred Option B. Once it's available, I'll update this comment to include a timestamped link to the livestream where I present this question. Edit: Link to video, unfortunately only showing the slides and with slightly broken audio: https://youtu.be/AQRlDs92XFA?t=19010 -- the relevant part is the subsequent 5 mins or so. |
This is strongly counter-intuitive for me. I understand that what I'm writing now is at risk of researcher bias and belief perseverance, but I'm wondering if it's possible that your audience in fact did not visually parse the syntax of this message and rather assessed aesthetic reaction to looking at it - in such case, seeing fewer sigils may be correlated to preference. If my hypothesis were to be correct (we could test it by constructing a simple HCI test where a subject has to look at a message like this and then answer a question or perform an action which would require to reason about the message) Saying that, my opinion is weakly held and I do not intend to oppose Option B if the group decides to pursue it. |
It's not just about the names of the keywords or their descriptiveness. Yes, different names can avoid confusing implications when interpreting meaning, which is important. This keywords topic highlights a still unaddressed readability concern of the syntax in But I still recognize the readability argument that is prompting the proposal to use these keywords. I would be okay with keywords only on the condition that they're not used to replace delimiters or other syntax used to represent the plain data -- in other words, I still prefer the visual cues of matching delimiters on the selectors definition list and the selector value tuple. So in the examples that @eemeli presented above as Option A and Option B, it could like something in between, like:
(Actually, in general, I'm personally on the other end of most people on verbosity vs. readability -- I prefer clarity much more over terseness or shaving off characters, so while others might find delimiter characters "verbose", I think they actually improve readability. Judicious use of keywords can also help. But it seems like most people find some amount of terseness more readable than my preferred extreme, and the question is how much and where they prefer the terseness and whether that creates confusion or irregularities.) To support people who may want to keep the syntax terse because they find some level of terseness more readable, I would also suggest that these keywords are optional because I don't think they should take the place of delimiters. But I don't know if optional syntax for readability is considered "bad form" by people who are have more experience or opinions on syntax. |
Link to video, unfortunately only showing the slides and with slightly broken audio: https://youtu.be/AQRlDs92XFA?t=19010 -- the relevant part is the subsequent 5 mins or so. |
replying to @stasm:
While I agree in principle, in practice I rarely have to explain the MFv1 pattern syntax (beyond just the nuts-and-bolts of it) to developers: developers understand what it is, as they are familiar with using microsyntaxes, whereas translators very often "don't get it"--even when told explicitly.
If by "budget of special characters", you mean the (I think it's unstated?) assumption all of us are working with is that we should only use printable ASCII characters in the syntax--and that we want to avoid MFv1's adventures with apostrophe, I guess that's true. My problem with at least some of the proposed keywords is that they feel superfluous to me--syntactic goo that we require developers to emit that don't really do anything. For example, in replying to @eemeli: That sounds well done and I look forward to seeing the video. My concern is that seeing might not produce the same result as using the syntax in anger. Your I do think there is something to providing syntax that identifies the selectors vs. the cases. replying to @echeran:
I think you and I are in violent agreement here. We need developers to learn and use the syntax; debug it visually; and apply it effectively. Terseness can sometimes help this, but sometimes becomes a barrier. I personally prefer syntaxes that have strong visual cues (to assist the parser and the reader). In fact, we are all guilty of using newlines to make the examples clear. In fact, this fragment:
is not an "array of cases". It's really this string:
... and @eemeli's
|
Interesting point about using newlines in our discussions, @aphillips. Related, my preference for the recommended (but not required) style would be to use capital letters for the keywords, to make them stand out more:
Such keywords are visible enough to me, which is why I'm proposing that we not use delimiters for variant keys, like so:
In fact, this may be clear enough for me that I don't mind the |
What I meant here is that I'd prefer a syntax which uses few special characters. Special characters are hard to learn: it's difficult to Google them, and some people don't even know what they're called (and that's OK). We're already treading on thin ice with three kinds of brackets ( For example, if in the future we want to add some runtime meta information which follows the variants, we can:
My position is that (2) is better because it scales to many more instances, and also is self-explanatory: it gives names to concepts, which means it's easier to talk about them (e.g. on StackOverflow). |
I agree, @stasm, that lots of different syntax characters with subtle different meanings is hard to use/difficult to teach. Previously my reaction might have been "well, it doesn't really matter which we choose--I'm going to strip this all away and hide the details behind my resource format", but that's a cop out. To be honest, I don't really want to teach people to write strings like this vs. using a structured format approach--but that is not an option given the goals we have. I don't see this as a choice between symbols and keywords. What we're creating is a grammar which will use a combination of keywords and symbols to create a pattern string. Whatever form that grammar takes will have to be learned by developers and checked by tools. |
Closed by #287. |
In recent conversations with @stasm and @mihnita, it's become obvious that especially with more complex messages involving local variables and multiple variants, it is not reasonable to expect a translator unfamiliar and untrained with MF2 syntax to work with the raw plaintext representation of a message and be able to immediately see which parts of it contain the actual message or messages to translate. Consider for instance this example from the current spec:
There's so much going on here that it's effectively a necessity to use some form of tooling assistance to extract the two variants from this message and present them individually to a translator, along with the contextual information provided by the rest of the message.
As a consequence, it is not reasonable or beneficial for us to keep this restriction on our design:
Following #252, we'll need to refactor the current preamble into two parts. When we do that, we should not be afraid of using keywords such as
let
andmatch
in our syntax, esp. as it seems we have something like a consensus forming in #256 on starting in "code" mode, where such terms would be quite natural.This change will help us reach a syntax that's easier to read and which has slightly fewer mysterious symbols and sigils that need to be deciphered.
The text was updated successfully, but these errors were encountered: