Overview
*First, glance at the Fine Print at the
foot of the document...
Twilight is an imperative, object
oriented, general purpose programming language. The guiding
principles of Twilight are simplicity, practicality, and
orthogonality. It is a language which is easy to learn and to be
productive in. An experienced programmer in Python, Java, C# or C++
will be able to pick up Twilight in a short period of time.
Motivation:
Why another language? There are a number of excellent languages out there, but I was after a specific set of features all of which I wanted to be able to use from within a single language environment and with a consistent, orthagonal syntax.
Features:
- Object Oriented Syntax with single inheritance and polymorphism
- Name and deployment modularity (name spaces, shared libraries)
- Operator overloading, +, -, *, %, etc are translated into method calls, allowing for convenient syntax for many common operations
- Convenient loop and conditional constructs, including foreach, for, while, and a continuous loop
- Simplified scoping, a variable may be a member (scoped by instance) or local to a method (where it is available everywhere in the method, much like Python). There is built in support for singletons which effectively provides a global scope as well.
- Method overloading based on number of arguments
- Convenient accessor handling, if no accessor methods are defined an optimized "direct" get is performed, later an accessor method can be added with no change to calling code
- Compilation to native code - no interpreter overhead
- Both static and dynamic typing - static for greater optimization and early discovery of certain coding errors, dynamic for greater productivity for prototyping or "quick and dirty" projects
- Automatic Memory Management (Garbage Collection)
- Exceptions
- Multi Threading (not yet implemented) (no artificial barriers to thread performance, e.g. reference counting)
- Simplicity, with an emphasis on building functionality in the class library
- An Open Source implementation
- Sooner rather than later
Implementation:
The ultimate product of Twilight is natively compiled code, a combination of library and executable, and header files required to use library code from other Twilight programs. This is presently achieved through generation of C code and compilation to native code.
The obligatory “Hello World”
--BEGIN HelloWorld.tw--
class Hello:World {
sub main() {
"Hello World".print();
}
}
--END HelloWorld.tw
TWX_StdLib.exe -buildFile buildFiles/buildTest.txt -deployPackage deployTest/HelloWorld -buildPath buildTest/HelloWorld -compileUnit StdLibTest_HelloWorld -main Hello:World HelloWorld.tw
For those adverse to typing, view the Examples/HelloWorld.tw file and execute the following command line to build it instead of your own:
TWX_StdLib.exe -buildFile Examples/buildFiles/helloWorld.txt
There will be a fair bit of output regarding the build and compile
process, followed, if all goes well, with “Hello World”
output to the console
For more information about the language
and to start working with it see Getting Started and Examples and Tutorials
*Fine Print:
This documentation is placed in the
Public Domain.
The information in this documentation
is provided in the hope it will be useful but includes NO WARRENTY
express or implied. Microsoft Windows and Windows are tradmarks of
Microsoft Inc, Redmond WA, Apple, Macintosh and MacOS are trademarks
of Apple Computer Inc, Cupertino CA, all other tradmarks referenced
herein property of their respective owners
