Skip to content
/ Typee Public
forked from Typee-Language/Typee

A new generic object oriented programming language.

License

Notifications You must be signed in to change notification settings

PhHays/Typee

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Typhon

A new generic object-oriented programming language.

Want to Contribute?

If you wish to contribute, just contact main administrator Schmouk by e-mail and be patient. You will eventually get a response and will enthousiastically be added to the contributors list. Current developments are in Python 3.6, based on Anaconda 3, with Eclipse Photon framework and PyDev plug-in. Windows is currently used also for these developments. So, if you get Linux expertise you're welcome!

What is Typhon?

Typhon is an Object Oriented Programming language. Its syntax is derived from other OOP language such as C++11, Java 8.0 and Python 3.6.

Rationale

At first, this was a personnal project. It aimed at developping an upper layer to Python with a true type verification. This had already been partially addressed by Google with their project PyType. The kind of annotations this project proposes is now widely accepted and inserted in new Python code. PyType is a static analyzer that infers and checks types for Python code.

Pytype is a static type inferencer and type checker for Python code. It is capable of analyzing existing Python code to determine what possible types could be used on APIs throughout the program. (source: Google project PyType)

Well. This is not exactly full type checking - while it is perfectly adapted to Python programming for which no type declaration is needed before manipulating objects.

But we wanted to get a typed language to further translate it in Python code, full static type checking having been done before automatically generating Python modules then running the Python interpreter on them.

Typhon: neither compiled nor interpreted but translated

Traditionnal OOP languages are either compiled (e.g. C++) or interpreted (e.g. Python). They even may be first compiled into an intermediate code which is then interpreted (e.g. Java and its Bytecode interpreted by a Java Virtual Machine that has to be implemented on each of the different targetted devices).

Typhon is neither compiled nor interpreted. It is rather translated into other OOP languages, such as Python which chronologically is the first addressed OOP language from: Python, C++ and Java. During the translation, type infering and checking is done not only for APIs as does PyType but also on all the other parts of the code.

While this may seem to be valuable for untyped languages such as Python, it should appear to be not useful for other typed languages, of course. Yes, but wait...

Typhon: one code for many implementations

Here is the core usefulness of Typhon: once a program has been written in Typhon, it can then easily be translated in any other available OOP language. At first, this will be a translator to Python. But as soon as other translators will be available, e.g. for C++ or Java, the same code will be available for translation in these languages also.

As long as related libraries are added to the package (for instance graphical ones or GPU parallel programming ones) and are programmed in Typhon with dedicated code (i.e. native embedded code) for the targetted OOP language, it should be easy to program applications for Windows, Linux, iOS or Android with a single code programmed in Typhon.

Here we are!

Typhon language characteristics

We list here only the main characteristics of Typhon.

  • Object Oriented Programming;
  • typed variables and objects;
  • classical scalar types;
  • Templated on functions, methods and operators - as with templates in C++ and generics in Java while with bonuses on operators;
  • auto typing in specific cases - as with auto in C++ and as is by default in Python;
  • 'for' and 'if' comprehensions - as in Python;
  • built-in containers for objects - as in Python: list, set, dict, plus array;
  • classical instructions plus bonuses - e.g. else associated with for and while as in Python or with switch;
  • classical exception handling;
  • classical operators plus a few bonuses - e.g. 0-shifting as built in Java;
  • few undefined operators available for users specific definitions;
  • unnamed functions - as in Java or Python lambdas;
  • an embed instruction for the embedding of native code in Python, C++ or Java for instance;
  • and few other goodies you will enjoy to use.

While navigating in Typhon GitHub repository you will find numerous documentation on Typhon grammar specification, the Typhon translator software architecture (see short description below) or the whole software documentation - as generated in HTML by an open source application, PyYadc (Yet another documentation compiler).

Please be aware that this project is under construction and that currently NO running version is available. Documentation as well as directories tree and their contents are highly subject to change, actually on a daily or at least on a weekly basis.

Reminder: if you wish to contribute, just contact main administrator Schmouk by e-mail and be patient. You will eventually get a response and will enthousiastically be added to the contributors list.

Typhon global architecture

Typhon has been specified as would have been any compiler. Our bedside book for a long has been "Engineering a Compiler, 2nd Edition, Keith D.Cooper & Linda Torczon, Elsevier, 2012" and we encourage the reader to read this book. We have choosen this book because it was newer than the famous Dragoon book "Compilers, principles, techniques, & tools, 2nd ed." from Alfred V. Aho, Monica S. Lam, Ravi Ethi and Jeffrey D. Ullman, Pearson-Addison Wesley, 2007, while this Dragoon book had been used to specify the Python interpretor.

Global architecture of a compiler

A compiler is composed of a front-end, a back-end and an optimizer.

The Front-End

It contains a scanner that scans the code and generates a first level of intermediate code: the tokenized code.

The generated tokenized code is provided to a parser that parses the tokens and generates a second level of intermediate code: the IC. The parser parses this code and checks it for syntax correctness. Syntax errors are emitted during this step of the compilation.

The generated IC is finally passed to an elaborator that elaborates all the other checkings - such as types infering and checking, for instance. Not declared variables or objects, or types errors are emitted during this step of the compilation.

The Back-End

It generates the final binary code for the targetted processing unit. It gets as input the intermediate code IC as generated by the elaborator of the Front-End once this IC has been fully checked and validated. The Back-End output is a binary file that contains either executable code within a targetted Operating System or binary code and linkage metadata to be later linked with other code.

The Optimizer

According to the targetted processing unit, it optimizes the finally generated binary code. According to the IC generated by the Front-End it may also provide optimizations within the IC, e.g. by duplicating code of small functions rather than calling them (speed optimization) or by removing dead code as long as this can be statically detected (space optimization).

Global architecture of Typhon

Well, Typhon is a translator not a compiler. So, we only implement the Front-End and the Back-End steps of a compiler.

Typhon Front-End

As for any compiler, Typhon gets a scanner for the tokenization of the code, a parser for syntax checking and an elaborator for undeclared variables detection, types infering and types checking.

It generates an Intermediate Code and passes it to the Back-End as long as all checks are ok.

Typhon Back-End

The Typhon Back-End finalizes the translation to the targetted programming language. Remember, as a first step, Python is the targetted language. C++ and Java will come next.

According to this, the Back-End of Typhon contains as many generators as targetted languages, each of them generating the corresponding code to be either interpreted (Python) or compiled (C++, Java) with the corresponding interpreter / compiler.

Optimizer

Typhon implements no optimizer. This step is left to the final interpreters and compilers that will do a definitively correct job.

Final step

The final step for the user is then to run the compiler or the interpretor of the targetted language. Of course, this step can be automated via scripting and Typhon project aims at providing such scripts to ease the whole process.

That's it

Enjoy!

About

A new generic object oriented programming language.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published