# Imperative vs. functional vs. linear functional

**URL:** <https://discourse.ats-lang.org/t/imperative-vs-functional-vs-linear-functional/86>\
**Category:** Google Group\
**Created:** [February 5, 2016, 4:36am UTC](https://discourse.ats-lang.org/t/imperative-vs-functional-vs-linear-functional/86 "2016-02-05T04:36:24Z")\
**Posts on this page:** 8\
**Page:** 1

<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:** [February 5, 2016, 4:36am UTC](https://discourse.ats-lang.org/t/imperative-vs-functional-vs-linear-functional/86/1 "2016-02-05T04:36:24Z")

</div>

I wrote a small article in the Effective-ATS series where  
3 styles of programming are compared:

[http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/HanoiTowers/index.html](http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/HanoiTowers/index.html)

Imperative: difficult to reasonable  
Functional: facilitating reasoning but is wasteful in terms of memory usage  
Linear functional: Functional + efficient memory usage

Cheers!

–Hongwei

---

<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:** [February 5, 2016, 5:44pm UTC](https://discourse.ats-lang.org/t/imperative-vs-functional-vs-linear-functional/86/2 "2016-02-05T17:44:15Z")

</div>

Website down.  
Cannot say I have much love for sourceforge these days.

---

<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:** [February 11, 2016, 2:33am UTC](https://discourse.ats-lang.org/t/imperative-vs-functional-vs-linear-functional/86/3 "2016-02-11T02:33:47Z")

</div>

> > Can you point to examples of how support for overloading is better than  
> > ML’s?

My understanding is that there is very little support for overloading in ML.

For instance, ‘xs - i’ means removing the element ‘i’ from the list ‘xs’ in  
the  
code I showed. That is, ‘-’ is given the following type in this case:

(list0(a), a) → list0(a)

This is not possible in ML as ‘-’ is given the type 'a \* 'a → 'a during  
type inference.

Also, dot-symbol overloading in ATS is not ML-like:

[http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/HTMLTOC/c260.html](http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/HTMLTOC/c260.html)

Overloading in ATS is completely ad-hoc. Basically, anything goes as long  
as the compiler  
can figure out what is being overloaded based on the arity and type  
information.On Wednesday, February 10, 2016 at 7:36:08 PM UTC-5, aditya siram wrote:

> Hi,  
> I really like what ATS can do but a lot of the examples, including the one  
> you link to, don’t seem to show off it’s overloading capabilities. I’m a  
> noob so I maybe misunderstanding the code but it seems to make calls to a  
> lot of type specific functions and datatypes like `list0_tabulate` and  
> `nil0`.
> 
> I have seen some of the overloading peek through in your template function  
> examples that use `fwork` but not much beyond.
> 
> Can you point to examples of how support for overloading is better than  
> ML’s?
> 
> Thanks!  
> -deech
> 
> On Wednesday, February 10, 2016 at 1:52:00 PM UTC-6, gmhwxi wrote:
> 
> > Thanks 🙂
> > 
> > One can certainly write ATS code that looks elegant. For instance:
> > 
> > [Redirecting to Google Groups](https://groups.google.com/forum/#!searchin/ats-lang-users/permute/ats-lang-users/LYHMWUMalIM/g4WCoANCEQAJ)
> > 
> > It takes time to write elegant code, though. People complaining about the  
> > syntax of ATS are often not knowing much about  
> > ATS. There are certainly amny Haskellers who think that anything  
> > non-Haskell is ugly.
> > 
> > On Wednesday, February 10, 2016 at 5:45:46 AM UTC-5, anonymous anomymous wrote:
> > 
> > > I always thought of functional programming somewhat wasteful (for reason  
> > > mentioned) but superior to other programming styles. Linear functional ATS  
> > > is really impressive. What am I saying? ATS on the whole is impressive!  
> > > Thanks, Professor, for the article. I hope, in time, the language gets the  
> > > popularity it deserves. I mean, it’s sad that such a good language is a bit  
> > > lacking in terms of attention. I often hear complaints about the syntax…  
> > > Programmers nowadays are really spoiled by Ruby and Python.
> > > 
> > > Best regards,  
> > > anonymous

---

<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:** [February 5, 2016, 6:22pm UTC](https://discourse.ats-lang.org/t/imperative-vs-functional-vs-linear-functional/86/4 "2016-02-05T18:22:36Z")

</div>

There is a backup link at github:

[http://ats-lang.github.io/EXAMPLE/EFFECTIVATS/On](http://ats-lang.github.io/EXAMPLE/EFFECTIVATS/On) Friday, February 5, 2016 at 12:44:16 PM UTC-5, Raoul Duke wrote:

> Website down.  
> Cannot say I have much love for sourceforge these days.

---

<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:** [February 10, 2016, 3:37pm UTC](https://discourse.ats-lang.org/t/imperative-vs-functional-vs-linear-functional/86/5 "2016-02-10T15:37:23Z")

</div>

For me, the main advantage of Python etc. is ease of installation. 🙂 (Not  
a super big fan of then as actual languages per se.)

---

<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:** [February 6, 2016, 7:37pm UTC](https://discourse.ats-lang.org/t/imperative-vs-functional-vs-linear-functional/86/6 "2016-02-06T19:37:35Z")

</div>

Also, I added a poorman’s demo for Hanoi Towers:

[http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/HanoiTowers/HanoiTowers\_txt.htmlOn](http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/HanoiTowers/HanoiTowers_txt.htmlOn) Friday, February 5, 2016 at 1:22:36 PM UTC-5, gmhwxi wrote:

> There is a backup link at github:
> 
> [http://ats-lang.github.io/EXAMPLE/EFFECTIVATS/](http://ats-lang.github.io/EXAMPLE/EFFECTIVATS/)
> 
> On Friday, February 5, 2016 at 12:44:16 PM UTC-5, Raoul Duke wrote:
> 
> > Website down.  
> > Cannot say I have much love for sourceforge these days.

---

<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:** [February 10, 2016, 7:52pm UTC](https://discourse.ats-lang.org/t/imperative-vs-functional-vs-linear-functional/86/7 "2016-02-10T19:52:00Z")

</div>

Thanks 🙂

One can certainly write ATS code that looks elegant. For instance:

[https://groups.google.com/forum/#!searchin/ats-lang-users/permute/ats-lang-users/LYHMWUMalIM/g4WCoANCEQAJ](https://groups.google.com/forum/#!searchin/ats-lang-users/permute/ats-lang-users/LYHMWUMalIM/g4WCoANCEQAJ)

It takes time to write elegant code, though. People complaining about the  
syntax of ATS are often not knowing much about  
ATS. There are certainly amny Haskellers who think that anything  
non-Haskell is ugly.On Wednesday, February 10, 2016 at 5:45:46 AM UTC-5, anonymous anomymous wrote:

> I always thought of functional programming somewhat wasteful (for reason  
> mentioned) but superior to other programming styles. Linear functional ATS  
> is really impressive. What am I saying? ATS on the whole is impressive!  
> Thanks, Professor, for the article. I hope, in time, the language gets the  
> popularity it deserves. I mean, it’s sad that such a good language is a bit  
> lacking in terms of attention. I often hear complaints about the syntax…  
> Programmers nowadays are really spoiled by Ruby and Python.
> 
> Best regards,  
> anonymous

---

<div class="post-metadata">

**Author:** ![aditya\_siram](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@aditya\_siram](https://discourse.ats-lang.org/u/aditya_siram)\
**Post date:** [February 11, 2016, 12:36am UTC](https://discourse.ats-lang.org/t/imperative-vs-functional-vs-linear-functional/86/8 "2016-02-11T00:36:08Z")

</div>

Hi,  
I really like what ATS can do but a lot of the examples, including the one  
you link to, don’t seem to show off it’s overloading capabilities. I’m a  
noob so I maybe misunderstanding the code but it seems to make calls to a  
lot of type specific functions and datatypes like `list0_tabulate` and  
`nil0`.

I have seen some of the overloading peek through in your template function  
examples that use `fwork` but not much beyond.

Can you point to examples of how support for overloading is better than  
ML’s?

Thanks!  
-deechOn Wednesday, February 10, 2016 at 1:52:00 PM UTC-6, gmhwxi wrote:

> Thanks 🙂
> 
> One can certainly write ATS code that looks elegant. For instance:
> 
> [Redirecting to Google Groups](https://groups.google.com/forum/#!searchin/ats-lang-users/permute/ats-lang-users/LYHMWUMalIM/g4WCoANCEQAJ)
> 
> It takes time to write elegant code, though. People complaining about the  
> syntax of ATS are often not knowing much about  
> ATS. There are certainly amny Haskellers who think that anything  
> non-Haskell is ugly.
> 
> On Wednesday, February 10, 2016 at 5:45:46 AM UTC-5, anonymous anomymous wrote:
> 
> > I always thought of functional programming somewhat wasteful (for reason  
> > mentioned) but superior to other programming styles. Linear functional ATS  
> > is really impressive. What am I saying? ATS on the whole is impressive!  
> > Thanks, Professor, for the article. I hope, in time, the language gets the  
> > popularity it deserves. I mean, it’s sad that such a good language is a bit  
> > lacking in terms of attention. I often hear complaints about the syntax…  
> > Programmers nowadays are really spoiled by Ruby and Python.
> > 
> > Best regards,  
> > anonymous
