4 ms·
Ada's refusal to make their language any more approachable is a problem.
by indolering 2y ago
Ada's refusal to make their language any more approachable is a problem.
- yjftsjthsd-h 2y agoWhat's unapproachable about it? And if your answer involves syntax, how do you explain Python?
- bluGill 2y agoMostly I have no clue how I would use it in my project without rewriting from scratch.
- yjftsjthsd-h 2y agoYou either write the main program in C and call Ada libaries, or you write the main program in Ada and call C libaries: https://learn.adacore.com/courses/intro-to-ada/chapters/interfacing_with_c.html https://learn.adacore.com/courses/intro-to-ada/chapters/inte... (And this seems pretty general; you'd have to do roughly the same thing to mix C/Rust, C/Pascal, Rust/Python, ...)
- bluGill 2y agoProblem is my main program is c++ complete with the stl that makes it useful. Vectors unique-ptr and all the other weird stuff that makes c++ better that c.
- skissane 2y agoI don’t think your problem has anything to do with Ada itself. You’d have the same issues using Rust or Go or Swift or Zig or whatever - if you make heavy use of C++’s features, it can make interop with other languages harder
- LiamPowell 2y agoIt's actually a little easier if you use GCC because you have interop at the class level: https://gcc.gnu.org/onlinedocs/gnat_ugn/Building-Mixed-Ada-and-C_002b_002b-Programs.html https://gcc.gnu.org/onlinedocs/gnat_ugn/Building-Mixed-Ada-a...
- bluGill 2y ago100% It seems like any language other than C has poor interoperability with anything other than C. C++ doesn't know how to deal with the rust borrow checker. Go will have issues with both. D is an exception - D supports C++ (I'm not sure how or how well, but they at least have some C++ ABI constructors). there are others (some languages running on the JVM usually work with java not C)
- touisteur 2y agoAll the while I've been calling C and C++ code (hard stuff but C++ interop is ... hard) from Ada for 15+ years and calling Ada code from C too. python from Ada and Ada from python too. Ada from Java through JNI. Writing postgres extensions in Ada. It's not always a panacea but it's possible.
- skissane 2y ago> It seems like any language other than C has poor interoperability with anything other than C Interop between C and classic 3rd generation languages such as Fortran, Pascal, Basic, COBOL, Algol, PL/I, tends to not be that hard [0] – because their feature set is at roughly the same level as C's: just functions/procedures without polymorphism or inheritance, relatively simple (non-OO) data types, etc. Whereas, C++/Go/Rust/Swift/Ada/etc all add lots of complex features on top, and it is when you use all those complex features, interop with C and classic 3GLs gets harder. Sometimes you can define a subset which omits many of those more complex features and makes interop easier, but then you lose out on the benefits those features bring [0] one complexity, is for historical reasons, sometimes these languages use different calling conventions than C – but on platforms on which that is an issue, it isn't uncommon for C compilers to support those additional calling conventions as an extension, and newer implementations of those languages for newer platforms are generally converging to C's calling conventions. Another is that some of these languages have data types for which C lacks native support – e.g. many COBOL implementations feature BCD arithmetic – but it is easy to write a routine in C to convert BCD to binary and back.
- tsimionescu 2y agoYou still do the same thing that you would when calling a C library: you serialize your STL objects into plain C objects, pass them to the external library, and deserialize back. If you need callbacks, you make sure that they catch any exception and return an error code. It's really no different from virtually any other C++ interop. There are a few languages that interop with C++ at a deeper level, essentially building a small part of a C++ compiler into their runtime. But they're relatively obscure - Clasp, an implementation of Common Lisp, is probably the only one that can really take an arbitrary C++ object (say, an std::vector<std::list<int>>) as an input to a Common Lisp function and work with it.
- MaxBarraclough 2y ago> There are a few languages that interop with C++ at a deeper level, essentially building a small part of a C++ compiler into their runtime The other approach is to compile to C++ source.
- bluGill 2y agonow interoperability costs performance for all the serialize/deserialize operations and so the language is too slow to be practical.
- sitzkrieg 2y agonot an ada issue
- MaxBarraclough 2y agoThe bookkeeping overheads might be trivial though. If it boils down to a handful of instructions per call, that's probably not so bad, depending on context. If large buffers are being copied, that's a problem, but hopefully that can generally be avoided.