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

**URL:** <https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228>\
**Category:** Google Group\
**Created:** [April 6, 2015, 8:47pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228 "2015-04-06T20:47:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [April 6, 2015, 8:47pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/1 "2015-04-06T20:47:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [April 6, 2015, 9:24pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/2 "2015-04-06T21:24:10Z")

</div>

> 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?

---

<div class="post-metadata">

**Author:** ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)\
**Post date:** [April 6, 2015, 10:32pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/3 "2015-04-06T22:32:38Z")

</div>

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](mailto: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](mailto:ats-lang-user...@googlegroups.com).  
> To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> Visit this group at [http://groups.google.com/group/ats-lang-users](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)  
> [https://groups.google.com/d/msgid/ats-lang-users/a4f94a25-8c76-467f-b19a-394dea829297%40googlegroups.com?utm\_medium=email&utm\_source=footer](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](mailto:brandon...@gmail.com)

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [April 7, 2015, 6:43pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/4 "2015-04-07T18:43:44Z")

</div>

> 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…

---

<div class="post-metadata">

**Author:** ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)\
**Post date:** [April 6, 2015, 8:53pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/5 "2015-04-06T20:53:20Z")

</div>

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](mailto: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](mailto:ats-lang-user...@googlegroups.com).  
> To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> Visit this group at [http://groups.google.com/group/ats-lang-users](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](https://groups.google.com/d/msgid/ats-lang-users/CAJ7XQb6q1pYpfrcR5mX0E22p1SZwVAHKg8OOJ-TxiaGoJ7yiLQ%40mail.gmail.com)  
> .

Brandon Barker  
[brandon...@gmail.com](mailto:brandon...@gmail.com)

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [April 7, 2015, 3:18am UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/6 "2015-04-07T03:18:48Z")

</div>

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:

> <https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/SMALL/GameOf24>
>
> //github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/SMALL/GameOf24

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.

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [April 10, 2015, 7:33pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/7 "2015-04-10T19:33:52Z")

</div>

‘!’ 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](mailto: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).

---

<div class="post-metadata">

**Author:** ![Raoul\_Duke](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@Raoul\_Duke](https://discourse.ats-lang.org/u/Raoul_Duke)\
**Post date:** [April 6, 2015, 8:49pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/8 "2015-04-06T20:49:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [April 7, 2015, 1:51am UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/9 "2015-04-07T01:51:10Z")

</div>

> 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 😉 . 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](http://bluishcoder.co.nz/2011/04/24/converting-c-programs-to-ats.html)
> 
> and
> 
> [Preventing heartbleed bugs with safe programming languages](http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe-languages.html)

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?

---

<div class="post-metadata">

**Author:** ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)\
**Post date:** [April 6, 2015, 9:24pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/10 "2015-04-06T21:24:42Z")

</div>

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](mailto: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](mailto:ats-lang-user...@googlegroups.com).  
> To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> Visit this group at [http://groups.google.com/group/ats-lang-users](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)  
> [https://groups.google.com/d/msgid/ats-lang-users/596688d2-76bc-46a8-beb7-b0cb62b328a3%40googlegroups.com?utm\_medium=email&utm\_source=footer](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](mailto:brandon...@gmail.com)

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [April 6, 2015, 9:21pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/11 "2015-04-06T21:21:49Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [April 9, 2015, 1:55pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/12 "2015-04-09T13:55:07Z")

</div>

> [http://bluishcoder.co.nz](http://bluishcoder.co.nz)

I found a broken link. On  
[http://bluishcoder.co.nz/2006/05/21/avi-follows-up-on-continuation-debate.html](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).

---

<div class="post-metadata">

**Author:** ![Artyom\_Shalkhakov](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Artyom\_Shalkhakov](https://discourse.ats-lang.org/u/Artyom_Shalkhakov)\
**Post date:** [April 7, 2015, 3:43am UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/13 "2015-04-07T03:43:41Z")

</div>

> 

> > 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](http://bluishcoder.co.nz/2011/04/24/converting-c-programs-to-ats.html)
> 
> and
> 
> [Preventing heartbleed bugs with safe programming languages](http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe-languages.html)

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.

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [April 6, 2015, 10:50pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/14 "2015-04-06T22:50:34Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [April 6, 2015, 9:19pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/15 "2015-04-06T21:19:03Z")

</div>

> 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?

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [April 7, 2015, 6:51pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/16 "2015-04-07T18:51:33Z")

</div>

> [Converting C Programs to ATS](http://bluishcoder.co.nz/2011/04/24/converting-c-programs-to-ats.html)
> 
> and
> 
> [Preventing heartbleed bugs with safe programming languages](http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe-languages.html)
> 
> –  
> [http://bluishcoder.co.nz](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.

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [April 8, 2015, 2:41am UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/17 "2015-04-08T02:41:39Z")

</div>

> > 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 😉 . 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](http://bluishcoder.co.nz/2011/04/24/converting-c-programs-to-ats.html)
> > 
> > and
> > 
> > [Preventing heartbleed bugs with safe programming languages](http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe-languages.html)
> 
> 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?

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [April 6, 2015, 10:29pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/18 "2015-04-06T22:29:34Z")

</div>

> […] 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?

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [April 10, 2015, 7:02pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/19 "2015-04-10T19:02:15Z")

</div>

> ‘Yannick Duchêne’ via ats-lang-users \<[ats-l...@googlegroups.com](mailto: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).

---

<div class="post-metadata">

**Author:** ![Brandon\_Barker](https://sea1.discourse-cdn.com/flex019/user_avatar/discourse.ats-lang.org/brandon_barker/32/61_2.png) [@Brandon\_Barker](https://discourse.ats-lang.org/u/Brandon_Barker)\
**Post date:** [April 6, 2015, 8:50pm UTC](https://discourse.ats-lang.org/t/start-with-c-then-ats-or-with-ats-right-at-the-start/228/20 "2015-04-06T20:50:07Z")

</div>

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](mailto: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](mailto:ats-lang-user...@googlegroups.com).  
> To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> Visit this group at [http://groups.google.com/group/ats-lang-users](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)  
> [https://groups.google.com/d/msgid/ats-lang-users/1d521742-0931-45bb-9349-5433debbab35%40googlegroups.com?utm\_medium=email&utm\_source=footer](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](mailto:brandon...@gmail.com)
