# Elan 2.0

- It applies the technology and philosophy of Elan to coding in Python, VB, C#, and Java.
- It can convert code instantly between these languages.
- Code in all languages is saved as a .elan file in a language neutral format, called the 'Reference Language'. Only .elan files may be loaded into the IDE, though after loading they will then be automatically translated into the target language, which is saved in the 'header comment' of the file.
- You may 'export' code (via the File menu) as, for example, a .py file, for loading into a different IDE. Note that the exported code may still be using Elan library methods and Types. However, we will – before the full 2.0 release – be making a version of the Elan library available as native .py, .vb, .cs, and .java code to facilitate running a program written in Elan within another IDE.
As well as writing code directly in Python, VB, C#, or Java, you can write and run code directly in the Reference Language.
- In all the target languages Elan deliberately imposes restrictions on coding patterns that would not necessarily be imposed when writing in that language in another IDE. These restrictions are of two distinct forms:

- Enforcement of the 10 commandments of good programming
- Restrictions that ensure 100% compatibility when code is translated

## 2.0.0-alpha1 - limitations and known issues

- Alpha1 supports procedural programming only. OOP will be added in 'alpha2', and Functional Programming (FP) in 'alpha3'.
- Auto-completion is neither complete, nor completely consistent: it might not show some expected items, and might show some that aren't applicable, but you can always just type the names that you want in full.
- The online documentation (help) is a work in progress. Generally it has been kept up to date with changes to Elan, but some areas are incomplete. Before we get to full release, the online help system will be such that whichever language you are working on, the online documentation will automatically show all code examples in that language.
- Worksheets have been temporarily removed, pending updates. When restored, they will automatically present in the same language that you have selected in the editor.

## The Elan 2 IDE

- Is completely free
- Runs within a browser, meaning that there is no install required, nor any registration. It may be installed on a school server, or just saved as a web page on the desktop, such that it may be used without Internet access.
- Has a powerful 'frame-based editor' that:
  - reduces the need for typing
  - eliminates the possibility of many forms of syntax error
  - provides a common language for kinds of instruction such as 'variable', 'constant', 'set', 'procedure', 'function'
- Has a built-in library that works identically in all languages.
- Provides four kinds of graphics – Turtle, Block, Vector, and Html – that work identically in all languages.
- Has a simple, but powerful, debugger.
- Offers integrated documentation that is linked directly from the code.
- Supports integrated worksheets.
- Is guaranteed '100% AI-free`.
- Deliberately prevents pasting in .py, .vb, .cs, or .java, code from an external source.

## The 10 commandments of good programming

There are many more than 10 widely recognised principles of good programming practice. These 10 have been singled out because the designers of Elan believe that anyone learning to program should never learn to break any of them in the first place, and that they should ideally be enforced by the programming language. Elan 1.0 was the first language, designed for education, that enforced all 10. Elan 2.0 enforces them, through its Code Editor, when writing Python, VB.NET, C#, and Java.

1. Thou shalt not define any global variable
2. Thou shalt not change any constant
3. Thou shalt not change the Type of any variable
4. Thou shalt not create any null reference
5. Thou shalt not break out of any loop
6. Thou shalt not exit any method before its end
7. Thou shalt not create any impure function
8. Thou shalt not access any private member
9. Thou shalt not inherit from any concrete class
10. Thou shalt not override any concrete method

The nature and rationale for each of these commandments will be more fully explained in future documentation.

## Coding restrictions designed to guarantee portability

These restrictions exist to ensure that all code generated within the Elan IDE may be automatically translated with 100% correctness from any one supported language into any other.

It is not necessary to know these rules, because there is either no mechanism to break them or you will receive a clear message if you try to. Each of these restrictions exists to prevent use of coding features that are supported in some languages, but have no equivalent syntax in at least one other. The surprising thing, we suggest, is how few such restrictions are necessary.

- Loops
  - The 'for each' syntax is used even for a traditional 'for' loop, by means of the range method.
  - A 'repeat...until' loop must be implemented using the 'while' loop syntax.
- Literal strings
  - are always bounded by double quotes: "apple".
  - 'interpolated strings' use the syntax specific to each language (for Java that is the `String.formatstr.formatstring.formatString.formatString.format` method).
- Identifiers
  - are case sensitive, but you cannot have two in the same scope that differ only by case.
  - may not conflict with reserved words in any of the languages. In such a case you may just extend the identifier e.g. using `next_next_next_next_next_` instead of `nextnextnextnextnext`.
- Operators
  - Two integers may not be divided using '/'. You use the divAsInt or divAsFloat depending on the result you need.
  - The equality operators `isisisisis` and `isntisntisntisntisnt` may be used only for numeric or Boolean Types. To test equality of strings, and all other Types, you must use the equals or notEqualTo function.
  - The 'power' operator '^' is not recognised for any language: you use the pow function instead.
- Indexing
  - A 2D array is implemented as a list of lists, and accessed with double index e.g. [3][4], but it may be initialised (like an an array) using any of: createList, createListOfLists, or createBlockGraphics.
  - An index value cannot be negative.
- Exceptions and errors. You cannot access the exception instance within a catch clause(s).
- Tuples. Items are accessed by e.g. `myTuple.item_0myTuple.item_0myTuple.item_0myTuple.item_0myTuple.item_0`, `myTuple.item_1myTuple.item_1myTuple.item_1myTuple.item_1myTuple.item_1`. They may not be accessed by index, nor is 'tuple deconstruction' (into separate variables) supported.
- Passing by reference is possible only within a procedure and to do this you use the `AsRefAsRefAsRefAsRefAsRef` Type which acts like a wrapper around the instance of interest.