DEV Community

loading...
Cover image for Styling vs Scripting. 
Which one is the hardest to learn/control?

Styling vs Scripting. Which one is the hardest to learn/control?

dennisfrijlink profile image Dennis Frijlink ・1 min read

If you're a common web developer or even when you just started, you'd probably already have heard about the terms Javascript and CSS. Both are meant for different purposes and both (most of the time) are necessary for delivering the product.

However, many (web) developers have a prefer to pay more attention to one of the two sides. Javascript is a programming/scripting language that allows you to implement complex features on web pages. Think of data fetching or interactive UI (like modals, triggers etc.). By programming in Javascript you'll have to think logically and sometimes be creative with solutions/functions. With CSS in that case, a stylesheet language, it is not possible to implement features like we just mentioned. However that doesn't mean CSS is not important or even complex. The opposite is true! Many software developers who started once with their career as programmer, chose for backend programming because of the complexity of CSS. You have to think about a lot of things by styling with CSS. Think of responsive web design, mixins, spacing, positioning etc.

For both many developers/companies have introduced frameworks & libraries to make life for webdevelopers easier. Think of React.js (JS), Vue.js (JS), Bulma (CSS), Tailwind(CSS).
But the fact remains that many developers still prefer one over the other.

So what's your opinion about it? Is scripting in Javascript harder or styling in CSS? And why you prefer one over the other? Let me know in the comments below!

Discussion (9)

pic
Editor guide
Collapse
ivanjeremic profile image
Ivan Jeremic

Regex is the most difficult thing to learn.

Collapse
dennisfrijlink profile image
Dennis Frijlink Author

Regex is a term I dont hear much but it is used in Javascript, right?

Collapse
ivanjeremic profile image
Ivan Jeremic

Every programming language I know has Regex

Collapse
leob profile image
leob

Javascript is "imperative" - they're instructions - "first do this, then do that". If you know the principles of programming, then the basics of Javascript are pretty easy - and easy to reason about, for the average programmer.

CSS however is "declarative", not imperative - you state or "declare" the result that you want. If you do that wrong then the result will not be as you want it, but it's often hard to find out why - you can't simply debug it like you would debug Javascript.

On top of that what makes CSS 'hard' is that there are often many ways to accomplish the same thing - for instance layout (with float, or with flexbox, or with CSS grid).

One explanation for these "redundancies" is that CSS has a lot of historical baggage - it wasn't originally designed as a layout or styling mechanism for our modern day apps, rather it was designed for styling static content-focused websites, so a lot of features were tacked on later to make it work better for modern day "apps".

So, CSS is not only less intuitive/accessible for the average programmer (it's not a programming language), but it's also huge (looking at the scope and the number of features).

Collapse
dennisfrijlink profile image
Dennis Frijlink Author

Thanks for sharing your mind! Yess CSS indeed has a lot of ways of doing the same thing which makes it complex at the same time. Beside that I never thought about the fact you can't debug CSS, simply because of the fact it's not a programming language.

Collapse
sargalias profile image
Spyros Argalias

I think they're both very difficult because of how much there is to learn and because of how counter-intuitively they seem to work sometimes (they work differently to how you would expect).

I would say styling is both easier and harder. When starting out, I would say it's harder because there are so many unintuitive things and exceptions to rules. Kind of like the JavaScript "this binding" (which is also super unintuitive in my opinion), except tons of things in CSS are like that. Finally, in my experience, developers seem to completely neglect "clean code" and good architecture for CSS, making some projects impossible and far worse than your average JavaScript code.

The good thing is that you can mitigate those problems with CSS by learning from good resources and learning it so well that the unintuitive things are no longer a problem. Also there is far less to learn than with JavaScript or other scripting languages. So that's why I think that aspect of CSS is easier overall.

JavaScript isn't as bad. It's got some weird things (like "this binding") and there is a ton to learn, but those things make good sense in my opinion.

Collapse
dennisfrijlink profile image
Dennis Frijlink Author

Thanks for your detailed answer. I agree with the fact that there is way more to learn in Javascript than in CSS.

Collapse
jonyk56 profile image
Jonyk56

styling is my worst nightmare

Collapse
dennisfrijlink profile image
Dennis Frijlink Author

Yeah I hear that a lot! Many people choose for backend programming or focussing on the JS in the frontend because of styling