What would be the point in developing LSL3 rather than just using any of the many languages that work with Mono?
These forums are CLOSED. Please visit the new forums HERE
How to optimize code and when not to. |
|
Argent Stonecutter
Emergency Mustelid
![]() Join date: 20 Sep 2005
Posts: 20,263
|
03-03-2006 06:57
What would be the point in developing LSL3 rather than just using any of the many languages that work with Mono? |
Keknehv Psaltery
Hacker
![]() Join date: 11 Apr 2005
Posts: 1,185
|
03-03-2006 07:20
Naturally they would keep the existing LSL working -- LL never breaks existing functionality.
I'm with Strife on this -- If SL supported C, I would write in it. My skills in programming C aren't quite as polished as I'd like, mainly because I rarely have an occasion to write in it. If I wrote C in SL, though, I'm sure my skills would improve. And then SL could be marketed as immersive programming software-- It's much more fun to program things and sell them for money. Also, I'm sure we'd all get a bit more exposure to various languages-- reading C, C++, C#, Python.. _____________________
|
Zepp Zaftig
Unregistered Abuser
Join date: 20 Mar 2005
Posts: 470
|
03-03-2006 09:40
I'd love to use C++ in SL, but I think LL really need to continue supporting scripters who have learned LSL, but do not yet know any RL languages - as well as the large exisiting base of LSL library and open-source code. IMO, LSL.MONO (or whatever) is a neccesary bridge before LL develop and release a MONO API. They've already made an LSL compiler that can compile to Mono, and I'm not suggesting that they should stop supporting LSL. I just don't see much point in making a new version of the language itself. I assume that what was meant with LSL3 was a new version of the language itself i.e. changes to the syntax etc. LSL can be kept a simple language like it is and those who want arrays, object oriented programming etc. can use another language instead. Because the semantic distance between LSL and the Second Life world model is small, so LSL may well remain the most "natural" way to script second life. |
Argent Stonecutter
Emergency Mustelid
![]() Join date: 20 Sep 2005
Posts: 20,263
|
03-03-2006 10:20
If SL supported C, I would write in it. |
Argent Stonecutter
Emergency Mustelid
![]() Join date: 20 Sep 2005
Posts: 20,263
|
03-03-2006 10:41
LSL is like a state-event driven version of C without arrays, structs, pointers etc., I don't see how that is more natural than anything else. Maybe some people will still prefer LSL, but personally I would much rather use an object oriented language like C#. For example: CODE
Around 1983 I write a preprocessor for Forth called RatForth that would read the C-like code and generate the Forth code above it. CODE
The former is Ratfor, the latter is the generated Fortran. Again, the Ratfor looks like C, but the Fortran doesn't. The surface appearance of a language has very little to do with the semantics. |
Zepp Zaftig
Unregistered Abuser
Join date: 20 Mar 2005
Posts: 470
|
03-03-2006 12:06
Argent, what exactly is it about LSL that you think makes it's more natural for SL than other languages?
|
Strife Onizuka
Moonchild
![]() Join date: 3 Mar 2004
Posts: 5,887
|
03-04-2006 15:11
Argent, what exactly is it about LSL that you think makes it's more natural for SL than other languages? I'll answer this; we already have LSL. I'm not advocating a single Mono compatible language. I'd like to pick and choose. As to LSL3 I don't see the point in developing it, I don't see LL making LSL better. BTW we are straying off topic _____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey |
Zepp Zaftig
Unregistered Abuser
Join date: 20 Mar 2005
Posts: 470
|
03-04-2006 18:43
I'll answer this; we already have LSL. I'm not advocating a single Mono compatible language. I'd like to pick and choose. As to LSL3 I don't see the point in developing it, I don't see LL making LSL better. BTW we are straying off topic Aye, I can agree to that. |
Argent Stonecutter
Emergency Mustelid
![]() Join date: 20 Sep 2005
Posts: 20,263
|
03-04-2006 19:13
Argent, what exactly is it about LSL that you think makes it's more natural for SL than other languages? About the only things I'd like to add to LSL are arrays that can be passed by reference, like in Tcl or C. I don't want to see arrays of arrays or pointers to anything, because that complicates the garbage collection immensely... once you get back to the top level you need to be reference-free. |
Keknehv Psaltery
Hacker
![]() Join date: 11 Apr 2005
Posts: 1,185
|
03-04-2006 19:58
You have a point, Argent. But LSL is, of course, missing some basic lower-level functionalities that many find useful-- arrays being the most notable ones, with various other more fiddly things missing.
LSL gets close, but it's still missing things in C that are really useful. If they made LSL3 to be a hybrid between the current LSL and C, keeping the state/event structure but allowing lower-level manipulation, then I might consider using it. What would be really neat would be some sort of Mono assembly language-- then we can have hyper-optimized scripts to factor RSA-1024 (That was a joke). Assembly would be useful, because if the language(s) are missing a feature, you can say "Ah, well, I guess I'll just have to do this the long way..." Databases anyone? _____________________
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
03-04-2006 20:42
What C features would you add? I wouldn't touch pointers/malloc/free with a 10' pole here - too much chance for errors or malicious code, so elaborate policing/bounds checking would have to be added to the VM.
Arrays for sure. User-definable data types would be nice. Very nice. And arrays... if lists had much lower overhead and allowed direct access to individual elements without an O(n) lookup for every llList2... call (which I believe is how things are now). But I guess it would be simpler to give us arrays, since there's no real way to implement that. Switch-case? Unless they implement it as a jump table, the compiler will expand that out into if-else blocks, so all you gain is code readability. Something I've wished for a few times - the ability to specify a state name in a variable. So you could change states by calling "state varName;". I think that would be pretty powerful, and useful, it would let us streamline a lot of decision/input based state changes. And my latest annoyance - to not have a 400 character string take up 800 bytes of memory. And more memory is always nice ![]() |
Argent Stonecutter
Emergency Mustelid
![]() Join date: 20 Sep 2005
Posts: 20,263
|
03-05-2006 05:17
You have a point, Argent. But LSL is, of course, missing some basic lower-level functionalities that many find useful-- arrays being the most notable ones, with various other more fiddly things missing. I wouldn't want a hybrid between LSL and C. C is completely inappropriate for the target audience... bringing in traditional arrays, associative arrays, Lisp-style lists, or some other non-referenceable but handle-based "collection" object is the biggest need, because all the copying that the current implementation requires is the main thing that's killing it now. |
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
03-05-2006 08:39
One thing I found in my 12 script monster of a vendor, breaking up code into seperate scripts actually has a positive effect on overall speed.
So if your code allows it you can do things like: CODE touch_start(integer x) { Replaced with: CODE touch_start(integer x) { This runs significantly faster in my case, not to mention that it reduced memory useage by about 30k using multiple scripts to hold the list as separate chunks ![]() On that note, if you are storing data in some kind of pattern, then breaking a big list down into several smaller lists is a good move. For example, I have a vendor with 50 items, entered in the order they are read from the notecard. I convert this list into 5 smaller lists of 10. Knowing the maximum size of each list I can happily load an item, e.g if I want item number 25 then I just divide by 10 and round up, which tells me that the item is in list #3. If I am using link-messaged scripts to hold the lists then addressing this list is extremely easy provided each list listens for link messages containing a particular integer, in this case the number 3. |
Masakazu Kojima
ケロ
![]() Join date: 23 Apr 2004
Posts: 232
|
03-05-2006 10:43
What would be really neat would be some sort of Mono assembly language Since it would be trivial to "hack" it and send whatever CIL you want, maybe they will have the assembler and VM secure (Mono does most of the work), and open up CIL to everyone. Then you could use whatever language you want, without the client having to support it. I wouldn't count on it though. Any of it. |
Strife Onizuka
Moonchild
![]() Join date: 3 Mar 2004
Posts: 5,887
|
03-15-2006 08:09
Instead of useing ZERO_VECTOR or ZERO_ROTATION or even a global variable storing them. Use ((rotation)"" ![]() and ((vector)"" ![]() they each cost 4 bytes ![]() Which is less then it takes to push a value into the stack. ![]() This is the point that using ESL rocks. Simple way to shave a few bytes. CODE
You can also do this with integers and floats, saving 1 byte. CODE
what i didn't mention, that this is actualy slower. _____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey |
Kermitt Quirk
Registered User
![]() Join date: 4 Sep 2004
Posts: 267
|
Evaluation of if's
03-20-2006 04:51
OK... here's something I've always wondered. If the first part of an if statement is false, will LSL still evalute the entire if statement? I've seen diff languages deal with this both ways.
For example... Will the "b == c" part be evaluated in this? CODE integer a = 1; If it would, then this would probably run faster. (Although I assume it'd use more space on the stack) CODE integer a = 1; |
Strife Onizuka
Moonchild
![]() Join date: 3 Mar 2004
Posts: 5,887
|
03-20-2006 05:18
It will execute the entire argument even if it is false.
If it would, then this would probably run faster. (Although I assume it'd use more space on the stack) It would be faster if the first were false, but otherwise slower if the first were true. Splitting it adds 4 bytes to the bytecode. If the first argument is false more often then true, then there will be some proformance gains. _____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey |
Kermitt Quirk
Registered User
![]() Join date: 4 Sep 2004
Posts: 267
|
03-20-2006 05:29
It will execute the entire argument even if it is false. It would be faster if the first were false, but otherwise slower if the first were true. Splitting it adds 4 bytes to the bytecode. If the first argument is false more often then true, then there will be some proformance gains. Good. That's exactly what I expected. Because of that I tend to nest things, especially if the second part of the if is a function call, so at least now I know it's worth continuing. |
Sky Honey
Coder
![]() Join date: 16 May 2005
Posts: 105
|
03-20-2006 05:31
Darn, Strife beat me. Well anyway:
CODE integer test() { output: Object: test Object: Hello, Avatar! _____________________
|
Johntron Thirty
Registered User
Join date: 4 Mar 2005
Posts: 24
|
Code kung foo
03-20-2006 14:58
Wow, this post is way too drawn out. I think we should just ask LL to auto-optimize the code at compile time and be done with it.
|
lyndell Aleixandre
Registered User
Join date: 17 Oct 2005
Posts: 5
|
03-26-2006 09:53
Pffft.... like that will ever happen .. lmao
|
Argent Stonecutter
Emergency Mustelid
![]() Join date: 20 Sep 2005
Posts: 20,263
|
03-26-2006 10:51
Wow, this post is way too drawn out. I think we should just ask LL to auto-optimize the code at compile time and be done with it. |
Strife Onizuka
Moonchild
![]() Join date: 3 Mar 2004
Posts: 5,887
|
08-17-2006 21:29
It's been a while, and i have a few optimizations i haven't posted yet.
To start things off, a replacement for llGetListLength that is 15% faster. CODE
CODE
CODE
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey |
Bobbyb30 Zohari
SL Mentor Coach
Join date: 11 Nov 2006
Posts: 466
|
01-15-2007 17:47
rotation a = <0,0,0,1>;//1
//becomes... and saves 8 bytes rotation b = <0.0,0.0,0.0,1.0>;//2 so rotation a takes more space than rotation b? Just curious but would the placement of {}'s affect a scripts speed/memmory? Would Ex:1 run slower than ex:2? Ex:1 default { state_entry() { llSay(0, "Hello, Avatar!" ![]() } touch_start(integer total_number) { llSay(0, "Touched." ![]() } } Ex:2 default { state_entry(){ llSay(0, "Hello, Avatar!" ![]() } touch_start(integer total_number){ llSay(0, "Touched." ![]() } } |
Bobbyb30 Zohari
SL Mentor Coach
Join date: 11 Nov 2006
Posts: 466
|
01-15-2007 17:52
You can also do this with integers and floats, saving 1 byte. CODE
what i didn't mention, that this is actualy slower. 1 byte? Are we that desperate to get 1 byte? |