Skip to content

Commit 36061e4

Browse files
authored
Merge pull request #60 from nature-lang/feature/arm64
feat: basic support arm64
2 parents 45166f0 + 8c48feb commit 36061e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+7868
-3803
lines changed

README.md

+1-184
Original file line numberDiff line numberDiff line change
@@ -59,51 +59,6 @@ Quickly compile and execute using the docker integrated environment:
5959
docker run --rm -it -v $PWD:/app --name nature naturelang/nature:latest sh -c 'nature build main.n && ./main'
6060
```
6161
62-
## 🌱 Release Schedule
63-
64-
Nature's versioning adheres to [Semantic Versioning](https://semver.org/). Versions 0.1 ~ 1.0 have two parts:
65-
66-
The first half always has a beta indication, denoting that it's not ready for production.
67-
68-
The second half is stable with backward-compatible syntax API. By this time, nature is suitable for personal indie/open-source projects, but LTS versions aren't provided.
69-
70-
With the release of version 1.0, nature will be officially used for open-source/commercial projects and will have an LTS version.
71-
72-
| Version | Content | Expected Release Date |
73-
| ----------- | -------------------------------------------- | --------------------- |
74-
| v0.1.0-beta | Basic syntax release | 2023-05 |
75-
| v0.2.0-beta | Type system/Basic syntax refinement | 2023-07 |
76-
| v0.3.0-beta | Package management/Basic syntax refinement | 2023-09 |
77-
| v0.4.0-beta | Small test cases/Basic standard library | 2023-11 |
78-
| v0.5.0-beta | LSP development/Core syntax refinement | 2024-02 |
79-
| v0.6.0-beta | Medium test cases/bug fixes | 2024-04 |
80-
| v0.7.0 | Large test cases/Stable syntax API | 2024-07 |
81-
| v0.8.0+ | Preparations for the official release | 2024-09 |
82-
| v1.0.0 | Official release | 2025- |
83-
84-
Current version: 0.4.0-beta. Key functionalities still being planned will be gradually integrated in upcoming versions.
85-
86-
- Integration and optimization of essential syntaxes like switch/try
87-
- wasm architecture compilation
88-
- Coroutine support
89-
- Compilation for the darwin system
90-
- Function tags support
91-
- Progressive GC refinement
92-
- riscv architecture compilation
93-
- Compilation for the windows system
94-
95-
## 🧭 Design Philosophy
96-
97-
In programming languages, there's a notion of first-class citizens. For example, in JavaScript, functions are the first-class citizens. Although in nature, functions can also be passed as values and have higher-order usages, they aren't its first-class citizens. So, what's most important for nature?
98-
99-
Compilation speed? Execution speed? Safety? Simplicity? None of these. Even though we aim for simplicity, we won't compromise on developer convenience.
100-
101-
For nature, the developer is paramount. We prioritize offering convenience, ensuring the code is aesthetically pleasing and intuitive. That's not to say nature doesn't provide fast compilation/execution, safety, simplicity, etc. We aim to balance these attributes with user-friendliness. However, when conflicts arise, the developer's convenience takes precedence.
102-
103-
For instance, despite most strong-typed languages opting for double quotes for standard strings, we chose single quotes to save a shift input, reducing strain on the pinky and offering a more concise read. The omission of brackets in 'if' and 'for' also stems from this principle.
104-
105-
Nature rarely introduces new syntactic sugar. Instead, we often choose already-existing, widely-recognized syntactic sugar from other languages, easing the learning curve and mental load for developers. Keyword abbreviations also follow popular abbreviations, e.g., i8 instead of int8_t, fn instead of func/function. fn is a common keystroke, and Rust has already popularized fn/i8, hence it drastically reduces potential misunderstandings and learning burdens.
106-
10762
## 🍺 Contribution Guide
10863
10964
There are many ways to contribute to nature: reporting BUGs, sharing ideas, participating in community discussions, coding, improving documentation, establishing standards, contributing resources, donations, and more.
@@ -123,145 +78,7 @@ Github Discussion Community: [https://github.com/nature-lang/nature/discussions]
12378
12479
## 🍼 Coding Example
12580
126-
Error Handling:
127-
128-
```rust
129-
type test = struct {
130-
[i8] list
131-
var div = fn(int a, int b):int {
132-
if b == 0 {
133-
throw 'divisor cannot be zero'
134-
}
135-
return a / b
136-
}
137-
}
138-
139-
var t = test {
140-
list = [1, 2, 3, 4, 5]
141-
}
142-
143-
var (item, err) = try t.list[8]
144-
if err.has {
145-
println("chain access list error=", err.msg)
146-
}
147-
148-
var (_, err) = try t.div(10, 0)
149-
if err.has {
150-
println("division error", err.msg)
151-
}
152-
```
153-
154-
Generics:
155-
156-
```rust
157-
// generic fn
158-
type numbert = gen i8|i16|i32|i64|u8|u16|u32|u64|f32|f64
159-
160-
fn sum(numbert a, numbert b):numbert {
161-
return a + b
162-
}
163-
fn cmp(numbert a, numbert b):bool {
164-
return a > b
165-
}
166-
167-
// type param
168-
type box<t> = struct {
169-
t width
170-
t length
171-
var area = fn(self s):t {
172-
return s.width * s.length
173-
}
174-
}
175-
176-
fn run() {
177-
var b = box<i8> {
178-
width = 5,
179-
length = 10
180-
}
181-
println('self area=', b.area())
182-
}
183-
184-
```
185-
186-
Union Types:
187-
188-
```rust
189-
type nullable<t> = t|null
190-
191-
nullable<i8> foo = 24
192-
if foo is null {
193-
// logic...
194-
return
195-
}
196-
197-
// x println(foo + 12), foo is a union type, cannot use binary
198-
199-
let foo as i8
200-
println(foo + 12)
201-
```
202-
203-
Function Tags:
204-
205-
```java
206-
@local @retry=5
207-
@test 24, 10 -> 4
208-
@test -5, 10 -> -5
209-
fn rem(int dividend, int divisor):int {
210-
if divisor == 0 {
211-
throw 'divisor cannot be zero'
212-
}
213-
return dividend % divisor
214-
}
215-
216-
@global @post increase_views
217-
fn read_blog():int {
218-
// logic ...
219-
}
220-
221-
@comment Based on label prompt + test for automatic code generation testing
222-
@prompt sum up a and b
223-
@test 12, 13 -> 25
224-
@test -5, 10 -> 5
225-
fn sum(int a, int b):int {}
226-
```
227-
228-
HTTP Server:
229-
230-
```js
231-
import http
232-
import http.router
233-
import http.resp
234-
235-
var app = http.server()
236-
237-
router.get('/', fn(ctx):resp {
238-
return resp.string('hello world')
239-
})
240-
241-
app.use(router).listen('127.0.0.1', 8000)
242-
```
243-
244-
For more coding examples 👉 [cases](https://github.com/nature-lang/nature/tree/master/tests/blackbox/cases)
245-
246-
## 📌 FAQ
247-
248-
1.Does nature use type prefix or suffix?
249-
250-
Nature consistently uses type prefixing, including the return type of functions. A primitive design example:
251-
252-
`fn sum(int a, int b):int c` shows that the function return type also uses type prefixing. Omitting all idents can lead to the function type declaration `fn(int,int):int`. Typically, the return value's ident also needs to be omitted, resulting in the formal function declaration `fn sum(int a, int b):int {}`.
253-
254-
2.What is the meaning of nature/logo?
255-
256-
The logo represents a spaceship, symbolizing the "Natural Selection" ship from "Three-Body". The name "nature" is derived from this.
257-
258-
3.Why isn't there any performance testing and comparison?
259-
260-
Nature is currently in its beta phase focusing on core functionality development. There hasn't been any optimization done on the compiler backend. Hence, performance testing would be unfair and meaningless.
261-
262-
4.How long has nature been in development?
263-
264-
The main repository has been under development for almost 3 years. The actual time invested is close to 6 years. What I want to emphasize is that the Nature project won't be abandoned arbitrarily and will be continuously developed and maintained with vitality.
81+
coding examples 👉 [cases](https://github.com/nature-lang/nature/tree/master/tests/cases)
26582
26683
## 🪶 License
26784

0 commit comments

Comments
 (0)