Reading the expanded C for "hello, world\n"

is, well, kind of scary. (I have similar feelings of scaryness when I
use haxe to generate other languages as back-end output.)

Do people really have success using GDB on the resulting C to debug
their original ATS program? I’d be a little more comfortable with the
whole "just shut your eyes and pretend C is assembly that you
hopefully will never have to look at as if your life depended on it"
if there were a debugger at the ATS source level.

(I realize that many functional languages often lack a source level
debugger. Though, even Haskell got some debugging work from Neil
Mitchell I think. ML has either PolyML’s debugger, or the Ocaml or F#
route. JVM-targeted languages tend to have debuggers I guess.)

thanks.

Due to very heavy use of templates in ATS2, using GDB on the C code
generated from ATS2 source can be incredibly challenging. This is a place
where an IDE can help a lot. Without a proper tool, I find it so difficult
trying
to figure out how the code for a particular instance is generated.On Sunday, December 14, 2014 11:29:36 AM UTC-5, Artyom Shalkhakov wrote:

On Sunday, December 14, 2014 2:53:36 PM UTC+6, Raoul Duke wrote:

is, well, kind of scary. (I have similar feelings of scaryness when I
use haxe to generate other languages as back-end output.)

Do people really have success using GDB on the resulting C to debug
their original ATS program? I’d be a little more comfortable with the
whole “just shut your eyes and pretend C is assembly that you
hopefully will never have to look at as if your life depended on it”
if there were a debugger at the ATS source level.

(I realize that many functional languages often lack a source level
debugger. Though, even Haskell got some debugging work from Neil
Mitchell I think. ML has either PolyML’s debugger, or the Ocaml or F#
route. JVM-targeted languages tend to have debuggers I guess.)

I debugged ATS1 compiler once, using GDB. It was quite unproductive,
mainly because GDB was to be dealt with.

Debugging ATS can be useful. For instance, it can be helpful to quickly
narrow down on some relevant parts of the program by observing its
behaviour at run-time (especially if such a program is large, and the time
constraints are tight).

I have some code for dealing with JS sourcemaps (mainly VLQ/Base64
encoding at this point) – beware, I have not run it, only made sure it
type-checks. The end goal is to be able to debug atscc2js-compiled programs
using off the shelf JS tools. If anybody is interested in picking it up,
I’ll create a repo or a gist.

Does anybody know of anything similar to JS sourcemaps for C?

thanks.

Part of the reason is that you saw a lot of macros in the C output.
Following is the JS output converted from the C output for the Hello
example.
A lot less scary, right :slight_smile:

/*
** The JavaScript code is generated by atscc2js
** The starting compilation time is: 2014-12-14: 14h:17m
*/

function
hello()
{
//
// knd = 0
//
// __patsflab_hello
ats2jspre_print_string(“Hello, world!”);
return/_void/;
} // end-of-function

// dynloadflag_init
var _057_tmp_057_patsopt_ccats_OLjWLU__dynloadflag = 0;

function
_057_tmp_057_patsopt_ccats_OLjWLU__dynload()
{
//
// knd = 0
//
// ATSdynload()
// ATSdynloadflag_sta(_057_tmp_057_patsopt_ccats_OLjWLU__dynloadflag(14))
if(ATSCKiseqz(_057_tmp_057_patsopt_ccats_OLjWLU__dynloadflag)) {
_057_tmp_057_patsopt_ccats_OLjWLU__dynloadflag = 1 ; // flag is set
hello();
} // endif
return/_void/;
} // end-of-function

function
my_dynload()
{
//
// knd = 0
//
_057_tmp_057_patsopt_ccats_OLjWLU__dynload();
return/_void/;
} // end-of-function

/* ATSextcode_beg() */
// COMMENT_line

ats2jspre_the_print_store_clear();
my_dynload();
alert(ats2jspre_the_print_store_join());
// COMMENT_line

/* ATSextcode_end() */

/* ****** ****** */

/* end-of-compilation-unit */On Sunday, December 14, 2014 3:53:36 AM UTC-5, Raoul Duke wrote:

is, well, kind of scary. (I have similar feelings of scaryness when I
use haxe to generate other languages as back-end output.)

Do people really have success using GDB on the resulting C to debug
their original ATS program? I’d be a little more comfortable with the
whole “just shut your eyes and pretend C is assembly that you
hopefully will never have to look at as if your life depended on it”
if there were a debugger at the ATS source level.

(I realize that many functional languages often lack a source level
debugger. Though, even Haskell got some debugging work from Neil
Mitchell I think. ML has either PolyML’s debugger, or the Ocaml or F#
route. JVM-targeted languages tend to have debuggers I guess.)

thanks.

is, well, kind of scary. (I have similar feelings of scaryness when I
use haxe to generate other languages as back-end output.)

Do people really have success using GDB on the resulting C to debug
their original ATS program? I’d be a little more comfortable with the
whole “just shut your eyes and pretend C is assembly that you
hopefully will never have to look at as if your life depended on it”
if there were a debugger at the ATS source level.

(I realize that many functional languages often lack a source level
debugger. Though, even Haskell got some debugging work from Neil
Mitchell I think. ML has either PolyML’s debugger, or the Ocaml or F#
route. JVM-targeted languages tend to have debuggers I guess.)

I debugged ATS1 compiler once, using GDB. It was quite unproductive, mainly
because GDB was to be dealt with.

Debugging ATS can be useful. For instance, it can be helpful to quickly
narrow down on some relevant parts of the program by observing its
behaviour at run-time (especially if such a program is large, and the time
constraints are tight).

I have some code for dealing with JS sourcemaps (mainly VLQ/Base64 encoding
at this point) – beware, I have not run it, only made sure it type-checks.
The end goal is to be able to debug atscc2js-compiled programs using off
the shelf JS tools. If anybody is interested in picking it up, I’ll create
a repo or a gist.

Does anybody know of anything similar to JS sourcemaps for C?

I think debugging is rare in ATS; I also worried about this, but never
actually ended up needing to use one. Of course, I spent a lot of time
dealing with the typechecking, but once that was fixed, the only problems I
had were able to be dealt with without a debugger.

Maybe in the future a debugger based on a checkpoint/restart solution could
be used if ATS gets an interpreter.On Sun, Dec 14, 2014 at 3:53 AM, Raoul Duke rao...@gmail.com wrote:

is, well, kind of scary. (I have similar feelings of scaryness when I
use haxe to generate other languages as back-end output.)

Do people really have success using GDB on the resulting C to debug
their original ATS program? I’d be a little more comfortable with the
whole “just shut your eyes and pretend C is assembly that you
hopefully will never have to look at as if your life depended on it”
if there were a debugger at the ATS source level.

(I realize that many functional languages often lack a source level
debugger. Though, even Haskell got some debugging work from Neil
Mitchell I think. ML has either PolyML’s debugger, or the Ocaml or F#
route. JVM-targeted languages tend to have debuggers I guess.)

thanks.


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/CAJ7XQb6ZLOWp966nm-NueNN-x8kKca4EFPprmyFQ3Dg5jScw5Q%40mail.gmail.com
.

Brandon Barker
brandon...@gmail.com