A high level interpreted language built on top of rust
Docker
.
Report Bug
.
Request Feature
- Table Of Contents
- About The Project
- Built With
- Getting Started
- Installation
- Syntax
- Contributing
- Raising an issue
- License
- Authors
Synthia is a programming language crafted on the robust foundation of Rust, tailored for individuals entering the world of programming, especially those in academic settings. It was designed with the intention of making programming accessible to university students who are keen to start their coding journey but may feel daunted by complex syntax and intricacies.
-
Built on Rust Backbone:
- Synthia builds upon the reliable and efficient Rust programming language. By inheriting Rust's core principles of performance, memory safety, and concurrency, Synthia provides a solid and secure environment for programming endeavors.
-
Faster Than Python:
- Synthia delivers superior performance compared to interpreted languages like Python. This speed advantage is crucial for handling computational tasks and projects with resource-intensive requirements.
-
Easier Syntax than C++:
- Synthia takes inspiration from Rust's syntax, ensuring a balance between simplicity and expressiveness. It is designed to be more approachable for beginners, offering an easier learning curve compared to the intricate syntax of languages like C++.
-
Tailored for University Folks:
- Synthia caters specifically to university students who are dipping their toes into the world of programming. The language aims to alleviate the initial apprehension often associated with syntax complexities, allowing students to focus on understanding fundamental programming concepts.
-
User-Friendly Approach:
- With a user-friendly syntax, Synthia strives to create a welcoming environment for newcomers. This approach enables aspiring programmers to grasp programming concepts without being overwhelmed by unnecessary intricacies.
Synthia is not just a programming language; it is a supportive tool for individuals taking their first steps into the exciting realm of coding. By blending the power of Rust with an emphasis on simplicity, Synthia empowers university students to unlock their programming potential with confidence.
Synthia is built on top of Rust
Git is a distributed version control system used for software development. It allows multiple developers to work on the same codebase simultaneously, keeping track of changes and managing versions. It also enables users to revert changes and collaborate more effectively.
Rust is a multi-paradigm, general-purpose programming language that emphasizes performance, type safety, and concurrency. It enforces memory safety ensuring that all references point to valid memory without requiring the use of a garbage collector or reference counting present in other memory-safe languages. To simultaneously enforce memory safety and prevent data races, its "borrow checker" tracks the object lifetime of all references in a program during compilation. Rust borrows ideas from functional programming, including immutability, higher-order functions, and algebraic data types. It is popular for systems programming
docker run immashiva/synthia
git clone https://github.com/ShivaBhattacharjee/Synthia
cd Synthia
To run the compiler in terminal
cargo run
- Make a file with .syn extension
$ touch helloworld.syn
- Write the following code
out("Hello world from Synthia!!");
- Type the following command from terminal
$ cargo run run helloworld.syn
- Output
Hello world from Synthia!!
cargo run
In Synthia, there are two primary functions for printing output: out
and bigPrint
. Each serves a specific purpose in displaying information.
The out
function is a versatile printing tool in Synthia. It can be used to print individual values, concatenate strings, and display the contents of objects. Here's an example:
make greeting = "Hello";
out(greeting, "World!");
The bigPrint function is designed to handle heavy data, such as printing all elements of an array or large datasets. It is particularly useful when dealing with extensive information that might be impractical for standard output. Here's an example:
make dataArray = [1, 2, 3, 4, 5];
sbigPrint(dataArray);
To declare a variable in Synthia, use the make
keyword.
make name = "example"
Synthia is a dynamically typed language, so there is no need to explicitly mention the data type.
Strings can be assigned using double quotes (""), while for integers or floats, you can simply mention the value without quotes.
make number = 12
make anothernum = 12.5
In Synthia, the language dynamically interprets the type based on the assigned value. Therefore, you don't need to specify the type explicitly.
In Synthia, functions are declared using the func
keyword. Here's an example of a function that calculates the sum of two values and prints the result:
make sum = func(a, b) {
make result = a + b;
out("The sum is", result);
};
sum("1", "2");
sum(9, 10);
In the first example, the function is called with string arguments, and in the second example, it's called with integer arguments. Synthia's dynamically typed nature allows you to use the function with different data types without explicitly specifying them.
In Synthia, function arguments are dynamically typed, but it's essential to ensure that the function is called with compatible data types for the expected behavior. In the example above, the sum function assumes that the arguments are numeric and can be added. Always be mindful of the expected input types when designing and using functions
In Synthia, conditional statements allow you to execute different blocks of code based on whether a given condition is true or false. Here's an example illustrating the use of a basic if-else
statement:
make x = 10;
make y = 5;
make z = 9.1;
if (x > y) {
out("x is greater than y!");
out(z);
} else {
out("x is not greater than y!");
}
x, y, and z are initialized with the values 10, 5, and 9.1 respectively.
The if (x > y) statement checks whether the value of x is greater than the value of y.
If the condition is true, it executes the block within the curly braces ({}) under the if statement. Outputs the message "x is greater than y!" using the out function. Outputs the value of z using the out function.
If the condition is false, it executes the block within the curly braces under the else statement. Outputs the message "x is not greater than y!" using the out function.
i. Ensure that the condition inside the if statement evaluates to a boolean result (true or false).
ii. The out function is used for printing messages and values to the console
In Synthia, objects are key-value pairs enclosed in curly braces {}
. Each key is associated with a value, forming a collection of properties. Here's an example of defining and accessing an object:
make testObj = {
"firstKey": "Hello",
"secondKey": "World",
};
out(testObj's firstKey, testObj's secondKey);
Objects in Synthia use the {} syntax, where each property consists of a key and a corresponding value. Keys and values are separated by a colon :. In the example above, testObj is an object with two properties: firstKey and secondKey, each associated with a string value.
To access the properties of an object, use the syntax object's key. In the example, testObj's firstKey and testObj's secondKey are used to retrieve the values associated with the respective keys.
The out function is used to print the values of the object's properties. In the provided example, it prints the values associated with firstKey and secondKey, resulting in the output.
Hello World
i. Keys in Synthia objects are enclosed in double quotes (").
ii. Ensure that the keys used to access object properties match the actual keys in the object.
In Synthia, arrays are used to store collections of elements. They are created using square brackets []
and can hold values of any type. Here's an example of defining and using an array:
make Synthia = ["Faster", "Simpler", "OpenSource"];
out(Synthia);
Arrays in Synthia use square brackets [] to enclose a list of elements. Elements within the array are separated by commas. In the provided example, the Synthia array contains three string elements: "Faster," "Simpler," and "OpenSource."
To access individual elements in an array, you can use their position, or index, within the array. In Synthia, array indices start from 0. For example:
out(Synthia[0]); # Outputs "Faster"
out(Synthia[2]); # Outputs "OpenSource"
The out function is used to print the entire array or specific elements. In the provided example, it prints the entire Synthia array, resulting in the output:
i. Array indices start from 0, so the first element in the array has index 0, the second has index 1, and so on.
ii. Ensure that the elements in the array are of compatible types.
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
-
If you have suggestions for adding or removing projects, feel free to open an issue to discuss it
-
Please make sure you check your spelling and grammar.
Wanna contribute to Synthia ?
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/FeatureName
) - Commit your Changes (
git commit -m 'Add some FeatureName'
) - Push to the Branch (
git push origin feature/FeatureName
) - Open a Pull Request
If you're experiencing any problems with Synthia, please be sure to review our issue template before opening a new issue. The template includes a list of questions and prompts that will help us better understand the issue you're experiencing, and it will ensure that we have all of the necessary information to investigate the problem.
We kindly ask that you provide as much detail as possible when submitting an issue, including steps to reproduce the problem, any error messages that you have seen, and any other relevant information. This will help us to identify and fix the issue more quickly.
Thank you for your cooperation, and we look forward to hearing from you!
Distributed under Apache License . See LICENSE for more information
- Shiva Bhattacharjee - Shiva Bhattacharjee