3 ms·
I like how Ada and Modula-2 have a separation between the definition of interfaces and their implementation: you can compile the interface spec and code against
by jll29 5y ago
I like how Ada and Modula-2 have a separation between the definition of interfaces and their implementation: you can compile the interface spec and code against it before the interface has a single implementation, which makes collaboration in a team easier.
I have not tried out Ada's multi-tasking capability, but it has a simple TASK syntax:
http://www.sigada.org/conf/sigada2005/SIGAda2005-CDROM/SIGAda2005-Tutorials/MA2_BingueCook_RT-Parallel-Programming-Ada95.pdf http://www.sigada.org/conf/sigada2005/SIGAda2005-CDROM/SIGAd...
This should make writing control code for new hardware easier, which is of course one of the core use cases.
When I wrote Pascal code as a kid and tried to learn C, I noticed how in Pascal you could concentrate on the problem, whereas in C you would constantly have to think about memory management and other distracting features (alas, this was before C89 improved a lot of things, notably type support so the compiler could help protect you from yourself).
- pjmlp 5y agoThat is why I never liked C and never changed my mind regarding it being a step back (several actually). Having done Turbo Pascal (3.0 - 6.0), before delving into C, was a eye opener for what a systems programming language should be able to offer as minimal set of abilities. Even the fact that C lacks something like New() is ridiculous, how many devs keep getting their array allocations wrong to malloc()? C++ allowed me to have a bit of that Ada/Turbo Pascal feeling back.
- gwbas1c 5y ago> I like how Ada and Modula-2 have a separation between the definition of interfaces and their implementation: you can compile the interface spec and code against it before the interface has a single implementation, which makes collaboration in a team easier. Java, C#, and Rust all have interfaces. (Although Rust might call them something different. I had a lot of trouble learning Rust.) Even in C you can typedef a function pointer. (Although I haven't done anything like that in ~20ish years.)
- pyjarrett 5y agoThe isn't talking about that sort of "interface" (which Ada also has). This refers to a difference in logical and physical program structure in which specifications are separate from bodies--formalized version of the header/source separation in C/C++. In addition to logical separation, this provides speed ups in recompilation times.
- Jtsummers 5y agoSo it's somewhat inaccurate that GP calls it an "interface", it's a specification. Ada packages have two parts: specification and implementation. The specification isn't really comparable to Java or C# interfaces and I don't think they're comparable to Rust traits either. Nor is it like typedef'ing a function pointer. The better analog is C's header files containing declarations, but not definitions, which are then implemented in various C files. A major contrast with C is that Ada's packages are named scopes and occur in pairs of spec/body, whereas in C you could have one header that is implemented over many C files, or one C files that implements many headers. And like C header files, the range of things you can declare in a package spec is essentially any valid thing in the language: types, variables, functions, procedures, more packages, tasks, etc. But C permits the definition and declaration of anything to be in the header file, there are restrictions on Ada package specifications in that regard (some things have to go in a package body). C header `#include` order also matters (since they're text inclusion, a conflict in definitions or the use of macros can impact the outcome), whereas the `with`ing of Ada packages can be done in any order.
- pyjarrett 5y agoA good description, and this is described in the video that all of these comments are about. :P
- pjmlp 5y agoInterfaces as generic CS term, not OOP languages features.