From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=BAYES_00,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Ada versus Pascal Date: Fri, 22 Oct 2021 18:12:49 +0300 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net NasbOFm88RuCpsjBUme+oABdvBArXR03csN8HCK8whZ6158i0b Cancel-Lock: sha1:tJH4w5FZ+Cm0ujVBe/lmZTQfTLI= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:63054 List-Id: On 2021-10-22 12:59, 711 Spooky Mart wrote: > On 10/22/21 1:18 AM, ldries46 wrote: > > [...] > >> Ada is stricter >> than other languages and is meant to have NO Operating system dependant >> items, so if you cannot go around something there must be a package on >> each operating system having the same interface everywhere. > > By this do you mean the same syntax and libs will run on all target > systems without fiddling with {IFDEF} and architecture compiler switch > woo foo for USES and repetitive cross-arch boilerplate? I'm not ldries46, but here is an answer: Ada standardizes _some_ functions for which some other languages use "OS" services, principally threading, which in Ada is the "tasking" feature. Indeed Ada tasking works in the same way whichever OS is used, and also in the "bare board", no-OS situation. This is very useful for developing multi-threaded embedded SW, because the Ada tasking code can be tested on desk-top workstations and then executed on the target system unchanged. (and no "ifdefs"). But real operating systems (as opposed to simpler real-time kernels) provide many services that are not standardized in Ada, for example inter-process communication. > One thing I can't stand about Pascal is the totally different functions > and logic from several operating systems that MUST be re-written several > times in the same code base to do the same job. This drives me mad. In > fact it irks me so much I was thinking of writing some libraries for > things I do that would handle this all automatically across arches. > There would go a couple months of Sundays. > > Think IPC with Pascal. Get a good IPC routine going for Linux in your > app, then you have to re-write it for MAC and Windows, and even some > other flavors of *nix. Indeed. > So am I to understand that the Ada compiler has somehow eliminated this > problem, by ensuring every target OS has a syntactically conformant > package to execute its methods using the same statements? Sadly no. However, there are some rudiments: - There is a standardized Ada interface (binding) to POSIX services. This is implemented in an Ada library called Florist. If you find or make a Florist implementation for the OSes you use, your Ada program can use the same OS service interfaces on all those OSes. - The gcc-based Ada compiler GNAT comes with a GNAT-specific library that provides some OS services with the same Ada API on any OS that GNAT supports. This includes some IPC, but I don't know exactly how far that goes, and the library may of course change from one GNAT version to the next. - There is an Ada library called Win32Ada that provides an extensive set of Microsoft Windows services, but it is a "thin binding" meaning that even the API is Windows-specific. The Ada applications I have created and worked with have needed only a few OS services, basically some IPC: text in and out via pipes to and from a child process. We implemented our own binding to the required OS services (pipe and process creation and destruction). The interface consisted of a package declaration (.ads file) that was basically the same for all the supported OSes (Windows, Linux, Mac OS X) but had different OS-specific package body files (implementations, .adb files). In practice I think the Linux and Mac OS X implementations were the same and used direct binding to fork() and pipe() etc. The Windows implementation used Win32Ada.