Eve Demos & Examples
One demo for every chapter of the tutorial, with the representative features of the chapter. Open a source in the code viewer: every demo is one file, except the module demo, which is a small project. A demo that needs a driver and its aspects is an Eve macro: the aspects and the driver are in the same file. The column Runs says whether the Eve virtual machine runs the demo today; a preview shows the syntax of a later level. The conformity tests are on the Feature Tests page.
Phase 1: Core language
The core of the language: one driver, no other file.
| # | Chapter | Demo | What it shows | Runs |
|---|---|---|---|---|
| 01 | Manifest | fibonacci.eve | A deterministic function that calls itself; expect as a self-check. | yes |
| 02 | Syntax | syntax_tour.eve | Every comment form, new, set, let, statements over several lines, print and write. | yes |
| 03 | Data Types | data_types.eve | Literals and their types, ordinals, ranges as domains, conversions, zero values and optional types. | yes |
| 04 | Date and Time | dates.eve | Parse and build dates, times and durations; format a date. | preview, level 5 |
| 05 | Control Flow | control_flow.eve | if, match, while with a header, for with a step, labelled loops, loop … repeat. | yes |
| 06 | Strings | strings.eve | Interpolation and formats, Unicode, split and join, text literals, regular expressions. | yes |
| 07 | Collections | collections.eve | List, DataSet, DataMap and Object; capture, builders, deconstruction, share or copy. | yes |
Phase 2: Eve code topology
The kinds of script. A driver and its aspects fit in one file, an Eve macro; only a module needs its own file.
| # | Chapter | Demo | What it shows | Runs |
|---|---|---|---|---|
| 08 | Scripts | free_script.eve | A free script: #!, statements in sequence, no driver. | yes |
| 09 | Drivers | driver_args.eve | Constants, a system variable, command-line arguments, recover and finalize. | yes |
| 10 | Aspects | aspects_report.eve | Two aspects and a driver in one file: apply, @ outputs, a fresh state at every apply, an error that crosses apply. | yes, as a project (macro: level 5) |
| 11 | Macros | pipeline_macro.eve | An Eve macro: a shared class, two concurrent aspects started in a parallel group. | yes, as a project (macro: level 5) |
| 12 | Modules | module_demo/module_demo.eve module_demo/lib/geometry.eve | A project: the driver imports a module of lib/ with a constant, a class, an extension method and a function. | yes |
| 13 | Subprograms | subprograms.eve | Parameters by value and by reference, defaults, a vararg, several results, defer. | yes |
Phase 3: Functional programming
Functions as values.
| # | Chapter | Demo | What it shows | Runs |
|---|---|---|---|---|
| 14 | Functions | functions.eve | Defaults, named arguments, recursion, two results; deterministic and stochastic (!) functions. | yes |
| 15 | Generators | generators.eve | Values made one at a time: a for loop, a builder, a generator object, an endless generator. | preview, level 5 |
| 16 | Closures | closures.eve | Counters that keep their own state; a function made with a parameter. | yes |
| 17 | Expressions | expressions.eve | Precedence, relations, tolerance, conditional expressions, builders, bulk operations, lambdas. | yes |
| 18 | Callbacks | callbacks.eve | A function given by name or as a lambda; a typed callback; a fold. | yes |
Phase 4: Object oriented features
Objects, classes and their relations.
| # | Chapter | Demo | What it shows | Runs |
|---|---|---|---|---|
| 19 | Objects | objects.eve | Object literals, attributes, == and is, references and copies. | yes |
| 20 | Classes | class_point.eve | A class with a constructor, defaults and methods. | yes |
| 21 | Inheritance | inheritance.eve | A subclass built through the constructor of its superclass. | yes |
| 22 | Generics | generics.eve | A generic class and a constraint that asks for a trait. | yes |
| 23 | Partials | partials.eve | An abstract class and a trait: the subclass writes the missing methods. | yes |
| 24 | Methods | methods.eve | Public and private methods, an extension method, the trait Printable. | yes |
Phase 5: Enterprise & system features
Jobs, errors, data and work on several cores. The concurrency demos are Eve macros: the shared declarations, the aspects and the driver are in one file.
| # | Chapter | Demo | What it shows | Runs |
|---|---|---|---|---|
| 25 | Processing | processing.eve | Jobs with retry, resume and stop; finalize and defer. | yes |
| 26 | Exceptions | exceptions.eve | Errors with a code and a message, $error, one recover for many jobs. | yes |
| 27 | Databases | databases.eve | A session, a record type, append, find, update and commit. | preview, level 5 |
| 28 | Multitasking | multitasking.eve | Async subprograms in a job: spawn, await, wait. | yes |
| 29 | Concurrency | atomic_counter.eve | Four workers count 4000 hits with a shared atomic variable. | yes, as a project (macro: level 5) |
| unsafe_counter.eve | A plain shared variable: only an exclusive aspect may change it; the compile errors of the other ways. | yes, as a project (macro: level 5) | ||
| channel_pipeline.eve | A producer, four workers and a collector connected by two channels. | yes, as a project (macro: level 5) | ||
| mutex_account.eve | A transfer changes two variables: a mutex makes them change together. | preview, level 5 | ||
| local_generator.eve | A generator local to an aspect needs no thread safety. | preview, level 5 | ||
| shared_generator.eve | A shared generator is called by every task: it must be thread safe. | preview, level 5 |
Phase 6: Internet features
Previews: these chapters describe later levels.
| # | Chapter | Demo | What it shows | Runs |
|---|---|---|---|---|
| 30 | Templates | templates.eve order.evh | An HTML page from a template file; text from a user is never code. | preview, level 7 |
| 31 | Networking | http_client.eve | Eve as a client: a request, a time-out, two requests that overlap in a job. | preview, level 5 |
| 32 | Protocols | http_errors.eve | An HTTP status of 400 or more is an error: retry a busy service, skip a missing order. | preview, level 5 |
| 33 | Server | hello_service.eve | A service with two routes. | preview, level 6 |
Phase 7: Implementation & tools
The tools and the library.
| # | Chapter | Demo | What it shows | Runs |
|---|---|---|---|---|
| 34 | Compiler | hello_world.eve | The traditional first program, with the commands that run, check and document it. | yes |
| 35 | Standard Library | library.eve | Built-ins without import: print and write, conversions, text, compare, batch. | yes |
| 36 | System Library | greeting.eve | Read the standard input; write and read a file. | preview, level 5 |
| 37 | EVE VM | vm_memory.eve | Memory made and freed in a loop and in a job; run with EVE_MEMSTATS=1. | yes |
| 38 | Algorithms | algorithms.eve | Newton square root with a precision, bubble sort, binary search, Euclid. | yes |
| 39 | Shell Commands | shell.eve | Run a shell command and take its output lines. | preview, level 5 |
| 40 | EveDB | none yet: bin/evedb.exe runs its self-check | The Eve test database; its demos are the database tests of level 5, which run against it. | planned, level 5 |