Improving JavaScript: Google throws AtScript into the mix

Better JavaScript ... even works with Microsoft's TypeScript

Google’s Miško Hevery, co-inventor of the popular AngularJS framework, has announced a new project to improve JavaScript by adding type annotations and other features.

Miško Hevery presents AtScript

Miško Hevery presents AtScript at ngEurope

The announcement came at the ng-europe Angular conference in Paris at the end of October 2014.

AtScript is the latest among numerous projects to fix up JavaScript’s deficiencies. Developers love JavaScript because it runs everywhere and performs well, thanks to fast engines like Apple’s Nitro and Google’s V8. That said, the absence of language features like types and classes make large, multi-developer JavaScript projects hard to maintain.

One solution is to write code in a different language that is compiled to JavaScript for deployment. Google’s Dart language is an example, with the twist that Dart can also be executed directly by a Dart VM (Virtual Machine) where this exists.

Google Web Toolkit is another one, which compiles Java to JavaScript. The downside of these options is that they replace JavaScript with another language, rather than making JavaScript itself better. This impairs interoperability with JavaScript libraries, and puts them at odds with official efforts to evolve JavaScript itself.

Microsoft’s TypeScript takes a different approach, being a superset of JavaScript that adds classes and strong typing but does not replace the language. TypeScript compiles to readable JavaScript, making debugging easier.

AtScript is more in tune with the TypeScript approach. It adds two features to JavaScript. The first is Annotations, which can be Type annotations, Field annotations, or Metadata annotations. Type annotations declare the type of a variable or argument. Field annotations let you specify the type and order of fields in a class. Metadata annotations attach metadata to the code, for example for use by frameworks.

The second feature is Introspection, which lets you query the annotations at runtime.

AtScript builds on EcmaScript 6 (ES6), which is the official next version of JavaScript, rather than EcmaScript 5 (ES5), the current version implemented in modern web browsers. ES6 adds classes and modules (a means of isolating and organising code), but not types. In order to deploy AtScript, it is compiled with the traceur compiler, which converts ES6 into ES5. There is also an option to compile to Dart.

The quick summary therefore is “AtScript = ES6 + Types + Annotations + Introspections”.

Is AtScript necessary, given that TypeScript does some of this already? Hevery says that AtScript is influenced by TypeScript (as well as Dart) but that TypeScript lacks runtime introspection and metadata annotations. However, you can use AtScript with TypeScript, so the two projects are not altogether in opposition. This could get messy though, since features like metadata have already been proposed for the next version of TypeScript.

Angular 2.0, the next version, is being rewritten from scratch in AtScript. This means it is an ES6 project.

“We're building AngularJS in ES6 now so you’ll have a framework that’s ready to take full advantage of ES6 as browsers add support,” says the team, though it will of course compile to ES5 code.

For more information on AtScript, see Hevery's keynote here. ®

Similar topics

Other stories you might like

  • Google has more reasons why it doesn't like antitrust law that affects Google
    It'll ruin Gmail, claims web ads giant

    Google has a fresh list of reasons why it opposes tech antitrust legislation making its way through Congress but, like others who've expressed discontent, the ad giant's complaints leave out mention of portions of the proposed law that address said gripes.

    The law bill in question is S.2992, the Senate version of the American Innovation and Choice Online Act (AICOA), which is closer than ever to getting votes in the House and Senate, which could see it advanced to President Biden's desk.

    AICOA prohibits tech companies above a certain size from favoring their own products and services over their competitors. It applies to businesses considered "critical trading partners," meaning the company controls access to a platform through which business users reach their customers. Google, Apple, Amazon, and Meta in one way or another seemingly fall under the scope of this US legislation. 

    Continue reading
  • Makers of ad blockers and browser privacy extensions fear the end is near
    Overhaul of Chrome add-ons set for January, Google says it's for all our own good

    Special report Seven months from now, assuming all goes as planned, Google Chrome will drop support for its legacy extension platform, known as Manifest v2 (Mv2). This is significant if you use a browser extension to, for instance, filter out certain kinds of content and safeguard your privacy.

    Google's Chrome Web Store is supposed to stop accepting Mv2 extension submissions sometime this month. As of January 2023, Chrome will stop running extensions created using Mv2, with limited exceptions for enterprise versions of Chrome operating under corporate policy. And by June 2023, even enterprise versions of Chrome will prevent Mv2 extensions from running.

    The anticipated result will be fewer extensions and less innovation, according to several extension developers.

    Continue reading
  • I was fired for blowing the whistle on cult's status in Google unit, says contractor
    The internet giant, a doomsday religious sect, and a lawsuit in Silicon Valley

    A former Google video producer has sued the internet giant alleging he was unfairly fired for blowing the whistle on a religious sect that had all but taken over his business unit. 

    The lawsuit demands a jury trial and financial restitution for "religious discrimination, wrongful termination, retaliation and related causes of action." It alleges Peter Lubbers, director of the Google Developer Studio (GDS) film group in which 34-year-old plaintiff Kevin Lloyd worked, is not only a member of The Fellowship of Friends, the exec was influential in growing the studio into a team that, in essence, funneled money back to the fellowship.

    In his complaint [PDF], filed in a California Superior Court in Silicon Valley, Lloyd lays down a case that he was fired for expressing concerns over the fellowship's influence at Google, specifically in the GDS. When these concerns were reported to a manager, Lloyd was told to drop the issue or risk losing his job, it is claimed. 

    Continue reading
  • End of the road for biz living off free G Suite legacy edition
    Firms accustomed to freebies miffed that web giant's largess doesn't last

    After offering free G Suite apps for more than a decade, Google next week plans to discontinue its legacy service – which hasn't been offered to new customers since 2012 – and force business users to transition to a paid subscription for the service's successor, Google Workspace.

    "For businesses, the G Suite legacy free edition will no longer be available after June 27, 2022," Google explains in its support document. "Your account will be automatically transitioned to a paid Google Workspace subscription where we continue to deliver new capabilities to help businesses transform the way they work."

    Small business owners who have relied on the G Suite legacy free edition aren't thrilled that they will have to pay for Workspace or migrate to a rival like Microsoft, which happens to be actively encouraging defectors. As noted by The New York Times on Monday, the approaching deadline has elicited complaints from small firms that bet on Google's cloud productivity apps in the 2006-2012 period and have enjoyed the lack of billing since then.

    Continue reading
  • UK competition watchdog seeks to make mobile browsers, cloud gaming and payments more competitive
    Investigation could help end WebKit monoculture on iOS devices

    The United Kingdom's Competition and Markets Authority (CMA) on Friday said it intends to launch an investigation of Apple's and Google's market power with respect to mobile browsers and cloud gaming, and to take enforcement action against Google for its app store payment practices.

    "When it comes to how people use mobile phones, Apple and Google hold all the cards," said Andrea Coscelli, Chief Executive of the CMA, in a statement. "As good as many of their services and products are, their strong grip on mobile ecosystems allows them to shut out competitors, holding back the British tech sector and limiting choice."

    The decision to open a formal investigation follows the CMA's year-long study of the mobile ecosystem. The competition watchdog's findings have been published in a report that concludes Apple and Google have a duopoly that limits competition.

    Continue reading
  • Google recasts Anthos with hitch to AWS Outposts
    If at first you don't succeed, change names and try again

    Google Cloud's Anthos on-prem platform is getting a new home under the search giant’s recently announced Google Distributed Cloud (GDC) portfolio, where it will live on as a software-based competitor to AWS Outposts and Microsoft Azure Stack.

    Introduced last fall, GDC enables customers to deploy managed servers and software in private datacenters and at communication service provider or on the edge.

    Its latest update sees Google reposition Anthos on-prem, introduced back in 2020, as the bring-your-own-server edition of GDC. Using the service, customers can extend Google Cloud-style management and services to applications running on-prem.

    Continue reading

Biting the hand that feeds IT © 1998–2022