100 loc programming language competition (May 30 - June 30)

1st Annual 100 Line-of-Code Programming Language Competition Rules

The competition is open to entries beginning at 0:00 UTC on May 30, 2017. Since that was more than an hour ago, it will have to begin when you first read about it.

1. The deadline is 0:00 UTC June 30, 2017. If your calendar says June 30, the contest is probably already closed.

This competition is just for fun (perhaps some year prizes will be part of the contest, that would be cool) and winners will likely be promoted (no details, think of something modest) or at the very least have one more thing to brag about.

The rules are strict so people competing know what to expect.

2. All qualified entries will be implemented in a language that existed prior to May 30, 2017. Otherwise you could be really clever and create two languages with a 100-loc interface to whatever. If you intend to make a larger API that useful for creating other APIs, great-- publish it, and use it next year.

Submissions may be implemented in any language from before this date, implementing any language (including existing languages or parts or combinations of existing languages, such as QBasic + Smallbasic + Javascript) as an interpreter, or compiler which compiles to any language existing prior to this date. Weird compiler/interpreter and/or interpreter/compiler hybrids (comterpreters) are also acceptable.

-- The language implementation should be in a single plaintext source file. If for some reason you require an exception to this part of the rule, please submit a request to me by PM, prior to June 14. Reasonable exceptions can be granted.

-- If you do not wish to post your entry to this subforum, please submit it to a timestamped forum that existed prior to May 30, 2017... and link to the entry on this subforum.

-- IF THESE RULES ARE POSTED ON ANOTHER FORUM: please first check the version posted here at:

http://www.thejoyfulprogrammer.com/qb64/forum/forumdisplay.php?fid=521

-- If you are replying to these rules posted on another forum, at least ensure that those rules are linked to on this official forum:

http://www.thejoyfulprogrammer.com/qb64/forum/forumdisplay.php?fid=522
"Post Competition Entries Here" so that your entry can be counted.

-- Please do not edit your timestamped entry. If you wish to edit your entry please append it to the same thread.

3. All qualified entries will be licensed under:

* a gpl-compatible license in this list:

http://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses
* and/or one of the osi-approved licenses on this page under the heading "popular licenses"

https://opensource.org/licenses
* and/or the expat license included after the next line:

All qualified entries will include source code, and a commented line in the program with the string "license: " followed by a URL to one of the licenses specified in this rule. Alternatively you may include the text of the following license as comments in your program:

Copyright © 2017 your-name-goes-here

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

4. All qualified entries will be exactly 100 LOC or fewer:

5. This means you can have up to 99 "newlines" whether your operating system or editor uses CR+LF, LF, or the obsolete CR as its newline. LF will count as 1 newline; CR+LF (used consecutively, without characters in between them) will count as 1 newline, no worries.

6. Any line or lines can be more than 255 characters in length; however, all qualified entries will be no more than 25500 characters. Whitespace counts, except leading at the top and trailing at the bottom of the program.

LICENSE COMMENTS WILL NOT COUNT towards this limit. (But other comments and whitespace will.)

7. (Perhaps the most interesting rule of all...)

Qualified entries do not have to be 100% original.

All qualified entries will provide credit and urls to any other works they use or adapt code from.

All qualified entries will be original, *or* based on works license-compatible with the license used for the entry.

All qualified entries will NOT be based on works from other authors entries to *this years* competition. In other words, if this were the 2nd annual competition instead of the 1st, you could base your entry from the 1st years entries but not the 2nd years entries. Since this is the 1st annual competition, you cannot base your entry on any other entry (except your own and works not yet entered.)

Just to clarify though: suppose the "Dragon Book" includes a license-compatible entry on page 70. In that case, 5 different people could base their entry on the program on that page. But they would all have to base it on that page; they couldnt base it on each others entries. (This will make judging originality and qualification more fun.) Either way, you get up to 15 points for originality.

8. Axes will be rated from 1 to 5 on the following criteria:

Originality * 3: This is the originality of the implementation foremost. Bonuses may be awarded for a really unique language.

Simplicity * 2: This is how approachable the language (or implementation) is to a beginner. You get points for simplicity, even though you may getting more points in other areas may complicate the language. This score will be at tradeoff for some, a boon for others.

Brevity * 2: Not at all the same as simplicity. Literally, shorter programs score higher. Probably based on actual number of characters or lines; to be determined. Criteria used for this score will be released when the contest closes.

Features * 2: This is a vague-sounding rating on "features" of the language. Like the other scores, it is possible to get a 1, 2, 3, 4 or 5 on this score, which is then multiplied (on this score, by 2.)

Documentation * 1: The lowest you can score on this is a 1, so this is a chance to increase your score by including quality documentation. Please make this documentation plaintext; it will not be scored on presentation, only usability.

-- Documentation will count towards the 25000-character, 100 LOC limit if it is not in a separate plaintext file. If it is in a separate plaintext file (which is not called by the language implementation) it will not count towards the limit.

-- Please limit this separate plaintext documentation to another 25000 characters, and consider releasing it under a GPL-compatible license (not required.)

(1 to 5) * 3 + (1 to 5) * 2 + (1 to 5) * 2 + (1 to 5) * 2 + (1 to 5) = minimum possible score of 10, maximum possible score of 50.

In the unlikely event that more than one person gets the highest score, more than one person will win.

Rule changes and suggestions are welcome, but would not have any effect on this years competition. Criteria / Rules may vary from year to year.

9. Apart from edits, multiple entries are allowed, at a potential cost-- judges are not required to review more than one entry from the same person.

Splash screen, IDE, expressions evaluator (Thanks to shian), simple do... loop with exit, simple if... else... fi and more.

Need Notepad to use file edit option, but that can be changed to compatible text editor in code.

t="Nano3":color 11,1:for s=160 to 4 step -1:cls:w=window():w.setfont(s,"pt",0,0)
at(xmax-txtw(t))/2,(ymax-txth(t))/2:? t:delay 1:next:w.setfont(16,"pt",0,0)
label restart
color 0, 11:cls:anyfile=files("*nano3.txt"):sort anyfile:? "nano3 Files:":?
for
i = 0 to ubound(anyfile):? i,anyfile(i):next
? : input "Enter file NUMBER (any else quits) > ",flnm
if
isnumber(flnm) then
if
flnm >= 0 and flmn <=ubound(anyfile) then : getfile = anyfile(flnm) : tload getfile, p : else : end : fi
else : end : fi
color 7, 1 : cls: for i = 0 to ubound(p):? i, p(i) : next
?:? "n(New) e(Edit) r(Run) k(Kill) f(Files) q(Quits)":input cmd
select case left(cmd,1)
case "n" : open "untitled nano3.txt" for output as #1
print #1, "nano3.txt for Nano3.bas (B+=MGA) "+right(date,4)+"-"+mid(date,4,2)+"-"+left(date,2): close #1
run "notepad untitled nano3.txt": goto restart
case "e" : run "notepad "+ getfile : goto restart
case "f" : goto restart
case "k" : kill getfile : goto restart
case "q" : end
case "r" : color 7, 4 : cls : dim v(25), w(250), stk() : cl = 0 : si = 0
label readline
w1 = word(p(cl), 1) : w2 = word(p(cl), 2)
for
i = 2 to 250 : ws = word(p(cl), i) : cvtValue ws : w(i) = ws : next
if w1 = "go" then
f = 0 : for i = 0 to ubound(p)
if word(p(i), 1) = "mark" and word(p(i), 2) = word(p(cl), 2) then cl = i : f = 1: exit for
next
if f = 0 then ? "Error: could not find go mark ";word(p(cl), 2) : goto fini
elif
w1 = "?"
vn = asc(w2) - 97 : wn = 3
while w(wn) <> "" : ? w(wn);" "; : wn++ : wend : input "";temp : v(vn) = temp
elif
w1 = "." or w1 = ";"
wn = 2 : while w(wn) <> "" : ? w(wn);" "; : wn++ : wend : if w1 = "." then ?
elif
w1 = "loop" : c = 1 : f = 0
for i = cl - 1 to 0 step -1 : fw = word(p(i), 1)
if fw = "do" then
c -- : if c = 0 then cl = i : f = 1 : exit for
elif fw = "loop"
c ++
fi
next
if f = 0 then ? "Error: could not find do to match loop on line ";cl : goto fini
elif
w1 = "exit" : c = 1 : f = 0
for i = cl + 1 to ubound(p)
fw = word(p(i), 1)
if fw = "loop" then
c -- : if c = 0 then cl = i : f = 1 : exit for
elif fw = "do"
c ++
fi
next
if f = 0 then ? "Error: could not find loop to match exit on line ";cl : goto fini
elif
w1 = "if" : es = "" : for i = 2 to 250 : es = es + w(i) : next : if eval(es) = 0 then cl = find(cl)
elif
w1 = "else" : cl = find(cl)
elif
len(w1) = 1 and asc(w1) > 96 and asc(w1) < 123 and w2 = "="
es = "" : for i = 3 to 250 : es = es + w(i) : next : v(asc(w1) - 97) = eval(es)
elif
w1 = "end" : goto fini
elif
w1 = "sub" : f = 0 : for i = cl + 1 to ubound(p) : if word(p(i), 1) = "return" then cl = i : : f = 1 : exit for
next : if f = 0 then goto fini
elif
w1 = "gosub" : f = 0
for i = 0 to ubound(p) : if word(p(i), 1) = "sub" and word(p(i), 2) = word(p(cl), 2) then f = 1: exit for
next : if f = 0 then ? "Error: could not find sub ";word(p(cl), 2) : goto fini else insert stk, si, cl : cl = i : si++
elif
w1 = "return"
si-- : cl = stk(si) : delete stk, si
fi
: cl += 1 : if cl > ubound(p) then goto fini
goto
readline
label fini
?:? getFile;" run is done." :?:input " Press enter to continue...";again:goto restart
case else : goto restart
end
select
sub
cvtValue(byref wrd)
if len(wrd) = 1 and asc(wrd) > 96 and asc(wrd) < 123 then wrd = v(asc(wrd)-97)
end
func find(ln)
local i, fw, c
c = 1
for i = ln+1 to ubound(p) : fw = word(p(i), 1)
if fw = "fi" then
c --
if c = 0 then find = i : exit func
elif fw = "if"
c ++
elif fw = "else" and c = 1
find = i : exit func
fi
next
? "Error: could not find fi to match line ";ln : goto fini
end
func word(byref source, wnumber) 'base 0, but word(s, 1) is first word if any
local w, p : source = trim(source) : if len(source) = 0 then word = "" : exit func
p = instr(source, " ")
while p > 0 : source = mid(source, 1, p) + mid(source, p + 2, len(source) - p - 1) : p = instr(source, " ") : wend
split source, " ", w : if wnumber > 0 and ubound(w) + 1 >= wnumber then word = w(wnumber - 1) else word = ""
end
func eval(s) 'thanks shian!
chain "env " + enclose("EVAL=") + " + str(" + s + ")"
eval = env("eval")
end
##################################################################################
# The MIT License (MIT)
# Copyright (c) 2017 B+=MGA
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
##################################################################################


. Help nano3.txt for Nano3.bas (B+=MGA) 2017-06-05
. all lines here are print lines except the next which wont show on run
v = "v"
. ============ VARIABLES
. all 26 lower case letters are variables a-z
. and their values are set with v = expression (v is first letter in line)
. These values will be subst in for printing, input and expression evaluation.
. ============ OUTPUT
. text to write on line, . signals print line
. ; same as . but next print will be on same line as last
. ============ INPUT
. ? v input prompt following letter, loads input to variable after ?
. Note: for INPUT or OUTPUT an single letter will be replaced by it's value.
. If the single lower case letter has not been assigned the rest of the line will blank.
. ============ EXECUTION FLOW
. mark lineLabel - sets line label
. go lineLabel - is GOTO
. sub - marks start of gosub routine
. return - marks the end of sub routine
. do not enter or exit an sub with go
. end will end program
. ============ LOOPING
. do - marks start of loop
. loop - marks the end of loop, required with do
. exit - commands exit from loop
. ============ BOOLEAN BLOCKS
. if - starts one and is followed by Boolean expression to evaluate
. else - optional, marks line to goto if Boolean evaluates false
. fi - marks end of Boolean block
. ============ EVALUATIONS
. All evaluations are done curtesy of SmallBASIC, so pi and exp() are constants
. available as well as trig functions..., string functions may or may not work.
. Strings are mystery to fiddle around with.
.
. So what can you do with nano3?

Here is gosub doing recursive factorial

alt with else factorial recursive test nano3.txt for Run nano3.txt (B+=MGA) 2017-06-04
do
? n Enter some number to get it's factorial, < 2 quits
if n > 1
m = 1
gosub F!
else
exit
fi
. The factorial is m
loop
. This ends the factorial recursive gosub test.
sub
F!
m = m * n
n = n - 1
if n > 1
gosub F!
fi
return



screenshots and zip:
http://thejoyfulprogrammer.com/qb64/forum/showthread.php?tid=814&pid=3453&rndtime=1496707474554310059#pid3453

The suspected code is this.

func
eval(s) 'thanks shian!
chain "env " + enclose("EVAL=") + " + str(" + s + ")" : eval = env("eval")
end


I haven't a clue how to fix for Linux systems.

Without this function, all the Boolean and math calculations are lost!
What works fantastic in Windows is lost in Linux.

Aha! (shian did leave a clue in Language Reference!) The 1st EVAL was in all caps and the 2nd was all lower case!

Here is newest Nano3-1.bas with caps fix, post #26 (unless replies are deleted)
http://thejoyfulprogrammer.com/qb64/forum/showthread.php?tid=814&pid=3481&rndtime=149679194429492495#pid3481

The newest Nano3-1.bas can also draw lines now too! see screen shot of framed butterfly.

http://thejoyfulprogrammer.com/qb64/forum/showthread.php?tid=814&page=5&...
reply #46 unless posts are deleted

Has much needed cls, wait, at and not so much needed solve to get X, Y intersect of 2 lines.
A 2nd Help page explains these and a little more on how to use ra command.

I did a calculator by numbered menu that looks like calc keys (maybe) that was almost twice as long as Nano3-2.bas!

I wish my NOOK worked with SmallBASIC so I could check out Chris program, looks like fun!
Update: It is working better (on-line samples) the print is so small it is impossible to see, no right click available to access font size.
Oh 3 vertical dots very tiny in bottom right corner, I tap and double tap and tap and hold down... nothing!