# MistSpark

After working on Nava, I released that Nava is an overly complex language (it might even need another overhaul) and I need to get into better background on creating programming languages with something much easier. So, I decided that I would attempt to design a simpler language and eventually program its interpreter. I don't have any ideas what to name it, so for now, it's called MistSpark (mtsk).

The main idea is that functions can be named like (name x y name z) like Snap! and Scratch, which is for readability. Here's an example I created to illustrate the syntax and tokenizer's design.

set :x: to []
repeat 10 times
add (length of :x: + 1) to :x:
log (item (length of :x:) of :x:)
log :x:


With more freedom with writing your functions' names, it can help make their functionality more clear. For example, if you are writing code for a game's API, you can name a function like achievement(id, goal_code, reward_code) to achivement (id) where doing (goal_code) does (reward_code). Of course, you free to write it transitionally if you wanted.

Here's all the main ideas of MistSpark.

• More clear functions by free name and argument place, supported with polymorphism and types.
• Minimal object-oriented programming, featuring things like variable/item tie-ins and items with names and values, but not things like classes and inheritance.
• The ability to write external modules and mods.

Here's some more examples.

! Hello World
log "Hello, world!"

! Factorial
set :number: to 5
set :fib: to {
set :x: to 1
for :i: = 2 to :number:
set "x" to (:x: * :i:)
return :x:
}

log (join ["Factorial of", (convert :number: to a "string"), "is", (call :fib:)] by " ")

! Fibonacci
function ["fib", [:n:, "number"]]
if (:n: = 1) or (:n: < 1)) then
return :n:
else
return ((fib(:n: - 1)) + (fib(:n: - 2)))
log (fib 9)

! FiizBuzz
for :i: = 1 to 100
if ((:i: % 3) = 0)
if ((:i: % 5) = 0)
log "FizzBuzz"
else
log "Fizz"
else
if ((:i: % 5) = 0)
log "Buzz"
else
log :i:


I don't have a repository and documentation made yet until progress was made towards the language and its interpreter, so please ask me if you have any questions.

i have a nother program to work on so i may not have time to make the interpreter.
do you have a repl.it account?

Yes, I do have one here.
If you want info in the tokenizer's design and some insistence, please let me know.

do you do three.js
if you dont thats ok too
i dont too and i learn from the threejs website and i make this

I don't either, and also what's the deal of the black background?

i didnt add a bg pic haha
no sun no moon
no direcitonal light system
after all its preclassic

you didn't see the blocks
i spawned you in the wrong place

I can see them now.

I suggest a tiny bit more syntax, because all that (get "x") stuff makes the code much harder to read than necessary. Being as I am a Logo person, I suggest :x as the abbreviation for the get function.

Thanks for the suggestion on renaming it from get to :. It would look like (:"x") because colons aren't part of the syntax and the reason of strings is to name variables like "pen color" instead to pen_color/penColor and easily get variables like (:(item 1 in (:"vars names"))) = (:"i"), but I might consider changing this if more people have a problem with it. I might change this soon or later.

Ah, that's a good point about spaces. Okay, new suggestion: :pen color:. The point isn't just to save two keystrokes, it's to lose the parentheses too, so people don't have to think about so much nesting in their program structure. You could still have get for the case of a computed variable name (or looked up var name, as in your example).

That's a much better way, and I am probably going to introduce this as the standard way to get variables. But the get function might stay in case you want to get variables with strings. But it's removed, we can rather use tables.

set :vars: to ["foo" = :foo:, "bar" = :bar:, "moo" = :moo:]
set (item "foo" in :vars:) to 42
log :foo:


@bh, I changed all the examples using from (get "x") to :x:, so you don't need to use a function and parentheses. I actually found it much better, but I smuggle in the ability to get variables by strings for two cases: using a string in a var argument or using (convert "x" to a "var"). Therefore, for anyone who wants to get any variables by a string (it should be for things like inputs), they can do so without defining a table.

Do we really want add ... to ... and other scratch-like functions? It will make it a bit harder to parse

Here's all of additional functions inherited from Scratch and their counter-parts.

• add "thing" to [] > insert "thing" to [] at ((length of []) + 1)
• replace 1 of [] to "thing" > set (item 1 of []) to "thing"
• repeat 10 times > for :i: = 1 to 10
• wait for 1 seconds > removed
• stop "all" / stop "others" / stop "myself" > break
• change :x: by 1 > set :x: to (:x: + 1)

I understand, most of these functions can be companied by other functions. Thanks for letting me know and I would take care of it.