Skip to content

Commit

Permalink
feat: improved examples to meet modified syntax and make the readme s…
Browse files Browse the repository at this point in the history
…lightly better
  • Loading branch information
Ze7111 committed Jul 24, 2024
1 parent 3d26802 commit 6f542fe
Show file tree
Hide file tree
Showing 19 changed files with 173 additions and 139 deletions.
165 changes: 87 additions & 78 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,101 +2,134 @@
<img src="../assets/helix-logo.svg" alt="Helix Programming Language Logo" width="100%">
</div>

<p align="center">
| <a href="https://www.helix-lang.com">Website</a> |
<a href="#helix-programming-language">Introduction</a> |
<a href="#why-helix">Why Helix?</a> |
<a href="#getting-started-with-helix">Getting Started</a> |
<a href="#goals">Goals</a> |
<a href="#community-and-contributing">Community</a> |
<a href="#license">License</a> |
</p>
| [Website](https://www.helix-lang.com) | [Introduction](#helix-programming-language) | [Why Helix?](#why-helix) | [Getting Started](#getting-started-with-helix) | [Goals](#goals) | [Community](#community-and-contributing) | [License](#license) |

# Helix Programming Language

Helix is an experimental language designed for seamless interoperability with Python, C, C++, and Rust. The project aims to provide developers with a fast, efficient, and easy-to-use language that can leverage the power of existing code and libraries in these languages. With its clean syntax and robust features, Helix aims to simplify the process of writing and maintaining code while maximizing performance.

----
--------------------------------------------------------------------------------

<div>
<img src="../assets/helix-code-example.png" width="450" align="right"
alt="Code Example">
</a>
<img src="../assets/showcase.png" width="450" align="right" alt="Code Example">
</div>

### Why Helix?
## Why Helix?

- **Performance**: Optimized for speed and efficiency, making it ideal for critical applications and systems programming.
- **Interoperability**: Seamlessly integrates with C++, Rust, and Python, allowing you to leverage existing codebases.
- **Productivity**: Advanced tooling, including a robust standard library, package manager, and build system.
- **Safety**: Strong type system and error handling to catch bugs at compile-time and runtime.

### Features
## Features

- **Concurrent Programming**: Easy-to-use async/await syntax for concurrent tasks.
- **Pattern Matching**: Powerful pattern matching for more readable and maintainable code.
- **Macros and Pre-Processors**: Extensible macros and pre-processors for code generation and optimization.
- **Rich Standard Library**: Extensive libraries to handle various programming tasks out of the box.
- **Object-Oriented Programming**: Support for classes and objects, enabling encapsulation, inheritance, and polymorphism for modular and reusable code.

## Helix Syntax Examples

### Unique Type System

Helix supports strong typing and flexible typing (like python) with a unique type bounding generic system:

<div align="left"><img src="../assets/type-bounds-example.png" alt="variables and types example" width="350">
<a href="#">
<img src="../assets/bumper.png">
</a></div>

### Native Interoperability

Helix has native interop with (python, rust, c and c++) out of the box, with many more in the works by the community:

<div align="left"><img src="../assets/ffi-example.png" alt="functions and classes example" width="450">
<a href="#">
<img src="../assets/bumper.png">
</a></div>

### Async Programming

Handle asynchronous tasks easily with `async` and `await`:

---
<div align="left"><img src="../assets/async-example.png" alt="async programming example" width="500">
<a href="#">
<img src="../assets/bumper.png">
</a></div>

--------------------------------------------------------------------------------

### Quick Start

#### Installation & Build

> [!WARNING]
> Helix is currently under development and does not yet have a useable compiler. The following instructions are for development and building the compiler itself.
> [!WARNING] Helix is currently under development and does not yet have a useable compiler. The following instructions are for development and building the compiler itself.
> [!NOTE]
> Linux is not tested, Most development is done on MacOS, if any issues arise with building on Windows or Linux, please open an issue.
> [!NOTE] Linux is not tested, Most development is done on MacOS, if any issues arise with building on Windows or Linux, please open an issue.
##### Prerequisites

- [xmake](https://xmake.io/#/)
- [python](https://www.python.org/downloads/)
- git
- C++ Compiler and STL (**clang**, **msvc** or **gcc**)

##### Windows

1. Clone the repo
```sh
$ git clone https://github.com/kneorain/helix-lang.git
$ cd helix-lang
```

```sh
$ git clone https://github.com/kneorain/helix-lang.git
$ cd helix-lang
```

2. Build
```sh
$ xmake build helix
```

```sh
$ xmake build helix
```

3. Run
```sh
$ xmake run helix
```

```sh
$ xmake run helix
```

##### MacOS, Unix or Linux

1. if you don't have python or xmake installed, install using [Homebrew](https://brew.sh/)
```sh
$ brew install xmake python
```
```sh
$ brew install xmake python
```
2. Clone the repo
```sh
$ git clone https://github.com/kneorain/helix-lang.git
$ cd helix-lang
```
```sh
$ git clone https://github.com/kneorain/helix-lang.git
$ cd helix-lang
```
3. Build
```sh
$ xmake build helix
```
```sh
$ xmake build helix
```
4. Run
```sh
$ xmake run helix
```
---
```sh
$ xmake run helix
```
--------------------------------------------------------------------------------
### Hello, World!
Here's how you can write and run a simple "Hello, World!" program in Helix:

```rs
```rust
fn main() {
print("Hello, World!");
}
Expand All @@ -109,36 +142,8 @@ helix hello_world.hlx
./hello_world
```

## Getting Started with Helix
##### Variables and Types
Helix supports strong typing and flexible variable declarations:
<div align="left">
<img src="../assets/variable-exmaple.png" alt="variables and types example" width="350">
<a href="#"><img src="../assets/bumper.png"></a>
</div>

##### Control Flow
Helix provides familiar control flow constructs like `if`, `while`, and `for`:
<div align="left">
<img src="../assets/control-flow-exmaple.png" alt="control flow example" width="400">
<a href="#"><img src="../assets/bumper.png"></a>
</div>

##### Async Programming
Handle asynchronous tasks easily with `async` and `await`:
<div align="left">
<img src="../assets/async-example.png" alt="async programming example" width="500">
<a href="#"><img src="../assets/bumper.png"></a>
</div>

##### Functions and Classes
Define functions and classes along with other data structures with clear and concise syntax:
<div align="left">
<img src="../assets/function-example.png" alt="functions and classes example" width="450">
<a href="#"><img src="../assets/bumper.png"></a>
</div>

## Goals

The Helix project aims to achieve the following goals:

- **Interoperability**: Helix will provide seamless interoperability with Python, C, C++, and Rust, allowing developers to integrate code from these languages with ease.
Expand All @@ -156,30 +161,34 @@ The Helix project aims to achieve the following goals:
- **Error Handling**: The language will provide robust error handling features to help developers write reliable and resilient code.

## Community and Contributing

Helix is an open-source project and we welcome contributions from the community. Whether you're fixing a bug, improving the documentation, or adding a new feature, we'd love to have your help!

- [Submit issues](https://github.com/kneorain/helix-lang/issues) and [pull requests](https://github.com/kneorain/helix-lang/pulls) on GitHub.
- Read our [Contributing Guide](CONTRIBUTING.md) to get started.

## License

Helix is released under the Attribution 4.0 International License. See the [LICENSE](https://github.com/kneorain/helix-lang/blob/main/license) file for details.

## Acknowledgements

The Helix project is made possible by the hard work and dedication of our contributors. Thank you to everyone who are helping make Helix a reality!

<div align="center">
<a href="https://github.com/kneorain/helix-lang/graphs/contributors">
<img src="https://contrib.rocks/image?repo=kneorain/helix-lang" />
</a>
<img src="https://contrib.rocks/image?repo=kneorain/helix-lang">
</a>
</div>

---
--------------------------------------------------------------------------------

Happy coding with Helix! 🚀

---
--------------------------------------------------------------------------------

### Links

- [Official Website](https://helix-lang.com)
- [Documentation](https://helix-lang.com/docs)
- [Tutorials](https://helix-lang.com/tutorials)
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file modified assets/async-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions assets/code/async-example.hlx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import std::future::{Future};

async fn fetch_data() -> string {
std::sleep(2000); // Simulate a long-running task
return "Data fetched";
return 1..10;
}

fn main() {
let future: Future = spawn fetch_data(); // start a os-manged child process
let data = await future;
println(data);

for i in data:
print(f"{i=}", end=", ");

print();
}
14 changes: 14 additions & 0 deletions assets/code/ffi-example.hlx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ffi "python" import sympy as sp;
ffi "c++" import "circle.hh";

fn main() {
let eq1: sp::Eq = sp::Eq(x + y, 10)
let eq2: sp::Eq = sp::Eq(x - y, 4)
let solutions = sp.solve((eq1, eq2), (x, y)); // type inferd by the compiler

print(solutions);

let circle = circle::Circle{10, 20};

print(circle->to_string());
}
29 changes: 0 additions & 29 deletions assets/code/function-example.hlx

This file was deleted.

19 changes: 10 additions & 9 deletions assets/code/showcase.hlx
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
struct Point {
class Point {
let x: int;
let y: int;

fn new(x: int, y: int) -> Point {
return Point{ x: x, y: y };
eval fn Point(self, x: int, y: int) {
self.x = x;
self.y = y;
}

fn move(&self, dx: int, dy: int) {
fn move(self, dx: int, dy: int) {
self.x += dx;
self.y += dy;
}

fn display(&self) {
print(f"Point at ({point.x}, {point.y})");
fn display(self) {
print(f"Point at ({self.x}, {self.y})");
}
}

fn main() {
let p: Point = Point::new(0, 0);
let p = Point(0, 0);

for i in range(1, 4) {
for i in 1..4 {
p.move(i, i);
p.display();
}

let value: int = p.x;
let value: u32 = p.x as u32;

match value {
0 -> print("The point is at the origin"),
Expand Down
Loading

0 comments on commit 6f542fe

Please sign in to comment.