Wednesday, August 12, 2015

Web Development: part 2

I learned something about web development that makes my head spin a little. Way back in the dark ages of the internet (1999) web developers built everything from the base elements of HTML, CSS, JavaScript, PHP, and probably a few others I don't know about yet. The point is that they built everything from scratch typing it up from a digital ex nihilo (out of nothing). So far, this is how I have been learning to code, either starting with a blank file or using a pre-made template that was created the ex nihilo method. This way of coding makes sense to me, it is relatively straight forward albeit time consuming.

Then I learned that this is not how web development works anymore. Nobody just codes everything from scratch. Over time coding languages evolved and web developers put together entire libraries of commands and alternate languages that take the base elements of coding and turn things that would take 10 lines of code into 1 line of code.

Here is a popular example that illustrates my point.




How to change the background color in JavaScript (base programming language)

Function changeBackground(color) {
          Document.body.style.background = color;
}

Onload="changeBackground ('red');"



Now here's that same code again but this time in JQuery (library that manipulates JavaScript)

$ ('body') .css ('background', 'red');



Alright, so now there are shortcuts that make coding quicker and easier, that's cool right? Well yes, it's very cool. So what's the problem then? The problem is that there are so many powerful libraries and alternate languages out there today that simply managing them has become a paramount skill for success in the industry and its a skill I don't have yet. The more code I see for websites the more I see that they are built off of lists of enormous libraries of commands that I have absolutely no understanding of.

I saw this first a few days ago training in PHP on Team Treehouse. I was walking through the construction of a functional website and the first half of the lesson was simply installing all of the extra libraries we would use. Heck even the libraries were inside a library that needed to be installed before we could begin! Then we started to utilize all these extra pre-made functions in the code and the magic started. Instead of having to code the sanitization of user input myself (would easily take up 100 lines of code) the instructor called the 'sanitize input' function from one of the libraries with one line of code. Instead of creating our own code for sending emails he just referenced 'quick mailer' and hours of troubleshooting turned into 4 lines of code that will work every time. Then things got even crazier when he moved every piece of code that was repeated between different pages, deleted it all from those pages, and brought it all back with 2 lines of code that referenced back to the saved template so that every new page on the site could be created in seconds and any changes could be made equally as fast.

So web development isn't about being able to code, although that is still a necessary skill, it is now more about knowing what tools (libraries and languages) are out there and when / how to use them. Any web page can be created any number of ways, there is rarely ever a single right way to reach your destination (true in programming, not so much in theological matters) the key is knowing how to get there efficiently and with solid code.

So I have more learning to do. I need to become familiar with importing libraries and reading the documentation for how to use them. I find the documentation to be the most intimidating part. I barely know what I'm looking for and scanning the hundreds of functions for the one or few that would accomplish what I need is like finding a needle in a haystack except the needle is proverbial and the haystack is on fire... or something like that...

And now I hear my two year old son is up to mischief...

Greg Out.

No comments:

Post a Comment