Skip to main content

C++ 14 kernel for Jupyter

Project description

This repo is originally created by Brendan Rius - `C Kernel for Jupyter`

You can see the original project at https://github.com/brendan-rius/jupyter-c-kernel

Plus, this C++ kernel only uses C++ 14. The others are being developed
(or not, who knows 😅)

CodeQL

C++ 14 kernel for Jupyter

Installation

:warning:

This kernel only works on Linux and macOS. If you want to use it on Windows, please consider using WSL, Docker, or using a virtual machine.

Normally, your target machine must meet these requirement packages before installing and using jupyter-cpp-kernel.

  • g++
  • python3, python3-pip
  • jupyter (recommend jupyterlab)

Install from PyPI

Installing on macOS

:warning:

You must all requirements above before doing anything else I don't use macOS too regularly, so I don't know how macOS get these packages But you can follow installation instructions on the Internet After that, you can copy this script and install the kernel

pip install jupyter-cpp-kernel
install_cpp_kernel --user

Installing on Debian/Ubuntu

sudo apt update && sudo apt full-upgrade -y 
sudo apt install -y g++
sudo apt install -y python3 python3-pip
sudo pip install --upgrade pip
sudo pip install jupyter # Or jupyterlab. Using `sudo` to install to the main packge
sudo pip install jupyter-cpp-kernel # Can be `sudo`, but using it with caution. Only for large deployment Jupyter server
install_cpp_kernel --user # Can be `sudo`, but using it with caution. Only for large deployment Jupyter server

Install from GitHub repo

Installing on macOS

:warning:

You must all requirements above before doing anything else I don't use macOS too regularly, so I don't know how macOS get these packages But you can follow installation instructions on the Internet After that, you can copy this script and install the kernel

pip install git+https://github.com/takinekotfs/jupyter-cpp-kernel.git
install_cpp_kernel --user

Installing on Debian/Ubuntu

sudo apt update && sudo apt full-upgrade -y 
sudo apt install -y g++
sudo apt install -y python3 python3-pip
sudo pip install --upgrade pip
sudo pip install jupyter # Or jupyterlab. Using `sudo` to install to the main packge
sudo pip install git+https://github.com/takinekotfs/jupyter-cpp-kernel.git 
install_cpp_kernel --user # Can be `sudo`, but using it with caution. Only for large deployment Jupyter server

Contributing

You can clone, create a fork or import this repo whenever you want.

Please follow the GitHub standards and the license

Sample codes

:warning:

  • Raw input into program is still not completed yet. You may cannot using cin or any user input parameter.

  • For the best practices, you shouldn't write using namespace std; because of the conflicts between the namespace. This problem doesn't come from the interpreter, it's actually the problem of g++ globally

Hello world

#include <iostream>

int main() {
    std::cout << "Hello World" << std::endl;
    return 0;
}

Declare variable (int) and take a math of them

#include <iostream>
#include <cmath>

int main() {
    int x = 3, y = 6;
    std::cout << "Sum of x and y is " << x + y << std::endl;
    std::cout << "Subtract of x and y is " << x - y << std::endl;
    return 0;
}

Condition

With If...else...

#include <iostream>

int main() {
    bool isMale = false;
    if (isMale) {
        std::cout << "Male" << std::endl;
    }
    else {
        std::cout << "Is not Male" << std::endl;
    }
    return 0;
}

With switch...case...

#include <iostream>

int main() {
    int number = 1;
    switch (number) {
        case 1:
            std::cout << "1" << std::endl;
        case 2:
            std::cout << "2" << std::endl;
        default:
            std::cout << "Not defined" << std::endl;
    }
    return 0;
}

Loop

For float condition

#include <iostream>

int main() {
    int lim = 10;
    for (int i = 0; i < lim; i++) {
        std::cout << i << std::endl;
    }
    return 0;
}

For fixed condition

#include <iostream>

int main() {
    int lim = 0;
    while (lim < 10) {
        std::cout << lim << std::endl;
        lim++;
    }
    return 0;
}

Exception handler

#include <iostream>

int main() {
    std::cerr << "Exception happened";
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyter_cpp_kernel-1.0.0a2.tar.gz (9.9 kB view hashes)

Uploaded Source

Built Distribution

jupyter_cpp_kernel-1.0.0a2-py3-none-any.whl (10.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page