Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'ve been talking with a friend about the purpose of Javascript, when and how i

ID: 641864 • Letter: I

Question

I've been talking with a friend about the purpose of Javascript, when and how it should be used, etc. He quoted that:

JavaScript was designed to add interactivity to HTML pages

[...]

JavaScript gives HTML designers a programming tool

HTML authors are normally not programmers, but JavaScript is a scripting language with a very simple syntax! Almost anyone can put small "snippets" of code into their HTML pages JavaScript can react to events
A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element JavaScript can read and write HTML elements
A JavaScript can read and change the content of an HTML element JavaScript can be used to validate data
A JavaScript can be used to validate form data before it is submitted to a server. This saves the server from extra processing
JavaScript can be used to detect the visitor's browser - A JavaScript can be used to detect the visitor's browser, and - depending on the browser - load another page specifically designed for that browser.
JavaScript can be used to create cookies - A JavaScript can be used to store and retrieve information on the visitor's computer.
However, it seems like Javascript's getting used to do a lot more than these days. My friend also advocates against using Javascript's OOP functionality, claiming that "you shouldn't be processing data, merely validating." Is Javascript really limited to validating data and making flashy graphics on a web page?

He goes on to claim "you shouldn't be attempting to access databases through javascript" and also says " in general you don't want to be doing your heavy lifting in javascript". I can't say I agree with his opinion, but I'd like to get some more input on this.

So, my question: Has Javascript evolved from the definition above to something more powerful, has the way we use it changed, or am I just plain wrong? While I realize this is a subjective question, I can't find any more information on it, so a few links would be good, if nothing else. I'm not looking for a debate, just an answer.

Explanation / Answer

People who think JavaScript is not a programming language are people who's opinion on JavaScript you should not respect.

JavaScript is a language that has grown organically inspired by semantics of Scheme and syntax of Java. It's original purpose was not general but it has now grown to be so.

JavaScript as a language is suitable to do just about any task if it's fit for it. Take a look at examples like node.js where JavaScript has access to host environment consisting of IO functionality which allows it to be used for generic server side programming

My friend also advocates against using Javascript's OOP functionality, claiming that "you shouldn't be processing data, merely validating." Is Javascript really limited to validating data and making flashy graphics on a web page?

No, JavaScript is a programming language, if you want to represent data structures, algorithms and logic then use the tools the language offers. Specifically 1st class functions and prototypes are powerful tools.

He goes on to claim "you shouldn't be attempting to access databases through javascript" and also says " in general you don't want to be doing your heavy lifting in javascript". I can't say I agree with his opinion, but I'd like to get some more input on this.

Wrong, In the browser we have a database called indexedDB which we access with JavaScript. It's a database baked right into the browser and if you want to use it (and you should) then you use JavaScript.

Also note that both mongodb and couchdb allow you to use javascript to run adhoc queries on the database directly.

As for heavy lifting, he's partly correct. If your doing heavy lifting you should be doing it in C or erlang. Although note that the term "heavy lifting" is vague, for example I wouldn't encode or decode videos in JavaScript, I wouldn't do image processing in JavaScript (use C). I wouldn't no number crunching in JavaScript (use fortran).

Has Javascript evolved from the definition above to something more powerful, has the way we use it changed, or am I just plain wrong

JavaScript was written in a period of 2 weeks just to slap minor scripting functionality into HTML. Since then it has grown severely. Since ES3 (1999) it has been a powerful general purpose programming language.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote