How is LTSL written?

The S&M crowd is getting naughty with the game files.

How is LTSL written?

Postby Kazmirzak » Sat Aug 02, 2014 5:53 am

Hello Josh,

I registered an account just to ask this question: how is LTSL written? Did you write the parser, interpreter etc from scratch in C++, or did you use good old 3rd party tools like bison, flex etc. to parse LTSL? I'm pretty sure it is not mentioned in the dev logs.

Thanks alot!
Kazmirzak
Recruit
 
Posts: 7
Joined: Sat Aug 02, 2014 5:16 am

Re: How is LTSL written?

Postby Cornflakes_91 » Sat Aug 02, 2014 5:54 am

well, reading the devlogs helps :P

everything is written from the ground up, at least josh never mentioned any 3rd party code
User avatar
Cornflakes_91
Admiral
 
Posts: 9202
Joined: Wed Mar 06, 2013 1:53 am
Location: Austria

Re: How is LTSL written?

Postby Kektain » Sat Aug 02, 2014 12:53 pm

Welcome to the forums! :)

If he mentioned using a tool, I missed it too. But one nice property of Lisp-like languages is that they're very easy to interpret. The source code is already an abstract syntax tree! I wrote my own small Lisp in Python maybe six months ago, and had it working in a single Friday afternoon with a few last changes the following Sunday, made while I was using it to develop something else. A few things were in my favor: circumstances let me skip the lexing step, it's interpreted instead of compiled to something else, and it doesn't support macros. But writing a simple Lisp compiler from scratch with all the minimum special forms is completely feasible in just a couple days!

It's something people should try, I think. I learned a ton, and it's motivated me to add Common Lisp to my toolset. :D
User avatar
Kektain
Lieutenant
 
Posts: 98
Joined: Fri Dec 07, 2012 11:19 pm

Re: How is LTSL written?

Postby thesilverspanch » Sun Aug 03, 2014 1:49 pm

I asked him in IRC while he was uploading the update. I also assumed he was using flex/bison (since thats the only way Im familiar with doing syntactic/semantic analysis), but he said that the LT engine itself was doing all the heavy lifting, which kind of blew my mind.
User avatar
thesilverspanch
Lieutenant Commander
 
Posts: 126
Joined: Sun Jul 06, 2014 9:18 pm
Location: Chico California

Re: How is LTSL written?

Postby Kazmirzak » Sun Aug 03, 2014 2:03 pm

thanks for your answers!

For me this is a coding miracle. At university you need one whole semester just to learn how to use flex and bison. And Josh simply hammers it down in one or two weeks (just besides everything else he does) :-) I just want to know where the cheat is. Maybe he designed the syntax in a way so compiling it is not a real issue?

One more question remains: is an LTSL script parsed every time a new object is created, or does Limit Theory produce some binary or intermediate code for every LTSL-Script?
Kazmirzak
Recruit
 
Posts: 7
Joined: Sat Aug 02, 2014 5:16 am

Re: How is LTSL written?

Postby FormalMoss » Sun Aug 03, 2014 2:24 pm

Kazmirzak wrote:
One more question remains: is an LTSL script parsed every time a new object is created, or does Limit Theory produce some binary or intermediate code for every LTSL-Script?


The way Josh explains it is that LTSL scripts are periodically polled.
That way, in Dev Update #19, you can see that as soon as he saves the change for the LTSL script, the engine updates itself immediately.

He also mentioned previously that having hundreds of individual script files could slow down the engine, but that's only at the extreme end of things.
YAY PYTHON \o/

In Josh We Trust
-=326.3827=-


User avatar
FormalMoss
Captain
 
Posts: 984
Joined: Fri Jun 06, 2014 8:06 am

Re: How is LTSL written?

Postby Katorone » Mon Aug 04, 2014 1:16 am

FormalMoss wrote:He also mentioned previously that having hundreds of individual script files could slow down the engine, but that's only at the extreme end of things.

If it ever gets to that, I'm sure Josh will add a parameter to allow a script to give itself a lower polling priority.
It's the smart thing to do, if you're relatively sure you won't be changing a script during play.
Beware of he who would deny you access to information, for in his heart he dreams himself your master.
User avatar
Katorone
Vice Admiral
 
Posts: 2297
Joined: Tue Dec 25, 2012 5:08 am
Location: Belgium

Re: How is LTSL written?

Postby Victor Tombs » Mon Aug 04, 2014 2:10 am

He gets most of the LTSL from a large arcane book past down to him by the coding wizards of the long forgotten original Elder Council. Limit Theory is a kind of initiation test Josh is undertaking to gain admittance to their hallowed and august ranks.

:shifty: I think he may get a pass but it depends on how he handles the content section of the test. ;)
Victor Tombs
Elder Council Member
 
Posts: 7181
Joined: Tue Dec 25, 2012 6:58 pm

Re: How is LTSL written?

Postby Kazmirzak » Mon Aug 04, 2014 7:24 am

The ancient coding wizards! How could I forget about them!

Its so crystal clear now:
Spoiler:      SHOW
the coding 'cave' the mysterious day/night-rhythm (A day on mars is 24 hours 39 mins), surely he's not from earth. Considering this knowledge which he can only have gathered if he worked his whole life 24/7 or has some ingenious masters (or both) leads to the conclusion that he is hardly a human, so he must be one of the remaining beings of the marsian high civilsation (that one that almost got extinct due to global cooling)! Another proof: Actually Josh uploads all dev logs in time, they are just suffering the time delay from mars to earth, see, if he presses "submit" on mars, the update won't be on earth before 8 hours later. And it won't get better the following months, since in December this year mars and earth are in sun-conjunction - the farthest away from each other.

OMG it all makes sense now. Thanks Victor! :-)

P.S. Josh... no kidding... you wrote parser and compiler and interpreter for a complete language just by hand... in a week?
Kazmirzak
Recruit
 
Posts: 7
Joined: Sat Aug 02, 2014 5:16 am

Re: How is LTSL written?

Postby Cornflakes_91 » Mon Aug 04, 2014 8:40 am

Too bad that the maximum light-speed delay between earth and mars ~22 minutes is...

Theory: busted! :P
User avatar
Cornflakes_91
Admiral
 
Posts: 9202
Joined: Wed Mar 06, 2013 1:53 am
Location: Austria

Re: How is LTSL written?

Postby Victor Tombs » Mon Aug 04, 2014 10:35 am

Kazmirzak wrote:OMG it all makes sense now. Thanks Victor! :-)


I forgot to welcome you to the LT forums, Kazmirzak. :wave: Sorry about that. I'm sure you will enjoy your time here. :D

Oh! And take no notice of what Cornflakes said. He thinks in human terms, he has little knowledge of the advanced devices the original EC possess. The ranks of the Council are filled with those supremely gifted individuals who are true Masters in a bewilderingly diverse collection of disciplines. Coding forms a small but significant part of the whole. :angel:

Josh may tell us more if he feels inclined to do so but the true EC jealously guard their privacy. They may decide he has revealed enough. ;)
Victor Tombs
Elder Council Member
 
Posts: 7181
Joined: Tue Dec 25, 2012 6:58 pm

Re: How is LTSL written?

Postby Kazmirzak » Sun Sep 21, 2014 2:29 am

Last http://forums.ltheory.com/viewtopic.php?f=12&t=3521&sid=e8bfe77b5e3c2fa49603fdb21c34777b#p64143 devlog:
Indeed, in the regular world of parsing massive languages with ambiguous grammars and so forth, it might not be such a simple thing. In the simple world of LTSL string lists, it took me one hour to have full-blown infix operators with correct precedence implemented in the language. The code that implements it is about 80 lines of C++. Simplicity pays off once again!


Ha! Now we know that Josh knows about the "regular world" of bison and flex, which uses "grammars" to describe a language. And now we also know he would rather hacks his own parser down in some plain C++ than use these crappy tools. :ugeek:

PS ~ I know, you're tired of hearing about LTSL [...]


@Josh: Any source code snippets for those guys that do like these dev logs? We are right here :wave: :wave:
Kazmirzak
Recruit
 
Posts: 7
Joined: Sat Aug 02, 2014 5:16 am

Re: How is LTSL written?

Postby Rabiator » Sun Sep 21, 2014 10:53 am

Katorone wrote:
FormalMoss wrote:He also mentioned previously that having hundreds of individual script files could slow down the engine, but that's only at the extreme end of things.

If it ever gets to that, I'm sure Josh will add a parameter to allow a script to give itself a lower polling priority.
It's the smart thing to do, if you're relatively sure you won't be changing a script during play.

Better yet, use some sort of surveillance on the file that notifies LT of someone writing to the file. Then reload it.

In Windows:
http://msdn.microsoft.com/en-gb/library/windows/desktop/aa365261%28v=vs.85%29.aspx

In Linux, the inotify system might be useful (http://en.wikipedia.org/wiki/Inotify)
Rabiator
Captain
 
Posts: 572
Joined: Thu Dec 13, 2012 4:16 pm

Re: How is LTSL written?

Postby Katawa » Sun Sep 21, 2014 11:26 am

This is almost certainly already the case, the game watching for changes to the script files or folders.
Being slow from running many scripts wouldn't be related to them being changed though, it would be due to the pilling on of extra conditions for game logic and objects.
woops, my bad, everything & anything actually means specific and conformed
User avatar
Katawa
Rear Admiral
 
Posts: 1544
Joined: Thu Apr 18, 2013 1:05 am
Location: that sound that makes the hairs on your neck raise

Re: How is LTSL written?

Postby lithander » Mon Oct 20, 2014 3:50 am

Writing a small interpreted scripting language isn't as hard as it sounds. I'm sure doing it from scratch is more fun than wrestling with a bison.^^ But the way he added not only a hot-loading custom scripting engine but also a full fledged, meticulously polished code editor that seamlessly integrates with the game app blows me away. Is that custom written too? It looks so beautiful!
Last edited by lithander on Mon Oct 20, 2014 4:04 am, edited 1 time in total.
lithander
Ensign
 
Posts: 12
Joined: Sat Dec 01, 2012 6:11 am

Next

Return to Scripting & Modding



Who is online

Users browsing this forum: No registered users and 2 guests