-
Notifications
You must be signed in to change notification settings - Fork 49
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
New principle: Do not design around third-party tools unless it actually breaks the Web #335
Comments
We should only use alternative (worse) names/keywords in the case that using the preferred word would actually break existing live content. I believe that we are talking about a preprocessor in this case, so I would prefer to not use an unusual name like |
I strongly object to this as a principle. If adopted as-is it would encourage terrible stewardship of the web. The web doesn't consist solely of browsers. All the tools that are used to author the web are part of the authoring experience. Browsers are the most important part of that experience: they have the largest audience and the longest history and future. But that doesn't make them the sole part of it, and willfully breaking widely-used tools in drastic, disruptive ways needs to be balanced by a correspondingly large benefit to authors in general, or by showing that we're avoiding a correspondingly large harm to the feature and its future users. For example, in the issue that's inspiring this, Sass is the most widely-used CSS preprocessor in the world, used directly or indirectly by a fairly high % of all web authors. @if is one of the most widely used rules in Sass, appearing in nearly all Sass stylesheets, either directly or indirectly via libraries using the feature. Adding an @if to CSS with a substantially different processing model would constitute immense harm to this population of web authors. The benefit (or avoided harm) of using @if over another reasonable name cannot reasonably be argued to counterbalance that harm. (I'm not litigating that issue here; I'm merely providing it as an example.) A substantially weaker version of this principle would be acceptable, codifying the good practice of valuing browsers and the future web higher than existing tooling (and proportional to usage/harm), but not infinitely so. |
It’s not about browsers. It’s about that standards are long-term and cannot be changed, while tools are temporary and can adapt to standards. Moreover if the tool authors explicitly expressed their willingness to adapt and asked for not making spec-related decisions based on the current tool features/syntax. Standards should not be designed in a less right way just on the ground of preventing conflicts with tools, regardless of how widely a specific tool is used. |
If adopted, this principle would dramatically harm web developers and damage the health of the web ecosystem as a whole. It’s absolutely true that “platform technologies need to exist for decades”, and as Tab points out tools are intrinsically part of a healthy and usable platform. Sass has existed for more than half of CSS’s lifespan (when Sass was first released, no browser fully supported (For context: I am the lead designer of Sass.) SymbiosisSass and similar tools exist in a symbiotic relationship with the CSS specification. Sass compiles to CSS, and in turn makes CSS more appealing for authors who need to manipulate and share styles. Sass comes up with new features that aren’t in CSS, and in turn inspires new CSS features such as variables, nesting, math functions, and color manipulation. This relationship is good for CSS authors because it allows them to articulate their intentions while still writing in a language that is CSS at its core. It’s good for the web because it allows CSS to meet the encapsulation and re-usability needs of large-scale users without abandoning core strengths of the language as with CSS-in-JS, and because it shows which avenues for feature growth are actually useful to users without needing to commit to implementing them in browsers. There are two key aspects of Sass that make this symbiosis work. First, Sass is a CSS superset. We go to tremendous lengths to ensure that all valid CSS is also valid Sass, and because of this Sass authors think of their stylesheets in terms of the CSS they’ll generate. This means that Sass authors are CSS authors, so harming Sass authors harms your own users. What’s more, intentionally introducing incompatibilities between CSS and Sass pushes Sass into a position of being a different language than CSS and thereby muddies users’ understanding of CSS itself. The second symbiotic aspect is that Sass’s new features are CSS-y. We make a strong effort to make the syntax and (where it makes sense) the semantics of Sass-specific features work well with the way CSS thinks. Sass is much more than just a C-style preprocessor: it speaks the language of CSS natively, which is why features like nesting and color manipulation port so well to plain CSS. Even variables, which had to work procedurally in Sass, use a declaration-style syntax specifically to feel at home in a CSS world. But if Sass features are CSS-y, it means we’re trusting you as the CSS team not to use that exact syntax to mean something completely different. Historically, Sass has been very willing to change to get out of CSS’s way. We changed how we parsed custom properties; we added special casing to support What would this principle mean for CSS tools?If the proposed principle were adopted, it would be a clear signal to Sass and any other CSS tool that we cannot trust any syntax that looks like CSS to be safe from future conflicts. This would leave us with no option but to abandon one of our symbiotic aspects, either of which would be extremely bad:
I suspect that many CSS purists may feel that Sass is already a custom dialect and so these changes are scarcely a loss, but that’s based on a misunderstanding of what Sass (and tools like PostCSS) are trying to do. Unlike some styling solutions, Sass has never been an attempt to replace CSS. We cling so firmly to our symbiotic principles precisely because we believe that CSS is an excellent way to conceptualize and represent styles. Sass aims to allow this representation of styles to be made into libraries that can be customized and shared, but users are always engaging with it the same way they engage with CSS because CSS is at its heart. Please don’t make us cut that heart out. |
This hits my point about browsers not being the sole player in this space. Standards can be changed, and regularly are. The limitation is just compat pain: how much will it hurt users when pages using the old version of the feature break; how much will it hurt authors who'd already written code against the old feature and now have to rewrite. Those same questions are exactly as valid for any tooling. Sass happens to just be an author-level tooling, since it runs server-side, but other CSS-modifying libraries run on the page, so both author and user concerns are valid here. By definition, these populations will be smaller than the set of all users of browsers, but they're often not insignificant. Asserting that we don't need to care about those at all is just as wrong as saying compat pain for any other web feature doesn't matter. |
If you don't want to choose The popularity of the term
Whereas a
I would actually consider it a mistake if CSS adopted control flow keywords as syntax for something that has nothing to do with control flow. |
Almost every decision we ever make in the CSSWG is based on a balance between some ideal long-term syntax, and the compatibility & migration pain that might be caused for authors. That has always been a balancing act, and always will be. In fact, it's the first principle of this organization that author pain should be considered above theoretical purity:
Yes, Sass can ship changes. And that would result in a massive number of web authors & teams who need to entirely re-tool their site architectures just to keep using CSS. That's bad for everyone involved, and should happen as rarely as possible. Meanwhile, as pointed out by @davidkpiano, there are other good alternatives here, and other tradeoffs worth considering. It feels agressive to imply that there's a clear-cut, all-or-nothing, platform purity principle here which suddenly outweighs all those considerations. |
SCSS could, for example, just add a new internal at-rule like |
@nex3 Some TLDR would be useful. |
I do not agree to this statement. To be able to write any preprocessor style, you FIRST need to know CSS. That's like saying I'm a baker, but all I do is to reheat frozen buns. CSS should not adapt to Sass/Scss, it should be the other way around. I don't see Java change stuff for Kotlin, or Javascript change things for React. Do you? Regarding which keywords or the nomenclature for conditional statements or control flow, I don't care as long as it is sane and make sense. ALL preprocessors needs to adapt to the specs and principles of CSS. I admit that Scss have been visionary in their syntax and tooling, but they also need to do it properly. To be clear, do not design around third party. |
Except JavaScript specification proposals did in fact change because of existing frameworks. Not React in that case (although we do sure like it to be the usual scapegoat in the frontend industry), but MooTools. See this post for more information about what happened and how the TC39 eventually adapted to the existing ecosystem instead going ahead and recklessly breaking it for the sake of dogmatic purity.
That’s such an awkward point to make. The
That’s an overly simplistic view of the situation. Some legitimate concerns have been raised in that conversation about what a conflict between Sass and CSS would imply, and just saying “well Sass (and its authors) should just deal with it” is not helpful in the resolution of the problem at hand (and similar future problems). It’s a massive ecosystem that spreads over a decade of use. You can’t just shrug at it. Doing so is as silly as suggesting that introducing a JS feature that would conflict with existing jQuery syntax (as an example) is solely jQuery’s maintainers problem, and theirs to fix. It's not.
This very point from @mirisuzanne. Anyone making blanket statements of the like of “well tough shit, just go ahead with CSS syntax without considerations for the existing surrounding ecosystem” is either not engaging in good faith into the discussion, or being willingly dismissive of people whose job it is to care for said ecosystem and its implications at large. |
I think this by @mirisuzanne gets to the core of this discussion better than just about anything else. There are people here discussing as if CSS has to "change", the reality is that it doesn't have to change anything, it merely has to start differently. It is an initial choice being made that can either still make sense as something like In this regard I agree with @davidkpiano in that css isn't a procedurally run code set, and using I understand this is quite specific to one example, as the discussion has been, when talking about a design principle; however I think this shows that "as long as it doesn't break the web" is too low a bar as a principle given the complexity of environment CSS already exists within. Changes have to respect real world context. |
Fwiw, the if/else CSS thing is being discussed for 5 years already. |
I'd like to propose another principle: Provide ways for third parties to extend a language and stay valid. Help third party tools to not get in the way of future specifications by having clear rules that can be verified by a validator. HTML requires custom elements to use a dash and custom attributes to start with If Sass had been encouraged to use I think it would also help authors to differentiate which parts are from the original language and which parts are from the third party tool. |
Seconding From the third party tooling perspective, I don't agree with the notion that impinging on SASS's implementation of |
And it's been called @when/@else for virtually that entire time, because this exact issue was brought up early. |
First of all, love and hugs. I see a lot of awesome people here. Secondly, I would love a bit more context, seems like the comments here (and Twitter threads) are arguing about different points. Is the CSS spec choosing
If it's 2, that's really hard to agree with. From a standards and conventions point of view, I think that sets a bad precedent. It will lead to other makers of 3rd party tools to think "well, if we are popular enough, the CSS spec will just design around us". I know Sass isn't just an ordinary 3rd party tool, so it's even more important for them to lead by example. Breaking changes are hard to deal with, but whoever chooses to use a third party tool has the responsibility to adapt changes. If it's 1, then it would be a different debate. It is no longer about the point of this thread: "Do not design around third-party tools". Perhaps that warrants a separate discussion. Probably one that should happen first. I've only found some examples by @tabatkins, looking at those does not lead me to think this MUST be named |
This is an oversimplification. The precedent has already clearly and repeatedly been set that Sass will adapt to new CSS features in almost every circumstance. To quote myself:
We also go to great lengths to avoid possible conflicts with CSS. Back when we added The crux of the issue is that if there is absolutely zero room for saying "please make a small change in a CSS draft with zero migration costs to avoid forcing a huge change to Sass with massive migration costs", if that's an argument that's forbidden on principle, that effectively invalidates the entire premise on which Sass exists. We can't make a CSS extension language that's compatible with plain CSS if there's absolutely zero space for us to add extensions that we can reasonably trust will be safe over time. Again, I want to emphasize here that Sass tries very hard to proactively avoid these conflicts. But this proposal punishes us for doing so: by saying "no matter how much effort tools put into remaining compatible with CSS and avoiding future conflicts, if you guessed wrong or we change our mind we will break you without a second thought," the TAG would tell authors that all their compatibility efforts are wasted. At that point, why even bother trying to be compatible? |
Existing sites could continue using older versions of the preprocessor. Zero migration costs.
SCSS and other preprocessors could be 100% forward-compatible by using prefixed at-rules like |
I was talking about the whole fundamental conditional thing, not the specific syntax. |
One way of looking at this is that it should have been clear to the Sass team (and perhaps to Sass users) that Sass syntax inventions could eventually clash with CSS. This risk, and awareness for this risk, seems to be missing (at least in this thread). That this here was to happen was not a matter of if, but when. (Oof.) While one may be empathetic about the popularity of Sass and “just” have a core standard of the Web yield, that may also set a dangerous precedent, signaling that tool authors do not need to think about the consequences of their work as long as it’s successful (i.e., popular). This does not seem healthy or useful. On the more pragmatic side, to what degree can we assume that CSS authors who make use of the latest CSS features do also keep their CSS tooling up-to-date? That is, if Sass was to move to an alternative to their In other words, does this have to end in disaster or could we make |
CSS has had an extension mechanism since the 90s, specifically for this purpose, vendor prefixes. Sass could, and should, have been using this mechanism for every extension. e.g. |
Fascinating conversation with so many great points being made. It seems however that we are straying away from our initial intent. Perhaps the specific example we used (Saas being the 3rd party tool, CSS and how Layering approachIn the broadest terms, capabilities of the Web platform do not take a dependency on external libraries or tools intended to extend or enrich such capabilities. These dependencies can be either syntactic or functional. We think of these as upper-layer dependencies. The same principle applies when we expose lower-layer OS/platform capabilities to the Web. There we are the ones who are not in position to demand/dictate API shape, capabilities or even uniformity between different OS/platforms. API design with layeringWhen designing Web capabilities, we consider user needs, use cases, pain points/opportunities, and existing upper layer patterns such as libraries or tools (especially the popular ones) that can benefit from lower layer implementation. Bringing these capabilities to the Web platform usually results in improved consistency, availability, performance, accessibility, reliability, and ideally interoperability. The specific exampleThe example we used was intended to demonstrate a syntax collision with an upper layer library/tool capability desirable to the Web layer. This must be avoidable through language extensibility (as pointed out by @plinss #335 (comment)) or changing the Web API syntax due to popularity of the feature. All in all, this is an example used for illustrative purposes. If you want to continue this specific conversation, with my CSSWG co-chair hat on, I would like to invite you to https://github.com/w3c/csswg-drafts where we can debate the past, current, and future of it. Here our focus is general platform design principles guidance, and I hope we can focus the conversation back to it. |
Maybe implementing both |
As @atanassov has mentioned, let's please keep the This discussion (and general repo) is about broader discussion of Web architecture principles. While this issue was prompted by |
I think it's important to note here that everyone has generally agreed on the idea that there is a reasonable layering of priorities here. The sticking point is in implying that such an order of priorities can be applied all-or-nothing, where concerns from the ecosystem can be entirely ignored when adding to the web platform — rather than simply taking priority into account as we discuss tradeoffs (which is already the assumption in every syntax conversation I've ever been part of). And I honestly don't believe that anyone would be willing to apply such an all-or-nothing rule universally. While @LeaVerou is pushing for it in relation to
Those are ecosystem concerns. And I agree with Lea that they are issues we need to consider (and the detailed discussion of it should happen on that thread, not here). But I'm very worried about this new principle being implied as an all-or-nothing rule in some cases, while merely a preference in others — based entirely (it seems to me) on how much TAG members like or dislike the syntax in question. |
Thank you @LeaVerou - that is exactly the nuanced clarification I was hoping for. |
Yes, that is also the nuanced statement I am happy to accept. It is notably weaker than what was stated in the OP. ^_^ |
I'm happy we are on the same page, but I honestly don't think my latter statement is weaker. The original statement was just more terse, and thus easier to fill in any blanks with assumptions, but I have not changed my mind on anything. E.g. in the example that started this thread, I do think that |
Automated tools will make migration entirely painless for users of affected third party tools. We live in a modern development world full of tokenizers, parsers, compilers, formatters, pretty printers. Auto-namespacing or otherwise renaming clashing token names in developer-facing code is no big deal nowadays. Web standards must be solid and make the best choices. Tools come and go, tools are easy to adapt. Standards are forever. |
This is simply not true. Even simple migrations are very expensive at scale, and migrations that require users to update to the latest version of tools to avoid naming conflicts are an order of magnitude more expensive than that. It's no exaggeration to say that, for example, migrating Sass users away from |
@nex3 Do you have some proof stats? ;-) |
@nex3 |
Please check the following code: @when supports(display: grid) {
} @else {
} The |
@ianthedev Could you move/repost that at the case-specific issue? ➡️ w3c/csswg-drafts#6684 |
@LeoniePhiline Thanks for reminding me. I just did it. |
I will go for a @while. @while media(max-width: 768px) { Something like: starting from this condition and while it's effective do this. In the following case seems something that needs to run only once, as said above. @when supports(display: grid) { } @else { } Btw, you got the key. Sass or not. |
@DennysDionigi Please post CSS design suggestions in the relevant issues in the csswg repo, in this case w3c/csswg-drafts#6684 |
I think this is succinctly addressed by:
Less / Sass / PostCSS are probably all guilty of making the same mistakes while creating "supersets" of CSS. CSS actually has a mechanism / naming pattern for "custom" identifiers, which is the dash So, if Sass manages to dodge a bullet if this proposal uses |
You've pinged the GitHub user accounts @when, @while and @else by this LOL. Use the formatting options the GitHub comment editor provides to mark them as code :) |
This was brought up in the CSS WG's discussion of
@when
vs@if
: w3c/csswg-drafts#112@when
was chosen over the far more common@if
to avoid conflicts with Sass, a CSS preprocessor.Web Platform technologies need to last for decades, and should not be designed around third party tools that just happen to be in use at the time, unless it is absolutely necessary because it breaks the Web (e.g.
array.contains()
that TC39 faced).The text was updated successfully, but these errors were encountered: