# Similarity of Julia to Asymptote Programming Language

**URL:** https://discourse.julialang.org/t/similarity-of-julia-to-asymptote-programming-language/109801
**Category:** New to Julia
**Tags:** question
**Created:** [February 6, 2024, 1:27pm UTC](https://discourse.julialang.org/t/similarity-of-julia-to-asymptote-programming-language/109801 "2024-02-06T13:27:02Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![brombo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brombo/32/47867_2.png) [@brombo](https://discourse.julialang.org/u/brombo)
#### Post date: [February 6, 2024, 1:27pm UTC](https://discourse.julialang.org/t/similarity-of-julia-to-asymptote-programming-language/109801/1 "2024-02-06T13:27:02Z")

</div>

I am just getting started in Julia but am very familiar with the Asymptote graphics program scripting language -

[Asymptote](https://asymptote.sourceforge.io/)

It seems to me that the Asymptote language has many of Julia’s features and is similar (nowhere near as extensive). I wondered what the opinion is of those who are more familiar with Julia and Asymptote.

---

<div class="post-metadata">

### Author: ![mike.ingold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike.ingold/32/203749_2.png) [@mike.ingold](https://discourse.julialang.org/u/mike.ingold)
#### Post date: [February 6, 2024, 2:19pm UTC](https://discourse.julialang.org/t/similarity-of-julia-to-asymptote-programming-language/109801/2 "2024-02-06T14:19:35Z")

</div>

What features do you see in common? I’m not familar with Asymptote, but the syntax and code samples I’m seeing on their site remind me of LaTeX/TikZ more than anything else.

---

<div class="post-metadata">

### Author: ![brombo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brombo/32/47867_2.png) [@brombo](https://discourse.julialang.org/u/brombo)
#### Post date: [February 6, 2024, 2:41pm UTC](https://discourse.julialang.org/t/similarity-of-julia-to-asymptote-programming-language/109801/3 "2024-02-06T14:41:19Z")

</div>

Multiple dispatch and strong typing for example. Asymptote does not have classes just structures but I can emulate a class using their structures. Here is some of my Asymptote code that is more Julia like (mainly overloading operators) -

```julia
// Conveinence Functions for Real Functions

typedef real REALFCT(real x);

REALFCT operator|(REALFCT f,REALFCT g) // f(g(x))
{
return new real(real x) {return f(g(x));};
}

real[] operator|(REALFCT f,real[] x) // f(x[])
{
real[] f_of_x;

for (int i=0; i < x.length; ++i)
{
f_of_x.push(f(x[i]));
}

return f_of_x;
}

REALFCT operator*(REALFCT f,REALFCT g) // (f*g)(x) = f(x)*g(x)
{
return new real(real x) {return f(x)*g(x);};
}

REALFCT operator*(real a,REALFCT g) // (a*g)(x) = a*g(x)
{
return new real(real x) {return a*g(x);};
}

REALFCT operator*(REALFCT g,real a) // (g*a)(x) = a*g(x)
{
return new real(real x) {return a*g(x);};
}

REALFCT operator+(REALFCT f,REALFCT g) // (f+g)(x) = f(x)+g(x)
{
return new real(real x) {return f(x)+g(x);};
}

REALFCT operator+(real a,REALFCT g) // (a+g)(x) = a+g(x)
{
return new real(real x) {return a+g(x);};
}

REALFCT operator+(REALFCT f,real a) // (f+a)(x) = f(x)+a
{
return new real(real x) {return f(x)+a;};
}

REALFCT operator-(REALFCT f,REALFCT g) // (f-g)(x) = f(x)-g(x)
{
return new real(real x) {return f(x)-g(x);};
}

REALFCT operator-(real a,REALFCT g) // (a-g)(x) = a-g(x)
{
return new real(real x) {return a-g(x);};
}

REALFCT operator-(REALFCT f,real a) // (f-a)(x) = f(x)-a
{
return new real(real x) {return f(x)-a;};
}

REALFCT linmap(pair Int,pair Int1) // Linear map from interval Int to interval Int1
{
real dy = Int.y-Int.x;
real dy1 = Int1.y-Int1.x;
real a = dy/dy1;

return new real(real y1) { return a*(y1-Int1.x)+Int.x;};
}

real linterp(pair pt1,pair pt2,real x) // Linear interpolate between pt1 and pt2
{
real dx = pt2.x-pt1.x;
return pt2.y*((x-pt1.x)/dx)-pt1.y*((x-pt2.x)/dx);
}

struct PieceWiseFunction
{
real[] X;
REALFCT[] F;
int Nx1;
int Nf1;

void init(real[] x, REALFCT[] f)
{
X = x;
F = f;
Nx1 = x.length-1;
Nf1 = f.length-1;
}

real f(real x)
{
int ix = search(X,x);
if (ix==-1)
{
return F[0](x);
}
if (ix==Nx1)
{
return F[Nf1](x);
}
return F[ix+1](x);
}
}

```

---

<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: [February 6, 2024, 3:01pm UTC](https://discourse.julialang.org/t/similarity-of-julia-to-asymptote-programming-language/109801/4 "2024-02-06T15:01:49Z")

</div>

> [@brombo](#):
>
> Multiple dispatch and strong typing for example.

It looks like Asymptote is a statically typed language, not a dynamically typed language (ala Julia)? And it only supports something like C++'s static overloading, which is different from multiple dispatch (ala Julia). For example, according to [the Asymptote manual](https://asymptote.sourceforge.io/doc/Functions.html), you can’t add new methods (new signatures) to an existing function and affect other functions that were declared previously:

> However, if `f` is overloaded by a new function definition, previous calls will still access the original version of `f`

See [this talk](https://www.youtube.com/watch?v=kc9HwsxE1OY) on why dynamic multiple dispatch semantics (ala Julia) are distinct from static overloading (ala C++ function overloading).

So, it seems like a very different language. (Of course, you can still find commonalities.)

---

<div class="post-metadata">

### Author: ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)
#### Post date: [February 6, 2024, 4:59pm UTC](https://discourse.julialang.org/t/similarity-of-julia-to-asymptote-programming-language/109801/5 "2024-02-06T16:59:30Z")

</div>

You can still use a Julia version of Asymptote, AsyPlots.jl [GitHub - sswatson/AsyPlots.jl: A Julia package for making figures with Asymptote and Cairo](https://github.com/sswatson/AsyPlots.jl)
