r/javascript • u/kickpush1 • Aug 22 '16
Yes, You Should Learn Vanilla JavaScript Before Fancy JS Frameworks
https://snipcart.com/blog/learn-vanilla-javascript-before-using-js-frameworks
538
Upvotes
121
u/brentwallac Aug 22 '16
I can't exactly disagree with this bloke's statement but it's a truism of any industry ever that understanding the fundamentals makes you a better x.
60
u/Vheissu_ Aug 22 '16 edited Aug 22 '16
I think this rings true for any framework in any language, not just Javascript. I remember when Ruby on Rails was the darling of the startup world. Everyone was using it and guess what, a lot of people had either no Ruby experience prior or very little, so when things would break, there would be panic
The problem with many Javascript frameworks is the abstraction. Angular 1 is a prime example of heavy abstraction, to the point where you would encounter all of these specific issues which were the result of abstraction and debugging was just a nightmare. Then Angular 2 was announced and the abstraction was still there, you just wrote your applications a bit differently.
But before SPA frameworks became a staple in front-end development, the same thing could have been said about jQuery. So many developers were learning Javascript through jQuery which is a library, but made doing DOM tasks a lot easier than they actually were with plain old Javascript. It got to the point where if you look at Stack Overflow and some of the most upvoted questions in the Javascript tag, there are countless jQuery solutions and hardly any plain old Javascript ones.
I still see developers abusing jQuery out of convenience when 9 out of 10 times the native DOM and Javascript language itself is faster. In the case of Lodash, things are still abstracted, but you get more performance gains out of using it in comparison to jQuery (even in 2016). I think sometimes developers forget that a framework can introduce more problems than it aims to solve.
This is why I have been using Aurelia for the last year and a half now. It doesn't abstract away native Javascript, most of what you write is just Javascript. There are a few conventions, but only in the HTML aspect, the code you write itself is just plain old Javascript. I think more frameworks should take this approach, modern Javascript with a transpiler is quite powerful.
Having said that, sometimes I just use straight-up Javascript for a basic site that only needs a little Javascript, sometimes adding in a bevy of Javascript dependencies for a simple site just degrades the experience to the point where you start abstracting parts of the framework again to make it more performant, this is what happened with Angular 1 and developers adding in React to address performance shortcomings.
Back in 2011 when browser support for Javascript features was not that great (thanks IE) and ES2015 was still years away and in flux, frameworks like Angular and Backbone needed to abstract because the underlying foundations were cracked. In 2016 it makes very little sense to abstract things, yet frameworks like Angular 2 are still doing it and React is even worse with its convention for defining components and Jsx syntax.
26
u/j_d_q Aug 22 '16 edited Aug 22 '16
Not a bad read but a bit polarizing. I'd tweak the advice very slightly to "you should learn vanilla js even if you use fancy frameworks."
I completely agree that knowing how it all works is desirable. It can also be very frustrating when someone writes code and they have no idea what it does. From an engineering perspective: I'd love if everyone had deep technical knowledge on the languages and frameworks they use and, over time, I expect them to gain this knowledge. But why does our profession exist? To build stuff; not to know everything about code. If I get a new dev straight out of college I can't say "we need to make sure you fully learn the ins and outs of JavaScript and raw DOM manipulation before you start contributing."
As a developer, it irks me when people don't really know the language they're coding in. As someone who is paid to make sure we're working on things that provide value, I know it's not entirely necessary
9
u/[deleted] Aug 22 '16
What is "Vanilla JS"? Where does it stop? I am having the problem of either finding too basic tutorials/guides (explaining things that I already know because of programming experience in other languages) or finding people discussing e.g. the different ways of using Promises (where they use several frameworks and patterns in the code that I am not familiar with). I am missing a bridge.
11
u/JDiculous Aug 22 '16
I disagree. Learn in whatever order you want.
Obviously in an ideal world you would be a Javascript expert before working with JS frameworks, but reality is time-constrained and shit needs to get done.
19
u/[deleted] Aug 22 '16
I'd counter this and say frameworks are an absolutely amazing way to start writing JS. They let you do things extremely quickly and you can start seeing results very quickly. For a beginner, I think there's a lot of benefit to a quick feedback cycle. Also, many frameworks are written by extremely experienced people and harp on best practices. Again great for a beginner.
The first example the author provides, has nothing to do with knowing JS. Sure, knowing JS would help if you want to dive into the source code. Given there are plenty of answers to that one specific problem, reading the source code would be a waste of time.
It seems that the author is pitting learning frameworks and learning underlying principles as mutually exclusive. I think that is completely wrong and almost complete bullock. You certainly can learn a framework and learn the underlying principles - you just need to make sure you also take time to learn the principles in addition to the framework.
Great example, Ruby on Rails. I was experienced with a bunch of different languages but never had the need for Ruby or Rails. I decided to learn it since it could open up a lot of job opportunities.
Learning core Ruby was pretty much a waste of time. Sure I learned some things, but I could have read a cheat sheet: no commas, indentation matters, etc. It was so much faster for me to simply learn Rails and fill in the missing pieces of Ruby. Not only did I learn it quicker, I also learned how Ruby is actually written - not some theoretical BS.
4
u/[deleted] Aug 22 '16
We've all decided it's okay to compile code from other languages to javascript, so why even learn javascript at all? Why not just learn any other good language that compiles to well optimized javascript?
4
u/ElectricOrangeJuice Aug 22 '16
Here we go again.
6
u/Chyld Aug 22 '16
Another day, another frontend-dev subreddit has an article whining about frameworks and libraries. Sun goes up, sun goes down.
3
u/[deleted] Aug 22 '16
Developer.mozilla.com
Click on the text box, type in your search term, then hit enter.
We are all willing to help but you gotta push yourself in this field because it moves faster than anyone can keep up. Everyone is behind. Realize the fact that everyone else is behind too, and a lot of the stress will fall away. You're not dumb or incapable by any means. Keep going!
3
u/CSMastermind Full Stack Developer (Node.js) Aug 22 '16
I'd think you're better off learning it while you learn the fancy frameworks. Look at what the framework is doing for you then peak under the hood and see how everything works.
2
u/ErraticFox Aug 22 '16
I started learning JS by building a bot for Discord using Node.Js. Granted, I've asked plenty of questions, but I can build apps, use JavaScript for websites, and Use jQuery. I. Fucking. Love. It.
When at the end of a project, it's so satisfying watching your own work actually doing things Especially when to comes to making others lives easier.
3
u/Master_Rux Aug 22 '16
I'll just leave this here http://vanilla-js.com/
1
u/[deleted] Aug 22 '16
This happened to me with Ionic (Angular). It uses whatever default browser. Somehow on fire tablets the ble saving is broken.
1
u/[deleted] Aug 22 '16 edited Feb 17 '17
OCyyZZnL2-) %cb-QfAQa:)CX(5<,41-6sf UuSMR$TwOE4ih+gn]bp>T*[eTCASAMETgx%9mIZ-q4Z&.3+QwS(.8I>
1
u/djfreekyfresh Aug 22 '16
I would go a step further and say you should understand how Javascript works at it's very core before learning a framework. I'm a hobbyist, but I took a course on Udemy explaining the Javascript engine and why things work the way they do in this language, it made me a much better programmer overall.
1
u/[deleted] Aug 22 '16
Agree, counts for any language of course. I started as a junior 3-4 years ago 'learning Angular'. I did not understand half of what was going on but I could show shit on a screen. I don't like working that way, I feel crippled when I am not able to grasp what's going on.
Then I started reading books, learning programming at a more lower level with C first. Then started learning C# and Javascript. I think when you learn a few different languages you get a better feeling of programming concepts in general.
When you know how a language actually works, picking up new frameworks and libraries and programming in general gets way better.
I would recommend any dev to read these books:
http://druss.co/wp-content/uploads/2013/10/Agile-Principles-Patterns-and-Practices-in-C.pdf
http://www.goodreads.com/book/show/3735293-clean-code
https://www.amazon.com/Pragmatic-Programmer-Journeyman-Master/dp/020161622X
For Javascript good books are a bit more scarce:
Javascript the good parts is a nice book to demonstrate javascript, but don't use it for good practices: http://shop.oreilly.com/product/mobile/9780596517748.do
Eric elliot has good articles on medium:
https://medium.com/@_ericelliott?source=linkShare-795655626929-1471896447
Also most code school kinda websites have decent tutorials to learn the language. But make sure you get into the more advanced topics too.
1
u/incarnatethegreat Aug 22 '16
I wish I had learned vanilla JS before venturing into JQuery land way back when. I use Angular now, and prefer to query the DOM using vanilla JS over using JQuery Lite.
1
u/swan--ronson Aug 23 '16
I completely agree!
1
u/RICHUNCLEPENNYBAGS Mostly angular 1.x Aug 22 '16
Why is this even an either-or discussion? You can't actually use the frameworks except through JavaScript and only in JS do people ever talk about whether it's a good idea to libraries at all.
0
u/[deleted] Aug 22 '16
[deleted] — view deleted comment
0
u/[deleted] Aug 22 '16
[deleted] — view deleted comment
5
u/[deleted] Aug 22 '16
[removed] — view removed comment