Program structure

Hello everyone
i am new to Julia language i need help regarding program structure of Julia language. (What is the program structure of Julia language?)

please be less vague…

1 Like

Welcome, first of all!

To me it is not very clear what you would like to know. The “program structure” can mean a lot of things, could you explain what you want to know or what you are trying to do? If it’s easier, maybe an example from a different language so we can understand what you are aiming for.

1 Like

I’m gonna get philosophical here. a program is, by the cambridge dictionary:

A series of instructions that can be put into a computer in order to make it perform an operation

so,using the strict definitions, the structure of a program is the way in which the instructions are arranged or organized so you can perform an operation. In this case, a julia program has julia instructions (defined by the julia syntax) and how do organize and execute those instructions are the structure of a julia program.

Lets write a simple program. Julia instructions (“Julia Code”) are executed by reading text contained in files. in Julia’s case, the .jl extension signals that the file contains Julia code. lets create a simple example. a file named example.jl with the following content:

#commentary. doesn't get executed
a = 2
b = 3
c = a+b
prinln(c)
println("hello world")

this is a series of valid julia instructions that can be executed. Now, how do we execute those instructions? there are some ways to do that:

  1. You can call the Julia binary to execute that file. (when you install Julia, you basically install a Julia interpreter, in the sense that interprets Julia syntax and transform Julia instructions to computer instructions). in the terminal:
$ julia example.jl
  1. You can call a Julia session, and execute your program inside that session:
$ julia

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.2.0 (2019-08-20)
 _/ |\__'_|_|_|\__'_|  |  
|__/                   |

julia> include("example.jl")
  1. you can compile your program and run the executable (i don’t know how to do this, as this is a functionality not included in the language right now, but there is a package that tries to do that.. (an executable is directly computer instructions)

after all this, a lot of questions are still left unanswered:

  • What is the julia syntax?
  • How do i interact with the rest of the computer?
  • How do i interact with other computers?
  • How do i interact with other programs?
  • How do i save and load my work?
  • How do i order all the variables in my program?

I don’t know the answer of all those questions, but in this community there is people that can. feel free to ask!. a great starting point is the official julia docs.

1 Like

just asking, you asked this on Stack Overflow, right?

Thank you very much for helping me .

1 Like

Right

1 Like