Sign in to follow this  
Grizwald

JankoScript: a language in the making

Recommended Posts

Grizwald    270
I have been developing (read: designing ^_^) the kernel-layer of my engine for a month or two now. I have designed a signal slot system, and remote signals too! Memory management, timers, window code. Just about anything that isn't graphics or game related. Now I'm going to design the glue to my engine. I call it Janko. It doesn't mean anything, so don't ask. I wanted a language that is simple. Meaning I don't need to write code like Java to get hello world:

class Main
{
  public static int main (blarhg)
  {
     System.out.println ("Hello World");
  }
}


I want it to be linearly executed when I want it to: ie: Engine.Console.print ("Hello World!"); The engine will include functions and objects, but they are going to be one in the same. Objects can be executed like functions, functions can have inner methods and attributes like objects (why i'm comparing them i don't know, since they are the same here) I think that would greatly simply the language a bit. Here is a final example: SomeOtherJankoObject.janko
import System;  //some static class exported by the app in which      
                //janko is embedded

object SomeOtherJankoObject
{
   object PrintText (string text)
   {
       System.print (text); 
   }
}


main.janko

import SomeOtherJankoObject

SomeOtherJankoObject obj;
obj.PrintText("Hi Beyotch!");


Note the object keyword. I don't believe it correctly defines what those particular entities are. Anyone have any good suggestions? also, the language is c-like in syntax. It has C if, while, for statements along with all the other standard statements. I'm not sure if I want to go with dynamic or static typing. So give poor old Grizwald some suggestions, before I cut out your throat. Implementation of the language won't be a problem, as I've made multiple interpreters for C-style languages.

Share this post


Link to post
Share on other sites
silvermace    634
instead of re-inventing the wheel, why not save time for yourself and your engine modders and use a widely known languge such as Lua/JScript/UnrealScript/QuakeC

1) you save time by not having to write a compiler, just use a industry hardened library tried tested and packaged.

2) your modders save time because they dont need to learn yet another scripting language.

3) all in all its just WAY more practical, you could literaly save months of work (bug fixes and stuff) and concentrate on producing a more quality game.

Share this post


Link to post
Share on other sites
Grizwald    270
I really don't care about time. I want the experience of it. And this language is different than most out there. It is a simple concept, so non-programmars will have an easy time with it. LUA or PYTHON with functions/classes and whatnot will look so cryptic to an average non-coder, who can't even comprehend a batch file.

Share this post


Link to post
Share on other sites
Lacutis    301
Are you really going to tell me that this:


class Main
{
public static int main (blarhg)
{
System.out.println ("Hello World");
}
}



Makes more sense to a non programmer than:

print "Hello World"


Or

function main()
print "Hello World"
end


Or

Main =
{
main = function ()
print "Hello World"
end
}



All of which do fundamentally the same as your example.
Have you actually used Lua?

Share this post


Link to post
Share on other sites
Gyrbo    187
Just so you know, everything programming related looks cryptic to a non-programmer.

As long as the language makes sense (read: is logical), the user will be able to use it.

Share this post


Link to post
Share on other sites
Matei    190
Well, I'd say that print "Hello World" is understandable to anyone who knows English, whereas System.out.println is pretty cryptic.

However, I'm really wondering why you're making no distinction between functions and objects. I think this makes the language more confusing, and is also wrong at a conceptual level. A function is a representation of an algorithm. An object is data, with perhaps some functions that operate on that data. It doesn't make sense for a function to have "fields" or "properties" like an object does. Nor does it make sense for an object to be "executed", or to take "arguments" (well, unless it's an object representing a function).

Share this post


Link to post
Share on other sites
Grizwald    270
Quote:
Original post by Matei
Well, I'd say that print "Hello World" is understandable to anyone who knows English, whereas System.out.println is pretty cryptic.

However, I'm really wondering why you're making no distinction between functions and objects. I think this makes the language more confusing, and is also wrong at a conceptual level. A function is a representation of an algorithm. An object is data, with perhaps some functions that operate on that data. It doesn't make sense for a function to have "fields" or "properties" like an object does. Nor does it make sense for an object to be "executed", or to take "arguments" (well, unless it's an object representing a function).


You can make a block a complete function, but not allowing access to any inner variables, and you can make a block a class, by controlling what is exposed and what's not. You can make it polymorphic (this it the more advanced stuff, that beginners wouldn't even care about) where you could inherit only certain variables

ie:

exposed inheritable int State;







If an block has a return type and or a parameter list, it is treated pretty much how a functor is treated in C++. If a block has none of those (a void return type is not the same as omitting one completely) then it is basically a class-type structure (that screams redundancy)
A block that is treated like a function, even though it IS a function, can share its exposed variables.
this allows for some interesting things to happen

blocks can return other blocks, including functions. And blocks can be built anonymously at runtime, using the Janko RTTI interface. lambda is naturally used to describe anonymous blocks. Lambda (like scheme) is what builds a block.



block block_that_returns_a_custom_block returns lambda
{
...
return lambda {
... stuff that is returned.
}
}

//or return another named block block

block other_block (int arg) returns block_that_returns_a_custom_block
{
...
}





of couse this can all be horribly abused, but i'm working on that

this really makes the code easy to parse for me (my parser is VERY simple)

I have a lot of work to do yet on the language, but I am happy with how it is turning out.

Share this post


Link to post
Share on other sites
silvermace    634
if your doing it to be simple, implement a Qbasic like language

ENGLISH is the best to use for non programmers.
you want Encapsulation.

if your doing it for the Learning experience, do whatever you like, just don't claim its for something else :D


English /QBasic like script:



function scriptStart
printout "Hello World";
end

object badGuy
health; //typeless
name;

function setName
name = setName(1); //simple argument lookup
end

function onCollision
health = health - 10;
end
end


Share this post


Link to post
Share on other sites
Grizwald    270
I already have an existing C-like language for shaders and materials, and describing some various physics effects, so I want to keep some consistency so I can reuse most of my language.

Janko is many things

Share this post


Link to post
Share on other sites
flangazor    516
Functions being first class objects is one of the powerful features of languages like Lisp, Scheme, ML, Dylan, etc. You're in good company. :)

Share this post


Link to post
Share on other sites
5MinuteGaming    274
You would creately increase your users capability for writing the scripts if you added highlevel statements such as those used in QBasic.

i.e.

Line (10,10)-(100,100),1,b,10

If your going for a scripting language a lot of these highlevel statements makes sense. Since a person coding it will not have to worry about memory management and other low-level concerns. Most common programming languages simply allow for the manipulation of memory such as C/C++, Java, Pascal, and their statements do not give any support for graphics or input devices. Although Java has built in classes which handle all of that for you. You should either build them in to your objects or into the statements.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this