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.

#ChapterDemoWhat it showsRuns
01Manifestfibonacci.eveA deterministic function that calls itself; expect as a self-check.yes
02Syntaxsyntax_tour.eveEvery comment form, new, set, let, statements over several lines, print and write.yes
03Data Typesdata_types.eveLiterals and their types, ordinals, ranges as domains, conversions, zero values and optional types.yes
04Date and Timedates.eveParse and build dates, times and durations; format a date.preview, level 5
05Control Flowcontrol_flow.eveif, match, while with a header, for with a step, labelled loops, loop … repeat.yes
06Stringsstrings.eveInterpolation and formats, Unicode, split and join, text literals, regular expressions.yes
07Collectionscollections.eveList, 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.

#ChapterDemoWhat it showsRuns
08Scriptsfree_script.eveA free script: #!, statements in sequence, no driver.yes
09Driversdriver_args.eveConstants, a system variable, command-line arguments, recover and finalize.yes
10Aspectsaspects_report.eveTwo 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)
11Macrospipeline_macro.eveAn Eve macro: a shared class, two concurrent aspects started in a parallel group.yes, as a project (macro: level 5)
12Modulesmodule_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
13Subprogramssubprograms.eveParameters by value and by reference, defaults, a vararg, several results, defer.yes

Phase 3: Functional programming

Functions as values.

#ChapterDemoWhat it showsRuns
14Functionsfunctions.eveDefaults, named arguments, recursion, two results; deterministic and stochastic (!) functions.yes
15Generatorsgenerators.eveValues made one at a time: a for loop, a builder, a generator object, an endless generator.preview, level 5
16Closuresclosures.eveCounters that keep their own state; a function made with a parameter.yes
17Expressionsexpressions.evePrecedence, relations, tolerance, conditional expressions, builders, bulk operations, lambdas.yes
18Callbackscallbacks.eveA function given by name or as a lambda; a typed callback; a fold.yes

Phase 4: Object oriented features

Objects, classes and their relations.

#ChapterDemoWhat it showsRuns
19Objectsobjects.eveObject literals, attributes, == and is, references and copies.yes
20Classesclass_point.eveA class with a constructor, defaults and methods.yes
21Inheritanceinheritance.eveA subclass built through the constructor of its superclass.yes
22Genericsgenerics.eveA generic class and a constraint that asks for a trait.yes
23Partialspartials.eveAn abstract class and a trait: the subclass writes the missing methods.yes
24Methodsmethods.evePublic 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.

#ChapterDemoWhat it showsRuns
25Processingprocessing.eveJobs with retry, resume and stop; finalize and defer.yes
26Exceptionsexceptions.eveErrors with a code and a message, $error, one recover for many jobs.yes
27Databasesdatabases.eveA session, a record type, append, find, update and commit.preview, level 5
28Multitaskingmultitasking.eveAsync subprograms in a job: spawn, await, wait.yes
29Concurrencyatomic_counter.eveFour workers count 4000 hits with a shared atomic variable.yes, as a project (macro: level 5)
unsafe_counter.eveA 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.eveA producer, four workers and a collector connected by two channels.yes, as a project (macro: level 5)
mutex_account.eveA transfer changes two variables: a mutex makes them change together.preview, level 5
local_generator.eveA generator local to an aspect needs no thread safety.preview, level 5
shared_generator.eveA 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.

#ChapterDemoWhat it showsRuns
30Templatestemplates.eve
order.evh
An HTML page from a template file; text from a user is never code.preview, level 7
31Networkinghttp_client.eveEve as a client: a request, a time-out, two requests that overlap in a job.preview, level 5
32Protocolshttp_errors.eveAn HTTP status of 400 or more is an error: retry a busy service, skip a missing order.preview, level 5
33Serverhello_service.eveA service with two routes.preview, level 6

Phase 7: Implementation & tools

The tools and the library.

#ChapterDemoWhat it showsRuns
34Compilerhello_world.eveThe traditional first program, with the commands that run, check and document it.yes
35Standard Librarylibrary.eveBuilt-ins without import: print and write, conversions, text, compare, batch.yes
36System Librarygreeting.eveRead the standard input; write and read a file.preview, level 5
37EVE VMvm_memory.eveMemory made and freed in a loop and in a job; run with EVE_MEMSTATS=1.yes
38Algorithmsalgorithms.eveNewton square root with a precision, bubble sort, binary search, Euclid.yes
39Shell Commandsshell.eveRun a shell command and take its output lines.preview, level 5
40EveDBnone yet: bin/evedb.exe runs its self-checkThe Eve test database; its demos are the database tests of level 5, which run against it.planned, level 5