ovr / StaticScript

:rocket: TypeScript compiler on top of TypeScript as frontend and LLVM as backend
Other
629 stars 29 forks source link

Roadmap & Ideas #8

Open ovr opened 5 years ago

ovr commented 5 years ago

General

StaticScript language should be compatibility with TypeScript as it possible but with additional features

JS Types:

Statements:

Tooling:

Objects and classes

There will be two types of objects:

Static object

It's not possible to mutate (add/drop fields from this objects), object are structures that mapped directly to memory and methods are functions with pointer to structure (this)

Dynamic objects

Unoptimized objects that will be V8 objects

Feel free to add ideas by comments

Advanced features of StaticScript

Types:

To implement it, we need to use own fork of TypeScript (https://github.com/static-script/TypeScript) and implement base support inside Frontend part

Own standart library:

Implement standart library on StaticScrtipt

This issue will be updated when new ideas will come :)

ghost commented 5 years ago

Great job ovr, I'm looking forward to this project.

lantos1618 commented 4 years ago

Cool project. Have you any ideas on how you're going to implement Async/await? also add dependency list cmake, make, llvm version...

rishavs commented 4 years ago

Will npm be used for project management? can we have ssc invokable by npx?

aiko-is-bored commented 3 years ago

Hello! I've actually a few ideas and wanted to rewrite an implementation of this project from scratch.

  1. Undefined: Just another way of saying null.

  2. Null: Use LLVM's getNull for floats. Every "Number" is just a floating point in LLVM. Strings are just just string-primitive as an object. Objects are the real kicker here.

  3. Objects: Use a dictionary-like structure. We can implement hash-tables easily. Simply put, we store strings, etc, in a hash table. This allows for easy, fast access in non-class objects, and even easier sharing. For example, console.log tells the compiler to find console, and then grab the hashed log element. We can easily extend the c-like string primitives as an object. But, it doesn't have to be that hard. Instead, we can just create a Java or C++ like class, and implement the new keyword found here: https://mapping-high-level-constructs-to-llvm-ir.readthedocs.io/en/latest/object-oriented-constructs/index.html

There are a few reworks I'm looking for here. The first one is the console_log. We want to have said support for the following things:

This will make programming and our life a lot easier. My idea for this is to make the modules like Go-ish.

import 'io'

function helloWorld(): Undefined {
   io.log("Hello world!") // <- or console.log("Hello world!")
}

helloWorld();

This allows for better, easier code. We also would want an args lib, preferably one with a default parsing algorithm, which is very possible. Check out https://godbolt.org/ to help. Try using C or C++ to get an array of arguments.

aiko-is-bored commented 3 years ago

Also, by default, functions should be LLVM's void.

hinell commented 3 years ago

@aiko-is-bored I think it's generally bad idea to reinvent the wheel. Only if you want to do it just for fun.