Current Status of ATS3 (2020-11-22)

761 views
Skip to first unread message

gmhwxi

unread,
Nov 22, 2020, 9:31:16 AM11/22/20
to ats-lang-users


Hi, there,


HX-2020-11-22:


(*

HX-2018-04-07: Let us get started!!!

*)


As of today, I am pleased to announce that ATS3 has reached a stage

where it can be realistically used in software construction. This is

achieved after slightly more than two and one-half years of continual

development by yours truly :)


######

#

# The current status

#

######


XATSOPT:


Xatsopt is a functioning compiler implemented in ATS2 for translating

ATS3 into a typed intermediate language of the name XATSCML, which is

both C-like and ML-like. It is planned for xatsopt to further

translate XATSCML into XATSCL0, a low-level C-like language. I now

primarily see xatsopt as a library (libxatsopt) for implementing tools

to support programming with ATS3.


XATS2JS:


Xats2js is a functioning compiler implemented in ATS2 for translating

XATSCML into JavaScript (or JS for short). It should be noted that

xats2js can compile tail-recursive calls into local jumps, effectively

supporting the common practice in functional programming of writing

loops as tail-recursive functions.


I will give detailed explanation elsewhere on using xats2js. Generally

speaking, one can now practice a form of co-programming with ATS3 and

JS. The JS code generated by xats2js from compiling ATS3 source can be

directly combined with other JS code (as if the generated code were

manually written in JS)


######

#

# Future Development

#

######


Documenting Xatsopt:


This has been assigned a high priority. It is hoped that other

people interested in ATS3 can start developing tools for ATS3 after

a minimal amount of documentation on xatsopt is made available.


Advanced Type-Checking:


While one can specify with linear types and dependent types in ATS3,

there is no type-checking for such advanced types in xatsopt. I plan

to concentrate on implementing support for such type-checking in the

next phase of ATS3 development.


######

#

# A little history of ATS3

#

######


Essentially, ATS3 refers to the third edition of ATS, and ATS/Xanadu

is currently the only implementation of ATS3. Note that the names ATS3

and ATS/Xanadu are often used interchangeably.


In the ATS family of languages, the first implementation is named

ATS/Proto (2004) and the language it implements is referred to as

ATS0. Please note that the implementation of ATS/Proto is written in

OCaml. The next implementation is ATS/Geizella (2007), which is also

written in OCaml. And the language implemented by ATS/Geizella is

referred to as ATS1. ATS/Anairiats (2008) is an implementation of ATS1

in itself; the implementation is first compiled by ATS/Geizella and

then by itself, succeeding in so-called bootstrapping. The next

edition of ATS is ATS2, which is given an implementation of the name

ATS/Postiats (2013) written in ATS1.


ATS/Xanadu implements ATS3 and the implementation is written in ATS2.

While there is currently no plan to bootstrap ATS3 by implementing it

in itself, it is perceivable that ATS/Xanadu can be readily translated

(manually) into such an implementation since the difference between

ATS2 and ATS3 in terms of both syntax and semantics is fairly minor

(for the part being used in compiler implementation).


##################################################################


Cheers!


--Hongwei


##################################################################


For previously post messages:


https://github.com/githwxi/ATS-Xanadu/tree/master/docgen/NOTES

##################################################################


Brandon Barker

unread,
Nov 22, 2020, 12:38:26 PM11/22/20
to ats-lang-users
Hi Hongwei,

That's exciting to hear. If and when they are available, could you point to any FFI examples or documentation for JavaScript? Perhaps, but not necessarily, related to DOM APIs in the browser (just as a common example)?

Hongwei Xi

unread,
Nov 22, 2020, 1:31:04 PM11/22/20
to ats-lan...@googlegroups.com
I will do a few examples today of co-programming with ATS3 and JS.

Conceptually, it is straightforward: ATS code is compiled to JS via xats2js
and the generated JS code can be directly combined with other JS code.
There is a very small library of JS code needed for running the generated
JS code.

In practice, it is equally straightforward :)

By the way, I would like to emphasize that xats2js is NOT meant to be an
optimizing compiler; it is more like a reference implementation of some sort.
The JS code generated by xats2js is currently not of high quality in terms of
efficiency (time-wise or memory-wise).

--
You received this message because you are subscribed to a topic in the Google Groups "ats-lang-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ats-lang-users/4Pb6GAuBiY4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ats-lang-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/15c50a5b-8b85-4843-889b-f608647479c7n%40googlegroups.com.

Hongwei Xi

unread,
Nov 22, 2020, 6:27:09 PM11/22/20
to ats-lan...@googlegroups.com
I could only manage one write-up so far:


I plan to implement some word games to showcase this style of co-programming.

Cheers!

Elronnd _

unread,
Nov 22, 2020, 6:31:32 PM11/22/20
to ats-lang-users
On Sun, 22 Nov 2020, gmhwxi wrote:                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                      
> As of today, I am pleased to announce that ATS3 has reached a stage where it can be realistically used in software construction. This is achieved after slightly more than two and one-half years of continual development by yours truly :)                                                                                                        
                                                                                                                                                                                                                                                                                                                                                      
Great to hear!                                                                                                                                                                                                                                                                                                                                        

                                                                                                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                                                      
> Xatsopt is a functioning compiler implemented in ATS2 for translating ATS3 into a typed intermediate language of the name XATSCML, which is both C-like and ML-like. It is planned for xatsopt to further translate XATSCML into XATSCL0, a low-level C-like language.                                                                              
                                                                                                                                                                                                                                                                                                                                                      
What is the final vision for XATSCL0?  Will it be compiled into c?  Or directly into native code (via custom backend, or llvm/similar)?                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                                                      
What is the effect on compilation speed of having (at least) two full intermediate languages?                                                                                                                                                                                                                                                         

                                                                                                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                                                      
> Xats2js is a functioning compiler implemented in ATS2 for translating XATSCML into JavaScript                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                                                      
JS doesn't have integers.  So how will code that uses integers be compiled?  Is code compiled to js is limited to 32-bit integers, since they can fit into the range of a double?                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                                                      
 -E                                                                                                                                                                                                                                                                                                                                                  

Hongwei Xi

unread,
Nov 22, 2020, 7:04:58 PM11/22/20
to ats-lan...@googlegroups.com
>>What is the final vision for XATSCL0?  Will it be compiled into c?  Or directly into native code (via custom backend, or llvm/similar)?

XATSCL0 should most likely be a subset of C.

To get into native code, one needs to remove function calls of C-style in XATSCL0.

>>What is the effect on compilation speed of having (at least) two full intermediate languages?

Right now, it is not a big concern as xatsopt does not do time-consuming optimizations. I suspect that
more time is likely spent on the phase of compiling XATSCL0 to native code.

>>JS doesn't have integers.  So how will code that uses integers be compiled?  Is code compiled to js is limited to 32-bit integers, since they can fit into the range of a double?

When compiled to JS, the int type in ATS is interpreted by some JS functions in a small library dabbed 'runtime'.
For instance, integer division is given the following implementation:

function
XATS2JS_gint_div_sint_sint
  (x1, x2)
{
//
  let q0 = x1 / x2;
//
  if
  (q0 >= 0)
  {
    return Math.floor(q0);
  }
  else
  {
    return Math.ceil( q0 );
  }
}

--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/ca34ad8d-77db-4e91-b548-400c3111c8c9n%40googlegroups.com.

Dambaev Alexander

unread,
Nov 22, 2020, 11:47:17 PM11/22/20
to ats-lan...@googlegroups.com
Glad to hear news about ATS3 implementation!


XATSOPT:

Xatsopt is a functioning compiler implemented in ATS2 for translating

ATS3 into a typed intermediate language of the name XATSCML, which is

both C-like and ML-like. It is planned for xatsopt to further

translate XATSCML into XATSCL0, a low-level C-like language. I now

primarily see xatsopt as a library (libxatsopt) for implementing tools

to support programming with ATS3.

Can I guess that XATSCL0 is basically the same as the C-file that we have now during compilation with patscc? Otherwise, what is the purpose of it?



Documenting Xatsopt:


This has been assigned a high priority. It is hoped that other

people interested in ATS3 can start developing tools for ATS3 after

a minimal amount of documentation on xatsopt is made available.

The more documentation - the better :)
 
Advanced Type-Checking:

While one can specify with linear types and dependent types in ATS3,

there is no type-checking for such advanced types in xatsopt. I plan

to concentrate on implementing support for such type-checking in the

next phase of ATS3 development.


Does this mean that currently ATS3 just ignores code related to linear/dependent types?

Hongwei Xi

unread,
Nov 23, 2020, 11:02:32 AM11/23/20
to ats-lan...@googlegroups.com
>>Can I guess that XATSCL0 is basically the same as the C-file that we have now during compilation with patscc? Otherwise, what is the purpose of it?

Patscc generates code that contains goto statements. This time I would exclude goto's in XATSCL0. In this way, compilers for ATS3 targeting other languages can also benefit from using XATSCL0.

>>Does this mean that currently ATS3 just ignores code related to linear/dependent types?

Yes, it ignores completely.

--

--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.

Andreas ZUERCHER

unread,
Nov 23, 2020, 5:17:35 PM11/23/20
to ats-lang-users
Hongwei,
In your 16dec2019 posting & its replies
https://groups.google.com/g/ats-lang-users/c/TnL5h-_mDOQ/m/35X4gneUBgAJ
you mentioned that your intended software architecture for the ATS3 compiler under development would have stages at which AST-to-AST transforms would be a key facilitator of extension functionality.  Some such AST-to-AST transforms might include, e.g., alternative syntax, full OOP that partially impairs programming-by-proofs, partial OOP that does not impair programming-by-proofs at all, alternative logic solvers, LLVM backend, and so forth.

In your reply on 29aug2020
it might seem that OOP might be such an extension that fits somewhere in the AST-to-AST transforms.

Has this vision of architecting the ATS3 compiler as having the originally-intended AST-to-AST transform-based extension points come to fruition (perhaps in some early not-final form) at this release?  Or did some trade-offs along the way cause these AST-to-AST transform-based extension points to be postponed for a while into the future?

d4v3y_5c0n3s

unread,
Nov 23, 2020, 11:20:59 PM11/23/20
to ats-lang-users
Thanks for the update, Hongwei.  It's really awesome to hear about the progress being made on ATS3!  I have a question I'd like to ask about ATS3's compilation.  You mentioned that rather than compiling ATS code straight into a C file, that ATS3 first compiles it into XATSCML, and in the future into XATSCL0.  You said this was to make it easier to compile ATS into languages other than C, which is awesome and I can definitely appreciate that.  My question is, will this change affect the execution speed of ATS3 code compared to ATS2?  I ask because I am currently working on building a game engine in ATS, and so performance is very important to my use case.  If ATS3 could potentially be slower than ATS2 was, please let me know, I'd be willing to try and contribute to the project to improve this aspect.
Thanks, and good luck with ATS3.

On Sunday, November 22, 2020 at 9:31:16 AM UTC-5 gmhwxi wrote:

Elijah Stone

unread,
Nov 24, 2020, 12:04:15 AM11/24/20
to ats-lang-users
On Sun, 22 Nov 2020, gmhwxi wrote:

> As of today, I am pleased to announce that ATS3 has reached a stage
> where it can be realistically used in software construction. This is
> achieved after slightly more than two and one-half years of continual
> development by yours truly :)

Great to hear!


> Xatsopt is a functioning compiler implemented in ATS2 for translating
> ATS3 into a typed intermediate language of the name XATSCML, which is
> both C-like and ML-like. It is planned for xatsopt to further translate
> XATSCML into XATSCL0, a low-level C-like language.

What is the final vision for XATSCL0? Will it be compiled into c? Or
directly into native code (via custom backend, or llvm/similar)?

What is the effect on compilation speed of having (at least) two full
intermediate languages?


> Xats2js is a functioning compiler implemented in ATS2 for translating
> XATSCML into JavaScript

gmhwxi

unread,
Nov 24, 2020, 1:36:31 AM11/24/20
to ats-lang-users

>> will this change affect the execution speed of ATS3 code compared to ATS2?

The short answer is no. If anything, I would bet that ATS3 code should run faster :)
I will strive to structure the compiler in a way that should be easy for others to contribute.

gmhwxi

unread,
Nov 24, 2020, 1:04:33 PM11/24/20
to ats-lang-users
Hi Andreas,

First, thanks for your past postings. I picked up a lot info from reading them.

As for as I can tell, this vision of architecting ATS/Xanadu as a network of AST-to-AST transform-based extension points is currently
being put into practice. So far, this network is just a line connectomg some AST transform functions: parse, trans01, trans12, trans 23, etc.
This line is expected to be turned into a tree (or even a graph) in the future.

d4v3y_5c0n3s

unread,
Nov 25, 2020, 3:05:26 PM11/25/20
to ats-lang-users
Thanks for the reply! :)
Reply all
Reply to author
Forward
0 new messages