Suppose ATS can be modified to take advantage of C++ features, is it
possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
The type system of ATS allows you to track heap-allocated linear objects.
Stack allocation means to store a value on the call stack of some function.
Whether a copy of the value or a pointer to the value is passed depends on
whether call-by-value or call-by-reference is used.
So if a high level language feature involves heap allocation one needs to
avoid it if one does not want GC dependency
It depends on what language features you want to use. Usually, there is
always a way to use linear features in ATS to
avoid GC dependency.On Thursday, February 27, 2014 1:03:42 PM UTC-5, H Zhang wrote:
But there is also no way for programmers to track the heap allocated
objects done by the ATS compiler, correct? So if a high level language
feature involves heap allocation one needs to avoid it if one does not want
GC dependency. Or use unboxed stack allocated structures? Doesn’t stack
allocation imply copying the value every time we want to pass it to someone
else?
Haitao
On Thursday, February 27, 2014 9:12:23 AM UTC-8, gmhwxi wrote:
ATS does not track heap-allocated non-linear values.
In theory, it is possible. But such a statement is not really meaningful.
Say I have a programming language that will never allow incorrect programs
to be constructed. It sounds wonderful. But if I tell you that you have
to spend a year
implementing quicksort in this language, what would you think about the
language?
ATS is meant for people to write programs productively.
On Thursday, February 27, 2014 1:41:58 AM UTC-5, H Zhang wrote:
I understand tracking user created memory is not free. I was referring
to resources that are auto allocated on the heap by ATS. There is no way
for programmers to track these. I am wondering if it is possible for ATS to
track them, at least in theory.
Haitao
On Wednesday, February 26, 2014 9:04:53 PM UTC-8, gmhwxi wrote:
Tracking resources is not free.
The programmer has to make a great effort and the type system is
merely a tool for the programmer to check whether tracking is done
properly.
It is not clear to me what kind of applications you have in mind.
Could you elaborate a bit as to why GC bothers you?
On Wednesday, February 26, 2014 10:53:45 PM UTC-5, H Zhang wrote:
Yes I agree that ATS is advanced. I am wondering how one can take full
advantage of ML style coding without using GC? If ATS can in theory track
the life cycle of the objects it automatically heap-allocates (not the ones
manually allocated by users) then can ATS take care of freeing the
resources as well instead of relying on GC? That is the part that is
bothering me.
Haitao
On Wednesday, February 26, 2014 6:21:47 PM UTC-8, gmhwxi wrote:
There may be some misunderstanding here.
I think linear types supported in ATS are far more advanced than RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use GC).
I bet that any C++ compilers you can find leak memories like a sieve.
On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is it
possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
To be more concrete suppose I am processing XML data with rich metadata
schema information. I would use an in-place parser (native library) to
parse the XML. I would like to touch the data as little as possible so they
stay opaque blobs (pointers) to the host language. I process the metadata
information extensively and reason about the data in the host language,
then only pull the relevant data lazily when needed. There is a cost every
time data or control have to cross the boundary between the host language
(Prolog) and the native library, so as I get more comfortable about the
processing I want to push some metadata processing logic into the library
to ease the bottleneck traffic. It would be nice to write these logic in
higher level constructs than C.
HaitaoOn Thursday, February 27, 2014 9:59:03 AM UTC-8, H Zhang wrote:
I would like to use ATS to write library code instead of C/C++. I would
like it to be more productive than using C. I don’t envision using
dependent/linear typing much but I think a high level language (that is
higher order functions, closure, pattern matching) that is high performance
and easily integratable (due to the compilation to C) is very attractive.
When I say library I don’t mean the low level abstraction such as array or
hash map, I mean a high level encapsulation such as libxml2 or zeromq. So
there is extensive logic inside the library that will benefit very much
from high level language features even if the main data structures can be
low level to avoid unnecessary copying and conversion.
Haitao
On Thursday, February 27, 2014 9:25:55 AM UTC-8, gmhwxi wrote:
Say I want to use ATS and Python together. There are in general too
approaches:
ATS is used like C
ATS source code compiles into Python
With (1), you need to take care of memory allocation/deallocation on your
own.
For Python, I would prefer (2). However, there is currently no compiler
from ATS source to Python.
If someone is interested in implementing one, I can provide guidance. It
is relatively a straightforward project.
For Prolog, (2) does not seem to be a viable option. Still, It is unclear
to me what you want to do by combining
ATS and Prolog. Why is it beneficial to actually combine these two?
On Thursday, February 27, 2014 1:38:00 AM UTC-5, H Zhang wrote:
I think that a complete application would have a dynamic host language
with REPL support (Lua, Python, Scheme, Prolog …). We can either use (a)
code written in ATS as library or (b) extend ATS code by embedding the
other language. The host languages all their own GCs that may or may not be
easily usable by ATS – they may use different abstractions and may not
expose a malloc/free style interface at all. It would be easier if ATS does
not have its own GC requirement. In my case I currently use Prolog, which
has its own unique GC abstractions (atom GC) and does not really expose a
malloc/free style interface as far as I know (and would be very
implementation dependent in any case).
Haitao
On Wednesday, February 26, 2014 9:04:53 PM UTC-8, gmhwxi wrote:
Tracking resources is not free.
The programmer has to make a great effort and the type system is
merely a tool for the programmer to check whether tracking is done
properly.
It is not clear to me what kind of applications you have in mind.
Could you elaborate a bit as to why GC bothers you?
On Wednesday, February 26, 2014 10:53:45 PM UTC-5, H Zhang wrote:
Yes I agree that ATS is advanced. I am wondering how one can take full
advantage of ML style coding without using GC? If ATS can in theory track
the life cycle of the objects it automatically heap-allocates (not the ones
manually allocated by users) then can ATS take care of freeing the
resources as well instead of relying on GC? That is the part that is
bothering me.
Haitao
On Wednesday, February 26, 2014 6:21:47 PM UTC-8, gmhwxi wrote:
There may be some misunderstanding here.
I think linear types supported in ATS are far more advanced than RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use GC).
I bet that any C++ compilers you can find leak memories like a sieve.
On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is it
possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
What if an option is added so they can be re-targetted to C++ smart
pointers instead? Then if one chooses such an option one automatically gets
reference counting so that GC is unnecessary unless cyclic references are
involved. One can then use linear types if necessary to break cycles?
HaitaoOn Thursday, February 27, 2014 9:25:55 AM UTC-8, gmhwxi wrote:
Say I want to use ATS and Python together. There are in general too
approaches:
ATS is used like C
ATS source code compiles into Python
With (1), you need to take care of memory allocation/deallocation on your
own.
For Python, I would prefer (2). However, there is currently no compiler
from ATS source to Python.
If someone is interested in implementing one, I can provide guidance. It
is relatively a straightforward project.
For Prolog, (2) does not seem to be a viable option. Still, It is unclear
to me what you want to do by combining
ATS and Prolog. Why is it beneficial to actually combine these two?
On Thursday, February 27, 2014 1:38:00 AM UTC-5, H Zhang wrote:
I think that a complete application would have a dynamic host language
with REPL support (Lua, Python, Scheme, Prolog …). We can either use (a)
code written in ATS as library or (b) extend ATS code by embedding the
other language. The host languages all their own GCs that may or may not be
easily usable by ATS – they may use different abstractions and may not
expose a malloc/free style interface at all. It would be easier if ATS does
not have its own GC requirement. In my case I currently use Prolog, which
has its own unique GC abstractions (atom GC) and does not really expose a
malloc/free style interface as far as I know (and would be very
implementation dependent in any case).
Haitao
On Wednesday, February 26, 2014 9:04:53 PM UTC-8, gmhwxi wrote:
Tracking resources is not free.
The programmer has to make a great effort and the type system is
merely a tool for the programmer to check whether tracking is done
properly.
It is not clear to me what kind of applications you have in mind.
Could you elaborate a bit as to why GC bothers you?
On Wednesday, February 26, 2014 10:53:45 PM UTC-5, H Zhang wrote:
Yes I agree that ATS is advanced. I am wondering how one can take full
advantage of ML style coding without using GC? If ATS can in theory track
the life cycle of the objects it automatically heap-allocates (not the ones
manually allocated by users) then can ATS take care of freeing the
resources as well instead of relying on GC? That is the part that is
bothering me.
Haitao
On Wednesday, February 26, 2014 6:21:47 PM UTC-8, gmhwxi wrote:
There may be some misunderstanding here.
I think linear types supported in ATS are far more advanced than RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use GC).
I bet that any C++ compilers you can find leak memories like a sieve.
On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is it
possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
What if an option is added so they can be re-targetted to C++ smart
pointers instead? Then if one chooses such an option one automatically gets
reference counting so that GC is unnecessary unless cyclic references are
involved. One can then use linear types if necessary to break cycles?
Haitao
On Thursday, February 27, 2014 9:25:55 AM UTC-8, gmhwxi wrote:
Say I want to use ATS and Python together. There are in general too
approaches:
ATS is used like C
ATS source code compiles into Python
With (1), you need to take care of memory allocation/deallocation on your
own.
For Python, I would prefer (2). However, there is currently no compiler
from ATS source to Python.
If someone is interested in implementing one, I can provide guidance. It
is relatively a straightforward project.
For Prolog, (2) does not seem to be a viable option. Still, It is unclear
to me what you want to do by combining
ATS and Prolog. Why is it beneficial to actually combine these two?
On Thursday, February 27, 2014 1:38:00 AM UTC-5, H Zhang wrote:
I think that a complete application would have a dynamic host language
with REPL support (Lua, Python, Scheme, Prolog …). We can either use (a)
code written in ATS as library or (b) extend ATS code by embedding the
other language. The host languages all their own GCs that may or may not be
easily usable by ATS – they may use different abstractions and may not
expose a malloc/free style interface at all. It would be easier if ATS does
not have its own GC requirement. In my case I currently use Prolog, which
has its own unique GC abstractions (atom GC) and does not really expose a
malloc/free style interface as far as I know (and would be very
implementation dependent in any case).
Haitao
On Wednesday, February 26, 2014 9:04:53 PM UTC-8, gmhwxi wrote:
Tracking resources is not free.
The programmer has to make a great effort and the type system is
merely a tool for the programmer to check whether tracking is done
properly.
It is not clear to me what kind of applications you have in mind.
Could you elaborate a bit as to why GC bothers you?
On Wednesday, February 26, 2014 10:53:45 PM UTC-5, H Zhang wrote:
Yes I agree that ATS is advanced. I am wondering how one can take full
advantage of ML style coding without using GC? If ATS can in theory track
the life cycle of the objects it automatically heap-allocates (not the ones
manually allocated by users) then can ATS take care of freeing the
resources as well instead of relying on GC? That is the part that is
bothering me.
Haitao
On Wednesday, February 26, 2014 6:21:47 PM UTC-8, gmhwxi wrote:
There may be some misunderstanding here.
I think linear types supported in ATS are far more advanced than RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use GC).
I bet that any C++ compilers you can find leak memories like a sieve.
On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is it
possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
Say I want to use ATS and Python together. There are in general too
approaches:
ATS is used like C
ATS source code compiles into Python
With (1), you need to take care of memory allocation/deallocation on your
own.
For Python, I would prefer (2). However, there is currently no compiler
from ATS source to Python.
If someone is interested in implementing one, I can provide guidance. It is
relatively a straightforward project.
For Prolog, (2) does not seem to be a viable option. Still, It is unclear
to me what you want to do by combining
ATS and Prolog. Why is it beneficial to actually combine these two?On Thursday, February 27, 2014 1:38:00 AM UTC-5, H Zhang wrote:
I think that a complete application would have a dynamic host language
with REPL support (Lua, Python, Scheme, Prolog …). We can either use (a)
code written in ATS as library or (b) extend ATS code by embedding the
other language. The host languages all their own GCs that may or may not be
easily usable by ATS – they may use different abstractions and may not
expose a malloc/free style interface at all. It would be easier if ATS does
not have its own GC requirement. In my case I currently use Prolog, which
has its own unique GC abstractions (atom GC) and does not really expose a
malloc/free style interface as far as I know (and would be very
implementation dependent in any case).
Haitao
On Wednesday, February 26, 2014 9:04:53 PM UTC-8, gmhwxi wrote:
Tracking resources is not free.
The programmer has to make a great effort and the type system is
merely a tool for the programmer to check whether tracking is done
properly.
It is not clear to me what kind of applications you have in mind.
Could you elaborate a bit as to why GC bothers you?
On Wednesday, February 26, 2014 10:53:45 PM UTC-5, H Zhang wrote:
Yes I agree that ATS is advanced. I am wondering how one can take full
advantage of ML style coding without using GC? If ATS can in theory track
the life cycle of the objects it automatically heap-allocates (not the ones
manually allocated by users) then can ATS take care of freeing the
resources as well instead of relying on GC? That is the part that is
bothering me.
Haitao
On Wednesday, February 26, 2014 6:21:47 PM UTC-8, gmhwxi wrote:
There may be some misunderstanding here.
I think linear types supported in ATS are far more advanced than RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use GC).
I bet that any C++ compilers you can find leak memories like a sieve.
On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is it
possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
But there is also no way for programmers to track the heap allocated
objects done by the ATS compiler, correct? So if a high level language
feature involves heap allocation one needs to avoid it if one does not want
GC dependency. Or use unboxed stack allocated structures? Doesn’t stack
allocation imply copying the value every time we want to pass it to someone
else?
HaitaoOn Thursday, February 27, 2014 9:12:23 AM UTC-8, gmhwxi wrote:
ATS does not track heap-allocated non-linear values.
In theory, it is possible. But such a statement is not really meaningful.
Say I have a programming language that will never allow incorrect programs
to be constructed. It sounds wonderful. But if I tell you that you have to
spend a year
implementing quicksort in this language, what would you think about the
language?
ATS is meant for people to write programs productively.
On Thursday, February 27, 2014 1:41:58 AM UTC-5, H Zhang wrote:
I understand tracking user created memory is not free. I was referring to
resources that are auto allocated on the heap by ATS. There is no way for
programmers to track these. I am wondering if it is possible for ATS to
track them, at least in theory.
Haitao
On Wednesday, February 26, 2014 9:04:53 PM UTC-8, gmhwxi wrote:
Tracking resources is not free.
The programmer has to make a great effort and the type system is
merely a tool for the programmer to check whether tracking is done
properly.
It is not clear to me what kind of applications you have in mind.
Could you elaborate a bit as to why GC bothers you?
On Wednesday, February 26, 2014 10:53:45 PM UTC-5, H Zhang wrote:
Yes I agree that ATS is advanced. I am wondering how one can take full
advantage of ML style coding without using GC? If ATS can in theory track
the life cycle of the objects it automatically heap-allocates (not the ones
manually allocated by users) then can ATS take care of freeing the
resources as well instead of relying on GC? That is the part that is
bothering me.
Haitao
On Wednesday, February 26, 2014 6:21:47 PM UTC-8, gmhwxi wrote:
There may be some misunderstanding here.
I think linear types supported in ATS are far more advanced than RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use GC).
I bet that any C++ compilers you can find leak memories like a sieve.
On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is it
possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
Yes I agree that ATS is advanced. I am wondering how one can take full
advantage of ML style coding without using GC? If ATS can in theory track
the life cycle of the objects it automatically heap-allocates (not the ones
manually allocated by users) then can ATS take care of freeing the
resources as well instead of relying on GC? That is the part that is
bothering me.
HaitaoOn Wednesday, February 26, 2014 6:21:47 PM UTC-8, gmhwxi wrote:
There may be some misunderstanding here.
I think linear types supported in ATS are far more advanced than RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use GC).
I bet that any C++ compilers you can find leak memories like a sieve.
On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is it
possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
I understand tracking user created memory is not free. I was referring to
resources that are auto allocated on the heap by ATS. There is no way for
programmers to track these. I am wondering if it is possible for ATS to
track them, at least in theory.
HaitaoOn Wednesday, February 26, 2014 9:04:53 PM UTC-8, gmhwxi wrote:
Tracking resources is not free.
The programmer has to make a great effort and the type system is
merely a tool for the programmer to check whether tracking is done
properly.
It is not clear to me what kind of applications you have in mind.
Could you elaborate a bit as to why GC bothers you?
On Wednesday, February 26, 2014 10:53:45 PM UTC-5, H Zhang wrote:
Yes I agree that ATS is advanced. I am wondering how one can take full
advantage of ML style coding without using GC? If ATS can in theory track
the life cycle of the objects it automatically heap-allocates (not the ones
manually allocated by users) then can ATS take care of freeing the
resources as well instead of relying on GC? That is the part that is
bothering me.
Haitao
On Wednesday, February 26, 2014 6:21:47 PM UTC-8, gmhwxi wrote:
There may be some misunderstanding here.
I think linear types supported in ATS are far more advanced than RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use GC).
I bet that any C++ compilers you can find leak memories like a sieve.
On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is it
possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
I think linear types supported in ATS are far more advanced than RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use GC).
I bet that any C++ compilers you can find leak memories like a sieve.On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is it
possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
Based on my own teaching experience, I would say that linear types
are fairly straightforward to learn/use. On the other hand, dependent types
seem to post a very big challenge for most programmers.On Thursday, February 27, 2014 9:47:20 PM UTC-5, H Zhang wrote:
I think I am starting to get your point on linear types. When I looked at
the library code that implements the linear types I saw a lot of
complicated syntax. But if one looks at how they are used (e.g. in ATS
compiler src) the complication is not necessarily there. That is
encouraging. It is great if the complication of the linear types can be
encapsulated inside the library module that implements the types.
Haitao
On Thursday, February 27, 2014 3:59:32 PM UTC-8, H Zhang wrote:
But programmers have to manage these linear resources explicitly, right?
ML type inference is also an attractive feature. Would using linear types
interfere with that? If a function returns a stack allocated object it will
need to be copied?
In my mind one should be able to have good partition of complexity to
minimize the mental load. For intricate customized native data structures I
can see the need to use dependent and linear types to ensure correctness.
But that should be limited to as small a portion of one’s code as possible?
In parts where high level business logic is involved one does not want to
worry about allocations of temporary objects. What one wants there is
conciseness and clarity so that code can be self-documenting.
Haitao
On Thursday, February 27, 2014 2:46:37 PM UTC-8, gmhwxi wrote:
The type system of ATS allows you to track heap-allocated linear
objects.
Stack allocation means to store a value on the call stack of some
function.
Whether a copy of the value or a pointer to the value is passed depends
on
whether call-by-value or call-by-reference is used.
So if a high level language feature involves heap allocation one needs
to avoid it if one does not want GC dependency
It depends on what language features you want to use. Usually, there is
always a way to use linear features in ATS to
avoid GC dependency.
On Thursday, February 27, 2014 1:03:42 PM UTC-5, H Zhang wrote:
But there is also no way for programmers to track the heap allocated
objects done by the ATS compiler, correct? So if a high level language
feature involves heap allocation one needs to avoid it if one does not want
GC dependency. Or use unboxed stack allocated structures? Doesn’t stack
allocation imply copying the value every time we want to pass it to someone
else?
Haitao
On Thursday, February 27, 2014 9:12:23 AM UTC-8, gmhwxi wrote:
ATS does not track heap-allocated non-linear values.
In theory, it is possible. But such a statement is not really
meaningful.
Say I have a programming language that will never allow incorrect
programs
to be constructed. It sounds wonderful. But if I tell you that you
have to spend a year
implementing quicksort in this language, what would you think about
the language?
ATS is meant for people to write programs productively.
On Thursday, February 27, 2014 1:41:58 AM UTC-5, H Zhang wrote:
I understand tracking user created memory is not free. I was
referring to resources that are auto allocated on the heap by ATS. There is
no way for programmers to track these. I am wondering if it is possible for
ATS to track them, at least in theory.
Haitao
On Wednesday, February 26, 2014 9:04:53 PM UTC-8, gmhwxi wrote:
Tracking resources is not free.
The programmer has to make a great effort and the type system is
merely a tool for the programmer to check whether tracking is done
properly.
It is not clear to me what kind of applications you have in mind.
Could you elaborate a bit as to why GC bothers you?
On Wednesday, February 26, 2014 10:53:45 PM UTC-5, H Zhang wrote:
Yes I agree that ATS is advanced. I am wondering how one can take
full advantage of ML style coding without using GC? If ATS can in theory
track the life cycle of the objects it automatically heap-allocates (not
the ones manually allocated by users) then can ATS take care of freeing the
resources as well instead of relying on GC? That is the part that is
bothering me.
Haitao
On Wednesday, February 26, 2014 6:21:47 PM UTC-8, gmhwxi wrote:
There may be some misunderstanding here.
I think linear types supported in ATS are far more advanced than
RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use
GC).
I bet that any C++ compilers you can find leak memories like a
sieve.
On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is
it possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
I think that a complete application would have a dynamic host language with
REPL support (Lua, Python, Scheme, Prolog …). We can either use (a) code
written in ATS as library or (b) extend ATS code by embedding the other
language. The host languages all their own GCs that may or may not be
easily usable by ATS – they may use different abstractions and may not
expose a malloc/free style interface at all. It would be easier if ATS does
not have its own GC requirement. In my case I currently use Prolog, which
has its own unique GC abstractions (atom GC) and does not really expose a
malloc/free style interface as far as I know (and would be very
implementation dependent in any case).
HaitaoOn Wednesday, February 26, 2014 9:04:53 PM UTC-8, gmhwxi wrote:
Tracking resources is not free.
The programmer has to make a great effort and the type system is
merely a tool for the programmer to check whether tracking is done
properly.
It is not clear to me what kind of applications you have in mind.
Could you elaborate a bit as to why GC bothers you?
On Wednesday, February 26, 2014 10:53:45 PM UTC-5, H Zhang wrote:
Yes I agree that ATS is advanced. I am wondering how one can take full
advantage of ML style coding without using GC? If ATS can in theory track
the life cycle of the objects it automatically heap-allocates (not the ones
manually allocated by users) then can ATS take care of freeing the
resources as well instead of relying on GC? That is the part that is
bothering me.
Haitao
On Wednesday, February 26, 2014 6:21:47 PM UTC-8, gmhwxi wrote:
There may be some misunderstanding here.
I think linear types supported in ATS are far more advanced than RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use GC).
I bet that any C++ compilers you can find leak memories like a sieve.
On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is it
possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
ATS does not track heap-allocated non-linear values.
In theory, it is possible. But such a statement is not really meaningful.
Say I have a programming language that will never allow incorrect programs
to be constructed. It sounds wonderful. But if I tell you that you have to
spend a year
implementing quicksort in this language, what would you think about the
language?
ATS is meant for people to write programs productively.On Thursday, February 27, 2014 1:41:58 AM UTC-5, H Zhang wrote:
I understand tracking user created memory is not free. I was referring to
resources that are auto allocated on the heap by ATS. There is no way for
programmers to track these. I am wondering if it is possible for ATS to
track them, at least in theory.
Haitao
On Wednesday, February 26, 2014 9:04:53 PM UTC-8, gmhwxi wrote:
Tracking resources is not free.
The programmer has to make a great effort and the type system is
merely a tool for the programmer to check whether tracking is done
properly.
It is not clear to me what kind of applications you have in mind.
Could you elaborate a bit as to why GC bothers you?
On Wednesday, February 26, 2014 10:53:45 PM UTC-5, H Zhang wrote:
Yes I agree that ATS is advanced. I am wondering how one can take full
advantage of ML style coding without using GC? If ATS can in theory track
the life cycle of the objects it automatically heap-allocates (not the ones
manually allocated by users) then can ATS take care of freeing the
resources as well instead of relying on GC? That is the part that is
bothering me.
Haitao
On Wednesday, February 26, 2014 6:21:47 PM UTC-8, gmhwxi wrote:
There may be some misunderstanding here.
I think linear types supported in ATS are far more advanced than RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use GC).
I bet that any C++ compilers you can find leak memories like a sieve.
On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is it
possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
The programmer has to make a great effort and the type system is
merely a tool for the programmer to check whether tracking is done
properly.
It is not clear to me what kind of applications you have in mind.
Could you elaborate a bit as to why GC bothers you?On Wednesday, February 26, 2014 10:53:45 PM UTC-5, H Zhang wrote:
Yes I agree that ATS is advanced. I am wondering how one can take full
advantage of ML style coding without using GC? If ATS can in theory track
the life cycle of the objects it automatically heap-allocates (not the ones
manually allocated by users) then can ATS take care of freeing the
resources as well instead of relying on GC? That is the part that is
bothering me.
Haitao
On Wednesday, February 26, 2014 6:21:47 PM UTC-8, gmhwxi wrote:
There may be some misunderstanding here.
I think linear types supported in ATS are far more advanced than RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use GC).
I bet that any C++ compilers you can find leak memories like a sieve.
On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is it
possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
I think I am starting to get your point on linear types. When I looked at
the library code that implements the linear types I saw a lot of
complicated syntax. But if one looks at how they are used (e.g. in ATS
compiler src) the complication is not necessarily there. That is
encouraging. It is great if the complication of the linear types can be
encapsulated inside the library module that implements the types.
HaitaoOn Thursday, February 27, 2014 3:59:32 PM UTC-8, H Zhang wrote:
But programmers have to manage these linear resources explicitly, right?
ML type inference is also an attractive feature. Would using linear types
interfere with that? If a function returns a stack allocated object it will
need to be copied?
In my mind one should be able to have good partition of complexity to
minimize the mental load. For intricate customized native data structures I
can see the need to use dependent and linear types to ensure correctness.
But that should be limited to as small a portion of one’s code as possible?
In parts where high level business logic is involved one does not want to
worry about allocations of temporary objects. What one wants there is
conciseness and clarity so that code can be self-documenting.
Haitao
On Thursday, February 27, 2014 2:46:37 PM UTC-8, gmhwxi wrote:
The type system of ATS allows you to track heap-allocated linear
objects.
Stack allocation means to store a value on the call stack of some
function.
Whether a copy of the value or a pointer to the value is passed depends on
whether call-by-value or call-by-reference is used.
So if a high level language feature involves heap allocation one needs
to avoid it if one does not want GC dependency
It depends on what language features you want to use. Usually, there is
always a way to use linear features in ATS to
avoid GC dependency.
On Thursday, February 27, 2014 1:03:42 PM UTC-5, H Zhang wrote:
But there is also no way for programmers to track the heap allocated
objects done by the ATS compiler, correct? So if a high level language
feature involves heap allocation one needs to avoid it if one does not want
GC dependency. Or use unboxed stack allocated structures? Doesn’t stack
allocation imply copying the value every time we want to pass it to someone
else?
Haitao
On Thursday, February 27, 2014 9:12:23 AM UTC-8, gmhwxi wrote:
ATS does not track heap-allocated non-linear values.
In theory, it is possible. But such a statement is not really
meaningful.
Say I have a programming language that will never allow incorrect
programs
to be constructed. It sounds wonderful. But if I tell you that you have
to spend a year
implementing quicksort in this language, what would you think about the
language?
ATS is meant for people to write programs productively.
On Thursday, February 27, 2014 1:41:58 AM UTC-5, H Zhang wrote:
I understand tracking user created memory is not free. I was referring
to resources that are auto allocated on the heap by ATS. There is no way
for programmers to track these. I am wondering if it is possible for ATS to
track them, at least in theory.
Haitao
On Wednesday, February 26, 2014 9:04:53 PM UTC-8, gmhwxi wrote:
Tracking resources is not free.
The programmer has to make a great effort and the type system is
merely a tool for the programmer to check whether tracking is done
properly.
It is not clear to me what kind of applications you have in mind.
Could you elaborate a bit as to why GC bothers you?
On Wednesday, February 26, 2014 10:53:45 PM UTC-5, H Zhang wrote:
Yes I agree that ATS is advanced. I am wondering how one can take
full advantage of ML style coding without using GC? If ATS can in theory
track the life cycle of the objects it automatically heap-allocates (not
the ones manually allocated by users) then can ATS take care of freeing the
resources as well instead of relying on GC? That is the part that is
bothering me.
Haitao
On Wednesday, February 26, 2014 6:21:47 PM UTC-8, gmhwxi wrote:
There may be some misunderstanding here.
I think linear types supported in ATS are far more advanced than
RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use
GC).
I bet that any C++ compilers you can find leak memories like a
sieve.
On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is
it possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
But programmers have to manage these linear resources explicitly, right? ML
type inference is also an attractive feature. Would using linear types
interfere with that? If a function returns a stack allocated object it will
need to be copied?
In my mind one should be able to have good partition of complexity to
minimize the mental load. For intricate customized native data structures I
can see the need to use dependent and linear types to ensure correctness.
But that should be limited to as small a portion of one’s code as possible?
In parts where high level business logic is involved one does not want to
worry about allocations of temporary objects. What one wants there is
conciseness and clarity so that code can be self-documenting.
HaitaoOn Thursday, February 27, 2014 2:46:37 PM UTC-8, gmhwxi wrote:
The type system of ATS allows you to track heap-allocated linear objects.
Stack allocation means to store a value on the call stack of some function.
Whether a copy of the value or a pointer to the value is passed depends on
whether call-by-value or call-by-reference is used.
So if a high level language feature involves heap allocation one needs
to avoid it if one does not want GC dependency
It depends on what language features you want to use. Usually, there is
always a way to use linear features in ATS to
avoid GC dependency.
On Thursday, February 27, 2014 1:03:42 PM UTC-5, H Zhang wrote:
But there is also no way for programmers to track the heap allocated
objects done by the ATS compiler, correct? So if a high level language
feature involves heap allocation one needs to avoid it if one does not want
GC dependency. Or use unboxed stack allocated structures? Doesn’t stack
allocation imply copying the value every time we want to pass it to someone
else?
Haitao
On Thursday, February 27, 2014 9:12:23 AM UTC-8, gmhwxi wrote:
ATS does not track heap-allocated non-linear values.
In theory, it is possible. But such a statement is not really meaningful.
Say I have a programming language that will never allow incorrect
programs
to be constructed. It sounds wonderful. But if I tell you that you have
to spend a year
implementing quicksort in this language, what would you think about the
language?
ATS is meant for people to write programs productively.
On Thursday, February 27, 2014 1:41:58 AM UTC-5, H Zhang wrote:
I understand tracking user created memory is not free. I was referring
to resources that are auto allocated on the heap by ATS. There is no way
for programmers to track these. I am wondering if it is possible for ATS to
track them, at least in theory.
Haitao
On Wednesday, February 26, 2014 9:04:53 PM UTC-8, gmhwxi wrote:
Tracking resources is not free.
The programmer has to make a great effort and the type system is
merely a tool for the programmer to check whether tracking is done
properly.
It is not clear to me what kind of applications you have in mind.
Could you elaborate a bit as to why GC bothers you?
On Wednesday, February 26, 2014 10:53:45 PM UTC-5, H Zhang wrote:
Yes I agree that ATS is advanced. I am wondering how one can take
full advantage of ML style coding without using GC? If ATS can in theory
track the life cycle of the objects it automatically heap-allocates (not
the ones manually allocated by users) then can ATS take care of freeing the
resources as well instead of relying on GC? That is the part that is
bothering me.
Haitao
On Wednesday, February 26, 2014 6:21:47 PM UTC-8, gmhwxi wrote:
There may be some misunderstanding here.
I think linear types supported in ATS are far more advanced than
RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use
GC).
I bet that any C++ compilers you can find leak memories like a sieve.
On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is
it possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
I would like to use ATS to write library code instead of C/C++. I would
like it to be more productive than using C. I don’t envision using
dependent/linear typing much but I think a high level language (that is
higher order functions, closure, pattern matching) that is high performance
and easily integratable (due to the compilation to C) is very attractive.
When I say library I don’t mean the low level abstraction such as array or
hash map, I mean a high level encapsulation such as libxml2 or zeromq. So
there is extensive logic inside the library that will benefit very much
from high level language features even if the main data structures can be
low level to avoid unnecessary copying and conversion.
HaitaoOn Thursday, February 27, 2014 9:25:55 AM UTC-8, gmhwxi wrote:
Say I want to use ATS and Python together. There are in general too
approaches:
ATS is used like C
ATS source code compiles into Python
With (1), you need to take care of memory allocation/deallocation on your
own.
For Python, I would prefer (2). However, there is currently no compiler
from ATS source to Python.
If someone is interested in implementing one, I can provide guidance. It
is relatively a straightforward project.
For Prolog, (2) does not seem to be a viable option. Still, It is unclear
to me what you want to do by combining
ATS and Prolog. Why is it beneficial to actually combine these two?
On Thursday, February 27, 2014 1:38:00 AM UTC-5, H Zhang wrote:
I think that a complete application would have a dynamic host language
with REPL support (Lua, Python, Scheme, Prolog …). We can either use (a)
code written in ATS as library or (b) extend ATS code by embedding the
other language. The host languages all their own GCs that may or may not be
easily usable by ATS – they may use different abstractions and may not
expose a malloc/free style interface at all. It would be easier if ATS does
not have its own GC requirement. In my case I currently use Prolog, which
has its own unique GC abstractions (atom GC) and does not really expose a
malloc/free style interface as far as I know (and would be very
implementation dependent in any case).
Haitao
On Wednesday, February 26, 2014 9:04:53 PM UTC-8, gmhwxi wrote:
Tracking resources is not free.
The programmer has to make a great effort and the type system is
merely a tool for the programmer to check whether tracking is done
properly.
It is not clear to me what kind of applications you have in mind.
Could you elaborate a bit as to why GC bothers you?
On Wednesday, February 26, 2014 10:53:45 PM UTC-5, H Zhang wrote:
Yes I agree that ATS is advanced. I am wondering how one can take full
advantage of ML style coding without using GC? If ATS can in theory track
the life cycle of the objects it automatically heap-allocates (not the ones
manually allocated by users) then can ATS take care of freeing the
resources as well instead of relying on GC? That is the part that is
bothering me.
Haitao
On Wednesday, February 26, 2014 6:21:47 PM UTC-8, gmhwxi wrote:
There may be some misunderstanding here.
I think linear types supported in ATS are far more advanced than RAII.
Yes, atsopt uses GC (but the code generated by atsopt may not use GC).
I bet that any C++ compilers you can find leak memories like a sieve.
On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is it
possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.
The support for exceptions in ATS is a feature; it is not a necessity.On Wednesday, February 26, 2014 8:53:17 PM UTC-5, H Zhang wrote:
Suppose ATS can be modified to take advantage of C++ features, is it
possible to replace GC with RAII instead, at least in theory? Another
advantage is that the need to add support for exceptions also disappears. I
am suggesting this possibility only for ATS implementation purposes – I
don’t suppose one wants to model C++ datatypes – we can still assume the
current ATS/C model of abstraction for user code.