Cangjie, a New Open-Source Compiled Language with Native Effect Handlers and Algebraic Data Types

TL;DR · AI Summary
Cangjie is a new open-source compiled language that natively supports algebraic effect handlers and algebraic data types, aiming to enhance expressiveness in functional programming and system reliability.
Key Takeaways
- Cangjie features native effect handlers for efficient handling of side effects l
- The language supports pattern matching and algebraic data types (ADTs), similar
- Cangjie is open-sourced on GitHub under the MIT license, targeting use in high-r
Outline
Jump quickly between sections.
Cangjie is a new open-source compiled language combining functional programming features with low-level control capabilities.
Cangjie natively supports algebraic effect handlers, enabling declarative handling of side effects.
The language offers strong ADT support, enhancing code safety and readability through pattern matching.
The Cangjie compiler uses LLVM as backend, generating highly efficient native code suitable for systems programming.
The project is open-sourced on GitHub and welcomes contributions, aiming to build toolchains for high-reliability systems.
The team plans to integrate formal verification support and expand applications in distributed systems.
Mindmap
See how the topics connect at a glance.
查看大纲文本(无障碍 / 无 JS 友好)
- 仓颉语言概述
- 核心特性
- 效应处理器
- 代数数据类型
- 模式匹配
- 技术架构
- LLVM 编译后端
- 静态类型系统
- 生态与发展
- MIT 开源许可证
- GitHub 社区驱动
Highlights
Key sentences worth saving and sharing.
Cangjie's effect handlers require no runtime dependency and statically resolve side effects via the type system.
Its algebraic data type design draws from ML-family languages but adds optimized support for recursive types.
The compiler backend uses LLVM, ensuring generated code performance approaches hand-written C++.
Cangjie, a New Open-Source Compiled Language with Native Effect Handlers and Algebraic Data Types - InfoQ
Your choice regarding cookies on this site
We use cookies to optimise site functionality and give you the best possible experience.
I Accept I Do Not Accept Settings
[BT](https://www.infoq.com/int/bt/ "bt")
InfoQ Software Architects' Newsletter
A monthly overview of things you need to know as an architect or aspiring architect.
Enter your e-mail address
Select your country - [x] I consent to InfoQ.com handling my data as explained in this Privacy Notice.
Close
Live Webinar and Q&A: Architecting for Autonomous Reliability: Embedding AI into Your Observability Stack (Jun 25, 2026)Save Your Seat
Close
Toggle Navigation
Facilitating the Spread of Knowledge and Innovation in Professional Software Development
English edition
[Write for InfoQ](https://www.infoq.com/write-for-infoq/ "Write for InfoQ")
Search
Unlock the full InfoQ experience
Unlock the full InfoQ experience by logging in! Stay updated with your favorite authors and topics, engage with content, and download exclusive resources.
or
Don't have an InfoQ account?
- Stay updated on topics and peers that matter to youReceive instant alerts on the latest insights and trends.
- Quickly access free resources for continuous learningMinibooks, videos with transcripts, and training materials.
- Save articles and read at anytimeBookmark articles to read whenever youre ready.
NewsArticlesPresentationsPodcastsGuides
Topics
[Development](https://www.infoq.com/development/ "Development")
- [Java](https://www.infoq.com/java/ "Java")
- [Kotlin](https://www.infoq.com/kotlin/ "Kotlin")
- [.Net](https://www.infoq.com/dotnet/ ".Net")
- [C#](https://www.infoq.com/c_sharp/ "C#")
- [Swift](https://www.infoq.com/swift/ "Swift")
- [Go](https://www.infoq.com/golang/ "Go")
- [Rust](https://www.infoq.com/rust/ "Rust")
- [JavaScript](https://www.infoq.com/javascript/ "JavaScript")
Featured in Development
Dany Lepage discusses the architectural journey of porting a hit VR title to seven non-VR platforms. He explains how his team solved the challenges of cross-progression, diverse input paradigms, and maintaining release velocity across Steam, iOS, and PlayStation. Beyond the tech, he shares candid lessons on the "product fit" gap when translating immersive social presence to 2D screens.

All in developmentFollow Topic
[Architecture & Design](https://www.infoq.com/architecture-design/ "Architecture & Design")
- [Architecture](https://www.infoq.com/architecture/ "Architecture")
- [Enterprise Architecture](https://www.infoq.com/enterprise-architecture/ "Enterprise Architecture")
- [Scalability/Performance](https://www.infoq.com/performance-scalability/ "Scalability/Performance")
- [Design](https://www.infoq.com/design/ "Design")
- [Case Studies](https://www.infoq.com/Case_Study/ "Case Studies")
- [Microservices](https://www.infoq.com/microservices/ "Microservices")
- [Service Mesh](https://www.infoq.com/servicemesh/ "Service Mesh")
- [Patterns](https://www.infoq.com/DesignPattern/ "Patterns")
- [Security](https://www.infoq.com/Security/ "Security")
Featured in Architecture & Design
Jimmy Morzaria discusses the evolution of Stripe’s database tier to support 5 million QPS with 5.5 nines of reliability. He explains the architecture of DocDB and shares how Stripe leverages a custom zero-downtime data movement platform to perform horizontal sharding, version upgrades, and multi-tenant migrations - all while maintaining the strict consistency required for global commerce.

All in architecture-designFollow Topic
[AI Infrastructure](https://www.infoq.com/ai-ml-data-eng/ "AI Infrastructure")
- [Big Data](https://www.infoq.com/bigdata/ "Big Data")
- [Machine Learning](https://www.infoq.com/machinelearning/ "Machine Learning")
- [NoSQL](https://www.infoq.com/nosql/ "NoSQL")
- [Database](https://www.infoq.com/database/ "Database")
- [Data Analytics](https://www.infoq.com/data-analytics/ "Data Analytics")
- [Streaming](https://www.infoq.com/streaming/ "Streaming")
Featured in AI, ML & Data Engineering
Justin Reock discusses the reality of AI’s impact on engineering, moving past anecdotes to hard data from DORA and DX research. He explains the "GenAI Divide" - where 95% of pilots fail - and shares how leaders can use the SPACE and Core 4 frameworks to measure true ROI. He explains how to balance speed with quality, reduce developer fear, and apply agentic solutions across the entire SDLC.

All in ai-ml-data-engFollow Topic
[Culture & Methods](https://www.infoq.com/culture-methods/ "Culture & Methods")
- [Agile](https://www.infoq.com/agile/ "Agile")
- [Diversity](https://www.infoq.com/diversity/ "Diversity")
- [Leadership](https://www.infoq.com/leadership/ "Leadership")
- [Lean/Kanban](https://www.infoq.com/lean/ "Lean/Kanban")
- [Personal Growth](https://www.infoq.com/personal-growth/ "Personal Growth")
- [Scrum](https://www.infoq.com/scrum/ "Scrum")
- [Sociocracy](https://www.infoq.com/sociocracy/ "Sociocracy")
- [Software Craftmanship](https://www.infoq.com/software_craftsmanship/ "Software Craftmanship")
- [Team Collaboration](https://www.infoq.com/team-collaboration/ "Team Collaboration")
- [Testing](https://www.infoq.com/testing/ "Testing")
- [UX](https://www.infoq.com/ux/ "UX")
Featured in Culture & Methods
In this podcast, Shane Hastie, Lead Editor for Culture & Methods, spoke to Michael Parker, VP of Engineering at TurinTech AI, about bringing joy back to software development in the AI era, the emerging role of "factory architects" who orchestrate AI agents rather than write code directly, and the cultural divide between AI hype and the reality developers face on legacy codebases.

All in culture-methodsFollow Topic
- [Infrastructure](https://www.infoq.com/infrastructure/ "Infrastructure")
- [Continuous Delivery](https://www.infoq.com/continuous_delivery/ "Continuous Delivery")
- [Automation](https://www.infoq.com/automation/ "Automation")
- [Containers](https://www.infoq.com/containers/ "Containers")
- [Cloud](https://www.infoq.com/cloud-computing/ "Cloud")
- [Observability](https://www.infoq.com/observability/ "Observability")
Featured in DevOps
Daniele Frasca explains the architectural evolution of Joyn, a German streaming giant. He discusses moving from fragile single-node setups to resilient serverless architectures using AWS. He shares insights on the Hub and Spoke pattern for data consistency, cell-based isolation to reduce blast radius, and cost-optimization strategies for achieving affordable multi-region active-active setups.

All in devopsFollow Topic
[Events](https://events.infoq.com/ "Events")
Helpful links
- [About InfoQ](https://www.infoq.com/about-infoq "About InfoQ")
- [InfoQ Editors](https://www.infoq.com/infoq-editors "InfoQ Editors")
- [Write for InfoQ](https://www.infoq.com/write-for-infoq "Write for InfoQ")
- [About C4Media](https://c4media.com/ "About C4Media")
- [Diversity](https://c4media.com/diversity "Diversity")
Choose your language

[InfoQ Homepage](https://www.infoq.com/ "InfoQ Homepage")[News](https://www.infoq.com/news "News")Cangjie, a New Open-Source Compiled Language with Native Effect Handlers and Algebraic Data Types
[Development](https://www.infoq.com/development/ "Development")
Cangjie, a New Open-Source Compiled Language with Native Effect Handlers and Algebraic Data Types
May 11, 2026 3 min read
by
- [](https://www.infoq.com/profile/Bruno-Couriol/)Bruno Couriol
Follow Application Consultant
#### Write for InfoQ
Feed your curiosity.Help 550k+ global
senior developers
each month stay ahead.Get in touch
Log in to listen to this article
Audio ready to play
Your browser does not support the audio element.
0:00 0:00
Normal 1.25x 1.5x
Like
Prof. Dan Ghica, who leads the Programming Languages Lab at Huawei’s Edinburgh Research Centre, recently presented Cangjie (CJ), a new application development language that features algebraic data types and effect handlers. The open-sourced language is positioned as a counterpart to Java, Kotlin, or Swift. Cangjie is taught by 80+ universities in China.
According to Ghica, Cangjie is a general-purpose, high-level, and expressive language designed to be safe and efficient. As with any new language, CJ learned from its predecessors and seeks to carve a specific position in the programming language (PL) space. CJ compiles to raw machine code, offering multiple backends that allow it to run on Linux, macOS, Windows, Android, iOS, and HarmonyOS.
Core features include static typing, pattern matching, concurrent garbage collection, algebraic data types (ADTs), and metaprogramming facilities such as macros and annotations. An example of pattern matching in Cangjie is as follows:
enum TimeUnit {
| Year(UInt64)
| Month(UInt64)
}
enum Command {
| SetTimeUnit(TimeUnit)
| GetTimeUnit
| Quit
}
main() {
let command = SetTimeUnit(Year(2022))
match (command) {
case SetTimeUnit(Year(year)) => println("Set year ${year}")
case SetTimeUnit(Month(month)) => println("Set month ${month}")
case _ => ()
}
}However, the most academically significant feature brought to the mainstream by Cangjie is arguably its native support for effect handlers. CJ’s implementation of effect handlers generalizes exceptions and claims to simplify dynamic binding. Effect handlers in CJ introduce new perform and resume keywords. The standard try/catch/finally block becomes try/catch/handle/finally.
class FileNotFound <: Command<String> {
public FileNotFound(let filename: String) {}
}
func readFile(name: String): String {
var actualName = name
if !fileExists(name) {
actualName = perform FileNotFound(name) // (1): control jumps to (2)
}
return File(actualName).read()
}
main() {
try {
let str: String = readFile("foo.txt")
println(str)
} handle (e: FileNotFound, r: Resumption<String, Unit> ) {
resume r with "/etc/default.txt" // (2): control jumps back to (1), returning a value
}
}Effect handlers can be used for many purposes, including nondeterminism and backtracking, scheduling, incremental computing, dependency injection and configuration (e.g., reader effect), mocking, and as shown before, exceptions. The following is an example of a CJ effect handler used for caching and memoization:
func withCache<Cmd, Result, Return>(fn: () -> Return): Return
where Cmd <: Hashable & Equatable<Cmd> & Command<Result>
{
let cache = HashMap<Cmd, Result>()
try {
fn()
} handle (cmd: Cmd, next: Resumption<Result>) {
let result = match (cache.get(cmd)) {
case None =>
let result = perform cmd
cache.put(cmd, result)
result
case Some(cached) =>
cached
}
resume next with result
}
}Ghica emphasizes that CJ’s effect handlers also provide native support for dynamic binding, allowing code to interact with its calling context. Ghica takes the example of a logging library which defines its logging method according to the device running the program:
So imagine that you write a library for a framework such as Oniro. That library can run on a laptop, on a mobile phone, on a watch, on some kind of IoT device that doesn’t have a screen, or a hard drive, or a console. There’s no standard way to do logging across all platforms. So then what do you do?
Well, in that case you need to use dynamic binding. Whenever your code needs to log something, you need to inform the context, saying some logging needs to be done, and the context will know how to handle the logging. But also unlike an exception, you need to be able to come back. You don’t want to just throw an exception and quit your execution. You want to perform that logging in a way controlled by the context and then resume the computation.
So for example on a desktop, I can just print to the console. Whereas if I’m on a mobile, the mobile doesn’t have a console. So if you want to do the logging, maybe you decide to open some kind of alert that presents the log, but also you could send it in an email, or just ignore it. You can do whatever you want. The context can decide as appropriate. And that really is all there is to it for logging. You can do logging in three lines of code. Now try to do the same thing with a language without effect handlers, and you will see that it is significantly more complicated.
While several frameworks utilizing effect handlers are available as third-party components for Cangjie, effect handlers are still considered an actively developed, experimental part of the language.
Ghica’s talk took place at OCX (Open Community Experience) 2026 in April in Brussels. OCX is the Eclipse Foundation’s flagship open-source conference, gathering developers, researchers, industry leaders, and policymakers for three days.
About the Author
[](https://www.infoq.com/profile/Bruno-Couriol/)
#### Bruno Couriol
MSc in Telecommunications. BSc in Mathematics.
Show more Show less
#### This content is in the Web Development topic
Follow Topic
##### Related Topics:
Followers: 4096
Follow Topic
Followers: 434
Follow Topic
Followers: 957
Follow Topic
Followers: 86
Follow Topic
Followers: 49
Follow Topic
* #### Related Editorial
* #### Related Sponsors
- #### Related Sponsor
Drop in Ably AI Transport.
Purpose-built infrastructure for the entire agent-to-user experience. [Start building](https://www.infoq.com/url/f/c8fe72db-3741-4495-a5f2-5d556c901ca5/).
Related Content
May 09, 2026
Apr 29, 2026
Apr 28, 2026
Apr 23, 2026
Apr 21, 2026
Apr 20, 2026
Apr 18, 2026
Apr 18, 2026
Apr 16, 2026
Related Sponsors
- #### Does your AI stack need a session layer? A maturity framework for teams building AI agents
Explore the missing “session layer” in the AI stack—where many production failures originate. This framework outlines maturity stages for delivering continuous, stateful AI experiences, from fragile HTTP streaming to resilient, multi-device, real-time systems with durable sessions. Read Now.
- Sponsored by

Related Content
Apr 20, 2026 
Apr 25, 2026
Apr 17, 2026
Mar 18, 2026 
Feb 20, 2026 
May 01, 2026
**The InfoQ** Newsletter
A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example
Enter your e-mail address
Select your country - [x] I consent to InfoQ.com handling my data as explained in this Privacy Notice.
- ##### [Cangjie, a New Open-Source Compiled Language with Native Effect Handlers and Algebraic Data Types](https://www.infoq.com/news/2026/05/cangjie-effect-handlers-adt/ "Cangjie, a New Open-Source Compiled Language with Native Effect Handlers and Algebraic Data Types")
- ##### [Attacker Bought 30 WordPress Plugins on Flippa and Backdoored All of Them](https://www.infoq.com/news/2026/05/wordpress-plugins-supply-chain/ "Attacker Bought 30 WordPress Plugins on Flippa and Backdoored All of Them")
- ##### [Cloudflare Introduces Flagship: an Edge-Native Feature Flag Service Built on OpenFeature](https://www.infoq.com/news/2026/05/cloudflare-flagship-openfeature/ "Cloudflare Introduces Flagship: an Edge-Native Feature Flag Service Built on OpenFeature")
- ##### [Netflix Serves 84% of Query Results from Cache with Interval-Aware Caching in Apache Druid](https://www.infoq.com/news/2026/05/netflix-druid-interval-cache/ "Netflix Serves 84% of Query Results from Cache with Interval-Aware Caching in Apache Druid")
- ##### [How GitHub Is Securing Agentic Workflows in Modern CI CD Systems](https://www.infoq.com/news/2026/05/github-agentic-workflows/ "How GitHub Is Securing Agentic Workflows in Modern CI CD Systems")
- ##### [OpenAI Introduces Websocket-Based Execution Mode to Reduce Latency in Agentic Workflows](https://www.infoq.com/news/2026/05/openai-websocket-responses-api/ "OpenAI Introduces Websocket-Based Execution Mode to Reduce Latency in Agentic Workflows")
- ##### [The AI Joy Gap: Why Some Developers Thrive While Others Struggle](https://www.infoq.com/podcasts/some-developers-thrive-while-others-struggle/ "The AI Joy Gap: Why Some Developers Thrive While Others Struggle")
- ##### [Applying Best Simple System for Now for Software Design](https://www.infoq.com/news/2026/05/best-simple-system-design/ "Applying Best Simple System for Now for Software Design")
- ##### [The Human Scalability Problem: Why Your Teams Don’t Scale Like Your Code](https://www.infoq.com/presentations/human-scalability/ "The Human Scalability Problem: Why Your Teams Don’t Scale Like Your Code")
- ##### [Coder Agents Enable Running AI Coding Workflows on Self-Hosted Infrastructure](https://www.infoq.com/news/2026/05/coder-agents-self-hosted-ai/ "Coder Agents Enable Running AI Coding Workflows on Self-Hosted Infrastructure")
- ##### [Netflix Introduces ‘Model Lifecycle Graph’ to Scale Enterprise Machine Learning](https://www.infoq.com/news/2026/05/netflix-ml-graph/ "Netflix Introduces ‘Model Lifecycle Graph’ to Scale Enterprise Machine Learning")
- ##### [MySQL 9.7: First Major LTS Since 8.4 Brings Enterprise Features to Community Edition](https://www.infoq.com/news/2026/05/mysql-97-lts/ "MySQL 9.7: First Major LTS Since 8.4 Brings Enterprise Features to Community Edition")
- ##### [Evolution of a Backend for a Streaming Application](https://www.infoq.com/presentations/streaming-application-aws-infrastructure/ "Evolution of a Backend for a Streaming Application")
- ##### [New DORA Report Claims Strong Engineering Foundations Drive AI Return on Investment](https://www.infoq.com/news/2026/05/dora-roi-ai-assisted-dev-report/ "New DORA Report Claims Strong Engineering Foundations Drive AI Return on Investment")
- ##### [Cloudflare Launches “Artifacts” Beta, Introducing Git-Like Versioning for AI Agents](https://www.infoq.com/news/2026/05/cloudflare-artifacts-ai-agents/ "Cloudflare Launches “Artifacts” Beta, Introducing Git-Like Versioning for AI Agents")
**The InfoQ** Newsletter
A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example
- Get a quick overview of content published on a variety of innovator and early adopter technologies
- Learn what you don’t know that you don’t know
- Stay up to date with the latest information from the topics you are interested in
Enter your e-mail address
Select your country - [x] I consent to InfoQ.com handling my data as explained in this Privacy Notice.
#### Events
- ##### QCon AI Boston
June 1-2, 2026
June 10, 2026
July 25, 2026
- ##### QCon San Francisco
November 16-20, 2026
#### Follow us on
Youtube 232K FollowersLinkedin 26K FollowersInstagram NewRSS 19K ReadersX 57.1k FollowersFacebook 21K LikesBluesky New
#### Stay in the know
The InfoQ PodcastEngineering Culture PodcastThe Software Architects' Newsletter
General Feedback [feedback@infoq.com](mailto:feedback@infoq.com) Advertising [sales@infoq.com](mailto:sales@infoq.com) Editorial [editors@infoq.com](mailto:editors@infoq.com) Marketing [marketing@infoq.com](mailto:marketing@infoq.com)
InfoQ.com and all content copyright © 2006-2026 C4Media Inc.
Privacy Notice, Terms And Conditions, Cookie Policy
Close
[BT](https://www.infoq.com/int/bt/ "bt")