How Java helps deliver the groceries

This guest post for Computer Weekly Open Source Insider is written by Ocado Technology’s Matthew Cornford in his position as head of product for the company’s Handling Robotics Department and Daniel Stoner in his role as senior software engineer for Supply Chain Systems.

Ocado Technology describes itself as an ‘innovation factory’ enabling the world’s retailers to deliver groceries online profitably, sustainably and scalably using capabilities across AI, ML, cloud, robotics, data and IoT.

Matthew & Dan write as follows…

Did James Gosling and his team of developers ever predict the sheer breadth of complex challenges Java helps solve today? From helping build mobile apps, to managing the intricacies of delivering groceries through intelligent robotics and automation, here’s why Java is a key language we’ve chosen for our mission to transform the online grocery sector through intelligent software and automation technology.

Delivering online groceries scalably, sustainably and profitably requires forecasting, complex simulations and huge amounts of automation. Low margins, customers with little tolerance for error or lateness and large, complex orders make online grocery a challenging retail sector to profit from. This complexity creates an opportunity to develop solutions using AI, robotics, cloud computing, simulation, digital twins, vision systems etc.

Considering all of our applications, some people are surprised to learn that our preferred programming language is Java.

Webshop to warehouse and wheels

Java helps us develop systems and applications that serve our business end-to-end: from webshop to warehouses, it even affects the ‘wheels’ delivering shopping. It also offers flexibility to build a personalised webshop experience and use the framework to deploy AI and ML technologies, like product recommendation engines.

State-of-the-art robotics power our automated warehouses. At Erith, the largest automated warehouse for online grocery, Java helps orchestrate our growing bot swarm of over 1,500 bots picking 6,000,000 grocery items for over 100,000 orders each week.

Java helps us plan and optimise thousands of daily delivery vehicle routes using proprietary forecasting systems that make 600,000 adjustments per problem space per second, factoring in millions of constraints, such as the speed of roads, driver breaks, and the size and temperature distribution of every single customer order. A single distribution centre might have 2,000 orders and 100 vans per day – that’s a lower bound of 10^4000 possible route permutations. (Compared to 10^82 atoms in the universe!)

So… why Java?

A common question we hear (and frequently ask ourselves!) is why Java and not a language like C++, or Rust? The answer is that we’re not just optimising our systems, but also developer productivity – this trade-off continually leads us back to Java.

Three factors make Java stand out: performance, development speed and its continuously evolving platform.


Some people think a comparable program written in C or C++ is faster than Java. High-performance applications like the LMAX Disruptor disprove that. There are many factors of application performance to consider when comparing languages, for example, executable size, start-up time, memory footprint and raw runtime speed. Comparing the performance of a particular application across two languages is inherently difficult unless you are able to write the application comparably in both languages.

Development speed

Many factors make developing in Java faster than other languages. It’s a typed, high-level language – so developers can focus on business problems and catch errors as early as possible. Modern IDEs provide a wealth of tools for developers to write correct code the first time. Java has a mature ecosystem and there are libraries and frameworks for almost everything. Support for Java is almost ubiquitous across middleware technologies.

Continuous evolution.

Java architect Mark Reinhold says that improvements in developer productivity and application performance drive JVM development. Over time, we’ve benefited from gains in our first two concerns – performance and development speed – just by being on a constantly evolving and improving language and platform.

Developers love it

What’s more, in every index of popular languages, including Tiobe, GitHub, StackOverflow and ITJobsWatch, Java is always near (or at) the top. By choosing Java as our language for developing high-performance apps we can recruit a global pool of talented developers – an important consideration for a company on a mission to transform the way the world shops.

We foster a culture of continual learning and Java’s popularity also means there are plenty of opportunities for us to support our developers in advancing their skills at conferences and events, or through Ocado Technology academy courses.

Best practice for apps in Java

While there are many recommended software practices to follow when developing high-performance applications in Java, within the JVM the Just-In-Time (JIT) compiler is likely the single most important concept to improve application performance in comparison to other languages. By profiling the running byte-code and compiling suitable byte-code down to native code at run-time, Java application performance can get very close to that of a native application.

Further, as a JIT compiler runs at the last possible moment, it has information available to it that an AOT compiler cannot have, mainly the exact chipset on which an application is running and statistics about the actual application. With this information, a JIT compiler can perform optimisations an AOT compiler wouldn’t be able to guarantee are safe, so a JIT compiler can actually outperform an AOT compiler in some cases.

Three main principles help us develop some of our high-performance systems:

  1. Extensively simulating for testing and research by building high fidelity simulations, emulations and visualisations of our business. 
  2. Ensuring all our code can be run deterministically during R&D, and the same code can also run in a real-time context.
  3. Avoiding premature optimisation which would slow us down in delivering new and commercially valuable features while still looking for those opportunities that allow our system to perform as optimally as possible!

Java @ the intersection of physical & digital

At launch, Gosling envisaged Java providing an interactive TV experience for consumers. 25 years on, technology has developed to solve problems in ways we could never have imagined.

AI and Robotics are incredibly powerful in their own right, but some of the most exciting opportunities present themselves at the intersection of both digital and physical worlds, like robotic picking, powered by cutting-edge robotics and computer visioning systems. We don’t know for certain what a world built with Java will look like 25 years from now, but we’re excited to find out.



Data Center
Data Management