<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 26 Jul 2022 at 17:35, Barry Smith <<a href="mailto:bsmith@petsc.dev">bsmith@petsc.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div><br></div>  Bindings for Fortran 20xx, Python 3, Julia? If the bindings are not, more or less, automatically generated, that would be problematic.<br><div><br></div></div></blockquote><div><br></div><div>So far, PETSc exposes a C API. Of course it is object oriented in spirit, but it is not object-oriented syntactically, and zero support function overload, not default arguments or multiple return values, etc. because it is rooted in C.</div><div><br></div><div>1) Then you want to automatically wrap Julia, which is also not object-oriented, but sort of method-oriented, featuring multiple dispatch.</div><div>2) And also Python, which is syntactically object oriented, but has no built-in/easy multiple dispatch or even function/method overload in argument number and types.</div><div><br></div><div>And then you realize you cannot automatically generate an idiomatic, nice looking, intuitive wrapper. You have to add "intellectual property" on top of the base C API. Exactly as I had to do with mpi4py, although I had the now long defunct C++ binding to provide inspiration.</div><div><br></div><div>IMHO, the only base language that is more or less amenable for automatic Python binding generation is C++. Look at Qt, or perhaps better, VTK/ParaView. They do a great job. Why? Because C++ is relatively easy to map to Python (as long as your C++ API does not go crazy with templates). We have pybind11, for example.</div><div><br></div><div>However, if the core of PETSc would become C++... would that still be the case that generating Julia wrappers is easy? Maybe yes, if the base PETSc C++ API constrains itself to follow a set or rules that would ease the map of `object.method(args, ...)` to `method(object, args, ...)` and things like that, but I'm not a Julia expert.</div><div><br></div><div>PS: Please don't take my words as advocacy for C++ (although it may be the second worst choice after C). I'm just pointing out that mapping C -> Python is not so easy to automate, unless you are OK with coding Python with a wrapper that is C-like and thus very unpythonic. </div><div><br></div><div><br></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Lisandro Dalcin<br>============<br>Senior Research Scientist<br>Extreme Computing Research Center (ECRC)<br>King Abdullah University of Science and Technology (KAUST)<br><a href="http://ecrc.kaust.edu.sa/" target="_blank">http://ecrc.kaust.edu.sa/</a><br></div></div></div></div>