L* C++

C++ Playground on iPhones and iPads


Introduction

Thank you so much for purchasing this application. We hope that you will find the tool useful and will enjoy using it.

L* C++ is an C++ integrated development environment iOS app. In other words, it allows you to write C++ programs, gets them executed (technically, interpreted) and see the output.

Our main audiences are students learning to program and developers writing back-end utility libraries such as those to perform computation in algebra, statistics and data compression, to train artificial intelligent model, etc. as opposed to GUI-based applications.

Features

Compared to similar tools in the market, L* C++ is

  1. Designed with the latest Swift + SwiftUI technology: Integrate well with the latest iPhones Look-and-Feel and at the same time designed with minimalism.
  2. Works offline: No Internet connection is required to run code. So you can play with C++ even on your flight or your train commute.
  3. Provide project management: You can create a new project (full version only), create a new file or importing an existing file to the project. We also support exporting a project as zip file. We also intend to support Git repository and build configuration in the future.
  4. Support project documentation: Don't just code, document your code too! Unlike many IDEs on the market (including those for Mac/PC), we include an easy access to your project documentation.
  5. Syntax highlighting code editor with code completion support: We are using existing powerful open source code editor, namely Monaco Editor, that many developers love and are already familiar with.
  6. No command lines to produce auxiliary files to execute a C++ program: Just hit Run and watch the magic.

Usage Tips

Project Documentation

The project's Overview tab loads the project documentation (like this page) in doc/index.html. You can put all the required resources (images, CSS) there.

On the related topic, it is best to organize your projects like many open source community, namely into directories such as

  • src for private headers and implementations,
  • include for public headers (your API),
  • data for program data, models, ...

Multiple Source Files

In traditional C++ development environment, you can split a program into multiple source files, say a.cpp and b.cpp. Then you compile them into separate object files a.o and b.o and then link them into an architecture-dependent (ARM, x86, ...) executable, say myprogram that could be executed in the Terminal by typing ./myprogram.

At this first release, L* C++ could not perform linkage and iOS also disallows execution of native programs. So we actually interpret C++ program instead of performing the traditional compilation-linkage. In other words, we are executing the C++ code line-by-line whereas the executable is a binary file containing instructions that could be executed by the CPU directly. That means for now, we cannot support multiple source files and so you need to #include all source into a single program. For instance, if you want to run the program a.cpp that has some function implemented in b.cpp, you must add #include "b.cpp" in the file a.cpp.

We are sorting out the right user interface for all the required customizations akin to Xcode build targets and schemes.

Standard Output

The standard output is the most fundamental form of output for command lines program: to print out textual messages to communicate with the user. Our app supported this via a limited implementation of C++ std::cout (it does not work with std::string yet but does work for many other common types). Standard C API such as printf will not work and since it is a good coding practice to avoid printf for security reason, we do not intend to support it in the future.

See our "Hello World" program hello.cpp for an example.

Standard C Library

You can use a majority of the standard C APIs in your app such as those involving math, string manipulation, memory allocation, memory copy and initialization, random number generation, etc. The one you cannot use are

  • those involving function pointers as arguments such as qsort and bsearch declared in the C header stdlib.h (but note that there are better alternatives for these particular functions in C++ standard template library algorithm) as well as
  • those dealing with FILE due to iOS sandbox limitations and security restrictions
  • and please also avoid setjmp.

In the future, we will attempt to port fstream in C++ standard library for file I/O.

C++ Standard Template Library (STL)

For C++ standard template library, we supply libc++ from the LLVM project but our knowledge of its implementation is limited.

  • C++ containers (vector, map, set, linked_list and the like) should work properly; as are standard container algorithm.
  • Some string methods do not (namely, less than comparison and related operators) while all other string methods do.

  • Input/output stream does not work due to dependency on some locale code. But we provide a temporary implementation of std::cout for output.
  • Threading-related stuffs (atomic, condition_variable, future, mutex, thread) are definitely not available until we port them. Nevertheless, they are not relevant since our goals are single threaded programs.

Other Limitations

There are several other limitations in the current release that you should be aware of

  1. You cannot terminate a running program. Until we figure out a monitoring system, please let the program run until completion so the interpreter could perform appropriate clean up.
  2. The interpreter cannot catch runtime error such as null pointer access. You need to make appropriate check in your code. The interpreter simply invokes iOS system service on your behalf.
  3. We currently lack debugging capability such as breakpoints and stepping through the program but we do intend to have some diagnostic and tracing in the future.

Examples

This Getting Started project includes several example programs to illustrate the capability of our C++ interpreter:

  • hello.cpp: Classical "Hello World" program.
  • fibonacci.cpp: Elementary program to produce Fibonacci numbers.
  • polymorphism.cpp: Polymorphism in C++ Object-Oriented Programming.
  • functional.cpp: Templates and Functional Programming in C++ language.
  • math.cpp: Examples of standard mathematical functions.
  • prng.cpp: Random number generation.
  • string.cpp: Illustrations of null terminated C strings and std::string.
  • sort.cpp: Using C++ STL to sort a container.
  • permutations.cpp: Using C++ STL to enumerate permutations.

Privacy Policy

This app does not collect any user information. All your files belong to you.