Kaspersky Internet Security 2012 -->

Saturday, October 26, 2013

Why Node chose JavaScript


Node is programmed using JavaScript, a language familiar to web development professionals. JavaScript’s syntax and naming conventions are influenced by C and Java, but the language is higher-level, meaning it generally takes less lines of code in JavaScript to express the equivalent C or Java logic. Despite JavaScript’s comparative brevity, however, it is powerful. In its early years, JavaScript was disparaged due to incompatibilities between browser implementations and difficulty of debugging, but, as time went on, implementations improved and the expressiveness of the language gained appreciation.
JavaScript is excellent for specifying asynchronous logic because functions are “first-class objects.” This means the language allows functions themselves to be passed as function arguments, used as return values, and assigned to variables.
Callback functions are used to specify asynchronous logic. A callback is a function argument that contains a reference to program logic. Callbacks indicate an action to take when a programming event occurs or after intermediary logic is completed. JavaScript’s callback syntax is very elegant: either a function name or syntax- defining function logic can be passed as a callback.
JavaScript also has the advantage of being portable between the browser and the server. As long as any APIs accessed by logic are available on both the browser and the server, the same logic should run in either environment. Form validation, for example, is often duplicated on the client and the server. Why write the same code twice? Reusing logic on both the browser and the server enforces consistency and means not having to reinvent the wheel. It also means you have to maintain less code. Another benefit is you don’t have to mentally context-switch between languages when working on different parts of a web application. Staying in one language is likely to increase your productivity and make development more enjoyable.

Web applications are just the beginning
Node can develop much more than web applications. Node is also a good fit for designing servers, protocols, and command-line applications.
Server applications such as file transfer, email delivery, and instant messaging applications have traditionally been created in non-dynamic languages such as C, C++, and Java. C is a flexible and powerful language but is comparatively low level and can be challenging to learn. C++ significantly extends C but offers a cornucopia of language features that, if not used correctly, allow you to “shoot yourself in the foot” (the ability to redefine operators like “+” is one example). Java has fewer sharp edges than C++ but is more verbose than C and less flexible than dynamic languages.
As we mentioned earlier, Node breaks from tradition and leverages JavaScript, which makes it accessible to a large number of programmers. Given JavaScript’s strengths, if Node is widely adopted by server developers, the result will likely be quicker application development and increased diversity in server software.
Node versions of a variety of traditional server applications have already been written. Node-based DNS servers, web crawlers, message queue servers, and many other types of applications exist.
Node is also useful for exploring and implementing TCP/IP protocols. A recent example of improving the Web with new protocols is the WebSocket protocol. The Web’s first real-time applications used AJAX to exchange messages with the web server. AJAX uses HTTP as a transport mechanism to send messages back and forth to the server. Because HTTP requires a lot of communication overhead, AJAX’s performance is limited and both server and client have to do extra work. WebSocket was created in 2010 to provide an alternative: a lightweight, bidirectional protocol specifically focused on real-time textual communication.

The popular Socket.io project, which implements a robust Node-driven WebSocket server, is a good example of Node being used for protocol development.

page3image34984
The things that make Node perfect for server development also make Node a great candidate for the development of command-line interface (CLI) applications. Examples of common CLI applications include version control applications, database clients, and compilers. In addition to its networking API, Node offers access to functionality commonly needed by CLI applications: filesystem, process, and operating system functionality.

The Node community has created modules that make CLI application development easy by elegantly handling option and command parsing. The combination of the familiar JavaScript language with Node’s elegant APIs and easy CLI parsing has the potential to unleash the creativity of many who have, until now, only dabbled in CLI application creation.

Node can pretend to be a browser
Because Node is programmed in JavaScript, the language of the Web, another useful thing that Node can do more easily than other web frameworks is emulate web browser functionality. Emulating a web browser is useful for “web scraping” (parsing HTML from files or websites) and automated web application testing.
JSDOM, a Node community add-on, allows Node to emulate the web browser’s Document Object Model (DOM). The DOM is essential for web browser emulation, acting as a JavaScript-accessible interface to HTML/CSS content. By emulating the DOM, Node can read and write HTML in a virtual browser. Node can then take advantage of high- level JavaScript libraries, like JQuery, that allow high-level manipulation of the DOM.

Summary
We think any web developer who spends the time to explore Node is going to end up thinking of web development in a new way and will greatly enjoy themselves in the process. 

No comments:

Popup Generator
Popup generator software, popunder, dhtml popup, dhtml window. Bodog
Use bodog bonus code 1349384 to get a huge 110% bonus at bodog poker. Additionally the same code can be used at bodoglife property for an exclusive bonus. Chicago Limousine Service
Chicago limousine service offers professional limousine tours and airport transportation. Wedding Cars West Yorkshire
Bliss wedding cars is an independent family run business based in wakefield, offering chauffeur driven transport covering huddersfield, dewsbury, pontefract & the surrounding district. Rolls royce silver shadow, silver spur and jaguar sovereign. Casino Bonus Code
The highest exclusive online casino and online poker bonus codes. Also featuring daily updated poker and casino news as well as strategy articles.Add Url To Health And Medicine Directory
Health directory including health article, health rescources, man health, woman health, addiction, nutrition, herb, weight loss products Search Engine Optimization Dallas Internet Marketing Services
Multilingual search engine marketing consulting, and search friendly web design. Catanich internet marketing dallas texas is a team of internet marketing consultants providing website marketing consulting services to online internet companiesAmpliación Del Pene
Por los 6 años pasados vigrx ha contenido como el suplemento masculino del virility del número 1 se convirtió científico para dar resultados seguros y eficaces ustedAdd Your Website To 100 Web Directories.
Add your website to 100 web directories. Herbal Viagra
Herbal supplements at an affordable price! Home Speakers
Search through this great collection of brand name speakers Truck Graphics
Customize rear window graphics for your vehicle, truck, suv or car! Truck window decals and more are available. Our categories are: art, fantasy, fishing, horses, hunting, military, nature, patriotic, racing, snow sports, and wildlife. Singapore Seminars
Singaporeseminars. Com is singapore's no. 1 seminar, events & conference portal. Looking for the best resources, here's the one stop portal in singapore. Chicago Limousine Service
Chicago limousine service offers professional limousine tours and airport transportation. Classic Cars Market Place Advertising Broker Services
Classic cars market place advertising brokers services will sell or find the car of your dreams. Antique custom vehicle,vintage car,hot rod,hemi engines. The american hot muscle car dream just a click away. We are your no1 marketing classiccar center Domalot Web Hosting
Offers cheap shared, virtual dedicated and dedicated web hosting services: linux or windows hosts. Also provides search, registration and transfers for domain names.