comp.lang.ada
 help / color / mirror / Atom feed
* Script-like jobs in Ada (ideas for HAC)
@ 2020-04-24 19:45 gautier_niouzes
  2020-04-24 23:22 ` cantanima.perry
                   ` (11 more replies)
  0 siblings, 12 replies; 22+ messages in thread
From: gautier_niouzes @ 2020-04-24 19:45 UTC (permalink / raw)


It's a poll - sort of.

The question is: what kind of jobs do you prefer let a scripting language do and not Ada?

My guess is that this kind of choice is related to toolsets, libraries and other aspects that are not necessarily related to languages.
For instance you would perhaps avoid using Ada for a 30-lines program that browses files and collects some information in those files (just an example). Or a little math / stats program? Or a small game?
But maybe the real reason (even if it is unconscious) you'd avoid Ada is because the compiler you are using is slow, or because it spits objects and executable files each time you change your small program. And you'd be more comfortable with a script that runs immediately without making garbage files.

A goal of the HAC compiler [1] is precisely to blur the border between a script and an Ada program: from the command line, you write "hax myprog.adb" and it just runs (that's already working). Now I'd be curious of examples of scripts you'd consider writing in Ada with HAC, if it supplied the convenient functions and libraries. It's all work-in-progress currently, and ideas of applications are welcome at this point of the development.

Thanks for any input!
--
[1] http://hacadacompiler.sf.net/  and  https://github.com/zertovitch/hac

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-24 19:45 Script-like jobs in Ada (ideas for HAC) gautier_niouzes
@ 2020-04-24 23:22 ` cantanima.perry
  2020-04-25  0:11 ` Nasser M. Abbasi
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: cantanima.perry @ 2020-04-24 23:22 UTC (permalink / raw)


What about REPL with hot code reloading?

I know this is the province of LISP and recently Nim did it too, and I guess most scripting languages do it, like iPython? Anyway, I mean this: long ago I used a programming language called Basic09 that despite its name had a lot in common with Pascal and Modula-2 -- well, OK, with Ada if you want to put it that way: it offered structured programming techniques and modular programming, including modules. Like any BASIC, you interacted with an interpreter, but with Basic09 you could compile to I-code, save, load, and I believe even reload that I-code, etc.

I've always wished that modern compiled languages allowed one to do something like that, so that you could combine the best of a compiled language with the best of an interpreted one. The fact that it's pretty rare probably shows how little I know, though.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-24 19:45 Script-like jobs in Ada (ideas for HAC) gautier_niouzes
  2020-04-24 23:22 ` cantanima.perry
@ 2020-04-25  0:11 ` Nasser M. Abbasi
  2020-04-25 19:00   ` Stephen Leake
  2020-04-25 18:52 ` Stephen Leake
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 22+ messages in thread
From: Nasser M. Abbasi @ 2020-04-25  0:11 UTC (permalink / raw)


On 4/24/2020 2:45 PM, gautier_niouzes@hotmail.com wrote:
> It's a poll - sort of.
> 
> The question is: what kind of jobs do you prefer let a scripting language do and not Ada?
> 
> My guess is that this kind of choice is related to toolsets, libraries and other aspects that are not necessarily related to languages.
> For instance you would perhaps avoid using Ada for a 30-lines program that browses files and collects some information in those files (just an example). Or a little math / stats program? Or a small game?
> But maybe the real reason (even if it is unconscious) you'd avoid Ada is because the compiler you are using is slow, or because it spits objects and executable files each time you change your small program. And you'd be more comfortable with a script that runs immediately without making garbage files.
> 
> A goal of the HAC compiler [1] is precisely to blur the border between a script and an Ada program: from the command line, you write "hax myprog.adb" and it just runs (that's already working). Now I'd be curious of examples of scripts you'd consider writing in Ada with HAC, if it supplied the convenient functions and libraries. It's all work-in-progress currently, and ideas of applications are welcome at this point of the development.
> 
> Thanks for any input!
> --
> [1] http://hacadacompiler.sf.net/  and  https://github.com/zertovitch/hac
> 


Main advantage of scripts, and by this I really mean bash, sh, python, and may
be perl, is that these come pre-installed on Linux. i.e. once you
install Linux, most likely you'll have bash, sh, python interpreter
ready to be used.  (for windows, it will be DOS scripts)

Hence any script written will run as is, with no need to having to first
"compile" it for that specific version of the OS. Also easy to email one
a script and they run on their end. No need to install a compiler first,
figure how to compile it, link it, etc...

That is I think is the main advantage of scripts over compiled
languages. Ease of use.

--Nasser

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-24 19:45 Script-like jobs in Ada (ideas for HAC) gautier_niouzes
  2020-04-24 23:22 ` cantanima.perry
  2020-04-25  0:11 ` Nasser M. Abbasi
@ 2020-04-25 18:52 ` Stephen Leake
  2020-04-26  6:49 ` mockturtle
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Stephen Leake @ 2020-04-25 18:52 UTC (permalink / raw)


On Friday, April 24, 2020 at 12:45:34 PM UTC-7, gautier...@hotmail.com wrote:

> For instance you would perhaps avoid using Ada for a 30-lines program that browses files and collects some information in those files (just an example). 

On the contrary; I often do exactly that, because I know I can do anything I need to in Ada. In bash (and other scripting languages I've tried), first I have to consult the web oracle to see if what I want to do is possible. It's just faster to use Ada.

> Or a little math / stats program? Or a small game?

Ditto.

Unless the game involves interacting with images on a screen. I've only done that once, in Visual Basic. I tried to redo it in Ada (using a Windows binding I wrote), and it was very painful.

> But maybe the real reason (even if it is unconscious) you'd avoid Ada is because the compiler you are using is slow, or because it spits objects and executable files each time you change your small program. And you'd be more comfortable with a script that runs immediately without making garbage files.

I use Gnu make to run everything, no matter what language it is in, so "garbage files" are just transparent. I have a set of foo.make files that contain the rules for all the languages I use.

> A goal of the HAC compiler [1] is precisely to blur the border between a script and an Ada program: from the command line, you write "hax myprog.adb" and it just runs (that's already working). 

On my systems, that's what "make myprog.run" does; no big deal.

> Now I'd be curious of examples of scripts you'd consider writing in Ada with HAC, if it supplied the convenient functions and libraries. It's all work-in-progress currently, and ideas of applications are welcome at this point of the development.

None. I trust AdaCore to stay in business as long as I'm writing code, and I trust that any Ada code I write will work as long as I need it.

Reliability/longevity is the biggest problem with "scripting" languages, and with many "modern" platforms. That visual basic game broke with each release of Visual Basic, until I got tired of maintaining it. I have a small music playing app I wrote for Android; it breaks with each release of Android. I never did get the car dashboard controls working after they broke the first time.

-- Stephe

-- Stephe

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-25  0:11 ` Nasser M. Abbasi
@ 2020-04-25 19:00   ` Stephen Leake
  2020-04-25 23:35     ` Dennis Lee Bieber
  0 siblings, 1 reply; 22+ messages in thread
From: Stephen Leake @ 2020-04-25 19:00 UTC (permalink / raw)


On Friday, April 24, 2020 at 5:11:43 PM UTC-7, Nasser M. Abbasi wrote:
> Main advantage of scripts, and by this I really mean bash, sh, python, and may
> be perl, is that these come pre-installed on Linux. 

As you point out below, Linux /= all computers.

An Ada compiler is one of the first things I install on any computer I buy; not a big deal.

> Hence any script written will run as is, with no need to having to first
> "compile" it for that specific version of the OS. 

Ada is far more cross-platform than bash; Ada will compile and run on Windows, bash won't (I know, you can install Mingw2, and I do).

More to the point Ada will do _exactly_ the same thing, or complain that it can't; a scripting language is likely to guess what you might want it to do.

> Also easy to email one
> a script and they run on their end. No need to install a compiler first,
> figure how to compile it, link it, etc...

I always have Ada installed. I never have the latest Hot Scripting Language installed, and when someone emails me a script in that (or more likely, a url for a script), installing that and then trying to get the script to work is _very_ frustrating! (most recent example was some Python script that required a module; the standard install process for modules was broken).

> That is I think is the main advantage of scripts over compiled
> languages. Ease of use.

Bosh. I am far more productive in Ada than in any other language.

-- Stephe

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-25 19:00   ` Stephen Leake
@ 2020-04-25 23:35     ` Dennis Lee Bieber
  0 siblings, 0 replies; 22+ messages in thread
From: Dennis Lee Bieber @ 2020-04-25 23:35 UTC (permalink / raw)


On Sat, 25 Apr 2020 12:00:00 -0700 (PDT), Stephen Leake
<stephen_leake@stephe-leake.org> declaimed the following:

>
>Ada is far more cross-platform than bash; Ada will compile and run on Windows, bash won't (I know, you can install Mingw2, and I do).

	Win10 Linux subsystem...

wulfraed@ElusiveUnicorn:~$ uname -a
Linux ElusiveUnicorn 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01
16:53:00 PST 2019 x86_64 GNU/Linux
wulfraed@ElusiveUnicorn:~$ df
Filesystem      1K-blocks       Used  Available Use% Mounted on
rootfs         1952443816  620300416 1332143400  32% /
none           1952443816  620300416 1332143400  32% /dev
none           1952443816  620300416 1332143400  32% /run
none           1952443816  620300416 1332143400  32% /run/lock
none           1952443816  620300416 1332143400  32% /run/shm
none           1952443816  620300416 1332143400  32% /run/user
cgroup         1952443816  620300416 1332143400  32% /sys/fs/cgroup
C:\            1952443816  620300416 1332143400  32% /mnt/c
D:\            2930134012  952932004 1977202008  33% /mnt/d
E:\            3906983932  503736440 3403247492  13% /mnt/e
Z:\            5860519932 3011486212 2849033720  52% /mnt/z
wulfraed@ElusiveUnicorn:~$

	Granted -- console only, and anything one builds within it can only be
executed from within it... But one /could/ use BASH scripts to access the
file system contents...



-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-24 19:45 Script-like jobs in Ada (ideas for HAC) gautier_niouzes
                   ` (2 preceding siblings ...)
  2020-04-25 18:52 ` Stephen Leake
@ 2020-04-26  6:49 ` mockturtle
  2020-04-26  9:26 ` Jeffrey R. Carter
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: mockturtle @ 2020-04-26  6:49 UTC (permalink / raw)


On Friday, April 24, 2020 at 9:45:34 PM UTC+2, gautier...@hotmail.com wrote:
> It's a poll - sort of.
> 
> The question is: what kind of jobs do you prefer let a scripting language do and not Ada?
> 
>

The threshold is fuzzy, but usually I go with a script if 

* I need to interact heavily with the system (e.g., moving files, directories, ...)

* I can do everything with basic shell commands.  For example, if I need to do some math like matrix algebra I do not use a script (not entirely true...  Once I did this by calling octave from the script and piping into it the required computations...  I would not advise it, though...)

* It is something quite simple and/or I need it "fast and dirty" (e.g., to do something to lots of files, but a "something" that I will not need in the future) so that the maintenance advantage that Ada gives you has not much impact. 

Sometimes in the gray area of problems too complex for a bash script, but not enough to justify the investment of initial  effort required by Ada, I go with Ruby  that is, IMHO, a fair compromise.  

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-24 19:45 Script-like jobs in Ada (ideas for HAC) gautier_niouzes
                   ` (3 preceding siblings ...)
  2020-04-26  6:49 ` mockturtle
@ 2020-04-26  9:26 ` Jeffrey R. Carter
  2020-04-26 14:49 ` Simon Wright
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Jeffrey R. Carter @ 2020-04-26  9:26 UTC (permalink / raw)


On 4/24/20 9:45 PM, gautier_niouzes@hotmail.com wrote:
> 
> The question is: what kind of jobs do you prefer let a scripting language do and not Ada?

Most of my scripts are a single line, which invokes an Ada compiler to build the 
project in the directory that contains the script.

-- 
Jeff Carter
"I'm a kike, a yid, a heebie, a hook nose! I'm Kosher,
Mum! I'm a Red Sea pedestrian, and proud of it!"
Monty Python's Life of Brian
77

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-24 19:45 Script-like jobs in Ada (ideas for HAC) gautier_niouzes
                   ` (4 preceding siblings ...)
  2020-04-26  9:26 ` Jeffrey R. Carter
@ 2020-04-26 14:49 ` Simon Wright
  2020-04-27 18:50 ` Bojan Bozovic
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Simon Wright @ 2020-04-26 14:49 UTC (permalink / raw)


gautier_niouzes@hotmail.com writes:

> The question is: what kind of jobs do you prefer let a scripting
> language do and not Ada?

The problem was a membership database, which as inherited was an Excel
spreadsheet with one sheet per year, and many issues of consistency and
form.

My first thought was Ada, but I totally failed at the "simple" task of
reading/writing a CSV file; looking at SQLite interfacing, producing a
GUI, sending mail, and the thought that someone else might well inherit
it from me, I decided that Python was the best compromise.

~3000 lines (including blanks).

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-24 19:45 Script-like jobs in Ada (ideas for HAC) gautier_niouzes
                   ` (5 preceding siblings ...)
  2020-04-26 14:49 ` Simon Wright
@ 2020-04-27 18:50 ` Bojan Bozovic
  2020-04-27 19:01   ` Optikos
  2020-04-27 20:31   ` Dmitry A. Kazakov
  2020-04-28  8:51 ` Jerry
                   ` (4 subsequent siblings)
  11 siblings, 2 replies; 22+ messages in thread
From: Bojan Bozovic @ 2020-04-27 18:50 UTC (permalink / raw)


On Friday, April 24, 2020 at 9:45:34 PM UTC+2, gautier...@hotmail.com wrote:
> It's a poll - sort of.
> 
> The question is: what kind of jobs do you prefer let a scripting language do and not Ada?
> 
> My guess is that this kind of choice is related to toolsets, libraries and other aspects that are not necessarily related to languages.
> For instance you would perhaps avoid using Ada for a 30-lines program that browses files and collects some information in those files (just an example). Or a little math / stats program? Or a small game?
> But maybe the real reason (even if it is unconscious) you'd avoid Ada is because the compiler you are using is slow, or because it spits objects and executable files each time you change your small program. And you'd be more comfortable with a script that runs immediately without making garbage files.
> 
> A goal of the HAC compiler [1] is precisely to blur the border between a script and an Ada program: from the command line, you write "hax myprog.adb" and it just runs (that's already working). Now I'd be curious of examples of scripts you'd consider writing in Ada with HAC, if it supplied the convenient functions and libraries. It's all work-in-progress currently, and ideas of applications are welcome at this point of the development.
> 
> Thanks for any input!
> --
> [1] http://hacadacompiler.sf.net/  and  https://github.com/zertovitch/hac

Make it embeddable! That's the advantage of scripting language, code/modules in compiled language can do all the heavy lifting, while providing ease of use of a scripting language.
That's normal for web and it's the way PHP, Python and Perl work. That's also normal in game development, where game logic is often written in some scripting language.
Also for some uses it would be useful if it could run compiled pseudocode, in a manner NET does.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-27 18:50 ` Bojan Bozovic
@ 2020-04-27 19:01   ` Optikos
  2020-04-27 20:31   ` Dmitry A. Kazakov
  1 sibling, 0 replies; 22+ messages in thread
From: Optikos @ 2020-04-27 19:01 UTC (permalink / raw)


On Monday, April 27, 2020 at 1:50:48 PM UTC-5, Bojan Bozovic wrote:
> On Friday, April 24, 2020 at 9:45:34 PM UTC+2, gautier...@hotmail.com wrote:
> > It's a poll - sort of.
> > 
> > The question is: what kind of jobs do you prefer let a scripting language do and not Ada?
> > 
> > My guess is that this kind of choice is related to toolsets, libraries and other aspects that are not necessarily related to languages.
> > For instance you would perhaps avoid using Ada for a 30-lines program that browses files and collects some information in those files (just an example). Or a little math / stats program? Or a small game?
> > But maybe the real reason (even if it is unconscious) you'd avoid Ada is because the compiler you are using is slow, or because it spits objects and executable files each time you change your small program. And you'd be more comfortable with a script that runs immediately without making garbage files.
> > 
> > A goal of the HAC compiler [1] is precisely to blur the border between a script and an Ada program: from the command line, you write "hax myprog.adb" and it just runs (that's already working). Now I'd be curious of examples of scripts you'd consider writing in Ada with HAC, if it supplied the convenient functions and libraries. It's all work-in-progress currently, and ideas of applications are welcome at this point of the development.
> > 
> > Thanks for any input!
> > --
> > [1] http://hacadacompiler.sf.net/  and  https://github.com/zertovitch/hac
> 
> Make it embeddable! That's the advantage of scripting language, code/modules in compiled language
> can do all the heavy lifting, while providing ease of use of a scripting language.
> That's normal for web and it's the way PHP, Python and Perl work. That's also normal in game
> development, where game logic is often written in some scripting language.
> Also for some uses it would be useful if it could run compiled pseudocode, in a manner NET does.

HAC's MIT license is conducive to embeddability.  Conversely, GNAT would be embeddable (ignoring all technical impracticalities thereof) only in GPLv3-licensed derivative works.  So that would be a difference that makes a difference in mission for HAC (no matter where it ends up 20 years from now feature-wise/language-coverage-wise).

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-27 18:50 ` Bojan Bozovic
  2020-04-27 19:01   ` Optikos
@ 2020-04-27 20:31   ` Dmitry A. Kazakov
  1 sibling, 0 replies; 22+ messages in thread
From: Dmitry A. Kazakov @ 2020-04-27 20:31 UTC (permalink / raw)


On 2020-04-27 20:50, Bojan Bozovic wrote:

> Make it embeddable!

Yes, that is the key feature. On top of that:

1. Asynchronous aborting of the running script with data cleanup.

2. External loadable module/packages for it written in Ada

3. Means to maintain the process state between calls to the script. For 
Python it is resolved by returning an object from the script. The object 
is then passed as an argument by the next call. For an Ada script one 
could do it better, as a kind of "library package".

BTW, there is another project alike AdaScript:

    http://www.pegasoft.ca/docs/sparforte12/doc/ref_adascript.html

which also lacks the above. It is a shame that GPS uses Python for the 
purpose. I am using Python too, because presently nothing is better. I 
considered Lua and Julia, but neither were usable.

Having yet another shell, is not interesting. From my experience no 
regular task deserves writing it in a script. Each time I do this in 
bash etc, I get punished for. When I am lucky I rewrite that in Ada. I 
am too lazy to do this from the start always hoping it would end 
differently. When I am not so lucky I am stuck for years with 
maintaining the crap which periodically stops working.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-24 19:45 Script-like jobs in Ada (ideas for HAC) gautier_niouzes
                   ` (6 preceding siblings ...)
  2020-04-27 18:50 ` Bojan Bozovic
@ 2020-04-28  8:51 ` Jerry
  2020-04-29 15:47 ` joakimds
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Jerry @ 2020-04-28  8:51 UTC (permalink / raw)


HAC in Jupyter(Lab)? https://jupyter.org/

Jerry

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-24 19:45 Script-like jobs in Ada (ideas for HAC) gautier_niouzes
                   ` (7 preceding siblings ...)
  2020-04-28  8:51 ` Jerry
@ 2020-04-29 15:47 ` joakimds
  2020-04-29 19:54 ` darek
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: joakimds @ 2020-04-29 15:47 UTC (permalink / raw)


Den fredag 24 april 2020 kl. 21:45:34 UTC+2 skrev gautier...@hotmail.com:
> It's a poll - sort of.
> 
> The question is: what kind of jobs do you prefer let a scripting language do and not Ada?
> 
> My guess is that this kind of choice is related to toolsets, libraries and other aspects that are not necessarily related to languages.
> For instance you would perhaps avoid using Ada for a 30-lines program that browses files and collects some information in those files (just an example). Or a little math / stats program? Or a small game?
> But maybe the real reason (even if it is unconscious) you'd avoid Ada is because the compiler you are using is slow, or because it spits objects and executable files each time you change your small program. And you'd be more comfortable with a script that runs immediately without making garbage files.
> 
> A goal of the HAC compiler [1] is precisely to blur the border between a script and an Ada program: from the command line, you write "hax myprog.adb" and it just runs (that's already working). Now I'd be curious of examples of scripts you'd consider writing in Ada with HAC, if it supplied the convenient functions and libraries. It's all work-in-progress currently, and ideas of applications are welcome at this point of the development.
> 
> Thanks for any input!
> --
> [1] http://hacadacompiler.sf.net/  and  https://github.com/zertovitch/hac

Hi Gautier,

I currently use Ada for scripting and need to compile "the script" before being able to execute it. I would find being able to use HAC for scripting very useful. The only issue I can see with it is the "with HAC_Pack; use HAC_Pack;" that seems to be required to use HAC. I would like to keep the "Ada scripts" cross-compiler if possible.

Best regards,
Joakim

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-24 19:45 Script-like jobs in Ada (ideas for HAC) gautier_niouzes
                   ` (8 preceding siblings ...)
  2020-04-29 15:47 ` joakimds
@ 2020-04-29 19:54 ` darek
  2020-04-30  8:02 ` gautier_niouzes
  2020-05-02  5:36 ` Trescott Jensen
  11 siblings, 0 replies; 22+ messages in thread
From: darek @ 2020-04-29 19:54 UTC (permalink / raw)


For heavy operations on texts/strings, and other one-off jobs I use Open Euphoria (openeuphoria.org). I run the code on Windows, and Linux. If you need some extra performance, it compiles to C, and then to binaries. 

Judge for yourself. 

Darek


1. Sample code: https://openeuphoria.org/wiki/view.wc?page=SampleCode
2. Libraries: https://openeuphoria.org/docs/apiref.html#_781_apireference
3. GUI with the Gtk : https://openeuphoria.org/wiki/view/eugtk.wc







On Friday, 24 April 2020 21:45:34 UTC+2, gautier...@hotmail.com  wrote:
> It's a poll - sort of.
> 
> The question is: what kind of jobs do you prefer let a scripting language do and not Ada?
> 
> My guess is that this kind of choice is related to toolsets, libraries and other aspects that are not necessarily related to languages.
> For instance you would perhaps avoid using Ada for a 30-lines program that browses files and collects some information in those files (just an example). Or a little math / stats program? Or a small game?
> But maybe the real reason (even if it is unconscious) you'd avoid Ada is because the compiler you are using is slow, or because it spits objects and executable files each time you change your small program. And you'd be more comfortable with a script that runs immediately without making garbage files.
> 
> A goal of the HAC compiler [1] is precisely to blur the border between a script and an Ada program: from the command line, you write "hax myprog.adb" and it just runs (that's already working). Now I'd be curious of examples of scripts you'd consider writing in Ada with HAC, if it supplied the convenient functions and libraries. It's all work-in-progress currently, and ideas of applications are welcome at this point of the development.
> 
> Thanks for any input!
> --
> [1] http://hacadacompiler.sf.net/  and  https://github.com/zertovitch/hac

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-24 19:45 Script-like jobs in Ada (ideas for HAC) gautier_niouzes
                   ` (9 preceding siblings ...)
  2020-04-29 19:54 ` darek
@ 2020-04-30  8:02 ` gautier_niouzes
  2020-04-30  8:44   ` Dmitry A. Kazakov
  2020-05-02  5:36 ` Trescott Jensen
  11 siblings, 1 reply; 22+ messages in thread
From: gautier_niouzes @ 2020-04-30  8:02 UTC (permalink / raw)


Thank you all for your answers and brainstorming.
Here are a few points, so far, to summarize:

- Clear need for adding strings and files manipulation,
    access to databases, UI, ...

- Embeddable: inside a real Ada program? Yes, it is possible.
  Here I just simplify what you find in hax.adb:
  ...
    CD : Compiler_Data;
  begin
    Set_Source_Stream (CD, [Some stream access], [Possibly related file name]);
    Compile (CD);
    if CD.Err_Count = 0 then
      Interpret_on_Current_IO (CD);
    end if;
    ...
    
- Freezing and restoring the state of the VM, and its data: it is possible.
    I still need to wrap the "global" variables for the state of the VM
    interpreter into an object type, but it is doable : they are located
    in a subpackage that could be turned into a record type with not much
    more effort than hitting it with a magic wand ;-) .

- Jupyter: seems something to be considered!
- Euphoria: seems a very good source of inspiration<!

- The nasty need for "with HAC_Pack; use HAC_Pack;"
    Yes it is still required - until the point where support
    for packages will be implemented in HAC.
    However, it is already possible to cross-compile, since there
    is a "real" package (spec + body) in pure Ada in
      exm/special/hac_pack.ads,
      exm/special/hac_pack.adb.
    For instance, the HAC demos and tests can be built with GNAT
    through the exm/hac_exm.gpr and test/hac_test.gpt project files
    respectively.
    That's the big difference between HAC and a classical
    scripting language system: in the classical setup, the frontier
    is permanently set between the slow/interpreted/dynamic-typing part
    and the fast/compiled/static-typing part.
    Typically people need to reprogram parts or all of their scripts
    as C++ inserts in order to have a decent performance.
    With HAC you have the option to switch to your preferred compiler,
    with native code generation and optimization options.
    For a mix VM/native code, we could imagine options or pragmas that
    triage units to VM or native code compilation. Just thinking loud...

Finally, here is an example of use (just written "live" using the LEA
editor, during a homeschooling session):

with HAC_Pack;  use HAC_Pack;

procedure einmaleins is
  x, y : integer;
begin
  x := 1 + rand (9);
  y := 1 + rand (9);
  put(x);
  put(y);
  put(x*y);
end;

_________________________ 
Gautier's Ada programming 
http://gautiersblog.blogspot.com/search/label/Ada 
NB: follow the above link for a valid e-mail address 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-30  8:02 ` gautier_niouzes
@ 2020-04-30  8:44   ` Dmitry A. Kazakov
  2020-05-01  7:31     ` gautier_niouzes
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry A. Kazakov @ 2020-04-30  8:44 UTC (permalink / raw)


On 2020-04-30 10:02, gautier_niouzes@hotmail.com wrote:
> Thank you all for your answers and brainstorming.

1. Where are the modules? It should be possible to write a module for 
the script e.g. a package that has functions and procedures, which call 
to Ada implementations. I.e. calling Ada from the script.

2. What about exceptions handling, the ones propagating out of the 
script into the Ada caller?

3. Aborting the script. Ideally the Interpret_on_Current_IO  you 
mentioned must be abortable per some event set via protected object, for 
example. E.g. from another task provided Interpret_on_Current_IO runs on 
the caller's context. The interpreter will look for the event 
periodically and propagate exception Canceled_Error if the event is set.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-30  8:44   ` Dmitry A. Kazakov
@ 2020-05-01  7:31     ` gautier_niouzes
  2020-05-01  7:51       ` Dmitry A. Kazakov
  0 siblings, 1 reply; 22+ messages in thread
From: gautier_niouzes @ 2020-05-01  7:31 UTC (permalink / raw)


On Thursday, April 30, 2020 at 10:44:22 AM UTC+2, Dmitry A. Kazakov wrote:

> 1. Where are the modules? It should be possible to write a module for 
> the script e.g. a package that has functions and procedures, which call 
> to Ada implementations. I.e. calling Ada from the script.

On the to-do list :-)

> 2. What about exceptions handling, the ones propagating out of the 
> script into the Ada caller?

Same, but this is a lower-hanging fruit: the VM has error states that could be grouped into an exception_raised state, which would trigger the expected behaviour (with an exception identity and message). If the exception is not handled from the VM, the VM interpreter would raise Unhandled_HAC_Exception with a message.

> 3. Aborting the script. Ideally the Interpret_on_Current_IO  you 
> mentioned must be abortable per some event set via protected object, for 
> example. E.g. from another task provided Interpret_on_Current_IO runs on 
> the caller's context. The interpreter will look for the event 
> periodically and propagate exception Canceled_Error if the event is set.

I add this to the to-do list right now, thanks!

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-05-01  7:31     ` gautier_niouzes
@ 2020-05-01  7:51       ` Dmitry A. Kazakov
  2020-05-01 15:46         ` gautier_niouzes
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry A. Kazakov @ 2020-05-01  7:51 UTC (permalink / raw)


On 2020-05-01 09:31, gautier_niouzes@hotmail.com wrote:
> On Thursday, April 30, 2020 at 10:44:22 AM UTC+2, Dmitry A. Kazakov wrote:
> 
>> 1. Where are the modules? It should be possible to write a module for
>> the script e.g. a package that has functions and procedures, which call
>> to Ada implementations. I.e. calling Ada from the script.
> 
> On the to-do list :-)
> 
>> 2. What about exceptions handling, the ones propagating out of the
>> script into the Ada caller?
> 
> Same, but this is a lower-hanging fruit: the VM has error states that could be grouped into an exception_raised state, which would trigger the expected behaviour (with an exception identity and message). If the exception is not handled from the VM, the VM interpreter would raise Unhandled_HAC_Exception with a message.
> 
>> 3. Aborting the script. Ideally the Interpret_on_Current_IO  you
>> mentioned must be abortable per some event set via protected object, for
>> example. E.g. from another task provided Interpret_on_Current_IO runs on
>> the caller's context. The interpreter will look for the event
>> periodically and propagate exception Canceled_Error if the event is set.
> 
> I add this to the to-do list right now, thanks!

With these changes I would consider integrating it into here:

    http://www.dmitry-kazakov.de/ada/max_home_automation.htm#5

I presume you have an equivalent of Unbounded_String, records and arrays 
of. That should make it. Is

    https://sourceforge.net/projects/hacadacompiler/

the major source where you publish updates?

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-05-01  7:51       ` Dmitry A. Kazakov
@ 2020-05-01 15:46         ` gautier_niouzes
  2020-05-01 16:22           ` Dmitry A. Kazakov
  0 siblings, 1 reply; 22+ messages in thread
From: gautier_niouzes @ 2020-05-01 15:46 UTC (permalink / raw)


On Friday, May 1, 2020 at 9:51:30 AM UTC+2, Dmitry A. Kazakov wrote:

> With these changes I would consider integrating it into here:
> 
>     http://www.dmitry-kazakov.de/ada/max_home_automation.htm#5
> 
> I presume you have an equivalent of Unbounded_String, records and arrays 
> of. That should make it.

On top of the to-do list now :-). But I have an idea how to implement it...

> Is
> 
>     https://sourceforge.net/projects/hacadacompiler/
> 
> the major source where you publish updates?

Yep. With a mirror @

  https://github.com/zertovitch/hac

in case of allergies to SourceForge.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-05-01 15:46         ` gautier_niouzes
@ 2020-05-01 16:22           ` Dmitry A. Kazakov
  0 siblings, 0 replies; 22+ messages in thread
From: Dmitry A. Kazakov @ 2020-05-01 16:22 UTC (permalink / raw)


On 2020-05-01 17:46, gautier_niouzes@hotmail.com wrote:
> On Friday, May 1, 2020 at 9:51:30 AM UTC+2, Dmitry A. Kazakov wrote:

>> Is
>>
>>      https://sourceforge.net/projects/hacadacompiler/
>>
>> the major source where you publish updates?
> 
> Yep. With a mirror @
> 
>    https://github.com/zertovitch/hac
> 
> in case of allergies to SourceForge.

Thanks, SourceForge is quite comfortable, in comparison to github.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Script-like jobs in Ada (ideas for HAC)
  2020-04-24 19:45 Script-like jobs in Ada (ideas for HAC) gautier_niouzes
                   ` (10 preceding siblings ...)
  2020-04-30  8:02 ` gautier_niouzes
@ 2020-05-02  5:36 ` Trescott Jensen
  11 siblings, 0 replies; 22+ messages in thread
From: Trescott Jensen @ 2020-05-02  5:36 UTC (permalink / raw)


On Friday, April 24, 2020 at 1:45:34 PM UTC-6, gautier...@hotmail.com wrote:
> It's a poll - sort of.
> 
> The question is: what kind of jobs do you prefer let a scripting language do and not Ada?
> 
> My guess is that this kind of choice is related to toolsets, libraries and other aspects that are not necessarily related to languages.
> For instance you would perhaps avoid using Ada for a 30-lines program that browses files and collects some information in those files (just an example). Or a little math / stats program? Or a small game?
> But maybe the real reason (even if it is unconscious) you'd avoid Ada is because the compiler you are using is slow, or because it spits objects and executable files each time you change your small program. And you'd be more comfortable with a script that runs immediately without making garbage files.
> 
> A goal of the HAC compiler [1] is precisely to blur the border between a script and an Ada program: from the command line, you write "hax myprog.adb" and it just runs (that's already working). Now I'd be curious of examples of scripts you'd consider writing in Ada with HAC, if it supplied the convenient functions and libraries. It's all work-in-progress currently, and ideas of applications are welcome at this point of the development.
> 
> Thanks for any input!
> --
> [1] http://hacadacompiler.sf.net/  and  https://github.com/zertovitch/hac

In my mind, one of the short-comings of shell scripts is the lack of ability to call library functions. If I need to use a library API, I have to turn to a compiled language or at least a scripting language that has cross-language support.

I have dreamed of having an Ada shell where I could interactively issue commands as I am working out how to complete a task, then generate a script/compile the instructions for reuse.

I really like the focus Ada has on the correctness of the code. I think scripts tend to be brittle because there are a lot of assumptions builtin and they are written in a quick-n-dirty way. Which I think is fine for one-off use or proof-of-concept work. But I would love to have the ability to do the fast-n-loose work to get my head around a problem, then when I understand it, clean-up/reuse the work I've done without having to switch languages and start from scratch. (But sometime it is best to just through out the crap and start over.)

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2020-05-02  5:36 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24 19:45 Script-like jobs in Ada (ideas for HAC) gautier_niouzes
2020-04-24 23:22 ` cantanima.perry
2020-04-25  0:11 ` Nasser M. Abbasi
2020-04-25 19:00   ` Stephen Leake
2020-04-25 23:35     ` Dennis Lee Bieber
2020-04-25 18:52 ` Stephen Leake
2020-04-26  6:49 ` mockturtle
2020-04-26  9:26 ` Jeffrey R. Carter
2020-04-26 14:49 ` Simon Wright
2020-04-27 18:50 ` Bojan Bozovic
2020-04-27 19:01   ` Optikos
2020-04-27 20:31   ` Dmitry A. Kazakov
2020-04-28  8:51 ` Jerry
2020-04-29 15:47 ` joakimds
2020-04-29 19:54 ` darek
2020-04-30  8:02 ` gautier_niouzes
2020-04-30  8:44   ` Dmitry A. Kazakov
2020-05-01  7:31     ` gautier_niouzes
2020-05-01  7:51       ` Dmitry A. Kazakov
2020-05-01 15:46         ` gautier_niouzes
2020-05-01 16:22           ` Dmitry A. Kazakov
2020-05-02  5:36 ` Trescott Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox