# C project utility scripts in Julia

**URL:** <https://discourse.julialang.org/t/c-project-utility-scripts-in-julia/75454>\
**Category:** General Usage\
**Tags:** ccall\
**Created:** [January 30, 2022, 7:40am UTC](https://discourse.julialang.org/t/c-project-utility-scripts-in-julia/75454 "2022-01-30T07:40:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gravlax](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Post date:** [January 30, 2022, 7:40am UTC](https://discourse.julialang.org/t/c-project-utility-scripts-in-julia/75454/1 "2022-01-30T07:40:55Z")

</div>

Dear all,

I was wondering if anyone has experience with the development of utility tools for a main code written in another language (e.g. C). Several activities around such code would require some kind of scripting (configuring, making, testing, input file generation and modification, output file analysis and visualisation…) which can be addressed with usual tools/languages (bash/make/cmake, perl, python, matlab).  
Would anyone have some hints, dedicated packages, or examples of how such activities could be handled in Julia?

Cheers and thanks!

---

<div class="post-metadata">

**Author:** ![lawless-m](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lawless-m/32/30869_2.png) [@lawless-m](https://discourse.julialang.org/u/lawless-m)\
**Post date:** [January 30, 2022, 8:48am UTC](https://discourse.julialang.org/t/c-project-utility-scripts-in-julia/75454/2 "2022-01-30T08:48:14Z")

</div>

Your question is a bit vague 🙂

But it’s quite simple to call other languages from Julia, through binary shared objects

ccall & PyCall for instance

[https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/](https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/)

I have some examples

C: [https://github.com/lawless-m/Czoo.jl](https://github.com/lawless-m/Czoo.jl)

Python: [https://github.com/lawless-m/XlsxWriter.jl/blob/master/src/XlsxWriter.jl](https://github.com/lawless-m/XlsxWriter.jl/blob/master/src/XlsxWriter.jl)

---

<div class="post-metadata">

**Author:** ![Gravlax](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Post date:** [January 30, 2022, 6:07pm UTC](https://discourse.julialang.org/t/c-project-utility-scripts-in-julia/75454/3 "2022-01-30T18:07:31Z")

</div>

thanks for the examples. Yes, my question was indeed not clear 😃  
Together with some colleagues we are preparing a suite of tests for a C code. This involves automatically compiling the code and running different families of tests (compiling, going through valgrind, omp parallel scaling, running various tests with different input options and checking the results stored in the hdf5 outputs, create a pdf report with figures).  
So far, I only have experience with computing using Julia and not much with I/O, scripting, interfacing. So I just wonder whether it would better to do these operations with Julia scripts rather than, say, python scripts.

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [January 30, 2022, 6:15pm UTC](https://discourse.julialang.org/t/c-project-utility-scripts-in-julia/75454/4 "2022-01-30T18:15:36Z")

</div>

As a language julia is super nice for scripting. Julia has super intuitive and powerful tools for scripting in the Base library. In practice I often use python however:

- python is preinstalled on most linux machines
- other programmers are often more familiar with python than julia
- julia has slower startup time than python

---

<div class="post-metadata">

**Author:** ![lawless-m](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lawless-m/32/30869_2.png) [@lawless-m](https://discourse.julialang.org/u/lawless-m)\
**Post date:** [January 30, 2022, 6:21pm UTC](https://discourse.julialang.org/t/c-project-utility-scripts-in-julia/75454/5 "2022-01-30T18:21:28Z")

</div>

There is no reason why you couldn’t use Julia.  
In my Czoo runtests.jl I make sure the C code is up to date with the simple

```julia
cd("../src"); read(`make`); cd("..")

```

obviously that does no error checking but that’s only me being lazy

You can control stdin, stdout and stderr of such things.

I’m biased in the “better” part. But I can imagine running the tests in parallel, either via Threads or even on different machines using Distributed.

It would make a good project for learning Julia without taking too much time away from your actual goal of improving the C.

And you can always call Python from Julia if you feel like it and use both!

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 30, 2022, 9:15pm UTC](https://discourse.julialang.org/t/c-project-utility-scripts-in-julia/75454/6 "2022-01-30T21:15:58Z")

</div>

> [@Gravlax](#):
>
> Together with some colleagues we are preparing a suite of tests for a C code. This involves automatically compiling the code and running different families of tests (compiling, going through valgrind, omp parallel scaling, running various tests with different input options and checking the results stored in the hdf5 outputs, create a pdf report with figures).

It’s far more flexible to test (and use) the code if you compile your C code as a library, not as a standalone program. Then you can test and call individual _functions_ interactively, and communications is _way_ easier than doing I/O through files and command-line options.

---

<div class="post-metadata">

**Author:** ![Gravlax](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Post date:** [January 31, 2022, 7:39am UTC](https://discourse.julialang.org/t/c-project-utility-scripts-in-julia/75454/7 "2022-01-31T07:39:17Z")

</div>

Indeed that’s likely the best option (especially for unit testing). I was just refrained to do it as I thought making a library would render debugging symbols unusable. But yes, in the end that’s likely what we’ll end up doing.  
I was wondering whether there would be a more “2020 way” of doing such things but in the end we use a C code so we may better stick to classical tooling (a lighter Julia version of the code has been initiated it but it’s far from being ready).
