Page 1 of 3

How is LTSL written?

Posted: Sat Aug 02, 2014 5:53 am
by Kazmirzak
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!

Re: How is LTSL written?

Posted: Sat Aug 02, 2014 5:54 am
by Cornflakes_91
well, reading the devlogs helps :P

everything is written from the ground up, at least josh never mentioned any 3rd party code

Re: How is LTSL written?

Posted: Sat Aug 02, 2014 12:53 pm
by Kektain
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

Re: How is LTSL written?

Posted: Sun Aug 03, 2014 1:49 pm
by thesilverspanch
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.

Re: How is LTSL written?

Posted: Sun Aug 03, 2014 2:03 pm
by Kazmirzak
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?

Re: How is LTSL written?

Posted: Sun Aug 03, 2014 2:24 pm
by FormalMoss
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.

Re: How is LTSL written?

Posted: Mon Aug 04, 2014 1:16 am
by Katorone
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.

Re: How is LTSL written?

Posted: Mon Aug 04, 2014 2:10 am
by Victor Tombs
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. ;)

Re: How is LTSL written?

Posted: Mon Aug 04, 2014 7:24 am
by Kazmirzak
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?

Re: How is LTSL written?

Posted: Mon Aug 04, 2014 8:40 am
by Cornflakes_91
Too bad that the maximum light-speed delay between earth and mars ~22 minutes is...

Theory: busted! :P

Re: How is LTSL written?

Posted: Mon Aug 04, 2014 10:35 am
by Victor Tombs
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. ;)

Re: How is LTSL written?

Posted: Sun Sep 21, 2014 2:29 am
by Kazmirzak
Last viewtopic.php?f=12&t=3521&sid=e8bfe77b5 ... 77b#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:

Re: How is LTSL written?

Posted: Sun Sep 21, 2014 10:53 am
by Rabiator
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 ... 85%29.aspx

In Linux, the inotify system might be useful (http://en.wikipedia.org/wiki/Inotify)

Re: How is LTSL written?

Posted: Sun Sep 21, 2014 11:26 am
by Katawa
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.

Re: How is LTSL written?

Posted: Mon Oct 20, 2014 3:50 am
by lithander
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!