Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.
/ julec-go Public archive

Jule's first compiler written in Go.

License

Notifications You must be signed in to change notification settings

julelang/julec-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Warning
These source codes have some known bugs that are left unfixed.
The latest Jule compiler is quite advanced and more stable than this compiler.
This compiler is the first Jule compiler developed to develop Jule's bootstrapping compiler.
It no longer gets updates and is not maintained.
Here is the latest Jule compiler



The Jule Programming Language

This repository is the main source tree of Jule.
It contains the reference compiler, API and standard library.

Website | Manual | Contributing | Community

Community

Join Julenours to support Jule, explore and interact with the community.

Our main community platforms:

Motivation

Warning
JuleC is still under pre development. Therefore, design changes and the like may occur in the language.
Some commits may not be fully honored due to some compiler/API errors.
Please report it with the Jule Issue Tracker if you come across something like this.

Our motivation is to develop a safe and fast programming language that focuses on systems programming. However, instead of ignoring C and C++ programming languages, which are widely used in systems programming, it is aimed to provide good interoperability support for these languages. Jule cares about security and tries to maintain the balance of performance. It guarantees memory safety and is committed to not contain undefined behavior (except Unsafe Jule), it has a reference compiler with obsessions that encourage developers to build safe software. It offers fully integrated Jule-C++ development with API and interoperability.

Showcase: quicksort.jule

fn quicksort(mut s: []int) {
    if s.len <= 1 {
        ret
    }

    let (mut i, last) = -1, s[s.len-1]
    for j in s {
        let mut x = &s[j]
        if (unsafe{ *x <= last }) {
            i++
            let mut y = &s[i]
            unsafe { *x, *y = *y, *x }
        }
    }

    quicksort(s[:i])
    quicksort(s[i+1:])
}

fn main() {
    let mut my_slice = [1, 9, -2, 25, -24, 4623, 0, -1, 0xFD2]
    outln(my_slice)
    quicksort(my_slice)
    outln(my_slice)
}

Design Principles

Jule is developed within the framework of certain design principles. These principles often follow the motivation for the emergence of Jule. Our aim is to present a design and implementation that meets these principles in the most balanced way.

Our Design Principles

  • Simplicity and maintainability
  • Fast and scalable development
  • Performance-critical software
  • Memory safety
  • Immutability by default
  • Efficiency and performance
  • High C++ interoperability

What is JuleC?

JuleC is the name of the reference compiler for the Jule programming language. It is the original compiler of the Jule programming language. The features that JuleC has represent the official and must-have features of the Jule programming language. This is sort of a standard for the Jule programming language and represents the minimum competency that unofficial compilers should have.

Memory Safety and Management

Memory safety and memory management is a major challenge in C , C++ and similar programming languages. Jule has a reference-based memory management design to solve these issues. Jule guarantees memory safety and uses reference counting for memory management. An account-allocation is automatically released as soon as the reference count reaches zero. Please read the memory management part of manual for more information about reference-counting approach of Jule.

Variables are immutable by default, and each variable is encouraged to be initialized at declaration. Safe Jule performs bounds checking and nil (aka null) checking. It is committed to have no undefined behavior. Unsafe behaviors are encouraged to be done deliberately with unsafe scopes. Please read the Unsafe Jule part of manual for more information about of Unsafe Jule.

Note
Jule also has different memory management methods.
For example, the std::memory::c standard library provides C-like memory management.

C++ Interoperability

Jule is designed to be interoperable with C++. A C++ header file dependency can be added to the Jule code and its functions can be linked. It's pretty easy to write C++ code that is compatible with the Jule code compiled by the compiler. JuleC keeps all the C++ code it uses for Jule in its api directory. This API makes it possible and easy to write C++ code that can be fully integrated into Jule.

    File: sum.hpp

    using namespace jule;
    
    Int sum(const Slice<Int> slice) {
        Int total{ 0 };
        for (const Int x: slice)
            total += x;
        return total;
    }

    File: main.jule

    use cpp "sum.hpp"
    
    cpp fn sum([]int): int
    
    fn main() {
        let numbers = [1, 2, 3, 4, 5, 6, 7, 8]
        let total = cpp.sum(numbers)
        outln(total)
    }

    The above example demonstrates the interoperability of Jule with a C++ function that returns the total of all values of an integer slice. The C++ header file is written entirely using the Jule API. The Int, and Slice types used are part of the API. The Int data type is equally sensitive to the system architecture as in Jule. The Jule source code declares to use sum.hpp first, and binds the C++ function into Jule accordingly. Then, a call is made from Jule and the result of the function is written to the command line.

    Future Changes

    JuleC is in early development and currently it can only be built from source. However, despite being in the early development stage, many algorithms (see the standard library) can be successfully implemented. It is planned to rewrite the compiler with Jule after reference compiler and standard library reaches sufficient maturity. JuleC has or is very close to having many of the things Jule was intended to have, such as memory safety, no undefined behavior, structures with methods and generics.

    A release is not expected until JuleC itself is developed with the Jule. The syntax and language design of the Jule programming language has emerged and is not expected to undergo major changes. When the reference compiler is rewritten with Jule, it is thought that AST, Lexer and some packages will be included in the standard library. This will be a change that will cause the official compiler's project structure to be rebuilt. The reference compiler will probably use the standard library a lot. This will also allow developers to quickly develop tools for the language by leveraging Jule's standard library.

    Also several packages that are part of JuleC have already been added to the standard library. Some of these packages are std::jule::lex, std::jule::build and std::jule::constant. Since these packages are part of JuleC and are intended to be used for bootsrapping purposes, they are updated simultaneously with JuleC.

    There is an idea to include a package manager in JuleC as well, although it doesn't have one yet. Jule's modern understanding of language and convenience suggests that there should be a package manager that comes with the compiler. This package manager will provide management of non-standard library packages developed and published by the community. Jule's standard library only gets updates with compiler releases.

    The language and standard library will continue to evolve and change in the future but JuleC will guarantee stability since its first stable release. Some packages of the standard library (std::math, std::conv, std::unicode::utf8 or etc.) are almost complete and are not expected to undergo major changes.

    Documentations

    All documentations about Jule and JuleC is on the website as manual.
    See Jule Manual

    To contribute to the website, manual or something else, please use the website repository.

    Compiler and C++ Standard Support

    JuleC officially supports some C++ compilers. When you try to compile with these compilers, it promises that code can be compiled in the officially supported C++ standard. JuleC is committed to creating code according to the most ideal C++ standard it has adopted, and that the generated code can be compiled by C++ compilers that fully support this standard. Likewise, this commitment is also true for the API of JuleC. Jule's ideal C++ standard is determined by the most ideal C++ standard, fully supported by officially supported C++ compilers.

    If you are getting a compiler error even though you are using the officially supported compiler and standard, please let us know with the Jule Issue Tracker. If you are trying to use a standard or a compiler that is not officially supported, you can still contact us to find out about the problem. But keep in mind that since it's out of the official support, it's likely that the maintainers won't make the effort to fix it.

    See compiling part of manual for supported compilers and C++ standards.

    Platform Support

    Jule supports multiple platforms. It supports development on i386, amd64 and arm64 architectures on Windows, Linux and macOS (Darwin) platforms. JuleC undertakes the effort, that the code and standard library it produces will be compatible with all these platforms. All supported platforms by JuleC are documented in the platform support part of manual.

    Building Project

    Note
    Please read the install from source part of manual for compiling from source code.

    When you enter the directory where the source code is located, you can find some compilation scripts for compiling of JuleC.
    These scripts are written to run from the src directory:

    • build: scripts used for compile.
    • brun: scripts used for compile and execute if compiling is successful.

    JuleC aims to have a single main build file.
    JuleC is in development with the Go programming language.

    Building with Go Compiler

    In src directory.

    Windows

    go build -o julec.exe -v cmd\julec\main.go

    macOS (Darwin)

    go build -o julec -v cmd/julec/main.go

    Linux

    go build -o julec -v cmd/julec/main.go

    Run the above command in your terminal, in the src directory of Jule project.

    Contributing

    Thanks in advance for your contribution to Jule!
    Every contribution, big or small, to Jule is greatly appreciated.

    The Jule project uses issues only for bug reports and proposals.
    To contribute, please read the contribution guidelines.
    For discussions and asking questions, please use discussions.
    Regarding security, please refer to the security policy.

    Code of Conduct

    See Julenour Code of Conduct

    License

    The JuleC and standard library is distributed under the terms of the BSD 3-Clause license.
    See License Details