Java programming is boring. So I made a monster.

Anyone who knows my programming self, knows that I love to make esoteric languages. (Thus the title of this blog.) I got bored of programming in Java for my course, so I decided to make an esolang that compiles to readable Java. It's as of yet unfinished, but I call it "Stoj", or "Short to Java". It's also "Jots" backwards! For example, here is a solution for T1L20, "Seal tracker", which outputs the largest and smallest latitudes and longitudes within the given input. (Of course, this would be made more trivial using a decent (golfing) language and a more lenient input format, but what's the fun in that?1)

Lesson_20_Activity 180.d@A@C-180.d@B@D t@E W:E{t@F 91'd@@G 181'd@@H W:G 90CR:H 180 CR|{?:F{f@F}#{"Incorrect Latitude or Longitude"P} "Please enter the latitude:"P Id@H"Please enter the longitude:"P Id@G}?:G 180Cr{?:G:D>{:G@D}?:G:C<{:G@C}}?:H 90Cr{?:H:B>{:H@B}?:H :A<{:H@A}}"Would you like to enter another location?"P?Ii0={f@E} }"Farthest North: ":B+P"Farthest South: ":A+P"Farthest East: ":D +P"Farthest West: ":C+P

Much better than Java, right?? Here's a more "readable" version:

Lesson_20_Activity
180 'd @@south
-180 'd @@north
180 'd @@west
-180 'd @@east

t @executing

W :executing {
    t @firstTime
    91 'd @@longitude
    181 'd @@latitude
    W :longitude 90 CR :latitude 180 CR | {
        ? :firstTime {
            f @firstTime
        } # {
            "Incorrect Latitude or Longitude"P
        }
        "Please enter the latitude:"P
        Id @latitude
        "Please enter the longitude:"P
        Id @longitude
    }
    
    ? :longitude 180 Cr {
        ? :longitude :east > {
            :longitude @east
        }
        ? :longitude :west < {
            :longitude @west
        }
    }
    ? :latitude 90 Cr {
        ? :latitude :north > {
            :latitude @north
        }
        ? :latitude :south < {
            :latitude @south
        }
    }
    
    "Would you like to enter another location?"P
    ? Ii 0 = {
        f @executing
    }
}
"Farthest North: " :north + P
"Farthest South: " :south + P
"Farthest East: " :east + P
"Farthest West: " :west + P
I'm currently thinking about making a "JToS" converter, that would translate Java code to Stoj code. This might be a bit difficult, unless I can get my hands on a Java lexer or if I decide to make one on my own.

TODO list

  1. Create functions.
  2. Create classes.
  3. Java's "foreach" construct
  4. Remove Java (after this year, hopefully)
  5. Add Java Code Linter
  6. Add dynamic variable renaming (for shorter programs)

1 ok fine I did a golf in J: ,@|:@:>@(>./;<./)@(#~0=90 180+./@:<"1|) very lax on IO, but does filter out bad values

Comments

Popular posts from this blog

PPCG.se - the past, quality, and now

Special moments in an AP Computer Science course