• Stars
    star
    145
  • Rank 254,144 (Top 6 %)
  • Language
    Shell
  • License
    Do What The F*ck ...
  • Created over 7 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A framework for creating Python/C++ polyglots, programs valid in both programming languages

Python++

A framework for cross language development

About

Python++ is a framework for creating Python/C++ polyglots, programs valid in both programming languages. Specifically, it is a collection of guidelines and boilerplate that allows you to write a single program which will produce the same output when compiled with a C++14 compiler or run with a Python3 interpreter. It does this with heavy usage of C style macros and numerous hacks of the syntax of both languages. No external transpiler or preprocessor (aside from the standard C/C++ preprocessor) is needed. The exact same Python++ file can be fed in unmodified to a stock C++ compiler and a stock Python interpreter and you will get the same output. The first version of Python++ was developed by William W Wold for the Stupid Shit No One Needs and Terrible Ideas Hackathon 2017.

Overview

Python++ consists of 3 things:

  1. ppp.ppp: This is itself a polyglot that can be copied to the top of your Python++ source, or placed alongside it and imported.
  2. guide.md: A comprehensive guide to writing Python++ programs.
  3. examples: examples of programs written in Python++.

Running

With Python

Running Python++ programs with Python3 is easy. Simply enter

python3 your_source_file.ppp

With C++

It is a bit trickier to compile as C++ because the compiler doesn't recognize .ppp as a valid file extension by default. Also, you need support for C++14. With a recent version of GCC, the following command works:

g++ -x c++ -std=c++14 your_source_file.ppp -o output_binary

-std=c++14 seems to be default on my system, but better to make it explicit. If you want to use an IDE or a different compiler I'm sure you can figure it out. If you do, feel free to edit this readme with instructions and send in a pull request.

Test Script

test.sh is a BASH script that automatically tests the given source code with both Python and C++. You must have Python3 and gcc installed to use it. It reports if the program worked with Python, if it worked with C++ and if the outputs from the two languages match, as well as displaying the output and any error messages.

Contributing

If you want to add a feature or fix a bug/typo, please do so and send in a pull request.

License

Python++ is licensed under the permissive Do What The Fuck You Want To Public License (WTFPL). See COPYING for details.

More Repositories

1

Pinecone

An unmaintained programming language
C++
865
star
2

gtk-layer-shell

A library to create panels and other desktop components for Wayland using the Layer Shell protocol
C
316
star
3

gtk4-layer-shell

A library to create panels and other desktop components for Wayland using the Layer Shell protocol and GTK4
C
132
star
4

BrainfuckIDE

A Brainfuck IDE/debugger designed to be intuitive, featureful and visually appealing
GDScript
92
star
5

wayland-debug

A command line tool to help debug Wayland clients and servers
Python
71
star
6

Hedgehog

C++ Wayland compositor
C++
17
star
7

mate-wayland-snap

Shell
11
star
8

bfstack

A Brainfuck framework
10
star
9

destylize

Browser extension to remove unicode text stylization, Now available for Firefox and Chrome (see below)
JavaScript
10
star
10

define_EVIL

8
star
11

wlbouncer

Control which Wayland protocol extensions are available to which clients on any Wayland compositor
C++
8
star
12

Object-Oriented-C

Why are we building this?
C
8
star
13

hello-wayland

Example and test Wayland apps
C
4
star
14

BrainfuckIDE_builds

Builds of my Brainfuck IDE built in Godot
4
star
15

GDMir

Godot module for building Wayland compositors with Mir
C++
4
star
16

mirco

A Mir based Wayland compositor
C++
3
star
17

solidjs-leaflet-map

Just playing around, probably not of interest to you
JavaScript
3
star
18

cpp-cheat-sheet

Demonstration of the basic concepts of the C++ language and how to use them
3
star
19

DroneRace

An open source drone racing game made with Godot (there is no PHP in this project. wtf GitHub?)
PHP
3
star
20

Skylight

The Skylight programming language
C++
2
star
21

bft

WIP Brainfuck tooling, written in Rust.
Rust
2
star
22

snap-out

Fixes the environment for an external program launched from inside a classic snap
Rust
2
star
23

nff

non-fungible files
Python
2
star
24

cryptvm

An attempt to build a Brainfuck VM with homomorphic encryption
C++
2
star
25

include_fixer

Utility to to fix broken C/C++ #includes
Python
2
star
26

7-Segment-Unicode

Make numbers look like they're on a 7 segment display
Python
2
star
27

FluidSim3D

An experimental 3D fluid dynamics simulator
C++
1
star
28

wmwwStatusline

A configurable Linux statusline written in C++ designed for use with sway and i3
C++
1
star
29

working_drm_demo

simple demo of using direct rendering manager in Linux
C++
1
star
30

desktop-environment-talk

1
star
31

4D_tic-tac-toe

A simple text based 4D tic-tac-toe game in java
Java
1
star
32

name-of

This project has moved: https://bit.ly/357tcAz
1
star
33

buzzfeed-cli

Ruby
1
star
34

wmstr

A simple yet useful UTF-8 string single header library for C++
C++
1
star
35

iron-c

WIP project to make C safe
C
1
star
36

wifi-sync

Sync saved wifi networks to a file
Python
1
star
37

widap-launcher

A simple linux program launcher
C++
1
star
38

ram_detector

A simple C program to detect the amount of used RAM on a Linux system
C
1
star
39

Brainfuck

C++
1
star
40

BattleshipTwitter

Rules for a Battleship-inspiered game to be played on Twitter
SCSS
1
star
41

personal

Scripts, helpers and configuration primarily intended for my own use
Python
1
star
42

basic-battle

Old multiplayer BASIC game
Visual Basic
1
star
43

repo-manager

A tool for managing directories of code repositories
Python
1
star
44

cmake-starter

A basic CMake C++ starter project
CMake
1
star