Skip to main content
Ocado Careers
Java - a key language for OSP

Java - a key language for OSP

Java helps us develop intelligent systems and high-performance applications serving our business from webshop to warehouses. Matthew Cornford explores the role of Java in our techstack and why it’s still so important.

Matthew Cornford, Head of Product, Handling Robotics, Ocado Technology and Contributor Daniel Stoner, Senior Software Engineer for our Supply Chain SystemsMay 26, 2020Our people11 min read

To deliver online grocery scalably, sustainably, and profitably, there’s intelligent forecasting, complex simulations, and huge amounts of automation involved. It’s the most difficult retail segment to deliver profitably because of the low margins and sheer complexity involved. Average orders currently contain over 70 items from three different temperature zones, including lots of fresh, delicate, low profit products like eggs, bread, and frozen peas. Layer this with discerning customers who expect accurate and on-time deliveries and you start to appreciate the size of the task. But this complexity makes the grocery sector an exciting testbed for developing some of the most advanced capabilities in areas such as AI, robotics, cloud computing, simulation, digital twins, vision systems, and many others. 

Given this complexity, some people are surprised to learn that, with all of our high-performance applications, our preferred programming language is Java.

Webshop to warehouse and wheels

Java helps us develop intelligent systems and high-performance applications that serve our business end-to-end: from our webshop to our warehouses; it even affects the vehicles that deliver shopping directly to people’s kitchen tables.

Java gives us the flexibility to offer an intuitive, personalised webshop experience, but also use the framework to deploy intelligent AI and ML technologies, like advanced product recommendation engines.

javaAKeyLanguage body01

State-of-the-art robotics power our highly automated warehouses. At our site in Erith, the largest automated warehouse for online grocery, where today over 1,500 bots process 100,000 orders, picking nearly 6,000,000 grocery items per week, Java helps us orchestrate this vast, growing, bot swarm. Bots whizz around the grid at a closing speed of up to 4 meters per second, with a clearance of 5mm between them. They generate about 5,000 data points, 1,000 times per second – that’s a GB of data per bot per day, or a total of 4 terabytes a day for an entire swarm of 3,500 within one highly automated warehouse. 

Our Routing team use Java to plan and optimise thousands of vehicle routes for delivering customer goods every day, 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!) It’s hardly surprising to hear that Routing uses more raw CPU compute power than any other Ocado function – even just managing the servers has its own complex Java optimisation algorithm.

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

Three factors influence our choice: performance, development speed, and Java’s continuously evolving platform. 


Some people think a comparable program written in C or C++ is faster than Java. High-performance applications such as the LMAX Disruptor prove this is a fallacy. 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:

Because Java is a typed, high-level language, developers can focus on business problems and catch errors as early as possible. Modern IDEs provide developers with a wealth of tools 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 has stated that for twenty years, two of the biggest drivers for JVM development have been improvements in developer productivity and application performance. So over time, we’ve been able to benefit from gains in our first two concerns – performance and development speed – just by being on a constantly evolving and improving language and platform. For example, one of the observed performance improvements between Java 8 and Java 11 is the performance of the G1 garbage collector, which allows our control systems more application time to perform computationally intensive calculations.

High-performance apps, best practice

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.

At Ocado Technology, we use three main principles to develop some of our high-performance systems:

  • Extensively simulating for testing and research.

  • Ensuring all our code can be run deterministically during R&D, and the same code can also run in a real-time context.

  • Avoiding premature optimisation which would slow us down in delivering new and commercially valuable features whilst still looking for those opportunities that allow our system to perform as optimally as possible. 

  • We build high fidelity simulations, emulations, and visualisations of our business that we use to test new algorithms, test production software before deployment, evolve new machine learning models, and playback production data for troubleshooting purposes.

We use simulations to model solutions before we build them, generate data to train our ML models before the real data exists, and optimise end-to-end processes after we have built them. You can't buy a simulation system that will cope with the number of moving elements that we have. Most systems come from automotive, where just hundreds of things are moving, but we have thousands. In fact, our original simulation system was built in Java, using gaming technology for visualisation.

java 02

Developers Love It

If performance, development speed and continuous platform evolution haven’t convinced you that 25 years on, Java remains a top language choice for developing high-performance apps, there’s a final factor to consider: developers love it. 

In every index of popular languages, including Tiobe, GitHub, StackOverflow, and ITJobsWatch, Java is always near or at the top. This position means we have a very large, global pool of talented developers to work with. And that’s an important consideration for a company that’s 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.

Java: At the Intersection of Physical and Digital Worlds?

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.

Change your world with us

Across Ocado Technology, we have a diverse, rich mix of teams and expertise working to solve complex problems. Learn more about our full range of opportunities here.

Related content

Java - a key language for OSP

Hello, robot

Robust wireless communications are critical to the operation of our smart warehouses. This article explains our approach to ensuring we can talk to our bots anytime, anywhere.

Learn more
Image: In Store Smartness

In store smartness

While our smart warehouse robots are the ones that often grab headlines, our in-store-fulfilment (ISF) solutions allow retailers to meet the growing demand for online orders using existing stores.

Learn more
Digital twins

Digital twins

Our smart warehouses host complex robotics and automation ecosystems, and no two are the same. So, before we change the physical world, we simulate in the digital world, with our digital twins.

Learn more