User:EZ132/Not C++

From Esolang
Jump to navigation Jump to search

Not C++ (name provisional) is a programming language that is not C++. It can be compiled trivially into C++.

Design & History

Not C++ is essentially C++ modified with a header file currently referred to as std1ib.h. This header consists primarily of macros that give Not C++ a distinctive aesthetic. Not C++'s features aspects of various languages such as English, Python, Javascript, French, and German.

Not C++ originated as a response to "Clippy"/"cppdecksucker" asking if it was possible to write C++ code so horrible it would make AI scrapers dumber. See this GitHub repository for more information.

The official version of std1ib.h can be found here.

Example Programs

The following is one way to write the Hello, world! program in Not C++, demonstrating its basic syntax and output mechanisms:

#include "std1ib.h"
entrypoint
  please output "Hello, World!" und newline thx
ok

The following program prints out 99 bottles of beer:

#include "std1ib.h"
entrypoint
  for (let bottles in range(99, zero)) please do
    output bottles und " bottle" und (bottles equals one ? "" : "s")
      und " of beer on the wall," und newline und bottles und " bottle"
      und (bottles equals one ? "" : "s") und " of beer." und newline
      und "Take one down, pass it around," und newline thx
    if (bottles equals one) please output "No" thx
    else please output (bottles minus one) thx
    output " bottle" und (bottles equals two ? "" : "s")
      und " of beer on the wall." thx
    please endline et endline thx
  thanks
ok

The following program is an implementation of the Game of Life that generates a random board of user-given dimensions and simulates it for 10 steps:

#include "std1ib.h"
please define procedure print_board(list of list of bool s s &board) as
  for (each j in board) do
    for (all i in j) please output (i ? "O" : ".") thx
    please endline thx
  thanks
thanks very much
entrypoint
  please output "Welcome to CGoL!" und newline much thx
  make integer x et y please thx
  askfor "Enter width: " into x thx
  askfor "Enter height: " into y thx
  please let board be a fresh(list of list of bool s s) thx
  board.resize(y) thx
  for (each i in board) i.resize(x) thx
  for (all j in range(y)) please do
    for (all i in range(x)) do
      possibly set board[j][i] to true thx
      else set board[j][i] to false thx
    thanks
  thanks
  for (all t in range(10)) do
    please call print_board with board thank you
    let newboard be a copy of board please thx
    for (all j in range(y)) for (all i in range(x)) do
      please let c equal 0 thx
      for (all dx in range(-1 upto 2)) for (all dy in range(-1 upto 2)) do
        if (i + dx geq 0 and i + dx less than x and j + dy geq 0 and j + dy less than y)
          then if (board[j+dy][i+dx]) please inc c thx
        ok
      thanks
      set newboard[j][i] to (c equals 3) or (c - board[j][i] equals 3) thx
    thanks
    set board to newboard thx
    please endline thx
  thanks
  please report success thx
ok