Compile Julia using the BaCon compiler (embedding)
Apr 11, 2023 16:24:14 GMT 1
Post by bigbass on Apr 11, 2023 16:24:14 GMT 1
Hello Guys
You may wonder what the ... is this all about?
one list of the fastest languages listed
(I am going to keep all my opinions out of this ok )
www.geeksforgeeks.org/top-10-fastest-programming-languages/
if you agree or disagree that is not the point the point is "for me"
can we use those languages with Bacon or not and if so add them to the list
so we have more options and possibilities
so is it even possible you don't know until you try
so here we go with a new adventure
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
if on a debian based OS there is a package but it is very old in apt-get
Almost everyone should be downloading and using the latest stable release of Julia.
julialang.org/downloads/
ADVANCED USE
In my case using Manjaro Raspberry pi3 64 bit OS
julialang-s3.julialang.org/bin/linux/aarch64/1.8/julia-1.8.5-linux-aarch64.tar.gz
there was no official package but no problem
you can run it from a folder for testing however
If you want to embed code and compile it with BaCon
manually installing it to your system permits the BaCon compiler
to find and link the libs and headers and friends
using PRAGMA
Note: I did get the c code example to work from a folder
but I just couldn't get it to compile in bacon from the folder
maybe at some other time I will figure out why ?
anyway I prefer to install it to my system to keep it easy and standard
docs.julialang.org/en/v1/manual/embedding/
------------------------------------------------------------------------------------
The first example is NOT embedded it is an easy scripted demo
using a benchmark to concat a string
geany 1.38 has syntax highlighting built in for Julia
it is called julia4.jl
-------------------------------------------------------------------------------
Now for Embedding Julia in BaCon
Read all the Details with the above links I will jump directly to a working example
in BaCon with less extra talk and get to the point quickly
You may wonder what the ... is this all about?
one list of the fastest languages listed
(I am going to keep all my opinions out of this ok )
www.geeksforgeeks.org/top-10-fastest-programming-languages/
if you agree or disagree that is not the point the point is "for me"
can we use those languages with Bacon or not and if so add them to the list
so we have more options and possibilities
so is it even possible you don't know until you try
so here we go with a new adventure
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
if on a debian based OS there is a package but it is very old in apt-get
Almost everyone should be downloading and using the latest stable release of Julia.
julialang.org/downloads/
ADVANCED USE
In my case using Manjaro Raspberry pi3 64 bit OS
julialang-s3.julialang.org/bin/linux/aarch64/1.8/julia-1.8.5-linux-aarch64.tar.gz
there was no official package but no problem
you can run it from a folder for testing however
If you want to embed code and compile it with BaCon
manually installing it to your system permits the BaCon compiler
to find and link the libs and headers and friends
using PRAGMA
Note: I did get the c code example to work from a folder
but I just couldn't get it to compile in bacon from the folder
maybe at some other time I will figure out why ?
anyway I prefer to install it to my system to keep it easy and standard
docs.julialang.org/en/v1/manual/embedding/
------------------------------------------------------------------------------------
The first example is NOT embedded it is an easy scripted demo
using a benchmark to concat a string
geany 1.38 has syntax highlighting built in for Julia
it is called julia4.jl
#!/usr/bin/julia
a = "Hello"
for index1 in 1:10000
global a = a * "benchmark"
end
println("length a:", length(a))
b = "Hello"
for index2 in 1:10000
global b = "benchmark" * b
end
println("length b:", length(b))
-------------------------------------------------------------------------------
./julia4.jl
Now for Embedding Julia in BaCon
Read all the Details with the above links I will jump directly to a working example
in BaCon with less extra talk and get to the point quickly
bacon julia_embedded.bac
'---ported Julia code and embedded it in BaCon bigbass April 11 2023
'gcc -o test -fPIC -I$JULIA_DIR/include/julia -L$JULIA_DIR/lib -Wl,-rpath,$JULIA_DIR/lib test.c -ljulia
PRAGMA INCLUDE <julia.h>
PRAGMA COMPILER gcc
PRAGMA OPTIONS -I/usr/include/julia
PRAGMA OPTIONS -I/usr/lib/julia/
PRAGMA OPTIONS -fPIC
PRAGMA LDFLAGS -ljulia
OPTION PARSE FALSE
'--- required: setup the Julia context
jl_init()
'--- run Julia commands
jl_eval_string("print(sqrt(2.0))")
'--- strongly recommended: notify Julia that the
'--- program is about to terminate. this allows
'--- Julia time to cleanup pending write requests
'--- and run all finalizers
PRINT
PRINT "lets mix some BaCon code in here !"
jl_atexit_hook(0)