Yandex Go Develops Custom DSL to Handle Complex Dynamic Ride Pricing Logic

Yandex Go has moved its ride pricing algorithm out of the main service code into a dedicated domain-specific language to avoid frequent deployments and tangled conditional logic. The pricing system accounts for geozones, demand surges, discounts, toll roads, extra stops, and special requirements such as transporting pets or sports equipment. Parameters are collected in parallel, dependencies are modeled as a graph, and requests run asynchronously on userver so that a single slow source does not break the entire calculation. Because rules change on average twice a week, keeping the logic in C++ would require rebuilding and redeploying 50 pods for roughly 40 minutes each time. The new DSL supports conditions, functions, immutable values, and fold operations instead of loops; rules are chained so each step receives the current price and metadata and returns an updated result. ANTLR 4 defines the grammar while the Z3 verifier ensures programs cannot produce invalid prices. The platform is already used by Yandex Taxi, Delivery, and the electric-vehicle charging service.

AntiMalwareTranslated from Russian

Read at source

Yandex Go has introduced a custom domain-specific language to manage the intricate logic behind calculating ride costs, replacing what would otherwise become an unmaintainable collection of conditional statements in the core service code.

Trip pricing at Yandex Go is far more complex than simple multiplication of distance and time. It incorporates geozones, real-time demand, discounts, toll roads, additional stops, and special requirements such as transporting a cat, bicycle, or skis. The same pricing engine is invoked not only when a ride is ordered but also when the route or payment method changes, when a trip ends, when support staff intervene, and when analysts verify data.

Pricing can be fixed, interval-based, or calculated by taximeter. To support this flexibility without constant redeployments, developers first gather parameters from multiple sources in parallel: tariff category, geozones, discounts, surge multipliers, and additional services. These dependencies form a graph executed asynchronously on userver, ensuring that failure of a non-critical source does not halt the entire calculation.

Previously the algorithm resided in C++, but because pricing rules change on average twice a week, frequent service updates became impractical. Redeploying the service across 50 pods takes approximately 40 minutes, and the growing set of dynamic configuration files would have turned the codebase into a museum of conditional statements.

Instead, Yandex created its own DSL featuring conditions, functions, immutable values, and fold operations in place of traditional loops. Rules are organized into sequential chains where each transformation receives the current price and parameters and returns a new result together with metadata. The language grammar is defined with ANTLR 4, and the Z3 theorem prover verifies that no program can generate an incorrect price.

As a result, changes to pricing logic no longer require service recompilation, erroneous versions can be rolled back instantly, and every calculation can be reproduced from input data and intermediate results. The pricing platform is already shared with Yandex Taxi, Delivery, and the electric-vehicle charging service.

Meridian digestThe week's most consequential security stories, distilled into one briefing.See the digest

More in Other

Mail.ru Reduces Lifetime 1TB Cloud Storage Promo to Standard 8GB Quota for Select Users
Kimi K3 Open Model Surpasses Closed AI Leaders with Million-Token Context and 896 Experts
Innostage Completes Functional Testing of PT NGFW 1.10.3 Across 156 Criteria