From baf637bbdb799e16e837a8127740649f5cfc2b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Dietrich?= Date: Mon, 4 Nov 2024 09:29:31 +0100 Subject: [PATCH 1/2] Added Cobol --- Dockerfile | 44 ++++++++++++++++-------------- README.md | 20 +++++++++++++- compiler/cobol.py | 65 ++++++++++++++++++++++++++++++++++++++++++++ compiler/compiler.py | 5 +++- docker-compose.yml | 4 +-- 5 files changed, 114 insertions(+), 24 deletions(-) create mode 100644 compiler/cobol.py diff --git a/Dockerfile b/Dockerfile index 547e129..8a0c633 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,11 @@ FROM ubuntu:22.04 RUN DEBIAN_FRONTEND=noninteractive apt-get update --fix-missing RUN DEBIAN_FRONTEND=noninteractive apt-get upgrade -y -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y apt-utils -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y curl - -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y git - -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y firejail +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y \ + apt-utils \ + curl \ + git \ + firejail ################################################################################## RUN DEBIAN_FRONTEND=noninteractive apt-get install -y make @@ -33,9 +32,9 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y rustc ### JAVA #RUN DEBIAN_FRONTEND=noninteractive apt-get install -y default-jdk -RUN curl -O https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.deb \ - && dpkg -i jdk-21_linux-x64_bin.deb \ - && rm jdk-21_linux-x64_bin.deb +RUN curl -O https://download.oracle.com/java/23/latest/jdk-23_linux-x64_bin.deb \ + && dpkg -i jdk-23_linux-x64_bin.deb \ + && rm jdk-23_linux-x64_bin.deb ### Haskell RUN DEBIAN_FRONTEND=noninteractive apt-get install -y ghc @@ -50,18 +49,14 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y r-cran-mapdata RUN DEBIAN_FRONTEND=noninteractive apt-get install -y r-cran-reshape ### Julia -RUN curl -O https://julialang-s3.julialang.org/bin/linux/x64/1.9/julia-1.9.3-linux-x86_64.tar.gz \ - && tar -xvzf julia-1.9.3-linux-x86_64.tar.gz \ - && rm julia-1.9.3-linux-x86_64.tar.gz \ - && mv julia-1.9.3/ /opt/ \ - && ln -s /opt/julia-1.9.3/bin/julia /usr/local/bin/julia +RUN curl -fsSL https://install.julialang.org | sh -s -- -y ### Zig -RUN curl -O https://ziglang.org/download/0.11.0/zig-linux-x86_64-0.11.0.tar.xz \ - && tar -xf zig-linux-x86_64-0.11.0.tar.xz \ - && rm zig-linux-x86_64-0.11.0.tar.xz \ - && mv zig-linux-x86_64-0.11.0/ /opt/ \ - && ln -s /opt/zig-linux-x86_64-0.11.0/zig /usr/local/bin/zig +RUN curl -fLO https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz \ + && tar -xf zig-linux-x86_64-0.13.0.tar.xz \ + && rm zig-linux-x86_64-0.13.0.tar.xz \ + && mv zig-linux-x86_64-0.13.0/ /opt/ \ + && ln -s /opt/zig-linux-x86_64-0.13.0/zig /usr/local/bin/zig ### Nim RUN curl -O https://nim-lang.org/choosenim/init.sh -sSf \ @@ -93,7 +88,10 @@ RUN DEBIAN_FRONTEND=noninteractive pip3 install \ sympy \ pyyaml -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y libcairo2-dev libpango1.0-dev +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y \ + ffmpeg \ + libcairo2-dev \ + libpango1.0-dev RUN DEBIAN_FRONTEND=noninteractive pip3 install \ pycairo \ manim @@ -117,6 +115,12 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gnat-12 ### Elixir RUN DEBIAN_FRONTEND=noninteractive apt-get install -y erlang-dev elixir +### Latex +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y texlive-latex-extra + +### COBOL +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gnucobol + ############################################################################################# COPY . /coderunner WORKDIR "/coderunner" diff --git a/README.md b/README.md index 7bb56ff..3f4459e 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ window.CodeRunner = { } //window.CodeRunner.init("wss://coderunner.informatik.tu-freiberg.de/") -window.CodeRunner.init("ws://127.0.0.1:8000/") +window.CodeRunner.init("ws://127.0.0.1:8001/") //window.CodeRunner.init("wss://ancient-hollows-41316.herokuapp.com/") @end @@ -139,6 +139,7 @@ window.CodeRunner.init("ws://127.0.0.1:8000/") @LIA.clojure: @LIA.eval(`["main.clj"]`, `none`, `clojure -M main.clj`) @LIA.clojure_withShell: @LIA.eval(`["main.clj"]`, `none`, `clojure -M -i main.clj -r`) @LIA.cpp: @LIA.eval(`["main.cpp"]`, `g++ main.cpp -o a.out`, `./a.out`) +@LIA.cobol: @LIA.eval(`["main.cob"]`, `cobc -x --free main.cob`, `./main`) @LIA.elixir: @LIA.eval(`["main.exs"]`, `none`, `elixir main.exs`) @LIA.elixir_withShell: @LIA.eval(`["main.exs"]`, `none`, `iex main.exs`) @LIA.go: @LIA.eval(`["main.go"]`, `go build main.go`, `./main`) @@ -635,6 +636,23 @@ Additionally, you can also use the `@LIA.clojure_withShell` macro, which will st @LIA.clojure_withShell +### COBOL : `@LIA.cobol` + +COBOL (Common Business-Oriented Language) is a high-level programming language designed for business data processing. It was developed in the late 1950s and early 1960s by a committee of computer professionals from private industry, universities, and government agencies. COBOL is known for its readability, self-documenting code, and English-like syntax, making it easy to understand and maintain. It is widely used in legacy systems, financial institutions, and government agencies for processing large volumes of data. The backend here uses the GnuCOBOL compiler to compile COBOL code, ensuring compatibility and efficient execution. + +For more information, you can visit the [COBOL programming language Wikipedia page](https://en.wikipedia.org/wiki/COBOL). + + +```cobol + IDENTIFICATION DIVISION. + PROGRAM-ID. HELLO-WORLD. + PROCEDURE DIVISION. + DISPLAY 'Hello, world'. + STOP RUN. +``` +@LIA.cobol + + ### Elixir : `@LIA.elixir` Elixir is a dynamic, functional programming language designed for building scalable and maintainable applications. It was created by José Valim and first released in 2011. Elixir runs on the Erlang Virtual Machine (BEAM), which provides excellent support for concurrency, fault tolerance, and distributed systems. Elixir leverages the strengths of Erlang while offering a more modern syntax and powerful metaprogramming capabilities. It is widely used for web development, embedded systems, and applications requiring high reliability. The backend here uses the Elixir compiler to execute Elixir code, ensuring robust and efficient performance on the BEAM platform. diff --git a/compiler/cobol.py b/compiler/cobol.py new file mode 100644 index 0000000..84535bf --- /dev/null +++ b/compiler/cobol.py @@ -0,0 +1,65 @@ +import re +from typing import List, Tuple +from compiler.helper import Response, Problem, run_command + + +def run(cmd: str, cwd: str) -> Response: + ''' + Run the GNU-Cobol gobc compiler with the given command within the current working directory. + ''' + + out = run_command(cmd, cwd) + + warnings = find_warnings(out.stderr) + find_warnings(out.stdout) + errors = find_errors(out.stderr) + find_errors(out.stdout) + + return { + "ok": len(errors) == 0, + "message": out.stdout + out.stderr, + "problems": warnings + errors + } + +def find_all(pattern: str, output: str) -> List[Tuple[str, str, str]]: + ''' + Detect all occurrences of pattern within an output-string. + ''' + + return re.findall("([^:\\s]+):(\\d+): " + + pattern + + ": ([^\n]+)", output) + +def find_warnings(output: str) -> List[Problem]: + ''' + Detect all warnings within the gobc output. + ''' + + return formatting(find_all("warning", output), "warning") + + +def find_errors(output: str) -> List[Problem]: + ''' + Detect all errors and fatal errors within the gcc output. + ''' + + err1 = find_all("error", output) + err2 = find_all("fatal error", output) + + return formatting(err1 + err2, "error") + + +def formatting(problems: List[Tuple[str, str, str]], kind: str) -> List[Problem]: + ''' + Turn a list of strings into a predefined format of type problem, which is used by the + remote editor to display errors. + ''' + + result = [] + + for (file, row, msg) in problems: + result.append(Problem({"file": file, + "type": kind, + "row": int(row) - 1, + "col": 0, + "text": msg})) + + return result \ No newline at end of file diff --git a/compiler/compiler.py b/compiler/compiler.py index 8d4f5dc..62aeef4 100644 --- a/compiler/compiler.py +++ b/compiler/compiler.py @@ -1,5 +1,5 @@ from typing import List -from compiler import ada, c, dotnet, elixir, ghc, go, java, mono, python, perl, rust, nasm, nim +from compiler import ada, c, cobol, dotnet, elixir, ghc, go, java, mono, python, perl, rust, nasm, nim from compiler.helper import Response2, Problem2, run_command, prefix @@ -60,6 +60,9 @@ def run(cmd: str, working_directory: str, files: List[str]) -> Response2: elif cmd.startswith("rustc "): rslt = rust.run(cmd, working_directory) + elif cmd.startswith("cobc "): + rslt = cobol.run(cmd, working_directory) + elif cmd.startswith("none"): rslt = {"ok": True, "message": "", "problems": []} diff --git a/docker-compose.yml b/docker-compose.yml index 08f0b4f..1acff88 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,6 @@ services: build: . image: liascript/coderunner:latest ports: - - "8000:8000" + - '8001:8000' environment: - - CODERUNNER_HOST=0.0.0.0 \ No newline at end of file + - CODERUNNER_HOST=0.0.0.0 From 46d5e894c4a7f2f7228929b508ab86ad8eafa85e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Dietrich?= Date: Mon, 4 Nov 2024 11:31:41 +0100 Subject: [PATCH 2/2] added multiple languages --- Dockerfile | 47 +++++++++++ README.md | 231 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 278 insertions(+) diff --git a/Dockerfile b/Dockerfile index 8a0c633..94f5f01 100644 --- a/Dockerfile +++ b/Dockerfile @@ -121,6 +121,53 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y texlive-latex-extra ### COBOL RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gnucobol +### Fortran +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gfortran + +### Algol +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y algol68g + +### APL +RUN curl -O https://www.dyalog.com/uploads/php/download.dyalog.com/download.php?file=19.0/linux_64_19.0.50027_unicode.x86_64.deb \ + && dpkg -i linux_64_19.0.50027_unicode.x86_64.deb \ + && rm linux_64_19.0.50027_unicode.x86_64.deb + +### Prolog +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y swi-prolog + +### Forth +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gforth + +### Pascal +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y fpc + + +### OCaml +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y ocaml + +### Scheme +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y guile-3.0 + +### Smalltalk +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gnu-smalltalk + +### Prolog +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y swi-prolog + +### Groovy +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y groovy + +### Scala +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y scala + +### Racket +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y racket + +### Tcl +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tcl + + + ############################################################################################# COPY . /coderunner WORKDIR "/coderunner" diff --git a/README.md b/README.md index 3f4459e..77667cb 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,8 @@ window.CodeRunner.init("ws://127.0.0.1:8001/") @LIA.ada: @LIA.eval(`["main.ada"]`, `gnatmake main.ada`, `./main`) +@LIA.algol: @LIA.eval(`["main.alg"]`, `none`, `a68g main.alg`) +@LIA.apl: @LIA.eval(`["main.apl"]`, `none`, `dyalog -script main.apl`) @LIA.c: @LIA.eval(`["main.c"]`, `gcc -Wall main.c -o a.out`, `./a.out`) @LIA.clojure: @LIA.eval(`["main.clj"]`, `none`, `clojure -M main.clj`) @LIA.clojure_withShell: @LIA.eval(`["main.clj"]`, `none`, `clojure -M -i main.clj -r`) @@ -142,7 +144,11 @@ window.CodeRunner.init("ws://127.0.0.1:8001/") @LIA.cobol: @LIA.eval(`["main.cob"]`, `cobc -x --free main.cob`, `./main`) @LIA.elixir: @LIA.eval(`["main.exs"]`, `none`, `elixir main.exs`) @LIA.elixir_withShell: @LIA.eval(`["main.exs"]`, `none`, `iex main.exs`) +@LIA.forth: @LIA.eval(`["main.fs"]`, `none`, `gforth main.fs -e BYE`) +@LIA.forth_withShell: @LIA.eval(`["main.fs"]`, `none`, `gforth main.fs`) +@LIA.fortran: @LIA.eval(`["main.f90"]`, `gfortran main.f90 -o a.out`, `./a.out`) @LIA.go: @LIA.eval(`["main.go"]`, `go build main.go`, `./main`) +@LIA.groovy: @LIA.eval(`["main.groovy"]`, `none`, `groovy main.groovy`) @LIA.haskell: @LIA.eval(`["main.hs"]`, `ghc main.hs -o main`, `./main`) @LIA.haskell_withShell: @LIA.eval(`["main.hs"]`, `none`, `ghci main.hs`) @LIA.java: @LIA.eval(`["@0.java"]`, `javac @0.java`, `java @0`) @@ -151,8 +157,11 @@ window.CodeRunner.init("ws://127.0.0.1:8001/") @LIA.mono: @LIA.eval(`["main.cs"]`, `mcs main.cs`, `mono main.exe`) @LIA.nasm: @LIA.eval(`["main.asm"]`, `nasm -felf64 main.asm && ld main.o`, `./a.out`) @LIA.nim: @LIA.eval(`["main.nim"]`, `nim c main.nim`, `./main`) +@LIA.ocaml: @LIA.eval(`["main.ml"]`, `none`, `ocaml main.ml`) @LIA.perl: @LIA.eval(`["main.pl"]`, `perl -c main.pl`, `perl main.pl`) @LIA.perl_withShell: @LIA.eval(`["main.pl"]`, `perl -c main.pl`, `perl -d main.pl`) +@LIA.prolog: @LIA.eval(`["main.pl"]`, `none`, `swipl -s main.pl -g @0 -t halt`) +@LIA.prolog_withShell: @LIA.eval(`["main.pl"]`, `none`, `swipl -s main.pl`) @LIA.python: @LIA.python3 @LIA.python_withShell: @LIA.python3_withShell @LIA.python2: @LIA.eval(`["main.py"]`, `python2.7 -m compileall .`, `python2.7 main.pyc`) @@ -161,9 +170,14 @@ window.CodeRunner.init("ws://127.0.0.1:8001/") @LIA.python3_withShell: @LIA.eval(`["main.py"]`, `none`, `python3 -i main.py`) @LIA.r: @LIA.eval(`["main.R"]`, `none`, `Rscript main.R`) @LIA.r_withShell: @LIA.eval(`["main.R"]`, `none`, `sh -c "cat main.R - | R --interactive"`) +@LIA.racket: @LIA.eval(`["main.rkt"]`, `none`, `racket main.rkt`) @LIA.ruby: @LIA.eval(`["main.rb"]`, `none`, `ruby main.rb`) @LIA.ruby_withShell: @LIA.eval(`["main.rb"]`, `none`, `irb --nomultiline -r ./main.rb`) @LIA.rust: @LIA.eval(`["main.rs"]`, `rustc main.rs`, `./main`) +@LIA.scala: @LIA.eval(`["@0.scala"]`, `scalac @0.scala`, `scala @0`) +@LIA.scheme: @LIA.eval(`["main.scm"]`, `none`, `guile --no-auto-compile main.scm`) +@LIA.smalltalk: @LIA.eval(`["main.st"]`, `none`, `gst main.st`) +@LIA.tcl: @LIA.eval(`["main.tcl"]`, `none`, `tclsh main.tcl`) @LIA.v: @LIA.eval(`["main.v"]`, `v main.v`, `./main`) @LIA.v_withShell: @LIA.eval(`["main.v"]`, `none`, `sh -c "cat main.v - | v repl"`) @LIA.zig: @LIA.eval(`["main.zig"]`, `zig build-exe ./main.zig -O ReleaseSmall`, `./main`) @@ -437,6 +451,36 @@ end Main; ``` @LIA.ada +### ALGOL : `@LIA.algol` + +ALGOL (Algorithmic Language) is a family of imperative, procedural, and structured programming languages that were developed in the late 1950s and early 1960s. ALGOL was designed to be a universal language for expressing algorithms and was influential in the development of modern programming languages. ALGOL 60, the most well-known version, introduced many concepts that are still used today, such as block structures, recursion, and parameter passing mechanisms. The backend here uses the ALGOL 60 compiler to compile and execute ALGOL code, ensuring compatibility with the original language specification. + +For more information, you can visit the [ALGOL programming language Wikipedia page](https://en.wikipedia.org/wiki/ALGOL). + +--- + +```algol +BEGIN + print(("Hello, World!", new line)) +END +``` +@LIA.algol + + +### APL : `@LIA.apl` + +APL (A Programming Language) is a high-level, array-oriented programming language that was developed in the 1960s by Kenneth E. Iverson. APL is known for its concise and expressive syntax, which uses a wide range of special symbols to represent mathematical functions and operations. It is particularly well-suited for numerical and array processing tasks, making it popular in scientific computing, data analysis, and financial modeling. The backend here uses the Dyalog APL interpreter, which provides a powerful environment for developing and executing APL code. + +For more information, you can visit the [APL programming language Wikipedia page](https://en.wikipedia.org/wiki/APL_%28programming_language%29). + +--- + +```apl +⎕←'abcd' ∘.= 'cabbage' +``` +@LIA.apl + + ### Assembly (nasm) : `@LIA.nasm` Assembly language is a low-level programming language that provides direct control over hardware through symbolic representation of machine code instructions. Each instruction in an assembly language corresponds closely to a machine code instruction supported by the architecture's CPU. Assembly language is often used in system programming, particularly for writing operating systems, device drivers, and embedded systems, where precise control of the hardware is essential. In the backend, the NASM (Netwide Assembler) compiler is used, which is a popular assembler for x86 architecture, known for its portability and flexibility. @@ -675,6 +719,7 @@ IO.puts "Hello World" ``` @LIA.eval(`["main.exs"]`, `none`, `iex main.exs`) + ### F# : `@LIA.fsharp` **F# Language Summary:** @@ -717,6 +762,50 @@ printfn "Hello from F#" ``` @LIA.eval(`["Program.fs", "project.fsproj"]`, `dotnet build -nologo`, `dotnet run`) + +### Forth : `@LIA.forth` + +Forth is a stack-based, extensible, and interactive programming language that was developed in the late 1960s by Charles H. Moore. It is known for its simplicity, flexibility, and efficiency, making it ideal for embedded systems, real-time applications, and low-level programming tasks. Forth uses a postfix notation, where operations are performed by pushing and popping values on a data stack. It provides direct access to memory and hardware, allowing for fine-grained control over system resources. The backend here uses the Gforth interpreter to execute Forth code, ensuring fast and reliable execution. + +For more information, you can visit the [Forth programming language Wikipedia page](https://en.wikipedia.org/wiki/Forth_%28programming_language%29). + +--- + +```forth +: hello ." Hello, world!" cr ; +hello +``` +@LIA.forth + +### Fortran : `@LIA.fortran` + +Fortran (Formula Translation) is a high-level programming language developed by IBM in the 1950s for scientific and engineering applications. It is known for its efficiency, numerical accuracy, and extensive library of mathematical functions, making it ideal for numerical computations, simulations, and data analysis. Fortran has evolved over the years, with the latest standard being Fortran 2018, which includes modern features like coarrays, improved parallelism, and interoperability with C. The backend here uses the GNU Fortran compiler (gfortran) to compile Fortran code, ensuring high performance and compatibility with modern Fortran standards. + +For more information, you can visit the [Fortran programming language Wikipedia page](https://en.wikipedia.org/wiki/Fortran). + +--- + +```fortran +program hello + print *, "Hello, world!" +end program hello +``` +@LIA.fortran + +### Groovy : `@LIA.groovy` + +Groovy is a dynamic, object-oriented programming language that runs on the Java Virtual Machine (JVM). It was created by James Strachan and first released in 2003. Groovy is known for its simplicity, flexibility, and seamless integration with Java, allowing developers to write concise and expressive code. It supports features like closures, dynamic typing, and metaprogramming, making it ideal for scripting, web development, and automation tasks. The backend here uses the Groovy compiler to execute Groovy code, ensuring compatibility with the JVM and access to the Java ecosystem. + +For more information, you can visit the [Groovy programming language Wikipedia page](https://en.wikipedia.org/wiki/Apache_Groovy). + +--- + +```groovy +println "Hello, world!" +``` +@LIA.groovy + + ### GO : `@LIA.go` Go, also known as Golang, is a statically typed, compiled programming language designed by Google engineers and first released in 2009. It is known for its simplicity, efficiency, and strong support for concurrent programming. Go combines the performance and safety of a compiled language like C with the ease of use and productivity features of dynamically typed languages. It is particularly well-suited for building large-scale, distributed systems, cloud services, and other performance-critical applications. The backend here uses the `golang-go` compiler to compile Go code, ensuring fast and reliable execution. @@ -902,6 +991,7 @@ println("result 2: ", quad2) ``` @LIA.julia_withShell + ### Nim : `@LIA.nim` Nim is a statically typed, compiled programming language that combines the performance of C with the expressiveness of modern languages like Python. First released in 2008, Nim is known for its simplicity, efficiency, and flexibility, making it suitable for systems programming, web development, and scientific computing. Nim features a powerful metaprogramming system, automatic memory management, and a syntax that is easy to read and write. It compiles to C, C++, and JavaScript, enabling cross-platform development with high performance. The backend here uses the Nim compiler to execute Nim code, ensuring efficient and optimized output. @@ -915,6 +1005,36 @@ echo "Hello World" ``` @LIA.nim + +### OCaml : `@LIA.ocaml` + +OCaml is a statically typed, functional programming language that was developed in the late 1990s as an extension of the Caml language. It is known for its strong type system, type inference, and support for functional, imperative, and object-oriented programming paradigms. OCaml is widely used in academia and industry for developing compilers, interpreters, theorem provers, and other applications that require high reliability and performance. The backend here uses the OCaml compiler to execute OCaml code, ensuring efficient and optimized execution. + +For more information, you can visit the [OCaml programming language Wikipedia page](https://en.wikipedia.org/wiki/OCaml). + +--- + +```ocaml +print_string "Hello, world!\n";; +``` +@LIA.ocaml + +### Pascal : `@LIA.pascal` + +Pascal is a high-level, procedural programming language developed by Niklaus Wirth in the late 1960s. It was designed to encourage good programming practices and provide a structured approach to software development. Pascal is known for its readability, simplicity, and strong typing, making it ideal for teaching programming concepts and developing reliable software. It introduced many features that are now common in modern programming languages, such as block structures, data structures, and modular programming. The backend here uses the Free Pascal compiler to compile Pascal code, ensuring compatibility and efficient execution. + +For more information, you can visit the [Pascal programming language Wikipedia page](https://en.wikipedia.org/wiki/Pascal_%28programming_language%29). + +--- + +```pascal +program HelloWorld; +begin + writeln('Hello, world!'); +end. +``` +@LIA.eval(`["main.pas"]`, `fpc main.pas`, `./main`) + ### Perl : `@LIA.perl` Perl is a high-level, dynamic programming language known for its versatility and powerful text-processing capabilities. Originally developed by Larry Wall in 1987, Perl has evolved to become a popular choice for system administration, web development, and network programming. It is especially strong in string manipulation, regular expressions, and file handling, making it ideal for tasks involving data extraction, reporting, and automation. Perl's flexible syntax allows for rapid development and prototyping. The backend here uses the Perl interpreter to execute Perl scripts, ensuring compatibility and efficient performance. @@ -944,6 +1064,46 @@ my $x = 42; ``` @LIA.perl_withShell +### Prolog : `@LIA.prolog` + +Prolog is a logic programming language that was developed in the early 1970s by Alain Colmerauer and Robert Kowalski. It is based on formal logic and provides a declarative approach to problem-solving, where programs are defined as sets of logical rules and facts. Prolog is particularly well-suited for tasks involving symbolic reasoning, artificial intelligence, and natural language processing. It is known for its pattern matching and backtracking capabilities, which allow for efficient search and inference. The backend here uses the SWI-Prolog interpreter to execute Prolog code, ensuring compatibility and efficient execution. + +For more information, you can visit the [Prolog programming language Wikipedia page](https://en.wikipedia.org/wiki/Prolog). + +--- + +```prolog +likes(mary, chocolate). +likes(mary, wine). +likes(john, wine). +likes(john, mary). + +% Define the query rule to find pairs X and Y where john likes X and X likes Y +query :- + likes(john, X), + likes(X, Y), + format('X = ~w, Y = ~w~n', [X, Y]). +``` +@LIA.prolog(query) + +--- + +Additionally, you can also use the `@LIA.prolog_withShell` macro, which will start a Prolog shell after the code has been executed. + +```prolog +likes(mary, chocolate). +likes(mary, wine). +likes(john, wine). +likes(john, mary). + +% Define the query rule to find pairs X and Y where john likes X and X likes Y +query :- + likes(john, X), + likes(X, Y), + format('X = ~w, Y = ~w~n', [X, Y]). +``` +@LIA.prolog_withShell + ### Python2 : `@LIA.python2` Python 2 is a version of the Python programming language that was widely used for many years, first released in 2000. It is known for its simplicity, readability, and versatility, making it popular for web development, automation, data analysis, and scripting. Python 2 introduced many features that made Python a popular choice among developers, but it also had some design limitations that led to the development of Python 3. Python 2.7, the last release of Python 2, reached its end of life on January 1, 2020, meaning it no longer receives updates or support. The backend here uses the Python 2 interpreter to execute Python 2 code, ensuring compatibility with legacy systems and software that still rely on this version. @@ -1048,6 +1208,20 @@ print("Hello World") ``` @LIA.r_withShell +### Racket : `@LIA.racket` + +Racket is a general-purpose, multi-paradigm programming language that was developed as a descendant of the Scheme programming language. It is known for its extensibility, expressive syntax, and powerful macro system, making it ideal for language-oriented programming, domain-specific languages, and software development. Racket provides a rich set of libraries and tools for building web applications, graphical user interfaces, and educational software. It is widely used in academia and industry for research, teaching, and prototyping. The backend here uses the Racket interpreter to execute Racket code, ensuring efficient and reliable performance. + +For more information, you can visit the [Racket programming language Wikipedia page](https://en.wikipedia.org/wiki/Racket_%28programming_language%29). + +--- + +```racket +#lang racket +(displayln "Hello, world!") +``` +@LIA.racket + ### Ruby : `@LIA.ruby` Ruby is a high-level, interpreted programming language known for its simplicity and productivity. Developed by Yukihiro Matsumoto and first released in 1995, Ruby emphasizes ease of use and developer happiness, featuring a clean and elegant syntax that is easy to read and write. It supports multiple programming paradigms, including object-oriented, functional, and imperative programming. Ruby is particularly renowned for its use in web development, especially with the Ruby on Rails framework, which facilitates rapid development and deployment of web applications. The backend here uses the Ruby interpreter to execute Ruby code, ensuring efficient execution and support for modern Ruby features. @@ -1105,6 +1279,63 @@ fn main() { ``` @LIA.rust +### Scala : `@LIA.scala` + +Scala is a modern, functional programming language that runs on the Java Virtual Machine (JVM). It was developed by Martin Odersky and first released in 2003. Scala combines object-oriented and functional programming paradigms, providing a powerful and expressive language for building scalable and robust applications. Scala is known for its conciseness, type safety, and interoperability with Java, making it a popular choice for developing web services, distributed systems, and data processing applications. The backend here uses the Scala compiler to execute Scala code, ensuring efficient performance on the JVM. + +For more information, you can visit the [Scala programming language Wikipedia page](https://en.wikipedia.org/wiki/Scala_%28programming_language%29). + +--- + +```scala +object HelloWorld { + def main(args: Array[String]): Unit = { + println("Hello, world!") + } +} +``` +@LIA.scala(HelloWorld) + +### Scheme : `@LIA.scheme` + +Scheme is a minimalist, functional programming language that was developed in the 1970s as a dialect of Lisp. It is known for its simplicity, elegance, and expressive power, making it an ideal language for teaching programming concepts and exploring functional programming paradigms. Scheme features a simple syntax based on s-expressions and a powerful macro system that allows for easy metaprogramming. It is widely used in academic settings and research for its clarity and ease of understanding. The backend here uses the Scheme interpreter to execute Scheme code, ensuring efficient and reliable performance. + +For more information, you can visit the [Scheme programming language Wikipedia page](https://en.wikipedia.org/wiki/Scheme_%28programming_language%29). + +--- + +```scheme +(display "Hello, world!") +(newline) +``` +@LIA.scheme + +### Smalltalk : `@LIA.smalltalk` + +Smalltalk is an object-oriented, dynamically typed programming language that was developed in the 1970s at Xerox PARC. It is known for its simplicity, elegance, and powerful object model, making it an ideal language for teaching object-oriented programming concepts. Smalltalk features a live programming environment where developers can interact with objects directly, making it easy to explore and modify code in real time. Smalltalk has influenced many modern programming languages, including Java, Ruby, and Python. The backend here uses the Squeak Smalltalk interpreter to execute Smalltalk code, ensuring interactive and dynamic programming capabilities. + +For more information, you can visit the [Smalltalk programming language Wikipedia page](https://en.wikipedia.org/wiki/Smalltalk). + +--- + +```smalltalk +'Hello, world!' displayNl +``` +@LIA.smalltalk + +### TCL : `@LIA.tcl` + +Tcl (Tool Command Language) is a high-level, interpreted programming language known for its simplicity, flexibility, and extensibility. Developed by John Ousterhout in the late 1980s, Tcl is designed to be easy to learn and use, with a minimalistic syntax that emphasizes commands and procedures. Tcl is widely used for scripting, automation, and rapid prototyping, as well as for embedding in applications and extending with custom functionality. The backend here uses the Tcl interpreter to execute Tcl code, ensuring compatibility and efficient execution. + +For more information, you can visit the [Tcl programming language Wikipedia page](https://en.wikipedia.org/wiki/Tcl). + +--- + +```tcl +puts "Hello, world!" +``` +@LIA.tcl + ### V : `@LIA.v` V is a statically typed, compiled programming language designed for simplicity, performance, and safety. It was created by Alexander Medvednikov and first released in 2020. V aims to be a lightweight language that is easy to learn and use, with a syntax that is straightforward and similar to Go and Python. It focuses on providing a high level of efficiency while maintaining readability and ease of use. V supports both procedural and functional programming paradigms and is designed to compile to native machine code, resulting in fast execution and minimal runtime dependencies. The backend here uses the V compiler to compile V code, ensuring efficient and reliable performance.