Rust lang memory management

GC is not bad per se. We don’t write code in isolation. I interact with
GC’ed languages all day long, but sometimes I need to drop down to a lower
level to write extensions. You can’t just put GC in a library willy nilly.On Wed, Oct 1, 2014 at 4:36 PM, Raoul Duke rao...@gmail.com wrote:

On Wed, Oct 1, 2014 at 3:57 PM, Haitao Zhang zht...@gmail.com wrote:

That requires GC at some stage

why is GC so bad? :slight_smile:


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/a17ftxArgIw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAJ7XQb6GamW31i-mYBK1RxkMiiwjOVDz%2Bf-w%2BC3eY%3DmnR1U6%2BA%40mail.gmail.com
.

Rust is Apache/MIT licensed so that whatever they do should be okay to
borrow in ATS as well?

The way I think about the language mismatch problem, if we take data
structures as the central of focus of programming, is that managed
languages don’t let you control every detail of the data structure that is
most important to you, while c/c++ forces you to manage every little detail
that is unimportant to you. For the data structure that carries the whole
program state I want to be very careful about everything, but in any given
function I am only working on a small part of it I want to be able to use
abstract (not just primitive) temporary or not so temporary smallish
structures without having to manually manage all the life cycles. I don’t
know if Rust is It but I do think it is an important gap to address.On Wednesday, October 1, 2014 10:35:18 AM UTC-7, gmhwxi wrote:

Interesting.

My guess is that some kind of (sophisticated) flow analysis is involved.

Is everything on stack?

Putting everything on stack would make it so difficult to do
general-purpose programming
even if it is still possible.

Why can’t ATS do something similar?

You mean to rely on flow analysis (instead of linear types) for memory
management?

Well, this has to do with my training. The lessons I learned from
automated theorem-proving
made me constantly try to avert complex algorithms of heavy heuristic
nature.

On Wednesday, October 1, 2014 12:20:34 PM UTC-4, H Zhang wrote:

Rust is able to do support ADT and pattern matching without requiring the
use of GC. Does anyone know how that is achieved? Is everything on stack?
Why can’t ATS do something similar?

Haitao

However, the values to be matched against are usually compound values
that need to be created at run-time. I guess Haitao’s question is about
where
such compound values are stored and how they are freed.

i still don’t get it. i can have (things approximating at least) ADTs
in C/++/Obj-C, can i not?

(note: i’m not arguing for non-gc, i just do not yet understand the
issue here, it all seems confused and conflated and confabulated to
me.)

The typechecker of ATS will enforce type-correctness,
which will get rid of a lot of stupid bugs.On Wednesday, October 1, 2014 4:00:57 PM UTC-4, Raoul Duke wrote:

it isn’t the burden of finger typing on keyboards.

it is the burden of stupid bugs crashes etc. later.

If you want to just do exe_name := file_name_step + “.exe” and not have
to worry about it, then what’s wrong exactly with using normal ADTs?

~SheaOn Wed, Oct 01, 2014 at 03:41:40PM -0700, H Zhang wrote:

The problem with letting it dangle now and fix it later that is: 1) I have
to remember doing that and also pick up what I was doing before and 2)
assuming the tools give meaningful warnings so I can go right to where the
issue is the “fix” would still pollute the code and make it harder to read.
Really I should be able to say exe_name := file_name_stem + “.exe” and
forget about it. I don’t care about the performance here nor memory usage.
Just needs it to be safe. But it is a heavy price to pay if I have to use
Python to get little niceties like this. If 90% of the cases can be handled
automatically I don’t mind handling the cases that can’t be resolved. Then
I can reserve the mental energy to use linear types on things that really
matter to me performance wise (time and space).

On Wednesday, October 1, 2014 2:45:06 PM UTC-7, gmhwxi wrote:

It is the mental distraction that is annoying.

I once tried to juggle 3 oranges (or apples) in front of the students
taking my class
so as to show them how difficult it is. When programming, people tend to
juggle many
concepts mentally, complicating programming unnecessarily.

In ATS, you can always use a non-linear type first and then change it to a
linear one
later. This allows you to focus on what you are doing.

On Wed, Oct 1, 2014 at 4:40 PM, H Zhang <zht...@gmail.com <javascript:>> wrote:

It is the mental distraction that is annoying. E.g. in C for something
trivial like changing the extension of a filename one needs to allocate a
string, pass it on and later remember to free it. That is just very
distracting from the logical flow. Not only that, it is very annoying to
read codes that are littered with things like that as it interferes with
following the programmer’s true intention.

On Wednesday, October 1, 2014 12:48:40 PM UTC-7, gmhwxi wrote:

without having to manually manage all the life cycles

Your assumption is that this must be very burdensome. But really? One
needs to actually
do it in order to get a real sense of it.

Think about a system that you want to implement. If there is something
that prevents you from
implementing the system, I bet it is unlikely due to the need to
manually manage something; it
usually happens at a much earlier stage.

On Wednesday, October 1, 2014 3:01:43 PM UTC-4, H Zhang wrote:

Rust is Apache/MIT licensed so that whatever they do should be okay to
borrow in ATS as well?

The way I think about the language mismatch problem, if we take data
structures as the central of focus of programming, is that managed
languages don’t let you control every detail of the data structure that is
most important to you, while c/c++ forces you to manage every little detail
that is unimportant to you. For the data structure that carries the whole
program state I want to be very careful about everything, but in any given
function I am only working on a small part of it I want to be able to use
abstract (not just primitive) temporary or not so temporary smallish
structures without having to manually manage all the life cycles. I don’t
know if Rust is It but I do think it is an important gap to address.

On Wednesday, October 1, 2014 10:35:18 AM UTC-7, gmhwxi wrote:

Interesting.

My guess is that some kind of (sophisticated) flow analysis is
involved.

Is everything on stack?

Putting everything on stack would make it so difficult to do
general-purpose programming
even if it is still possible.

Why can’t ATS do something similar?

You mean to rely on flow analysis (instead of linear types) for memory
management?

Well, this has to do with my training. The lessons I learned from
automated theorem-proving
made me constantly try to avert complex algorithms of heavy heuristic
nature.

On Wednesday, October 1, 2014 12:20:34 PM UTC-4, H Zhang wrote:

Rust is able to do support ADT and pattern matching without requiring
the use of GC. Does anyone know how that is achieved? Is everything on
stack? Why can’t ATS do something similar?

Haitao


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...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/feaf3c7e-cc59-4eb8-9df7-de315635e3fe%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/feaf3c7e-cc59-4eb8-9df7-de315635e3fe%40googlegroups.com?utm_medium=email&utm_source=footer
.


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 post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/12e14207-ecb7-468b-8f90-5240cae352d6%40googlegroups.com.

Yes, you can have different sets of malloc/free pairs as long as you don’t
use GC.
If you use GC, then you probably do not want to have different sets of
malloc/free pairs.On Wednesday, October 1, 2014 7:27:41 PM UTC-4, H Zhang wrote:

Yes that is what regions analysis does. That is a good “poor man”'s
substitute for regions analysis but I think in ATS you can’t really specify
multiple mallocs (?). You would have to drop back to C to do that.

On Wed, Oct 1, 2014 at 4:17 PM, Barry Schwartz < chem...@chemoelectric.org <javascript:>> wrote:

H Zhang <zht...@gmail.com <javascript:>> skribis:

The problem with letting it dangle now and fix it later that is: 1) I
have
to remember doing that and also pick up what I was doing before and 2)
assuming the tools give meaningful warnings so I can go right to where
the
issue is the “fix” would still pollute the code and make it harder to
read.
Really I should be able to say exe_name := file_name_stem + “.exe” and
forget about it. I don’t care about the performance here nor memory
usage.
Just needs it to be safe. But it is a heavy price to pay if I have to
use
Python to get little niceties like this. If 90% of the cases can be
handled
automatically I don’t mind handling the cases that can’t be resolved.
Then
I can reserve the mental energy to use linear types on things that
really
matter to me performance wise (time and space).

In my working days as a C programmer of slow programs that could eat
up memory freely, I used to use a little ‘reaping allocator’ I
wrote. Not at all complicated. Call it instead of malloc directly, and
use it just like malloc, but the allocated pieces had a link field in
them so you could free them all at once. So I’d start up the allocator
at the beginning of routine and put a ‘reap’ at the end. In between, I
could act somewhat as if I had a garbage collector.

Simple solutions often work fine.

(Python OTOH makes things so complicated that I wouldn’t trust a proof
of correctness of some Python code if it existed, and don’t trust
tests.)


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/a17ftxArgIw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
ats-lang...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/20141001231739.GA16565%40crud
.

In ATS, you can always use a non-linear type first and then change it to a
linear one
later. This allows you to focus on what you are doing.

do i get it right that you can start with Boehm first, too? as the
most easy route to Getting Something Working. and then easily
(easily?) migrate to statically tracked manual memory management?

it isn’t the burden of finger typing on keyboards.

it is the burden of stupid bugs crashes etc. later.

The typechecker of ATS will enforce type-correctness,
which will get rid of a lot of stupid bugs.

sure, agreed, i’m all for good typing :slight_smile: e.g. i assume/hope also
especially if linears are used to statically find memory problems.