Start with C then ATS or with ATS right at the start?

I’m not really an ATS user, and am just keeping an eye on it and learn
about it incrementally, from time to time, so I cannot answer myself a
question I have. As I believe this question is likely to come to the mind
of other people too, I though about asking it, directly.

I’m currently designing something (planned to be long) using Python for
convenience as a kind of model language, with the intent to later (when the
Python version will be clean enough) rewrite into C. I do it this way, as I
feel it’s easier to separate different concerns: starting with Python I can
avoid thinking about technical details and just think about the domain’s
logic, it’s also easier to rework things quickly in Python (while I’m not
to say it’s a perfect language).

After C, I’m planning to go with ATS, with a similar rational in mind: once
the the model implementation is OK, I will start to think about technical
details then later prove it’s free of runtime error, at least, and prove
some other properties too, if feasible. I though starting with C would be
easier than starting directly with ATS.

However, I have a doubt here: is there a risk I will waste my time going to
C before to ATS with the assumption it’s easy to adapt C to ATS (kind of
refinement, hence the tag) or am I afraid without real reasons and it can
be a good path?

May be people who are effectively using ATS (not just leaning it, like me),
may have an intuition about this question?

With thanks, and have a nice time.

That going from Python to C is not as much a scary prospect could be
considered a defect of using Python to get to ATS.

Please, can you elaborate on the last point?

The usual method for a typical for or while loop in ATS is to write a
recursive function/closure called loop … but, it does support the
for/while keywords … but I have never (as I recall) seen them except in
examples talking about how to use for and while loops…On Mon, Apr 6, 2015 at 6:29 PM, ‘Yannick Duchêne’ via ats-lang-users < ats-lan...@googlegroups.com> wrote:

Le lundi 6 avril 2015 23:50:39 UTC+2, Barry Schwartz a écrit :

[…] You want something in which recursion is
utterly natural. Otherwise you are going to have either bad ATS or the
need to rethink a whole lot of loops.[…].

Does that mean loops should be avoided if ATS is planned? What are the
issues with loops in ATS?


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/a4f94a25-8c76-467f-b19a-394dea829297%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/a4f94a25-8c76-467f-b19a-394dea829297%40googlegroups.com?utm_medium=email&utm_source=footer
.

Brandon Barker
brandon...@gmail.com

If you do not want GC at the end, then you probably have to use linear
types during re-fatoring
or after porting to C is done.

GC in indeed to be avoided for the core. The core is an HTTP and WebSocket
server, conforming to some personal style and requirement, and I don’t want
a GC at the time of parsing interpreting requests. The remaining is an
authoring application on top of this server, with an abstract interface
(the real UI in to be in a browser).

If you are less familiar with ATS, I suggest that you try to minimize the
use of dependent types
at the beginning.

I’m afraid I will need dependent types. Well, I know multiple time you
recommended to avoid starting with this kind of typing, and introduce it at
last. So I already knew I will have to go this way, as it was underlined
multiple times in this newsgroup.

Try to use run-time checks instead.

And to remove them later… one of my expectation, is to prove the multiple
assertions I have in the Python version.

After reading every one, I will not go with C, and will go with ATS from
the beginning, using embedded C for a start, however with proper signatures
to ensure C functions are used as expected, then later incrementally turn
embedded C into ATS.

From your comments (all of you), I feel it would be a waste of time to have
a C version then later convert it to ATS. Better a mix of both from the
start, to not end with C things which would unmanageable in ATS…

True, that is my hope as well, and I don’t think the C->ATS approach would
be good for large, de novo programs. It might be better to define the
interfaces in ATS in that case, then do a mix of C or “C-Style” ATS
(depending on your fluency), and gradually improve it.On Mon, Apr 6, 2015 at 4:49 PM, Raoul Duke rao...@gmail.com wrote:

I am not a real ATS user either.

But I would have done it the other way around, using ATS before C
because to me the whole point of me using ATS is to statically find
stuff that otherwise blows up at runtime with crappy old C. So my
personal hope / belief / faith / dream is that the short term hit of
getting running with ATS would pretty quickly amortize vs. all the
stupid debugging hell I’d do through with Crappy old C.

$0.02


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/CAJ7XQb6q1pYpfrcR5mX0E22p1SZwVAHKg8OOJ-TxiaGoJ7yiLQ%40mail.gmail.com
.

Brandon Barker
brandon...@gmail.com

To me, a large part of the answer depends what is being implemented.

I suggest the following route:

Say that your Python implementation is done.

Try to first use ATS to re-factor the Python implementation.

You can find a Python implementation of the Game-of-24 in the following
directory:

Please compare it with the implementation done in ATS and several other
languages (e.g.,
JS, Perl, PHP). This is the kind of re-factoring I have in mind.

During this re-factoring process, you can always compile and test your code
with the help
of the atscc2py compiler.

When the re-factoring done, you can start re-writing the remaining Python
code in C.

If you do not want GC at the end, then you probably have to use linear
types during re-fatoring
or after porting to C is done.

Anyways, this is just a rough outline. There will always be fine details
that need to be addressed
with caution.

If you are less familiar with ATS, I suggest that you try to minimize the
use of dependent types
at the beginning. Try to use run-time checks instead.On Monday, April 6, 2015 at 4:47:11 PM UTC-4, Yannick Duchêne wrote:

I’m not really an ATS user, and am just keeping an eye on it and learn
about it incrementally, from time to time, so I cannot answer myself a
question I have. As I believe this question is likely to come to the mind
of other people too, I though about asking it, directly.

I’m currently designing something (planned to be long) using Python for
convenience as a kind of model language, with the intent to later (when the
Python version will be clean enough) rewrite into C. I do it this way, as I
feel it’s easier to separate different concerns: starting with Python I can
avoid thinking about technical details and just think about the domain’s
logic, it’s also easier to rework things quickly in Python (while I’m not
to say it’s a perfect language).

After C, I’m planning to go with ATS, with a similar rational in mind:
once the the model implementation is OK, I will start to think about
technical details then later prove it’s free of runtime error, at least,
and prove some other properties too, if feasible. I though starting with C
would be easier than starting directly with ATS.

However, I have a doubt here: is there a risk I will waste my time going
to C before to ATS with the assumption it’s easy to adapt C to ATS (kind of
refinement, hence the tag) or am I afraid without real reasons and it can
be a good path?

May be people who are effectively using ATS (not just leaning it, like
me), may have an intuition about this question?

With thanks, and have a nice time.

‘!’ is taken from Girard’s linear logic, where it represents a form of
modailty
indicating that a proposition can be used repeatedly or not at all.On Friday, April 10, 2015 at 3:02:15 PM UTC-4, Yannick Duchêne wrote:

Le lundi 6 avril 2015 23:21:46 UTC+2, Barry Schwartz a écrit :

‘Yannick Duchêne’ via ats-lang-users ats-l...@googlegroups.com
skribis:
I would suggest modeling with Scheme instead of Python, and then going
straight to ATS.

I guess you may be right in many ways, indeed. I wanted to try something
in Python to better match the ATS target, and I faced an issue: there is no
tail-call optimization in Python.

There is with Scheme, but I’m not sure I can write assertions in Scheme as
easily as I do in Python, using sum/min/max, generator filter and map,
which is what I have in near to all of my assertions.

As I just learned about Scheme just a bit and long ago, I looking at it.
May be I will finally discover I can write assertions as easily (assertions
are an important aspect for me… I already caught errors very early with it).

Was the ! sign in ATS inspired by the same symbol in Scheme? Seems there
is a naming convention in Scheme, suggesting to use it for things involving
side effects, which made me think of its use in ATS (consumed vs
non-consumed).

I am not a real ATS user either.

But I would have done it the other way around, using ATS before C
because to me the whole point of me using ATS is to statically find
stuff that otherwise blows up at runtime with crappy old C. So my
personal hope / belief / faith / dream is that the short term hit of
getting running with ATS would pretty quickly amortize vs. all the
stupid debugging hell I’d do through with Crappy old C.

$0.02

Personally I’d go straight to ATS and skip the C step.

However, you says “Often I start with a C program and slowly add ATS
features as I go” in the first link :-p . Just teasing :wink: . I will read
these two page. “embedding C in ATS”… that reminds me something, indeed. I
will have this in mind.

You’ll learn
ATS faster that way. If you get stuck you can always just embed C in
ATS itself. For examples of this see:

Converting C Programs to ATS

and

Preventing heartbleed bugs with safe programming languages

Another question, along to the one of loops, which was raised (by Barry
Schwartz, if I’m not wrong), was the one of side‑effects: in your opinion,
should I avoid side effects in the models or not? I actually use bounded
side effect, to update value in place instead of returning a new value, ex.
with lists (I don’t mean global side effect). Is this easy to rewrite into
ATS?

I can’t really claim to be fluent in any style of ATS; I feel it is still a
little harder than C, and requires you to be familiar and extremely ready
to use unsafe.sats … but you do get some additional safety features even
there, to the extent that you don’t use unsafe.sats… I think others may
have more words of wisdom here than myself though.

I need to try this again sometime soon.On Mon, Apr 6, 2015 at 5:19 PM, ‘Yannick Duchêne’ via ats-lang-users < ats-lan...@googlegroups.com> wrote:

Le lundi 6 avril 2015 22:53:41 UTC+2, Brandon Barker a écrit :

True, that is my hope as well, and I don’t think the C->ATS approach
would be good for large, de novo programs. It might be better to define the
interfaces in ATS in that case, then do a mix of C or “C-Style” ATS
(depending on your fluency), and gradually improve it.

Do C-style ATS differs a lot compared to C? I mean, a comparison in terms
of difficulties. Is it easily accessible with a reasonable C background?


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/596688d2-76bc-46a8-beb7-b0cb62b328a3%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/596688d2-76bc-46a8-beb7-b0cb62b328a3%40googlegroups.com?utm_medium=email&utm_source=footer
.

Brandon Barker
brandon...@gmail.com

I am not a real ATS user either.

But I would have done it the other way around, using ATS before C

ATS already compiles to C :-p , and that’s even one of the big reason I’m
interested in ATS. That said, honestly, I have not checked if the generated
C are workable.

http://bluishcoder.co.nz

I found a broken link. On
http://bluishcoder.co.nz/2006/05/21/avi-follows-up-on-continuation-debate.html
the link labelled “Avi Bryant has a long post” leads to a parking (too bad,
I wanted to read this).

However, I have a doubt here: is there a risk I will waste my time going
to
C before to ATS with the assumption it’s easy to adapt C to ATS (kind of
refinement, hence the tag) or am I afraid without real reasons and it
can be
a good path?

Personally I’d go straight to ATS and skip the C step. You’ll learn
ATS faster that way. If you get stuck you can always just embed C in
ATS itself. For examples of this see:

Converting C Programs to ATS

and

Preventing heartbleed bugs with safe programming languages

Without knowing what you are after, I’d like to second Chris’s suggestion.
Note that the templates of ATS2 make a C++ coding style feasible. By that,
I mean that you’ll find it much easier to reuse some existing code, to
tailor some existing function templates for your needs.

For instance, in ATS1, to write a function that prints an array of elements
of some type you introduced, you basically had two alternatives:

  1. roll your own function that involved iterating over said array in a
    tail-recursive fashion,
  2. or, you could have used some higher-order function, but in this case,
    you had to wrestle with the nit-picky typechecker

In ATS2 it’s just a matter of function template specialization for your
element, and you are done.

The usual method for a typical for or while loop in ATS is to write a
recursive function/closure called loop … but, it does support the
for/while keywords … but I have never (as I recall) seen them except in
examples talking about how to use for and while loops…

Yes, I remember I added words about it the ATS wiki. If there is no
specific issues in converting loops into recursive functions, then I may
have no reason to worry about loops in the model, right? (*) I care about
this point, as I indeed have many loops in the current model.

(*) And I remember ATS turns tail recursions into jumps/loops at the time
of generating C.

True, that is my hope as well, and I don’t think the C->ATS approach would
be good for large, de novo programs. It might be better to define the
interfaces in ATS in that case, then do a mix of C or “C-Style” ATS
(depending on your fluency), and gradually improve it.

Do C-style ATS differs a lot compared to C? I mean, a comparison in terms
of difficulties. Is it easily accessible with a reasonable C background?

Converting C Programs to ATS

and

Preventing heartbleed bugs with safe programming languages


http://bluishcoder.co.nz

I just finished reading the two pages, and the first, especially, adds
useful clarification and should be part of any ATS introduction.

These two pages also remind me some questions I will post later in specific
threads.

I actually use bounded side effect, to update value in place instead of
returning a new value, ex. with lists (I don’t mean global side effect). Is
this easy to rewrite into ATS?

In my opinion, this is the right way to handle effects. ATS has features
that make it very pleasant for handling local effects.On Monday, April 6, 2015 at 9:51:10 PM UTC-4, Yannick Duchêne wrote:

Le mardi 7 avril 2015 03:30:11 UTC+2, Chris Double a écrit :

Personally I’d go straight to ATS and skip the C step.

However, you says “Often I start with a C program and slowly add ATS
features as I go” in the first link :-p . Just teasing :wink: . I will read
these two page. “embedding C in ATS”… that reminds me something, indeed. I
will have this in mind.

You’ll learn
ATS faster that way. If you get stuck you can always just embed C in
ATS itself. For examples of this see:

Converting C Programs to ATS

and

Preventing heartbleed bugs with safe programming languages

Another question, along to the one of loops, which was raised (by Barry
Schwartz, if I’m not wrong), was the one of side‑effects: in your opinion,
should I avoid side effects in the models or not? I actually use bounded
side effect, to update value in place instead of returning a new value, ex.
with lists (I don’t mean global side effect). Is this easy to rewrite into
ATS?

[…] You want something in which recursion is
utterly natural. Otherwise you are going to have either bad ATS or the
need to rethink a whole lot of loops.[…].

Does that mean loops should be avoided if ATS is planned? What are the
issues with loops in ATS?

‘Yannick Duchêne’ via ats-lang-users <ats-l...@googlegroups.com
<javascript:>> skribis:
I would suggest modeling with Scheme instead of Python, and then going
straight to ATS.

I guess you may be right in many ways, indeed. I wanted to try something in
Python to better match the ATS target, and I faced an issue: there is no
tail-call optimization in Python.

There is with Scheme, but I’m not sure I can write assertions in Scheme as
easily as I do in Python, using sum/min/max, generator filter and map,
which is what I have in near to all of my assertions.

As I just learned about Scheme just a bit and long ago, I looking at it.
May be I will finally discover I can write assertions as easily (assertions
are an important aspect for me… I already caught errors very early with it).

Was the ! sign in ATS inspired by the same symbol in Scheme? Seems there
is a naming convention in Scheme, suggesting to use it for things involving
side effects, which made me think of its use in ATS (consumed vs
non-consumed).

My somewhat limited experience trying things this way suggests that doing a
C implementation can be helpful, in some cases, unless you are either a
very fluent C programmer, ATS programmer, or both.On Mon, Apr 6, 2015 at 4:47 PM, ‘Yannick Duchêne’ via ats-lang-users < ats-lan...@googlegroups.com> wrote:

I’m not really an ATS user, and am just keeping an eye on it and learn
about it incrementally, from time to time, so I cannot answer myself a
question I have. As I believe this question is likely to come to the mind
of other people too, I though about asking it, directly.

I’m currently designing something (planned to be long) using Python for
convenience as a kind of model language, with the intent to later (when the
Python version will be clean enough) rewrite into C. I do it this way, as I
feel it’s easier to separate different concerns: starting with Python I can
avoid thinking about technical details and just think about the domain’s
logic, it’s also easier to rework things quickly in Python (while I’m not
to say it’s a perfect language).

After C, I’m planning to go with ATS, with a similar rational in mind:
once the the model implementation is OK, I will start to think about
technical details then later prove it’s free of runtime error, at least,
and prove some other properties too, if feasible. I though starting with C
would be easier than starting directly with ATS.

However, I have a doubt here: is there a risk I will waste my time going
to C before to ATS with the assumption it’s easy to adapt C to ATS (kind of
refinement, hence the tag) or am I afraid without real reasons and it can
be a good path?

May be people who are effectively using ATS (not just leaning it, like
me), may have an intuition about this question?

With thanks, and have a nice time.


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/1d521742-0931-45bb-9349-5433debbab35%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/1d521742-0931-45bb-9349-5433debbab35%40googlegroups.com?utm_medium=email&utm_source=footer
.

Brandon Barker
brandon...@gmail.com