Public Repository

Last pushed: a year ago
Short Description
c++ just in time compiler.more info at: http://www.jyt.io/guide
Full Description

Contents

What is Jyt?

Jyt is an LLVM based just-in-time compiler for C++ 14.

Jyt enables you to iterate quickly over your ideas and explore APIs by providing you with an interactive programming experience in a REPL. We also support hot-module reloading, with a few limitations.

Installation

Ubuntu / Linux Mint 17.3 (64bit)

  • Install dependencies: sudo apt-get install -y wget bzip2 make cmake g++-5 clang-3.6 llvm-3.6 openssl
  • Download the debian Jyt package.
  • Install the package through double click or the cmd: sudo dpkg -i Jyt.deb

OSX

  • Install the latest version of Xcode
  • Download the Jyt image:
  • Mount the dmg file.
  • Drag Jyt.app to /Applications
  • Optionally, you can add a shortcut to your path by dragging jyt into usr/local/bin

Docker

Type the following to get into the Jyt REPL:

sudo docker run -it loopperfect/jyt jyt

If you would like to mount a local folder, use the following:

sudo docker run -v `pwd`/src:/src -it loopperfect/jyt jyt

All arguments you append to the end will be passed to jyt.
If you ommit the jyt at the end of the command, it will go straight to your container's bash.

How to Jyt

Hello World

Launch Jyt at the command line, or double-click the app:

$ jyt

Start writing C++!

"Hello world"

Clearing the Jyt

There is currently no way to clear history or undo executions.

Close Jyt and relaunch it for a blank slate.

Hot-Reload

We support a limited form of hot-reloading for files in the working directory. Hot-reloading is where the compiler detects changes to your source files and integrates them automatically. You can see a demo of this on our YouTube channel.

To use hot-reload, specify the --hot flag when you start Jyt. Now when you save a file, it will automatically be re-compiled into the running program.

Limitations

Currently, the hot-reloader simply re-evaluates files that have changed. If you have an include guard, this will have no effect. However, Jyt will define JYTTER, when using Jyt, and JYT_HOT when hot-reload is enabled. These preprocessor flags will allow you to control the hot-reload process.

We also do not allow you to redefine functions or classes; only lambdas can be modified. This is a limitation that will be fixed in later versions. You can see how a program can be written in this style on our GitHub.

Examples

Executing files

Lets call meaning() from meaining.cpp and jump into interactive mode (-i):

//meaning.cpp
#include <iostream>
void meaning() {
  std::cout << 42 << std::endl;
}
jyt meaning.cpp -i  # prints 42
$ meaning(); // write more c++

Meta-programming

Jyt enables meta-programming capabilities at run-time through a run-time object. For example, you can evaluate a C++ string:

$ jyt
#include <string>
#include <jyt/runtime.hpp>

std::string inc = "iostream";
std::string s = "std::cout << 42 << endl;";
jyt.include(inc);
jyt.eval(s); // prints 42

Linking Libraries

$ jyt
#include <jyt/runtime.hpp>
jyt.addIncludePath("/path/to/includes");
jyt.addIncludePath("/path/to/libs");
jyt.linkLibrary("myLib.so");
#include <myLib.h>
myLib::func();

Async

The current implementation of std::thread and std::async doesn't run in a seperate thread.

However, we implemented void Async(auto func);, which does run in a real thread. In the future we intend to make this function obsolete and fix std::thread.

$ jyt
#include <jyt/runtime.hpp>
#include <iostream>
auto f = [](){ std::cout << "Hello from another thread" << std::endl; }
jyt.async(f)

Command Line Arguments

-x : exec mode

Usage: jyt -x a.cpp b.cpp c.cpp

Includes all listed files and executes functions with share the filename e.g.
jyt -x primes.cpp executes primes() from primes.cpp

-e : script mode

Usage: jyt -e a.cpp b.cpp

Includes all listed files and executes in script mode.
This means basicallly an line-by-line execution within a "virtual" main function.
If you want to define a function you need to mark it as extern.

extern template<class T> auto test(T){ return sizeof(T); }

-i : interactive mode

Usage: jyt -x a.cpp -e b.cpp -i

Starts the REPL after executing all files.
Jyt starts in this mode if you don't pass any arguments

Known Bugs <a name="bugs"></a>

  • Crash on calling a main-function. Work-around: #define main main_t
  • No inline assembly support
  • std::map and std::vector are slow
  • jyt -x a.cpp a.cpp doesn't work. Work-around: include and call in script mode

License

Jyt may be used for commercial or non-commercial use. However, you may not modify it or sell it. We provide no warranty for Jyt. Please refer to the full license for more information.

Usage Statistics

The beta version of Jyt collects usage statistics. These are:

  • The date and time that Jyt was launched
  • The data and time that a command was sent to Jyt
  • The operating system and version

The code you send to Jyt is never collected.

Open-source Components

Jyt is built using the following open-source components:

Docker Pull Command
Owner
loopperfect

Comments (0)