Hidden code

I’m new to Julia and almost new to programming, so sorry if the question is stupid. Is Julia a programming language where the code is hidden from a user (like C) or not (like Python)? I found information that I can use USE_GPL_LIBS=0 to create proprietary software but I don’t know whether it means “hidden” code.

Typically, code generated by Julia is compiled from a source code file, so the source file would typically live somewhere on the user’s computer (which means it can be inspected and edited). However, there are also efforts underway to compile Julia code into a binary executable:

I am not aware of any efforts for code obfuscation of the binaries. Julia users generally prefer open source. However, I imagine it is technically possible to achieve this, even if it hasn’t been done yet.

3 Likes

Aside from some limited things(parser, some types I think), most of the core language is written in julia itself and not hidden. GPL thing is not for hiding codes but for licence of the codes that are ‘borrowed’ (called using their C interface API) from external libraries and they are still open sourced but not MIT licenced as Julia’s code.

Is this actually true? That the compiled version is a file somewhere on the system? I thought when I ran Julia code it compiled it and put it directly in memory.

Sort of. For packages, Julia caches a lowered version of the code (I don’t know the details but I know what it caches is neither machine code nor LLVM IR). Most of what’s compiled indeed gets put into memory and winds up getting thrown away. Ultimately the plan is to cache that as well, but it’s probably a while off.

1 Like

The compilation of the code is cached, but this cache is generated from source code that lives in a directory on your computer. You can find the cached code and the source files in the .julia directories. There is also an in memory cache that is not saved.

One can bake modules into the system image in which case its possible to deliver something without providing the source code.

Is it as easy and seamless as in languages like C? Does it have drawbacks? Can it be done with the package provided by chakravala? Do I understand right that Julia can potentially be an almost full substitute to C, C++, C#?

@rohqhq Your question is abut whether or not Julia is a compiled language. Others have given some good answers. So if I may would it be OK to say something else?
For learning, you might be interested that we can actually see what code Julia is creating by using the macros called @code_llvm and @code_native

@code_llvm prints the llvm compiler bitcodes which Julia generates, for example

julia> f(x)=x^2
f (generic function with 1 method)

julia> @code_llvm f(2)
; Function f
; Location: REPL[1]:1
; Function Attrs: uwtable
define i64 @julia_f_35333(i64) #0 {
top:
; Function literal_pow; {
; Location: intfuncs.jl:243
; Function *; {
; Location: int.jl:54
  %1 = mul i64 %0, %0
;}}
  ret i64 %1
}
2 Likes

@rohqhq the macro @code_native prints the assembly language statements which Julia produces for your architecture. So if you are into seeing what exactly is being emitted by the Julia compiler and is being run then you can.
This is actually done by many, many people who want to get the highest performance form a code.

julia> f(x)=x^2
f (generic function with 1 method)

julia> @code_native f(2)
        .text
; Function f {
; Location: REPL[1]:1
        pushq   %rbp
        movq    %rsp, %rbp
; Function literal_pow; {
; Location: intfuncs.jl:243
; Function *; {
; Location: int.jl:54
        imulq   %rcx, %rcx
;}}
        movq    %rcx, %rax
        popq    %rbp
        retq
        nopl    (%rax)
;}
2 Likes

No, it is work in progress, since (in constrast to C) it is an extra feature, not something one would use in a normal workflow.

Possibly yes, but if you need to deliver applications and want to protect intellectual property by not providing source code (whatever that is worth), Julia is not (yet) the ideal solution.

Since you said you just started programming, I wonder if this is relevant though. Personally, I would not worry about it and just learn Julia.

3 Likes

The questions asked by rohqhq are indeed those that I would ask when preparing a business where Julia is used. I would actually only do this as someone who has major experience with Julia. In principle I would say that everything can be achieved but especially baking things into the system image requires some manual tweaking here and there. Just as an instance https://github.com/JuliaLang/PackageCompiler.jl is currently not working at all on Julia 1.0 since one has to install manually all dependencies into the global environment.

1 Like

@rohqhq Please listen to @Tamas_Papp Learn Julia and have some fun. There is a great community here.

Also if you can, tell us why you are enquiring about not making the code available. I am not being hostile to you - I should explain that there have been discussions on this board on similar topics in the past.
We need contributions from people like you.

Sure. I read a little bit about Julia and (maybe I’m wrong but) from my point of view the language has the potential to become the universal language, i.e. we can use Julia instead of Python, C, R, etc. It’s clear for me that Julia can be a full substitute for Python, R, etc. but I don’t know whether it can be a full substitute for languages like C. It would be great if yes. To be a full substitute for languages like C, Julia has to have the feature to hide the code. It’s necessary for many software projects not only because of protection of intellectual property (it’s important too) but also because open code means high exposure to hackers (correct me, if no). Although I’m going to use Julia for econometrics now, in the future I’m going to write software, so I want to know whether it’s suitable for it.
UPD: Software isn’t a right word. I want to break into robotics. I’m not sure whether the word “software” is applicable to robotics. But I’m still interested whether Julia can be used in software because I didn’t find this domain in the domain section.

This is absolutely wrong. Security through obscurity - Wikipedia

6 Likes

@rohqhq I was going to reply to agree with @tobias.knopp
Have a look at Linus’Law: “Given enough eyeballs all bugs are shallow” Linus's law - Wikipedia

Indeed, think about closed source software. There could be bugs in a package which have been in existence for years. Or bugs recently introduced. From personal experience, I have had to look at Linux kernel code line by line on many occasions. I am not a kernel contributor, but the skill of beign able to understand kernel code has been good for me.
Specific instances include an Ethernet network card which worked fine under tests - but when connected to a Cisco switch stopped working (this was a bug related to forward error congestion packets).
It was even there in the code - a comment along the lines of “Watch it - this will stop working after a bit with a Cisco switch if FEC is enabled”.
Another instance was tracking down the behaviour of the OOM killer on a large SGI NUMA machine, which pulled the machine down. Being able to pinpoint what the OOM killer was doing was invaluable.
With a commercial Unix I would not have had any hope of doing anything like this.

Being constructive, we are seeing more and more software being developed with open source but commercial support available.
The software is open sourced, and perhaps released on a GitHub repository. There will be some good forums or email lists created. However should you need commercial support then a support contract can be purchased.
One example is the PBSPro batch system from Altair. Academic sites in the past would tent to implement the free of charge OpenPBS, which was a rather old fork of PBS. commercial sites would implement the paid-for PBSPro. Altair were very enlightened and realised that market share is important to them, and having open source developers and bug finders from both the academic and commercial worlds is important.
SO PBSPro is now dual licensed - you can download the source - as I have done. Or you can get a support contract, which means that if your companies $$$$ HPC system goes down you have someone to ring up.

4 Likes

The information about open source and exposure to hacking is interesting. Thank you for breaking down this misconception.
I still have several questions and I would be grateful if someone answers.

  1. Is Julia suitable for creating software now and potentially? I didn’t find this section in the domain section of this forum. And if it can be used for it, can Julia potentially compete with languages like C? Does it have drawbacks (that don’t relate with immaturity) that make it worse than languages like C in this domain?
  2. I’m still curious about closed code. Now I understand that one can potentially do it. But is the structure of code worse than in languages like C for it? I mean Julia may have some drawbacks that make creating closed code program less efficient than in languages like C, and it’s not because of immaturity, but because of the limits of the language.

Basically, my main question is can Julia be a full substitute for Python, C, etc. So these questions I ask to know the answer. If I miss some important issues related to this question, let me know. You’ve already answered some of my questions (thank you for that) but it’s still not clear for me what limits Julia has at this moment and what limits Julia has in the long-run period. I want to distinguish these limits in my mind.

Julia is a modern and performant language, and can replace Python and C in many, but not all contexts. Eg I would be surprised to see a Linux kernel written in Julia.

You are asking very abstract and mostly irrelevant questions about Julia, probably because you have not used it (enough) and may not have a lot of experience with programming (yet). This is common with people in a similar situation; users without much experience frequently believe that one can (and should) “evaluate” the language before investing in it.

I would suggest that your time may be better spent on just learning Julia, possibly by implementing a project you care about. Something related to scientific/numerical/statistical would be the best match for the language at this point.

2 Likes

This isn’t quite an answer to the question you asked but I think it may ultimately be the goal (IIUC) of your questions: I think Julia is one of a number of good options of a language to learn as someone new to programming. It does have some drawbacks for a new programmer — the tooling support is relatively immature, but that is changing quickly I think — but I believe the merits of the language outweigh those small disadvantages.

I doubt it is going to “take over” the other languages you mention, because language choice depends on not just the merits of the language, but the general inertia present in communities of people using those languages, and the overall ecosystem of support and packages available. If you want to have the most directly useful skills that will make it possible to get into a particular industry you should figure out what language that community already uses and learn that. But it is probably better to know multiple languages: learning programming languages becomes easier and easier the more you learn, and you will be most valuable to employers if you understand coding well enough to be facile in multiple languages. Learning a well principled language, which I think Julia is, is a good place to start.

2 Likes

Learning Julia will also spoil programming in less powerful languages (many of which are used widely) forever. It is like having a multitool which has a lightsaber as one of its tools.

4 Likes