JavaScript is a front-end programming language, programming engineers often use JavaScript on browser development, also called front-end development. So what is Node.js? We always mention it with JavaScript. Node.js is based on JavaScript: it lets JavaScript be executed on server side machines, so we can say Node.js is a back-end programming language. If we combine both Node.js and JavaScript, that will help us to build a complete website with both back-end and front-end programming.

Only one programming language in your life

In my programming experience, I studied many programming languages such as C/C++, Java, PHP, JavaScript, Node.js, Action Script, Shell Script, Python, Perl, Dart, Golang. I am not good in all of these programming languages, in fact, I was only familiar with three of these languages: PHP, JavaScript and Node.js.

There are many different demands that we need to solve in the world: different programming languages have different purpose for different things. JavaScript is created for the browsers: it can make the browser come to life. C and C++ is the basic programming of computer, whereas Java is created to support any devices and operating systems. PHP is created for the website crafting. Shell Script is a built-in language on linux system. Perl is also a built-in language on linux and it is more powerful than shell script. Golang gives the engineer a simplest programming language.

Nobody has time to learn every programming language, if there is a programming language can solve any problem mentioned above, that possible be JavaScript. Why? JavaScript can be used on website, Android App, IOS App , Server Side, IoT devices (Internet of Things),

I hope that engineers only need to learn one programming language in their lives: this language can be used in any environment.

You need to learn JavaScript

You don’t like something if you don’t understand it.

I agree the JavaScript is not a easy language, but it is not a hard language too.

If you can spend a lot of time learning C/C++ or Java, but you do not want to spend a little time learning JavaScript, and you just judge it because you read some bad JavaScript's code, then you will refuse to accept this language. That is a horrible attitude.

JavaScript is easier than C/C++, Java, Python and can be used in more environments than those program languages. I will explain how easy it is later.

Give JavaScript a chance

Some people like JavaScript but some people don't.

People who don't like JavaScript will say that JavaScript has many mythical and secret things, it is not a easy programming language for beginners to learn, also it is a little hard for advance developers. I think some of these people are right but it doesn't mean JavaScript is a bad language. Any programming languages have it's secret parts, we will say something is a magic if we don't understand what it is.

How easy JavaScript is

First, in Javascript, it is easy to define an array and object, because you can use bracket to represent an array and use curly bracket to represent an object in JavaScript, which makes it easy to handle objects and arrays even for the JSON data. The following example is how the JavaScript to handle these variables:

  1. // array
  2. var ay = [1, 2, 3];
  4. //object
  5. var o = {"key": "value"};
  7. //JSON
  8. var json1 = {"k": [1,2,3] }
  9. var json2 = [ {"k1": "v1"}, {"k2": "v2"}]

Second, JavaScript do not support member types such as public/protected/private, so you do need to case about these definitions. In most situations we really don't need to set the member types. The less features it has, the more easy it will be.

Anonymous function: let you quickly create functions and do not need to give it a name.

Closure : A easy way to get the parent's variables. Sometimes, closure will confuse you and produce many bugs, but if you understand the feature more, you will find that anonymous function and closure are good friends.

JavaScript drawback

  • Performance is not good enough.
  • Callback hell : it will make the code hard to read. We will use promise to solve this problem, like the library "Q", but another problem is that promises will be everywhere.
  • Function is a class or a object.

What you can not do on JavaScript

  • Function overloading
  • Private/Protected variables and methods. Actually, you can have private variables and methods in JavaScript, but you need to do some magic programming.
  • Self specify pointer
  • Struct : Use object or function to instead of struct.
  • interface

回應 (Leave a comment)