INDUSTRIES BENIFITTED BY JAVA SCRIPT

Adithya Gangadhar Shetty
6 min readJun 25, 2021

--

In this blog I have discussed about Javascript solving industry use case one such company is eBay . To Understand the USE-CASE one must have a better knowledge of javascript so lets get started.

JAVASCRIPT

JavaScript is a scripting or programming language that allows you to implement

complex features on web pages every time a web page does more than just sit there and display static information for you to look at displaying timely content updates, interactive maps, animated 2D/3D graphics, scrolling video jukeboxes, etc. you can bet that JavaScript is probably involved. It is the third layer of the layer cake of standard web technologies, two of which (HTML and CSS) we have covered in much more detail in other parts of the Learning Area.

WHAT JAVA SCRIPT DOES !

The core client-side JavaScript language consists of some common programming features that allow you to do things like:

Store useful values inside variables. In the above example for instance, we ask for a new name to be entered then store that name in a variable called name.

Operations on pieces of text (known as “strings” in programming). In the above example we take the string “Player 1: “ and join it to the name variable to create the complete text label, e.g. ''Player 1: Chris".

Running code in response to certain events occurring on a web page. We used aclick event in our example above to detect when the button is clicked and then run the code that updates the text label.

And much more!

What is even more exciting however is the functionality built on top of the client-side JavaScript language. So-called Application Programming Interfaces (APIs) provide you with extra superpowers to use in your JavaScript code.

APIs are ready-made sets of code building blocks that allow a developer to implement programs that would otherwise be hard or impossible to implement. They do the same thing for programming that ready-made furniture kits do for home building — it is much easier to take ready-cut panels and screw them together to make a bookshelf than it is to work out the design yourself, go and find the correct wood, cut all the panels to the right size and shape, find the correct-sized screws, and then put them together to make a bookshelf.

They generally fall into two categories.

Browser APIs are built into your web browser, and are able to expose data from the surrounding computer environment, or do useful complex things. For example:

The DOM (Document Object Model) API allows you to manipulate HTML and CSS, creating, removing and changing HTML, dynamically applying new styles to your page, etc. Every time you see a popup window appear on a page, or some new content displayed (as we saw above in our simple demo) for example, that's the DOM in action.

The Geolocation API retrieves geographical information. This is how Google Maps is able to find your location and plot it on a map.

The Canvas and WebGL APIs allow you to create animated 2D and 3D graphics. People are doing some amazing things using these web technologies —see Chrome Experiments and webglsamples.

Audio and Video APIs like HTMLMediaElement and WebRTC allow you to do really interesting things with multimedia, such as play audio and video right in a web page, or grab video from your web camera and display it on someone else's computer (try our simple Snapshot demo to get the idea).

Third party APIs are not built into the browser by default, and you generally have to grab their code and information from somewhere on the Web. For example:

The Twitter API allows you to do things like displaying your latest tweets on your website.

The Google Maps API and OpenStreetMap API allows you to embed custom maps into your website, and other such functionality.

There’s a lot more available, too! However, don’t get over excited just yet. You won’t be able to build the next Facebook, Google Maps, or Instagram after studying JavaScript for 24 hours — there are a lot of basics to cover first. And that’s why you’re here — let’s move on!

COMPANY THAT USE USE JAVASCRIPT

There’s no denying that JavaScript is everywhere, but just how are some of the world’s largest tech companies using JavaScript? For these 10 companies, JavaScript is immensely important, and that doesn’t look like it’s going to change any time soon.

  • Microsoft
  • PayPal
  • Netflix
  • Groupon
  • Uber
  • Facebook
  • Google
  • eBay
  • WALMART
  • LINKEDIN

JavaScript Is Everywhere!

These are only 10 examples, but you can certainly find more. So much of the web runs on JavaScript, it’d be much harder to find a company that doesn’t use JavaScript in some way.

These companies are among the largest tech companies in the world. Many are also running the largest production deployments of NodeJS. The others are responsible for important parts of the JavaScript ecosystem as a whole

eBay - The Company which a web app 50x faster by switching programming languages Where JAVA SCRIPT played a main Role

By compiling code to WebAssembly, developers can build apps that deliver consistently high-performance in the web browser, similar to that offered by apps running natively.

eBay was keen to exploit that performance for a web version of its barcode scanner, a feature it offers in its Android and iOS apps to allow sellers to scan items they are auctioning.

“WebAssembly was different. It has tremendous potential, we just did not have the right use case. Well, that changed recently,” said the eBay software engineering team in an eBay blog post.

One of the advantages of WebAssembly (Wasm) is that it offers code portability for a variety of languages, allowing developers to take code they’ve written for other platforms and compile to WebAssembly so it can run in major web browsers.

Consequently, eBay was able to take the existing version of its barcode scanner written in C++ and compile that to Wasm using Emscripten, adopting the Docker and Node.js-based approach outlined here.

After a few minor teething problems, the eBay team was able to run the barcode scanner in the browser, using a Worker thread and JavaScript glue code.

The Wasm-based scanner was able to process images of the barcode at 50 Frames per Second (FPS), compared to about 1FPS in an earlier JavaScript-based scanner eBay had tested, a speed-up the team described as “astonishing.”

The problem was the Wasm-based scanner was still unable to detect barcodes in 40% of cases.

The team were initially puzzled why the same C++ code that worked in about 100% of cases when compiled to native code for Android and iOS apps was failing when compiled to Wasm to run in the browser. It eventually emerged that these native apps were able to bypass problems with image quality using platform-specific APIs that allowed for autofocus and other features.

eBay’s solution was to run multiple barcode scanners alongside each other in the browser: eBay’s own Wasm-based scanner, the open-source barcode reader ZBar compiled to Wasm, and the original JavaScript-based scanner code.

The structure of the final web-based barcode scanner.

Only by running all three side-by-side in separate web worker threads, and having each attempt to read the barcode, was the scanner web app able to handle close to 100% of barcodes.

“To our surprise, with three threads racing against each other, the success rate was indeed close to 100%. This again was totally unexpected,” write the team.

“JavaScript did perform very well on certain scenarios, and this factor seemed to close the gap. So yes, ‘always bet on JavaScript.’”

In tests, ZBar contributed to 53% of successful scans, followed by eBay’s custom C++ scanner with 34%, and finally the JavaScript library with 13%.

The final web-based barcode scanner also proved to be a success with customers during an A/B test, leading to a 30% increase in eBay users who completed the process of listing an item for auction on the site.

“Technology evolves at a very rapid pace. Every day we hear new things getting launched. But only a few make a difference to customers, and WebAssembly is one of them,” the team said.

THANKS FOR WATCHING

--

--