Sass, scss, less, and why/when/which/where to use them?

After developing a little project that is still ongoing, I have learnt a lot about html and css, although still dabbling in JS. This being said, I heard people talk about sass and scss, but since I had a deadline I didn't stop too much to think about those. Now that I'm looking more into them, they seem quite interesting and like a potentially good resource to use. Looking online, however, I've seen mixed opinions. A lot of people recommend them for everyone, others for big projects, and some just prefer to stick to plain CSS. And trying to look up what the difference is, I've only found sorta vague info like "sass and scss are the same but sass uses indents while scss uses {}, etc", and I am frankly a little confused. Sorry if the following is a lot of questions, but I am just very curious for input from people who work with these: - How worth it is it to use these as a personal developer? - Which one is recommendable over the other ones, in your opinion, and for what reason? Or perhaps there's no considerable difference? - If one wants to stick with base CSS, is it a sort of voluntary hinderance? - What size/scope of project would definitely require these?
88 Replies
Joao
Joao7mo ago
This is a classic question that can only be answered with "it depends"... you don't need a CSS pre-processor, it just makes some tasks easier.
ἔρως
ἔρως7mo ago
what he said, basically sass also extends the syntax of the css, even the nesting, to do things that regular css can't
Jochem
Jochem7mo ago
(just as a point of house keeping and future reference, this is more of a question for #discussions than #front-end. No need to move this there, but if you have similar general questions that's where they're supposed to go)
ἔρως
ἔρως7mo ago
if i had to pick, i would pick based on how lazy my personal project is meant to be
Joao
Joao7mo ago
Agreed, let's keep it short. For me: - SCSS because using brackets feels more natural to me given how CSS already uses them. - Any project that needs to have enough rules that makes it worth to split it into multiple files, if nothing else for organization. - Mixins make some things like media queries or dark theme easier to handle (at least for me).
ἔρως
ἔρως7mo ago
functions make stuff easier, like variables and colors
Joao
Joao7mo ago
Consider also that you can default to use SCSS and still write CSS normally, since it would be valid anyway. So you don't really lose anything.
ἔρως
ἔρως7mo ago
yup, all valid css is valid scss (when i say "sass" i mean "scss", by the way)
Joao
Joao7mo ago
And when I say SCSS I mean SASS 😂 Whatever, same difference
ἔρως
ἔρως7mo ago
it's just horrible python syntax vs normal css
Joao
Joao7mo ago
curly braces FTW
ἔρως
ἔρως7mo ago
there's a lot of stuff that is worth it with sass, like having a file to configure all the colors and sizes and make repeated selectors a lot easier for browsers that can't accept :is and :where i actually like python, but the sass syntax is just hot steamy garbage, in my opinion better just use scss's syntax and live happy
What size/scope of project would definitely require these?
for this specific question, none require it but it makes collaborating A LOT easier, specially if you have a good file structure
Joao
Joao7mo ago
Yes, I think we should ask why not to use SCSS at this point. Probably only for simpler projects, but then again just the ability to organize files logically makes it totally worth it.
Highly Nonexistent
Noted!!
ἔρως
ἔρως7mo ago
well, a self-contained awful project is a good reason to do not use scss but for everything else, if you have a good workflow, integrating sass is just painless and a very good idea
Highly Nonexistent
And I see, these are actually very helpful answers!! I do like that one can just use css normally when using scss, and overall just having the same syntax. I will look into these both but I think I have a little better grasp on them. So if I use scss I'm assuming that i'd just have to learn the syntax of sass but most other things would be the same (and vice versa) ?
ἔρως
ἔρως7mo ago
well, yes but actually no but yes sass is to css what typescript is to javascript
glutonium
glutonium7mo ago
some additional things such as loops for example and variable declaration (all though u can still do css like declaration) those have some new syntexes but 90% of scss is just vanila css
ἔρως
ἔρως7mo ago
and with that, comes a lot of stuff that's impossible in css, like loops and new functions and the glorious mixins
glutonium
glutonium7mo ago
and even css now has nesting, that makes it even more like css
ἔρως
ἔρως7mo ago
yes, but the sass nesting is just amazing
glutonium
glutonium7mo ago
yaa xD
Jochem
Jochem7mo ago
though it's important to remember that scss just compiles down to regular css. Nothing that you do in SCSS is impossible in vanilla css, you just get super big shortcuts in writing it
glutonium
glutonium7mo ago
I don't like the fact that in css u need to add the & all the time
Highly Nonexistent
Ah yes, I had seen those other features and knew that the preprocessors could do things in an easier way!! My question was between preprocessors, is there anything that sass doesn't have on scss or the other way around, for example?
Jochem
Jochem7mo ago
afaik sass and scss are the same thing, just a different syntax sass being the weird indentation dependent one, and scss being a superset of css syntax
glutonium
glutonium7mo ago
sass also has modules no? idk if scss has it
Jochem
Jochem7mo ago
scss even just stands for "sass-y css"
ἔρως
ἔρως7mo ago
yes, they do
glutonium
glutonium7mo ago
like @use sass:math
Jochem
Jochem7mo ago
Sass: Syntax
Syntactically Awesome Style Sheets
glutonium
glutonium7mo ago
dats nice
Jochem
Jochem7mo ago
Sass supports two different syntaxes. Each one can load the other, so it’s up to you and your team which one to choose. * SCSS * The Indented Syntax
Highly Nonexistent
Ohhhhhhhhhh I thought they might have been two separate things
Joao
Joao7mo ago
So, in summary: use SCSS and enjoy 😄
ἔρως
ἔρως7mo ago
what i meant isn't that it makes css do impossible things, but things that you couldn't do with just plain css
glutonium
glutonium7mo ago
i feel like scss better makes it feel more natural xD and idk, i feel like curly braces makes it more readable
ἔρως
ἔρως7mo ago
it's the same, but one is just (s)css and the other is just unusable
Jochem
Jochem7mo ago
well, it lets you do things with css that would be impractical to write by hand, but it still just produces vanilla CSS output
ἔρως
ἔρως7mo ago
i think you aren't understanding what i meant, but you're right in what you said let me try to find my cursed code from 2 weeks ago
Jochem
Jochem7mo ago
probably don't bother, it's not really relevant to the discussion and I'm heading offline 🙂 just wanted to make sure that someone trying to make a choice between vanilla and sass knew that sass cannot make a browser do anything that css and some time typing / generating couldn't do
ἔρως
ἔρως7mo ago
yes, that's basically it but then you can do stuff like this:
[data-component="xyz"] {
@each $selector in ("&:last-child", "&:has(+ template:last-child") {
@at-root {
main > #{selector.nest(&, $selector)} {
color: red;
}
}
}
}
[data-component="xyz"] {
@each $selector in ("&:last-child", "&:has(+ template:last-child") {
@at-root {
main > #{selector.nest(&, $selector)} {
color: red;
}
}
}
}
which is cursed, but can be extremely useful and this is something you can't do with css but the end result will always be normal css
Jochem
Jochem7mo ago
I mean, it compiles down to vanilla CSS so you can it just takes a lot of typing
ἔρως
ἔρως7mo ago
can you escape the nesting in vanilla css?
Jochem
Jochem7mo ago
you're running an @each loop, which will generate code. You can generate that code yourself using a keyboard. you say yourself it turns into vanilla CSS
ἔρως
ἔρως7mo ago
yes, but what it is doing is impossible with css, currently but the final result is pure clean vanilla css
glutonium
glutonium7mo ago
i think jochem here is saying whats equivalent to all languages get compiled to binary while the other person saying what's equivalent to saying some languages r easy and some r hard xD I think both are on different page xD
ἔρως
ἔρως7mo ago
in css, if you nest, you can't escape the nesting
Jochem
Jochem7mo ago
then it's clearly not impossible, it would just be more verbose like the generated CSS sass produces
Highly Nonexistent
Either way I get what you both mean !! It's useful to not have to type the same things over and over for repetitive tasks like this
ἔρως
ἔρως7mo ago
yes, but remember that the final result has to be proper css
Highly Nonexistent
While either way still being able to combine it with CSS because it's not just a whole new language
ἔρως
ἔρως7mo ago
well, it's what's called a "superset"
glutonium
glutonium7mo ago
it's actually a rule of thumb in programming thay you don't repeat code it's a better practice cause it makes your code cleaner xD
ἔρως
ἔρως7mo ago
it is a whole language that's piggy-backing another base language and the output of compiling that language is the piggy language when you compile scss, you get css when you compile typescript, you get javascript
glutonium
glutonium7mo ago
u can also try checking out pug that's for html that's also a nice preprocessor helps u code faster
Highly Nonexistent
Oh, that one I hadn't heard of
glutonium
glutonium7mo ago
yaa it's nice
Highly Nonexistent
Will look into it as well!!
glutonium
glutonium7mo ago
they aren't hard cause the base language html itself is basic and easy it's just the syntax that's different
Highly Nonexistent
Yeah I mean, anything that cuts down unnecessary time and convolution is always welcome
ἔρως
ἔρως7mo ago
yup, and sass helps a lot with that
glutonium
glutonium7mo ago
btw does astro lets u use pug in it?
ἔρως
ἔρως7mo ago
i don't use astro so, i have no idea i use php for the backend
glutonium
glutonium7mo ago
i was wondering is u can use pug with react, i found out babble does let u do that but i saw that the syntex is just messed up 😂 hmm k no prob xD
ἔρως
ἔρως7mo ago
i mean, react makes it so you have to use cursed stuff like <> and </> to avoid giving your code a serious case of divivitis
glutonium
glutonium7mo ago
ahahah
b1mind
b1mind7mo ago
Pug+stylus 😋
ἔρως
ἔρως7mo ago
i didn't coin that term, by the way i heard that stylus is better, but never tried it
glutonium
glutonium7mo ago
react is already cursed enough and when I saw how the syntex goes with pug i said, nope.. life is already enough messed up
Highly Nonexistent
Stylus?
b1mind
b1mind7mo ago
You would hate it from what you said above 😂
ἔρως
ἔρως7mo ago
i mean, it has dot-syntax for maps instead of the horrendous map-get($variable, 'key_name') ... or whatever cursed thing it uses another language that generates css
b1mind
b1mind7mo ago
I think with Vue and if you use Svelte-preprocess I had talked them into adding support but now they use vite-preprocess by default
Highly Nonexistent
Ahhhh
b1mind
b1mind7mo ago
Yea it's the one you left out hehe
glutonium
glutonium7mo ago
sounds good
Highly Nonexistent
So how does vue fit or break with the whole sass less thing? Sorry not vue Stylus lol
b1mind
b1mind7mo ago
If nothing else I'd always use PostCSS if I already was using a bundler typically with SCSS too. Just cause postCSS plugins are awesome.
Highly Nonexistent
Could you give me an example? Also I had never heard of PostCSS before either lol, so I am gonna be asking a lotta questions if everyone keeps mentioning more interesting things
b1mind
b1mind7mo ago
PostCSS Plugins
Transform CSS with the power of JavaScript. Auto-prefixing, future CSS syntaxes, modules, linting and more are possible with hundreds of PostCSS plugins.
b1mind
b1mind7mo ago
Too many to give examples But I use autoprefix, one the merge media query ones, font face, ummm 🤔 then kinda depends. You can write lots of modern CSS with a few too, and not have to worry as much about support, as it will compile to polyfill or fallback for you.
Highly Nonexistent
Huh, this is all very interesting, and while I would love to explore all of these, I think this is a little overwhelming will all the different options. Why would someone use PostCSS over scss, for example? Or does it even matter which one I choose? I'm not even a front end dev!! But I do think having the opportunity to use these skills one day somewhere could be good
b1mind
b1mind7mo ago
Like I said I use both, but you can use just postCSS if you just wanted the extra boost from plugins or using more current CSS. or just use SCSS which ever xD Vite is setup for both out of the box and mostly what I'm using these days too so that factors in. It's not hard to add to most build/bundlers these days though.
Highly Nonexistent
Ohhh okay, I assumed that you could not use both at the same time or something, that's at least better to know
b1mind
b1mind7mo ago
Kevin Powell
YouTube
Learn how to power-up your CSS with PostCSS
If you're going to use the preset-env, I'd strongly recommend adding the PostCSS Language Support plugin to VS Code, so that it recognizes the CSS you are writing: https://marketplace.visualstudio.com/items?itemName=csstools.postcss PostCSS is an absolutely amazing tool, so let's see how we can use it! 🔗 Links ✅ PostCSS: https://postcss.or...
b1mind
b1mind7mo ago
Kevin Powell
YouTube
CSS is getting better, but Sass is still relevant
🎓 Learn Sass, how we can use it with other tools like PostCSS, and how we can use it for things like theming, design systems, and general project architecture in my course BeyondCSS https://beyondcss.dev?utm_campaign=launchpromo&utm_source=youtube&utm_medium=whyiusesass (use coupon code earlybird for 20% off, valid until the 4th at midnight EDT)...
Highly Nonexistent
Time to add those to the queue of Kevin Powell videos to watch