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

Standardize syntax #2104

Open
corysimmons opened this issue Feb 2, 2016 · 20 comments
Open

Standardize syntax #2104

corysimmons opened this issue Feb 2, 2016 · 20 comments
Milestone

Comments

@corysimmons
Copy link

https://github.com/stylus/stylus/wiki/1.0.0#what-to-change-in-syntax proproses some great changes to the syntax:

  • $ preluding every variable
  • : separating property: value's in declarations
  • etc.

This has been in the proposal since Dec. 30th 2013.

Can we please just make this the standard already so every Stylus project in the world isn't using a different syntax flavor and people like the maintainer of Emmet don't keep forcing colonless syntax down everyone's throat because they personally like colonless syntax.

Using Stylus on CodePen is really annoying because I can't configure Emmet to not be stupid.

2013..

@mehcode
Copy link

mehcode commented Feb 6, 2016

Additionally can we decide on braces/semicolons vs indent/no-semicolons for the strict syntax? It doesn't even have to be a released version. If the three of you agree on X it would drive a dozen projects to stop supporting one of the versions and with that a dozen dozen users.

Of course since I'm here I'll throw my 🎩 in the ring to braces/semicolons as it would mean stylus is an extension of CSS vs. a replacement. Also I just finished adding autocomplete to the atom package for stylus and I found out it doesn't work in its braceless mode.

//cc @kizu / @Panya

@corysimmons
Copy link
Author

Braceless as Stylus should be an extension of a good language. :)

@mehcode
Copy link

mehcode commented Feb 6, 2016

I'd be fine with whatever going forward. As long as the maintainers can agree on it and document it somewhere official.

One more reasoning for braces. The web development community is in the process of moving from coffee script to babel because of it being future javascript. The community at large that uses CSS is more likely to adopt a preprocessor that strictly extends the syntax rather than adjusting it.

I'd be estatic if we can enforce colons at the compiler level. It'd make so many things (like autocomplete) not need to be as hacked to pieces.

@corysimmons
Copy link
Author

JS community isn't moving towards braces. It's moving towards ES6 and StandardJS which removes as many unnecessary characters as possible (e.g. you don't need to wrap arrow functions that return one liners, removing semicolons, etc.). Extra characters suck and make it hard to read vs sweet, sweet, indentation.

There's a reason Python is pretty much universally thought of as a beautiful/simple language, and it's also the same reason I hate using SCSS/LESS.

@mehcode
Copy link

mehcode commented Feb 6, 2016

I didn't say braces. I meant standard/future-standard JS. An interesting note here is that a couple ES7 proposals (class properties) actually require semicolons in the grammar (explicitly disallowing ASI in some places). So JS is moving towards semicolons at any rate.

I don't care about whether it looks nice or not. I use and like python as well.

@corysimmons
Copy link
Author

An interesting note here is that a couple ES7 proposals (class properties) actually require semicolons in the grammar (explicitly disallowing ASI in some places). So JS is moving towards semicolons at any rate.

Ah really? Crap.

@mehcode
Copy link

mehcode commented Feb 6, 2016

@corysimmons
Copy link
Author

lol, that's what I get for being a hipster. Time to move to semistandard I suppose. Thanks for the heads up!

@flying-sheep
Copy link

@corysimmons @mehcode read to the end. it’s a bug, the semicolon isn’t really required, and babel will stop requiring it soon

@corysimmons
Copy link
Author

But it's soooo much to read. I got halfway through before it seemed like they already picked what they were doing (contrary to your good ideas).

I just don't want to write a bunch of JS that isn't future proof. :(

@flying-sheep
Copy link

uh, just read the summary here then.

@corysimmons
Copy link
Author

@flying-sheep okay so standardjs is cool to use then? (sorry i don't know what any of that class stuff means)

@flying-sheep
Copy link

sure.

@kizu kizu added this to the 1.0 milestone Feb 11, 2016
@eddiemonge
Copy link
Contributor

: separating property: value's in declarations

Please don't do this. To me, this is what really separates Stylus from Sass. It makes writing code so much easier since I don't have to worry about punctuation. I know that it probably does make the code harder to maintain but the point of tools like this are to make it easier for the end user.

the maintainer of Emmet don't keep forcing colonless syntax down everyone's throat because they personally like colonless syntax

Its not just their opinion but seems to be pretty popular despite what that one stylus syntax guide says.

@darsain
Copy link

darsain commented Mar 30, 2016

: separating property: value's in declarations

Please don't do this.

Apart of other issues, no colons means you can't use hashes, as this will be recognized as a selector:

hash = {
  value: 100%
}
.foo
  width hash.value // selector with no props below, lets throw an error

And code looks horrible if you use colons only when you need it, so colons were always in my coding style guide for stylus.

I agree with everything on that list, and my vote would be for indentation significant no-braces python-like syntax. Main selling point for stylus was always its simplicity and nice syntax, so keep it as close to it as possible. Will definitely hate the $, but understand the need for it 😐.

@eddiemonge
Copy link
Contributor

Why couldn't you use a virtual hash?

hash.value = 100%

.foo
  width hash.value // selector with no props below, lets throw an error

I'm not sure what part of your example breaks since I've never used a hash in my stylus like that before. Is it the parsing of the hash (which should be doable since it has the equal and brackets so regexing it shouldn't be too bad [I don't know what the regex looks like so thats a purely speculative guess])?

@Panya
Copy link
Member

Panya commented Mar 31, 2016

The problem with the hash example is not about defining the hash, but about using the hash's value:

.foo
  width hash.value // this is ambiguous with a nested selector and parser will look for a related block with declarations if : is omitted.

@janwirth
Copy link
Contributor

janwirth commented Apr 5, 2016

@eddiemonge I could not agree more. I wrote a small paper comparing SASS/LESS/Stylus and Stylus had by far the most terse syntax, powerful features in general as well as transparency. If I got a kick from shitting $$$ all over my codebase I would write PHP. Supporting both indent and braces syntax severely shallows the learning curve as you are using a CSS superset with the possibility to outgrow the last millenium.

I do not understand the need for all the sigils. In fact, I think it may actually screw up many existing stylus projects.
We could solve the hash-semicolons problem through prefixing hashes with a sigil to distinguish them from primitives and selectors.

If the stylus syntax is being castrated I will fork it and call it io.styl or something 🎌 as the syntax is what makes stylus so great.

@spiralx
Copy link

spiralx commented May 19, 2016

Surely given the proposal for enforcing the $ prefix for variables, it would be:

$hash = {
  value: 100%
}
.foo
  width $hash.value // selector with no props below, lets throw an error

My personal view is that

  • the $ prefix for variables is something I do anyway now and you get used to it quickly

  • enforcing : between property names and values seems unnecessary with var-prefixes:

    $color = #444
    $hash = {
      margin: 1em,
      width: 40vw
    }
    
    div
      {$hash}
      color $color
    
      h3
        color $color
        margin 0 0 $hash.margin

    and it should cope better with current selector vs. variable ambiguity.

  • brace-less and indented layout is by far the biggest reason for me to use Stylus - without it I might as well use SASS and take advantage of its larger development community and usage.

@flying-sheep
Copy link

yes. if var-sigils are coming, enforcing : is superfluous

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants