public
Last active

Sass vs Stylus vs LESS

  • Download Gist
less.less
Less
1 2 3 4 5 6 7 8 9 10 11 12
.border-radius (@radius) {
-webkit-border-radius: @radius;
-o-border-radius: @radius;
-moz-border-radius: @radius;
-ms-border-radius: @radius;
border-radius: @radius;
}
 
.user-list {
// need to use special `.` syntax
.border-radius(10px);
}
sass.sass
Sass
1 2 3 4 5 6 7 8 9 10
@mixin border-radius($radius)
-webkit-border-radius: $radius
-o-border-radius: $radius
-moz-border-radius: $radius
-ms-border-radius: $radius
border-radius: $radius
 
.user-list
// need to use special `@` syntax
@include border-radius(10px)
stylus.styl
Stylus
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// This and all CSS3 funcs are included in `nib` stylus plugin.
border-radius()
-webkit-border-radius: arguments
-o-border-radius: arguments
-moz-border-radius: arguments
-ms-border-radius: arguments
border-radius: arguments
 
.user-list
border-radius: 10px
 
 
// or
 
.user-list {
border-radius: 10px;
}

Why stylus:

  • Customizable syntax. You can write plain CSS or you may drop braces / semicolons or even :s etc.
  • Transparent mixins. If you don't need a lot of features, you can just stick to dropping vendor prefixes. But, of course, advanced features are supported too.
  • nib. Contains all CSS3 mixins. It's like a compass for sass but way better because of transparent mixins. No need to remember awkward namespaces (like @import "compass/css3/text-shadow").

This is just awesome. Thanks a lot Paul for this comparison it just enlightened me. Will totally use Stylus from now on!

Your comparison is lacking, @paulmillr. Compass version (Sass syntax, which allows you to drop semicolons and braces too):

@import "compass"
.user-list
    @import border-radius(10px)

Compass is like a CSS cookbook: It contains solutions to a lot of known and reoccuring CSS problems and patterns, not just CSS3 mixins. It's the most complete and well-documented collection out there, and this is why you should use it. From something as easy as @include border-top-right-radius, for just rounding the top right corner, or @include horizontal-list for creating a horizontal UL menu, to complex spriting creation: http://compass-style.org/help/tutorials/spriting/.

Compass has a great community too. Want plug'n play CSS animations? No problem: https://github.com/ericam/compass-animate. Responsive (fluid) grids? http://susy.oddbird.net/

And yes: No need to remember awkward namespaces either, because you just @import "compass", and that's it.

@torkiljohnsen as you may see, i've used .sass in the example.

This two extensions allowance is bullshit. Stylus can into both .sass and .scss syntaxes without problems.

Stylus has cookbooks too, we're using them.

Still, I need to remember which properties I need to include mixins for. E.g. @include border-radius(10px) or border-radius: 10px?

Compass is the cookbook, and it's accessible at @import "compass". nib's small collection of mixins also requires installation and invocation, just like Compass, with for instance .use(nib()) or @import "nib/gradients" for instance. Compared to Compass though, nib is tiny.

nib also tries to improve the clunky CSS syntax with it's own mixins and properties arrangements. For instance in nib you can do fixed: bottom right;, for a fixed, bottom right positioning, without mentioning position: anywhere. In Sass syntax you'd spot the @import immediately. Explicit is better than implicit in such cases IMO.

I just think your comparison is lacking. Your three selling arguements was the shorter syntax, the transparent mixins in nib which is supposedly like a compass for sass, and the lack of awkward namespacing. I find that Sass has a very similar syntax, that transparent mixins may be short and sweet but perhaps too implicit, and that nib does just a fraction of Compass does, and has just as awkward a namespace.

I think Stylus brings too little, and is too late to the party. It's sexy by all means, but not too big a difference from LESS or Sass/Compass. LESS wins the popularity contest by being easier to get up and running for non-coders, where Sass/Compass and Stylus requires command-line installation. Compass brings the biggest one-liner install of a cookbook though, which is an amazing timesaver, and why I land on that side of the fence. I wish you luck with your Stylus endeavors though! Any preprocessor is better than not using a preprocessor at all ;)

@torkiljohnsen I guess you actually meant:

@import "compass"
.user-list
    +border-radius(10px)
app.use(stylus.middleware({
  compile: function(str, path){
    return stylus(str).set('filename', path).set('compress', true).use(nib());
  }
}));

^^ seems legit.

Stylus is maintained activelly ;).

The vendor prefix thing isn't really valid anymore, because of autoprefixer.

Where did you read that stylus is no longer actively maintained as of October, 2013?

@paulmillr last commit in the stylus repo seems to have been sometime in December : https://github.com/learnboost/stylus

Where has it been announced that stylus is no longer actively maintained?

Sorry folks  — i've meant Sass but it is probably maintained too

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.