# Thoughts on the Taichi programming language - sparse computing and differentiable programming

**URL:** <https://discourse.julialang.org/t/thoughts-on-the-taichi-programming-language-sparse-computing-and-differentiable-programming/49251>\
**Category:** Community\
**Created:** [October 29, 2020, 5:26pm UTC](https://discourse.julialang.org/t/thoughts-on-the-taichi-programming-language-sparse-computing-and-differentiable-programming/49251 "2020-10-29T17:26:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [October 29, 2020, 5:26pm UTC](https://discourse.julialang.org/t/thoughts-on-the-taichi-programming-language-sparse-computing-and-differentiable-programming/49251/1 "2020-10-29T17:26:34Z")

</div>

I recently came across the [Taichi programming language](https://github.com/taichi-dev/taichi) and I was curious what people here think about it and how it compares to Julia and Swift. It seems to have a special focus on “[spatially sparse computing](https://taichi.readthedocs.io/en/latest/sparse.html)” and differentiable programming. Their documentation also says that they are in the process of moving towards LLVM. So I would appreciate any insights.

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [October 29, 2020, 5:56pm UTC](https://discourse.julialang.org/t/thoughts-on-the-taichi-programming-language-sparse-computing-and-differentiable-programming/49251/2 "2020-10-29T17:56:03Z")

</div>

Is it Python or is it not? That’s my thought.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [October 29, 2020, 9:38pm UTC](https://discourse.julialang.org/t/thoughts-on-the-taichi-programming-language-sparse-computing-and-differentiable-programming/49251/3 "2020-10-29T21:38:02Z")

</div>

They call it a “programming language […] embedded in Python”.

As far as I understand it, “yes” it’s Python (but not only; the add-on feels more like a library than a new language, and the add-on “extra language” is in some sense not Python, while I’ve not looked carefully), the compiler is not for Python code in general, only for the decorated kernels, and there’s not a preprocessor (in the sense of in “C with Classes”, later named C++). The compiler is a Python class, that works on the Python AST of those decorated kernels only.

There’s a clever sparse data structure involved, something Julia could replicate it seems, or just reuse.

Relevant:

[https://taichi.readthedocs.io/en/stable/syntax.html](https://taichi.readthedocs.io/en/stable/syntax.html)  
[https://taichi.readthedocs.io/en/stable/compilation.html#compilation](https://taichi.readthedocs.io/en/stable/compilation.html#compilation)  
[https://taichi.readthedocs.io/en/stable/export\_kernels.html](https://taichi.readthedocs.io/en/stable/export_kernels.html)

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [October 29, 2020, 9:41pm UTC](https://discourse.julialang.org/t/thoughts-on-the-taichi-programming-language-sparse-computing-and-differentiable-programming/49251/4 "2020-10-29T21:41:58Z")

</div>

Yeah, it seems more like a library than a language. However, they make extensive use of decorators to create a domain-specific language, and it looks like they’re also doing some hacking on type hints, like with this:

```python
@ti.kernel
def copy(x: ti.template(), y: ti.template()):
    for i in x:
        y[i] = x[i]

a = ti.field(ti.f32, 4)
b = ti.field(ti.f32, 4)
c = ti.field(ti.f32, 12)
d = ti.field(ti.f32, 12)
copy(a, b)
copy(c, d)

```

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [October 29, 2020, 9:53pm UTC](https://discourse.julialang.org/t/thoughts-on-the-taichi-programming-language-sparse-computing-and-differentiable-programming/49251/5 "2020-10-29T21:53:48Z")

</div>

Right, I believe this is all legal python ‘‘syntax’’. I tested the def (without “ti.”). The semantics of type hints in Python, are well, do nothing with them, always still I believe, some tools however e.g. mypy give them meaning, and here something different done. Semantic-wise, the Taichi CPU and GPU compiler does something for `@ti.kernel`, and semantic-wise then you could say it’s a superset of Python (or an allowed superset), while syntax-wise it’s just Python (unless there’s something I missed), and with a macro we could allow this exact syntax (and behavior) as was done with PythonSyntax.jl, while something like that may be overkill and you would just use PyCall?

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [October 29, 2020, 9:56pm UTC](https://discourse.julialang.org/t/thoughts-on-the-taichi-programming-language-sparse-computing-and-differentiable-programming/49251/6 "2020-10-29T21:56:51Z")

</div>

Yeah, decorators in Python are just higher-order functions. They take in the function below them and return a new function.
