Comparing version
{ | ||
"name": "eslang", | ||
"version": "1.0.22", | ||
"version": "1.0.23", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "email": "leevi@nirlstudio.com", |
128
README.md
# Espresso Script Language - eslang | ||
### A simple & expressive script language, which is inspired by Lisp, Python, JavaScript and many other great languages. | ||
## A simple & expressive script language, which is inspired by Lisp, Python, JavaScript and many other great languages. | ||
```lisp | ||
@@ -14,3 +14,3 @@ print "Hello, world!"; | ||
# Try it online | ||
### [Espresso Web Shell](https://eslang.dev) | ||
## [Espresso Web Shell](https://eslang.dev) | ||
```lisp | ||
@@ -40,21 +40,24 @@ help; # for help. | ||
# display item no. for counting | ||
.loader list "examples/":: for-each (= (item, no.) (print '#$(no.), $(item 0)'); | ||
# or use the for loop | ||
for (.loader list "examples/") (print (_ 0); | ||
# display path only | ||
.loader list "examples/":: for-each (= (item, no.) (print '#$(no.),', (var url (item 0):: slice (url first-of "examples/"); | ||
# add some decoration | ||
for (.loader list "examples/") (printf (_ 0), "blue underline") (printf '# $(_ 1)\n', "gray"); | ||
# Q: What's happening? | ||
var print-examples (=>:() (var examples (.loader list "examples/")) (=> pattern (examples for-each (=> (item, no.) (print (string format (pattern ?* "{0}, {1}, {2}"), no., (item 0), (item 1); | ||
# or better formatted as | ||
(for (.loader list "examples/") | ||
printf (_ 0), "blue underline"; | ||
printf '# $(_ 1)\n', "gray"; | ||
). | ||
# As a hint, here's a (more) friendly version. | ||
(var print-examples (=>:() | ||
var examples (.loader list "examples/"); | ||
(=> pattern | ||
(examples for-each (=> (item, no.) | ||
print (string format (pattern ?* "{0}, {1}, {2}"), no., (item 0), (item 1); | ||
# or use explicit variable name | ||
(for (item, no.) in (.loader list "examples/") | ||
printf '$no. ', "bold"; | ||
printf (item 0), "blue underline"; | ||
printf '# $(item 1)\n', "gray"; | ||
). | ||
# You may also want to check | ||
print print-examples; | ||
# with some stylish helpers | ||
var * (import "es/styles"); | ||
for (.loader list "examples/") (blue underline (_ 0))(gray '# $(_ 1)\n'); | ||
@@ -72,12 +75,19 @@ # Finally, the Y-combinator in Espresso | ||
### run an example, or your own code: | ||
## run an example, or your own code: | ||
```shell | ||
es examples/qsort1 | ||
# or run the example test suite | ||
es test examples/test | ||
# or just | ||
es test examples | ||
``` | ||
### REPL in terminal: | ||
## REPL in terminal: | ||
```shell | ||
es | ||
``` | ||
### You can do [almost the same things](#try-it-online) after calling | ||
## You can do [almost the same things](#try-it-online) after calling | ||
```lisp | ||
@@ -87,3 +97,3 @@ fetch "https://eslang.dev/@"; | ||
# or try | ||
fetch "https://eslang.dev/@":: finally (=>() (.loader list:: for-each print); | ||
fetch "https://eslang.dev/@":: finally (=>() (for (.loader list) (print (_ 0); | ||
``` | ||
@@ -94,3 +104,3 @@ | ||
```shell | ||
npm i --save eslang | ||
> npm i --save eslang | ||
``` | ||
@@ -104,6 +114,9 @@ | ||
### use [es-npm](https://www.npmjs.com/package/@eslang/es-npm) to create projects | ||
```shell | ||
npm i -g @eslang/es-npm | ||
es-npm | ||
### due to the re-design, the new ES package management tool, esp, will come soon | ||
The new ES package/module system is fully de-centralized. It only depends on any public or your own git server. Of course, you can still use any npm package as easy as, e.g. | ||
```lisp | ||
var axios (import "$axios"); | ||
# and of course, any node core package, e.g. | ||
var fs (import "$fs"); | ||
``` | ||
@@ -113,12 +126,15 @@ | ||
```shell | ||
git clone https://github.com/NirlStudio/eslang.git | ||
cd eslang | ||
# download the code | ||
> git clone https://github.com/NirlStudio/eslang.git | ||
> cd eslang | ||
npm install | ||
npm test | ||
# setup development environment. | ||
> npm install | ||
> npm test | ||
bin/es | ||
# run local version. | ||
> bin/es | ||
# or, start the local web shell | ||
npm run build & npm start | ||
npm npm start | ||
``` | ||
@@ -129,3 +145,5 @@ | ||
In Extensions sidebar, search for **eslang** | ||
note: new language server is under development and will be implemented by ES itself. | ||
### Atom Plugin | ||
@@ -137,3 +155,48 @@ [*language-espresso*](https://github.com/NirlStudio/language-espresso) | ||
# You can help to | ||
# Why it's created? A very long story ... | ||
Profoundly, it's motivated by the thinking of simplicity vs. complexity. After that, it came up with something more solid to be suitable for some kind of self-evolution general AI. So it tries some totally different programming language design philosophies. | ||
## Some principles | ||
### Simpler is better. | ||
- Don't reinvent the wheel. | ||
- Don't try to solve the unsolvable part of a problem. | ||
### No error, raise warnings to the worst situation. | ||
- No syntax error. It's purposed to compare its design with the structures of natural languages. In some future, with a AI-backed sematic processor, more annoying punctuations may be skipped. | ||
Above all the sweetener and/or mess, there's only two type of statement: | ||
```lisp | ||
(subject predicate object[s]) | ||
# or its imperative form | ||
(command object[s]) | ||
``` | ||
_note: As an extreme example, it's in serious consideration to render symbols by their parts of speech instead of type._ | ||
- All statements (all pieces of free texts) will be evaluated and give a result. Of course, a piece of code written by a lovely monkey will very likely be evaluated to nothing/null. But who knows. | ||
_note: Not all our DNA fragments are useful. But again, who knows._ | ||
_note: Actually, in the real world, a program breaks because we make it so, but it ultimately become to break unnecessarily. | ||
### Keep backward compatibility, as possible as you, the honorable creator, can. | ||
- If it changed, it's different. Probably it should bear a new name instead of a different version number. | ||
- If some software patrons choose to use old applications for decades, they should be allowed to do it. Probably hundreds of years make sense too. | ||
## Some tips for ES lang patrons | ||
### - Look for what you need, ignore what you do not understand. | ||
### - Do what you can do anywhere and anytime. | ||
### - Use convention over restriction. So it can be broken in a clean way, not an ugly way, when someone have to. | ||
### - Consider types as a kind information to help to optimise, not to restrict. | ||
## You can use it to | ||
### create both you backend and frontend applications. | ||
### build your own programming lang or just create a different dialect, e.g: make it fully localized to your own language. | ||
## You can help to | ||
### - Test it in various OSes and browsers. | ||
@@ -149,2 +212,3 @@ ### - Use it in your projects. | ||
**Enjoy the Espresso.** |
1512132
0.17%205
45.39%