Nava/JASL

I'm designing an event-driven object-orientated language called Nava or JASL.
https://github.com/Sombrero64/Nava-JASL

event:start()
  print: "Hello, world!";
end)

Here's a port of my lastest Snap project, Drawing Lines.

event:init()
	import: turtle;
	global object $screen$ = (screen.new);
	global object $turtle$ = (turtle.new);
	$screen$ + $turtle$;
end)

event:start()
	with $screen$, $turtle$ do
		~screen~.size = (240, 180);
		~screen~.color = (0, 0, 0);
		~screen~.show;
		as ~turtle~ do
			repeat by 50 do
				this.penDown = false;
				this.color = ((pick: 0, 100), (pick: 0, 100), (pick: 0, 100));
				this.trans = (pick: 0, 100);
				this.posRand;
				this.dir = 90;
				this.penDown = true;
				repeat by (pick: 350, 1000) do
					repeat by (pick: 1, 10) do
						this.step: (pick: 0, 10);
					end 
					this.dir = 90 * (pick: 0, 3);
				end 
			end 
		end 
	end
end)

What do you guys think of it?

1 Like

What does this mean?

This is not (imho) idiomatic English. "Repeat by 50" would mean 50, 100, 150, etc. It should be "repeat 50 times," which also eliminates the need for the "do."

Does this syntax imply a procedure call?

This is the sort of thing that makes me happy to be programming in Snap!!

But really to have an opinion about your language I'd have to know more about its scheduler, how it handles critical sections, etc. -- the semantics, not the syntax.

P.S. What does the name mean?

It adds $turtle$ to $screen$, which creates a sprite for the window. $screen$.append: $turtle$; does the same thing.

You can replace it with repeat 10 times or repeat 10 do. I already noticed this before, and added these so you can use them instend.

Yeah.

It's a programming language that I'm designing, it doesn't have a compiler yet. I have plans to write a book that teachs you how to write a compiler for it.

Nava is named after my bombay cat, Nava G. Lawson. Nava is trim up of Navajo (where she came from) and she's overall the mascot of the language. JASL is anycomn of Jimbo's Another Scripting Language, and its the file extension (.jasl) of the scripts.

That doesn't stop you having ideas about the semantics! Like, you know, what happens if a second event of the same type happens while you're in the middle of a script handling the first one? Things like that. Does it provide the Scheme numeric tower? What other built in types are there? Is list indexing 0-origin or 1-origin?

It should work out fine. They should both work simultaneously.

There are scripts (code that can be ran later on), tuples and paths. There are few more.

It might a simpler version of it. After all, Nava can store numbers, integers and floats (reals); not rational and complex numbers for now.

It starts from 1.

Wait, you can't just say that as if it's obvious! It won't work out fine unless you think hard about concurrency and critical sections.

Or I guess I should say, go ahead and build it, and then we'll see...

No, when people say "the Scheme numeric tower" they mean infinite-precision integers, exact rationals, floats, and complex numbers. Sounds like you are just providing the hardware numeric types, like most languages.

Yay!! There's hope for this language.

I made my own language too but its not ool and it has a interpeter

at="""

""".split("\n")
datapins=[]
def con():
    global lt
    lt=[]
    for i in at:
        lp = False
        try:
            tp = int(i.split(' ')[0])
        except ValueError:
            lp = True
        if lp:
            lt.append(tuple(i.split(' ')))
        else:
            lt.append(int(i.split(' ')[0]))
def loop(iac):
    if len(lt[iac]) == 4:
        if lt[iac][0] == 'Add':
            lt[int(lt[iac][1])] = (lt[int(lt[iac][2])] + lt[int(lt[iac][3])])
        elif lt[iac][0] == 'And':
            lt[int(lt[iac][1])] = (int(lt[int(lt[iac][2])] and lt[int(lt[iac][3])]))
        elif lt[iac][0] == 'Or':
            lt[int(lt[iac][1])] = (int(lt[int(lt[iac][2])] or lt[int(lt[iac][3])]))
        elif lt[iac][0] == 'Xor':
            lt[int(lt[iac][1])] = (int(int(lt[int(lt[iac][2])]) + int(lt[int(lt[iac][3])]) == 1))
        else:
            raise Exception()
    elif len(lt[iac]) == 3:
        if lt[iac][0] == 'Isneg':
            lt[int(lt[iac][1])]=(lt[int(lt[iac][2])] < 0)
        elif lt[iac][0] == 'Iszero':
            lt[int(lt[iac][1])]=(lt[int(lt[iac][2])] == 0)
        elif lt[iac][0] == 'Jump':
            iac = lt[iac][1] if lt[int(lt[iac][2])] else iac
        elif lt[iac][0] == 'Output':
            print(lt[iac][1]+":"+lt[int(lt[iac][2])])
        elif lt[iac][0] == 'Input':
            lt[int(lt[iac][1])] = datapins[int(lt[iac][2])]
        elif lt[iac][0] == 'Isnot':
            lt[int(lt[iac][1])] = (int(not lt[int(lt[iac][2])]))
        else:
            raise Exception()
    elif len(lt[iac]) == 1:
        if lt[iac][0] == '//':
            pass
        else:
            raise Exception()
    elif len(lt[iac]) == 1:
        if lt[iac][0] == 'Halt':
            raise Exception('HALT!!!')
        else:
            raise Exception()
    else:
        raise Exception()
    iac+=1
    return None
def init():
    setdp()
    con()
iac=0
init()
while True:
    loop(iac)

I decided to move the repo to a new home.
https://github.com/Nava-JASL/Nava-JASL

Thanks @sombrero your JASL gave me an idea.

1 Like

I reworked on Nava's features, and it's no longer an event-driven language.

That's a big change! Want to say anything about your reasons?

I think it could be a generic programming language that can be used for pretty much anything. Don't worry, you can create alternatives to events.

global tuple trigger1 = (false, {});

launch({
	while true {
		when trigger1.1 { run(trigger1.2); }
	}
});

trigger1.2 = {
	print("Hello, world!");
};

wait(2.5);
trigger1.1 = true;

Updated the Drawing Line script to look like the new Nava.

import &turtle&

global object screen = (screen.new);
global object turtle = (turtle.new);
screen + turtle;

with screen, turtle {
	#screen#.size = (240, 180);
	#screen#.area = (300, 260);
	#screen#.show;
	as #turtle# {
		repeat 50 {
			self.penDown = false;
			self.color = (rand(0, 100), rand(0, 100), rand(0, 100));
			self.trans = rand(0, 100);
			self.posRand;
			self.dir = 90;
			self.penDown = true;
			repeat rand(350, 1000) {
				repeat rand(1, 10) {
					self.step(rand(0, 10));
				} 
				self.dir = 90 * rand(0, 3);
			}
		}
	}
}
1 Like

It has been a while scene making updates on Nava, so this what the program should look like now by today's standards.

import &turtle&

program DrawingLines {
	global object screen = (screen.new)
	global object turtle = turtle.new(screen)

	with screen, turtle {
		#screen#.size = (240, 180)
		#screen#.area = (300, 260)
		#screen#.show
		as #turtle# {
			repeat 50 {
				self.penDown = false
				self.color = (rand(0, 100), rand(0, 100), rand(0, 100))
				self.trans = rand(0, 100)
				self.posRand
				self.dir = 90
				self.penDown = true
				repeat rand(350, 1000) {
					repeat rand(1, 10): self.step(rand(0, 10))
					self.dir = 90 * rand(0, 3)
				}
			}
		}
	}
}
2 Likes

I decided to rework on Nava, so...

program DrawingLines
	import turtle
	
	static object screen = (screen.new)
	static object turtle = (turtle.new, pet)
	
	with screen, turtle
		$screen$.size = (240, 180)
		$screen$.area = (300, 260)
		$screen$:show
		
		as $turtle$
			repeat 50
				self.penDown = false
				self.color = (random(0, 100), random(0, 100), random(0, 100))
				self.trans = random(0, 100)
				self:posRand
				self.dir = 90
				self.penDown = true
				repeat random(350, 1000)
					repeat random(1, 10): self:step(random(0, 10))
					self.dir = 90 * random(0, 3)
1 Like

I decided to introduce syntax sugar for Nava. Because of this, you can make yourself home.

program DrawingLines (
	import (require turtle)
	
	static object screen = new screen
	static object turtle = new (turtle pet;)
	
	with screen, turtle (
		screen.size = (240, 180)
		screen.area = (300, 260)
		screen:show
		
		as turtle (
			repeat 50 (
				self.penDown = false
				self.color = ((rand 0, 100), (rand 0, 100), (rand 0, 100))
				self.trans = (rand 0, 100)
				self:posRand
				self.dir = 90
				self.penDown = true
				repeat (rand 350, 1000) (
					repeat (rand 1, 10): self:step (rand 0, 1)
					self.dir = 90 * (rand 0, 3)
				)
			)
		)
	)
)