
Ask HN: Do i really need a css preprocessor? - _dt47
Sass, LESS, most developers use a css preprocessor, but I don´t really see the use in them.<p>Should I still get used to using one for the sake of standards &#x2F; etiquette? Do most of you find it worth it to use one?
======
skylark
Having used both SASS and LESS professionally, I'll say that it's easy to end
up with an over-engineered mess that's difficult to maintain and reason about.

That said, the tooling around both preprocessors is great, so it shouldn't be
a huge burden to set it up. Because they're supersets of standard CSS, I don't
see a reason why you wouldn't use one. Use the features you like, ditch the
ones you don't.

------
MalcolmDiggs
Yes, and no.

Yes they can really help you organize larger projects easily. With variables,
you only have to write things once. If you change your "black" from #000 to
#1a1a1a, for example, that's one change instead of dozens. Nesting is another
useful feature that helps you separate one page/module from another, and keep
everything contained. Mixins and functions are super-useful if you find
yourself re-writing the same stuff over and over. Also, the preprocesing
itself is a great way to "lint" your styles (in a surface-level way). If
there's a syntax error, the preprocessor will just fail, exposing an issue
that might have gone unnoticed if you were using plain css.

But no, they don't help you write the most efficient CSS. So if performance is
your goal, you can probably write better/faster CSS if you target each element
manually, rather than letting the preprocessor target based on your nesting.

And no, they don't help you alleviate cross-browser issues; that's what auto-
prefixers and shims are for. Those are different tools, also useful.

And no, they don't help you keep your css tiny, that's what a concatenators,
minifiers, and utilities like "UnCss" are for. Also great tools, but separate
ones.

If you want to get all the benefits you can, your CSS build tool will need to
include many different phases. Preprocessing is only one phase; but may be an
important one, depending on what you're looking for.

Also,if you want to get started, just rename your .css to .less or .scss
instead, and preprocess it. Both less and scss are supersets of css, (so all
valid css is also valid less and scss). You can write vanilla css inside a
less file with no issues. That way, if the urge strikes you to experiment with
the features of the preprocessor, you can do so immediately.

------
lj3
That depends: do you use JS frameworks that require a compilation step? If
yes, then adding a step in there to compile your SASS or LESS code is easy and
has big advantages.

If you're using PHP or Python and don't use a JS framework that requires
compilation, then adding in tooling just for a css preprocessor might be more
work than it's worth. In that case, it might be more advantageous to use
whatever language you're using to generate css the same way you use it to
generate html.

~~~
herbst
Afaik most modern PHP or Python frameworks have preprocessing build in as
well. (Not always because of js). I see what you are saying tho, if you have a
plain PHP application and edit code via FTP, SCSS is a huge step in between.

For every semi modern environment it should be a non issue.

~~~
lj3
That's a good point. PHP and Python run their own server instances these days
instead of running in apache or nginx. I miss the simplicity of the old days.
:)

------
ryanto
It depends on the type of work you do. If you are putting together a handful
of pages and only plan on spending a few hours writing CSS then probably no
need for preprocessor.

On the other hand, if you're a front end developer or you find yourself
working on CSS multiple times a week then you should absolutely use a
preprocessor.

There are tradeoffs between the two approaches, but preprocessors do save you
time so the added complexity can be worth it the more you work on styling.

------
cauterized
Vanilla CSS is verbose, not DRY, and challenging to navigate and maintain.

You don't NEED a preprocessor. But as you find yourself writing larger CSS
codebases or trying to do more sophisticated things with it, you may find
yourself wishing for the features you get from a preprocessor.

------
jaxondu
You can get some Sass/LESS benefit using PostCSS with CSSNext plugin. CSSNext
will give you ability to use future CSS syntax now. If you want to go further,
there is even a PostCSS plugin precss that can replace Sass/LESS. I just use
CSSNext + autoprefixer + cssnano.

