
The ATS Programming Language – Unleashing the Potentials of Types and Templates - fspeech
http://www.ats-lang.org
======
fspeech
First let me say that I have not written anything substantial in ATS. I have
been pondering what it can be used for for a long time. I think ATS has some
really neat features. It is almost two languages combined into one from a
practical point of view:

1) An ML style language.

2) A linear type based imperative language.

On the plus side it has strong theoretical foundations; compiler code base is
small enough to be readable; it transpiles to everything and has top notch
performance at least for the C target using the second style. The catch is
that I would like to write code in the ML style, which requires GC for long
running programs (the ATS compiler itself does use the ML style without GC as
memory leak is not a concern for a batch mode application). That makes it hard
to start small with a library project. The linear type style is high
performance but a lot more challenging to use. Xi encourages users to start
with ML style and transition into the linear type only when needed.

I have experience doing proofs (group theory in math) using a dependent type
prover (Lean). Tooling is really important. Even with excellent type feedback
one really needs a lot of automation (like integrated SAT provers) to make the
work practical. My feeling about the linear type is the same. We need the
proofs to be mostly automated and a lot of nice feedback when the type
checkers fail for it to be practical. Though if safety and efficiency are both
critical someone may be willing to pay the price now to use linear types. So
maybe it will have good applications in the embedded software domain. In my
interest area resource usage is only a (small) part of the concern. Even if
one roots out all resource bugs one still has logic bugs to deal with so the
the availability of and the ease to use well tested libraries are a lot more
important than resource management to me.

This has been a really promising language project. If it gets some well-
deserved community love maybe it will really blossom.

------
doublec
I have some posts on my experiences of using ATS here
[http://bluishcoder.co.nz/tags/ats/](http://bluishcoder.co.nz/tags/ats/)

They're for the previous version of ATS but are still pretty relevant.

~~~
chenglou
Amateur question: how are linear types in "practice"? How much of concurrency
do they solve? And how are they different from modern HM types?

Sorry for being vague. I'm interested in this subject but layman materials on
it are hard to come by.

~~~
doublec
I can only speak as a user of linear types, not as a type theorist. They are
extremely useful in practice. In ATS they enable not just tracking memory but
any form of resource that needs to be cleaned up. If you fail to do so you get
a compile time error.

This removes much of the burden of wondering if you got the resource
management right. Especially when maintaining existing applications. If you
refactor things the compiler tells you when you got it wrong.

There is overhead since you are managing resource manually - both syntax-wise
and mental though.

For concurrency they enable 'solving' shared state by making it difficult to
share state. You really have to pass ownership of the resource to the other
thread so it can no longer be accessed anywhere else.

~~~
sgrove
How do linear types help in distributed systems - you mention sharing (or not
sharing) between threads, but I'm also intensely curious re: reasoning about
heterogeneous networks. Some rambling questions you might be able to shed some
light on -

1\. How much of a (self-contained vs distributed) system has to be completely
written in ATS? 2\. How much of the emergent system can be modeled in ATS to
take advantage of linear types while letting some other team(s) work in e.g.
nodejs 3\. What's the onboarding experience like for a dev new to typed
systems entirely? How long before they generally grasp the abstract concepts
and how to express them? Are there any particularly difficult pieces?

Thanks a ton for sharing your experience! Like Chenglou, I'm very curious
about linear logic/session-types/etc., but very new to the domain.

~~~
doublec
I've not had to do anything distributed with ATS that involved sharing data. I
mostly used zeromq to send information around and controlled access to
resources via processes.

It's a fairly steep learning curve for people new to types. Given exposure to
SML it's not too hard to just use that side of things plus linear types.
Dependent types and proofs add complexity but hopefully you can avoid it while
learning.

------
fspeech
Now it is easy to try ATS online as Xi (ATS creator) has added compilation to
js capability (the compilers also run in js via Emscripten).

