[Esoteric Programming Language] RightTime

Introduction

Motivation

We all know that the best time to do your homework is right before its due. However, the behavior of wait until the right time to do your homework is not always encouraged, especially disliked by your parents. Therefore, I designed RightTime, the ultimate next generation programming language that rewards you for doing your work at the right time.

 

Design Principles

  • The language should reward the programmer if and only if the programmer compiles a program at the right time.
  • The behavior of a RightTime program should be purely based on the time when it was compiled.
  • Time is relative, so RightTime programs should be relative as well.
  • RightTime promotes healthier lifestyles, so underweight or overweight programmers who skew the space and distort the time around them abnormally tend to write buggy programs as it is harder for them to catch the right time.

 

Why RightTime?

  • RightTime programmers do no need to write code; they just need to think hard and compile at the right time!
  • RightTime programs take essentially no space.
  • RightTime is convertible to most existing programming languages.
  • RightTime could solve complicated computing problems very easily!
  • RightTime is geeky, just like you.

 

Language Concepts

Syntax

There's no syntax for RightTime, so any string is accepted as a valid RightTime program. In other words, everything you write in a RightTime program is essentially comment. The content does not matter -- it is all about compiling at the right time! For example, here are two examples of valid RightTime programs:

The Time Recorder

The behavior of a RightTime program is defined by the time of its compilation. This time is represented as the number of seconds since the midnight of the day of compilation, and the RightTime compiler uses a real number to record this number as precisely as possible. For example, a RightTime program that is compiled at 9:00 am has a time represented as  32400.0000000000000... The time is separated into two parts by the decimal point. The first part indicates the interpretation mode of the time and the second part is the data section.

Interpretation Modes

The range of numbers before the decimal point of recorded time is 00000 ~ 86,399 since there are 86,400 seconds a day. This six-digits number define the interpretation mode of the program. Though there are thousands of interpretation modes, it is easy to grasp the main idea and soon you will be a RightTime master as well.

The Delimiter

No matter what the interpretation mode is, the delimiter of the data section is alway  9. That is, everything after the first 9 will be ignored. For example, given a time  0877.1288177381293907712368..., the data section is truncated at the first 9, and only  12881773812 is left.

Base Mode 「0」

The base mode is RightTime native mode that supports intuitive RightTime programming. The zero indicates that the programmers who want to use this mode have to compile their program within the first second passes midnight, which fits perfectly most programmers' lifestyles.

Literals

A literal in RightTime is a segment of time that has only 1's and 0's. The values of literals are the same as the binary numbers represented by the 1's and 0's.  111 is a literal with value 7.

Variables

RightTime rewards programmers by declaring variables for them if the time has numbers with the following structure:

  2 VaribleID 2 [InitialValue] 2

Both the variable identifier and the variable initial value are represented by binary numbers. Written in a regular expression fashion, this is equivalent to  2[01]+2[01]*2. If the variable initial value is not set, then it is initialized to 42 by default. For example, 2121002 declares variable #1 with its value initialized to 4.

Reference a variable with:

3 VariableID 3

Flow Control

RightTime rewards programmers by managing control flows for them if numbers with these structures are found:

  4 [Condition] 4 {Operation} 4

This causes the program to repeat the operations until the condition evaluates to true. If no condition is given, then it will loop forever unless a  5  is caught, which breaks the loop. For something like an if statement, consider timing for  4 Condition 4 {Operation} 54 .

Operators

All operators have three digits. The first one is always 6, and the rest specifies which operator it is.

Time Segment Operator
600 +
601 -
602 *
603 /
604 =
605 ==
606 %
607 or
608 and
610 not
... ...

Subroutines

All subroutines start with 7, end with 5 (break),  separate and pass parameters with 77. Built-in subroutines have another digit follows the first 7:

Time Segment (number of parameters) Subroutine Example
705 exit 705
71(x)5 print x 71115 prints 3
72(x, y)5 swap x and y 72303773135 swaps variable #0 and # 1
73(x, y)5 sleep number of x.y seconds 731007710005 sleeps the program for 4.8 seconds
74(x)5 returns a char based on the ASCII value of x 7410000015 returns "A"
75(*)5 returns a string by concatenating the input chars 75 7410000015 77 7410000105 5 returns "AB"
765 compile and run now 765
... ... ...

You can also define your own subroutines with similar timing, but time your subroutine so it looks like:

8 SubroutineID {77 Parameter} 77 {Operations} 5

For example, defining a subroutine that prints what is given can be timed as  80773037771130375.

Base Mode Sample Programs

Machine Mode 「1」

The Machine Mode of RightTime compiles directly to machine code, i.e. zeros and ones. To utilize the machine mode, make sure you compile within the second second passes midnight (1.00000... to 1.9999999). Using the same delimiter "9," the data section will be treated like a base-9 number and converted to a binary number. For example,  1.481301587609 will be compiled to machine code  1111111011011110100100001000111011.

 

Translators Modes 「2-86399」

Translator Modes enables direct translation to other inferior programming languages like C++ or Python. The interpretation mode indicates which language it translates to, and the data section specifies the content of the resulting program.

Mode Language
2 C
3 C++
4 Java
5 Python
6 JavaScript
... ...

Thanks to the superior design of RightTime, it is possible to compress any program written in these languages into zero lines of code!

 

Closing Thoughts

RightTime is the language of choice. The storage of any program takes potentially zero space and the time programmers spent on coding up a program is also essentially zero. As a result, RightTime programmers could invest more effort on writing comments, producing much easier to read, easier to maintain codes (no need for code changes anyways). RightTime is also backward compatible with traditional programming languages and even machine code. A bright future of RightTime is in front of us, we shall all expect.