|
1 |
| -# Ash-j Programming Language |
| 1 | +# ashj Programming Language |
2 | 2 |
|
3 |
| -**Ash-j** is a java implementation of the Ash programming language. jAsh is hugely influenced by **jlox**. |
| 3 | +Welcome to **ashj**, a lightweight, interpreted, object-oriented programming language. ashj is inspired |
| 4 | +by [Lox](http://www.craftinginterpreters.com/), a language developed in the book *Crafting Interpreters* by Robert |
| 5 | +Nystrom. ashj takes the core concepts of Lox and adds a unique twist, making it a powerful tool for developers |
| 6 | +interested in simplicity and expressiveness. |
4 | 7 |
|
5 |
| -## Difference from jlox |
| 8 | +## Table of Contents |
6 | 9 |
|
7 |
| -1. Added escape character support |
| 10 | +- [Introduction](#introduction) |
| 11 | +- [Getting Started](#getting-started) |
| 12 | +- [Features](#features) |
| 13 | +- [Installation](#installation) |
| 14 | +- [Usage](#usage) |
| 15 | +- [Examples](#examples) |
| 16 | +- [Contributing](#contributing) |
| 17 | +- [License](#license) |
8 | 18 |
|
9 |
| -_Thanks to Robert Nystorm and his amazing book Crafting interpreters for making this possible._ |
| 19 | +## Introduction |
| 20 | + |
| 21 | +ashj is a dynamic, interpreted programming language that supports object-oriented programming, functional programming |
| 22 | +paradigms, and more. It's designed to be simple and easy to learn, making it an excellent choice for beginners, as well |
| 23 | +as a convenient scripting language for experienced developers. |
| 24 | + |
| 25 | +Inspired by Lox, ashj retains the elegance and minimalism of its predecessor while introducing improvements and |
| 26 | +enhancements tailored for modern development. |
| 27 | + |
| 28 | +AshJ is implemented in **Java** and utilizes an **Abstract Syntax Tree (AST)** for interpreting code. This design makes |
| 29 | +it straightforward to extend and maintain. Additionally, a **C bytecode implementation** of AshJ, named **Ash**, is |
| 30 | +available [here](https://github.com/yahyafati/ash-lang), offering a more performance-oriented alternative. |
| 31 | + |
| 32 | +## Getting Started |
| 33 | + |
| 34 | +### Prerequisites |
| 35 | + |
| 36 | +- **Java 8** or later installed on your machine. |
| 37 | + |
| 38 | +### Installation |
| 39 | + |
| 40 | +Download the latest version of ashj from the [releases page](https://github.com/yahyafati/ashj-lang/releases). Once |
| 41 | +downloaded, you can run the installer for your operating system: |
| 42 | + |
| 43 | +- **Windows**: Run the `.exe` installer. |
| 44 | +- **macOS**: Run the `.pkg` installer. |
| 45 | +- **Linux**: Run the `.deb` or `.rpm` package installer. |
| 46 | + |
| 47 | +### Running ashj |
| 48 | + |
| 49 | +After installation, you can run ashj from the command line: |
| 50 | + |
| 51 | +```bash |
| 52 | +ashj path/to/your/script.ashj |
| 53 | +``` |
| 54 | + |
| 55 | +Or start an interactive REPL session: |
| 56 | + |
| 57 | +```bash |
| 58 | +ashj |
| 59 | +``` |
| 60 | + |
| 61 | +## Features |
| 62 | + |
| 63 | +- **Object-Oriented**: Supports classes and inheritance, allowing for the creation of complex data structures. |
| 64 | +- **First-Class Functions**: Functions in ashj can be passed around as first-class citizens, allowing for higher-order |
| 65 | + functions and functional programming techniques. |
| 66 | +- **Dynamic Typing**: Variables in ashj are dynamically typed, making it flexible and easy to use. |
| 67 | +- **Garbage Collection**: Automatic memory management through garbage collection. |
| 68 | +- **Lexical Scoping**: Supports block-scoped variables. |
| 69 | +- **Lightweight**: Minimalist language design for quick execution and fast development cycles. |
| 70 | + |
| 71 | +## Usage |
| 72 | + |
| 73 | +### Basic Syntax |
| 74 | + |
| 75 | +Here’s a quick overview of the syntax in ashj: |
| 76 | + |
| 77 | +```java |
| 78 | +// Variables |
| 79 | +var name = "ashj"; |
| 80 | +var age = 3 + 4; |
| 81 | + |
| 82 | +// Functions |
| 83 | +fun greet() { |
| 84 | + print "Hello, " + name + "!"; |
| 85 | +} |
| 86 | + |
| 87 | +greet(); // Outputs: Hello, ashj! |
| 88 | + |
| 89 | +// Classes |
| 90 | +class Animal { |
| 91 | + init(type) { |
| 92 | + this.type = type; |
| 93 | + } |
| 94 | + |
| 95 | + speak() { |
| 96 | + print "This is a " + this.type; |
| 97 | + } |
| 98 | +} |
| 99 | + |
| 100 | +var dog = Animal("Dog"); |
| 101 | +dog. |
| 102 | + |
| 103 | +speak(); // Outputs: This is a Dog |
| 104 | +``` |
| 105 | + |
| 106 | +### Control Structures |
| 107 | + |
| 108 | +```java |
| 109 | +// If-Else Statements |
| 110 | +if(age >18){ |
| 111 | +print "Adult"; |
| 112 | + }else{ |
| 113 | +print "Not an Adult"; |
| 114 | + } |
| 115 | + |
| 116 | +// While Loop |
| 117 | +var count = 0; |
| 118 | +while(count< 3){ |
| 119 | +print count; |
| 120 | +count =count +1; |
| 121 | + } |
| 122 | + |
| 123 | +// For Loop |
| 124 | + for( |
| 125 | +var i = 0; |
| 126 | +i< 5;i =i +1){ |
| 127 | +print i; |
| 128 | +} |
| 129 | +``` |
| 130 | + |
| 131 | +## Examples |
| 132 | + |
| 133 | +To see more examples, check out the `examples` directory in this repository. You can run these examples using the ashj |
| 134 | +interpreter: |
| 135 | + |
| 136 | +```bash |
| 137 | +ashj examples/hello_world.ashj |
| 138 | +``` |
| 139 | + |
| 140 | +## Contributing |
| 141 | + |
| 142 | +Contributions are welcome! If you have ideas for new features or have found bugs, please open an issue or submit a pull |
| 143 | +request. See the `CONTRIBUTING.md` file for more details. |
| 144 | + |
| 145 | +## License |
| 146 | + |
| 147 | +ashj is licensed under the MIT License. See the `LICENSE` file for more information. |
| 148 | + |
| 149 | +Certainly! Here’s how you can include an **Acknowledgements** section in your `README.md` file: |
| 150 | + |
| 151 | +--- |
| 152 | + |
| 153 | +## Acknowledgements |
| 154 | + |
| 155 | +AshJ would not have been possible without the inspiration and guidance provided by Robert Nystrom's book, *Crafting |
| 156 | +Interpreters*. This book offers a comprehensive guide to building interpreters from scratch, and its implementation of |
| 157 | +Lox served as the foundation for AshJ. |
| 158 | + |
| 159 | +A special thanks to Robert Nystrom for his incredible work in the programming community and for making *Crafting |
| 160 | +Interpreters* freely available to everyone. If you're interested in understanding the inner workings of interpreters, we |
| 161 | +highly recommend checking out his book at [craftinginterpreters.com](http://www.craftinginterpreters.com/). |
0 commit comments