# Interesting NASA "Language-Comparison" repository

**URL:** <https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356>\
**Category:** Teaching & Outreach\
**Tags:** examples\
**Created:** [November 21, 2019, 9:02pm UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356 "2019-11-21T21:02:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![GregVernon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregvernon/32/5611_2.png) [@GregVernon](https://discourse.julialang.org/u/GregVernon)\
**Post date:** [November 21, 2019, 9:02pm UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/1 "2019-11-21T21:02:04Z")

</div>

I came across [this GitHub repository](https://github.com/JulesKouatchou/basic_language_comparison) the other day, discovered it within the troves of NASA’s [software catalog](https://software.nasa.gov/) – the [repository’s entry on the catalog is here](https://software.nasa.gov/software/GSC-18111-1). I thought this might be useful for Julia novices.

> **Basic Comparison of Various Computing Languages**  
> _Python, Julia, Matlab, IDL, R, Java, Scala, C, Fortran_  
> We write codes to test the performance of the several computer languages. The codes solve simple tasks to test how the different languages handle loops, vectorization, multiprocessing, array manipulation, reading collections of files, etc. The goal is not to determine which language is better than the other but instead to highlight the strengths and weaknesses of each language. We also want stress the importance of having languages that can inter-operate with others to solve complex applications. The results (updated at least once a year) from this study are presented (including source codes) through a NASA website accessible to practitioners who need such information to determine which language is appropriate to accomplish a specific task.

---

<div class="post-metadata">

**Author:** ![gasagna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gasagna/32/1275_2.png) [@gasagna](https://discourse.julialang.org/u/gasagna)\
**Post date:** [November 21, 2019, 10:35pm UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/2 "2019-11-21T22:35:32Z")

</div>

I just cloned the repo and tried to further optimise the `laplace_jacobi` benchmark. Much of the speed of C in this benchmark comes from the optimisation flag `-Ofast`. In fact, executing the julia script with `julia -O3 --math-mode=fast` give pretty much the same times, if not slightly better.

---

<div class="post-metadata">

**Author:** ![GregVernon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregvernon/32/5611_2.png) [@GregVernon](https://discourse.julialang.org/u/GregVernon)\
**Post date:** [November 21, 2019, 11:18pm UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/3 "2019-11-21T23:18:08Z")

</div>

You might consider making an issue on their repository to bring this to their attention.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [November 21, 2019, 11:48pm UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/4 "2019-11-21T23:48:54Z")

</div>

There is no license file (that I can find).

Is it automatically in the public domain since it’s the work of US government employees?

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [November 21, 2019, 11:51pm UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/5 "2019-11-21T23:51:50Z")

</div>

[https://github.com/JulesKouatchou/basic\_language\_comparison/blob/3c84d449bf3238518f838296459236d46544ddb5/COPYRIGHT](https://github.com/JulesKouatchou/basic_language_comparison/blob/3c84d449bf3238518f838296459236d46544ddb5/COPYRIGHT)

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [November 22, 2019, 12:03am UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/6 "2019-11-22T00:03:21Z")

</div>

That’s not a software license though.

---

<div class="post-metadata">

**Author:** ![GregVernon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregvernon/32/5611_2.png) [@GregVernon](https://discourse.julialang.org/u/GregVernon)\
**Post date:** [November 22, 2019, 12:15am UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/7 "2019-11-22T00:15:39Z")

</div>

On the catalog entry there’s this:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/4/549c4a46cfd44bd7314405220f3fda279c77ad47.png)

---

<div class="post-metadata">

**Author:** ![GregVernon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregvernon/32/5611_2.png) [@GregVernon](https://discourse.julialang.org/u/GregVernon)\
**Post date:** [November 22, 2019, 12:18am UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/8 "2019-11-22T00:18:44Z")

</div>

Just because US government employees do work doesn’t automatically put something in the public domain - e.g. the designs of nuclear weapons, launch-codes, spy-planes, and encryption software are not public domain!

---

<div class="post-metadata">

**Author:** ![gasagna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gasagna/32/1275_2.png) [@gasagna](https://discourse.julialang.org/u/gasagna)\
**Post date:** [November 22, 2019, 12:48am UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/9 "2019-11-22T00:48:17Z")

</div>

I am benchmarking with more care the `laplace_jacobi` test, but the julia code is a bit slower than the C version. This is the MWE

```julia
using BenchmarkTools

const lib = tempname()
source = """
double _csolve(int N, double *u[]) {
    double tmp, diff;
    int i, j, r;
    double err;
    err = 0.0;
    for (r = 1; r != 1000; r++) {
        for (i = 1; i < N-1; i++) {
            for (j = 1; j < N-1; j++) {
                tmp = u[i][j];
                u[i][j] = ( 4.0*(u[i-1][j] + u[i+1][j] +
                                 u[i][j-1] + u[i][j+1]) +
                                 u[i-1][j-1] + u[i+1][j+1] +
                                 u[i+1][j-1] + u[i-1][j+1])/20.0;
                diff = u[i][j] - tmp;
                err += diff*diff;
            }
        }
    }
    return err;
}

"""
open(`gcc -fPIC -Ofast -march=native -xc -shared -o $(lib).dylib -`, "w") do pipe
    print(pipe, source)
end

function csolve(u::Vector{Vector{Float64}})
    ccall(("_csolve", lib), Float64, (Cint, Ptr{Ptr{Float64}}), length(u), u)
end

function solve(u::Matrix)
    n, m = size(u)
    error = zero(eltype(u))
    @inbounds begin
        for r = 1:1000
            for i in 2:n-1
                @simd for j in 2:m-1
                    temp = u[i, j]
                    u[i, j] = ( 4.0*(u[i-1, j] + u[i+1, j] +
                                     u[i, j-1] + u[i, j+1]) +
                                     u[i-1, j-1] + u[i+1, j+1] +
                                     u[i+1, j-1] + u[i-1, j+1])/20.0
                    diff = u[i, j] - temp
                    error += diff*diff
                end
            end
        end
    end
    return error
end

N = 100
 u = rand(N, N)
cu = [rand(N) for i = 1:N]
@btime solve($u)
@btime csolve($cu)

```

Running this with

```julia
julia --math-mode=fast --check-bounds=no -O3 test_laplace_jacobi_4.jl

```

gives

```julia
  72.297 ms (0 allocations: 0 bytes)
  56.904 ms (3 allocations: 1.78 KiB)

```

Any idea how to get to C speed?

---

<div class="post-metadata">

**Author:** ![GregVernon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregvernon/32/5611_2.png) [@GregVernon](https://discourse.julialang.org/u/GregVernon)\
**Post date:** [November 22, 2019, 12:50am UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/10 "2019-11-22T00:50:31Z")

</div>

I will say this, the README states:

> We implement the test cases from an angle of a novice programmer who is not familiar with the optimization techniques available in the languages.

I think it would be good to develop optimized versions of these routines, but perhaps as a forked project.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [November 22, 2019, 1:16am UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/11 "2019-11-22T01:16:23Z")

</div>

> **[Copyright status of works by the federal government of the United States](https://en.wikipedia.org/wiki/Copyright_status_of_works_by_the_federal_government_of_the_United_States)**
>
> A work of the United States government is defined by the United States copyright law, as "a work prepared by an officer or employee of the United States Government as part of that person's official duties". Under section 105 of the Copyright Act of 1976, such works are not entitled to domestic copyright protection under U.S. law and are therefore in the public domain.
> This act only applies to U.S. domestic copyright as that is the extent of U.S. federal law. The U.S. government asserts that ...

> [@GregVernon](#):
>
> the designs of nuclear weapons, launch-codes, spy-planes, and encryption software are not public domain!

Those are probably classified

---

<div class="post-metadata">

**Author:** ![GregVernon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregvernon/32/5611_2.png) [@GregVernon](https://discourse.julialang.org/u/GregVernon)\
**Post date:** [November 22, 2019, 1:26am UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/12 "2019-11-22T01:26:42Z")

</div>

> Those are probably classified

They most certainly are, which supports my point. Works by US government employees _are not necessarily_ public domain. From the Wikipedia page:

> **Publication of an otherwise protected work** by the U.S. government **does not put that work in the public domain**. For example, government publications may include works copyrighted by a contractor or grantee; copyrighted material assigned to the U.S. Government; or copyrighted information from other sources.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [November 22, 2019, 3:40am UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/13 "2019-11-22T03:40:33Z")

</div>

Just guessing: what happens if you swap the loops over i and j? Does simd do much here?

---

<div class="post-metadata">

**Author:** ![anon56330260](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@anon56330260](https://discourse.julialang.org/u/anon56330260)\
**Post date:** [November 22, 2019, 6:08am UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/14 "2019-11-22T06:08:32Z")

</div>

This is a stencil operation, so exchange i,j won’t help.(You still need to access its 8-neighborhood)

---

<div class="post-metadata">

**Author:** ![helgee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/helgee/32/2022_2.png) [@helgee](https://discourse.julialang.org/u/helgee)\
**Post date:** [November 22, 2019, 6:39am UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/15 "2019-11-22T06:39:18Z")

</div>

BTW, I did a similar comparison (not as comprehensive) for ESA a few years ago.

Here is the repo:

> **[GitHub - OpenAstrodynamics/benchmarks: Supplementary materials for "A...](https://github.com/OpenAstrodynamics/benchmarks)**
>
> Supplementary materials for "A Comparative Study Of Programming Languages for Next-Generations Astrodynamics Systems" - GitHub - OpenAstrodynamics/benchmarks: Supplementary materials for ...

And the paper I wrote about it:

> **[A comparative study of programming languages for next-generation...](https://link.springer.com/article/10.1007/s12567-017-0170-8)**
>
> Due to the computationally intensive nature of astrodynamics tasks, astrodynamicists have relied on compiled programming languages such as Fortran for the development of astrodynamics software. Interpreted languages such as Python, on the other hand,...

---

<div class="post-metadata">

**Author:** ![gasagna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gasagna/32/1275_2.png) [@gasagna](https://discourse.julialang.org/u/gasagna)\
**Post date:** [November 22, 2019, 10:08am UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/16 "2019-11-22T10:08:30Z")

</div>

I did that. What’s shown is the fastest ordering of looping on my machine.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [November 22, 2019, 1:39pm UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/18 "2019-11-22T13:39:27Z")

</div>

> [@dpsanders](#):
>
> Is it automatically in the public domain since it’s the work of US government employees?

If you publish to github, people are automatically allowed to fork it, even without a license, I believe, as part of minimum terms of service.

> However, without a license, the default copyright laws apply, meaning that you retain all rights to your source code and no one may reproduce, distribute, or create derivative works from your work.

> **Note:** If you publish your source code in a public repository on GitHub, according to the [Terms of Service](https://help.github.com/en/articles/github-terms-of-service), other GitHub users have the right to view and fork your repository within the GitHub site. If you have already created a public repository and no longer want users to have access to it, you can make your repository private. When you convert a public repository to a private repository, existing forks or local copies created by other users will still exist. For more information, see “[Making a public repository private](https://help.github.com/en/articles/making-a-public-repository-private).”

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [November 22, 2019, 2:31pm UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/19 "2019-11-22T14:31:56Z")

</div>

Those are protected by plain old secrecy—as in not telling people things you don’t want them to know—not copyright. If a government employee creates a work and posts it on the internet, then it is neither secret nor protected by copyright, therefore public domain.

---

<div class="post-metadata">

**Author:** ![alejandromerchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alejandromerchan/32/10500_2.png) [@alejandromerchan](https://discourse.julialang.org/u/alejandromerchan)\
**Post date:** [November 22, 2019, 8:30pm UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/20 "2019-11-22T20:30:03Z")

</div>

As a US government employee a few months ago, we were encouraged to put our work in the public domain as much as possible. Obviously we have secret and proprietary stuff that can’t be shared, but if we put for public consumption, it’s in the public domain.

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [November 23, 2019, 3:35am UTC](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356/21 "2019-11-23T03:35:10Z")

</div>

hmmm, I may be wrong but in America things are not protected by copyright unless they are explicitly stated not to be protected?

> **[What Automatic Copyright Laws Do and Do Not Protect](https://www.liveabout.com/what-is-automatic-copyright-protection-3514945)**
>
> Learn about automatic copyright protection, in which, under U.S. copyright law, a work is automatically protected by copyright when it is created.

[Next page](https://discourse.julialang.org/t/interesting-nasa-language-comparison-repository/31356.md?page=2)
