Your Digital Media Has Never Looked So Good

 
sjb64
Topic Author
Posts: 108
Joined: Thu Apr 16, 2015 1:13 pm
Location: Memphis, TN

Brightscript requests

Tue Oct 20, 2015 12:34 pm

A few items I'd like to see added to BRS. Figured maybe if I list them here, others will join in with ideas, and maybe some will make sense to Roku and be possible to implement without breaking existing code. Some of these have easy work arounds of course, but could be done better in the compiler I think. Some may be there already and I just haven't noticed them, and will appreciate being pointed in the right direction.

Switch / Case, this has come up more than once, even Joel piped in as something he'd like to see if memory serves me right. Using a compile time hash based jump table like C#, a run time check with ranges like TurboPascal/Delphi, or even a brute force walk (syntactic sugar to if else else else...). Any of them would be awesome, and the first one would be much more efficient than the stacked elses we have now.

A tokenize that doesn't eliminate empty values. This would allow better parsing of CSV and other non XML/Json EDI data, either using new function, or adjusting tokenize to have a second arity to all this. We can do this with Regex now but that is rather slow.

A case insensitive string compare, this could be implemented in the base compiler code much more efficiently than us adjusting to lower or upper case before compare.

Compiler constants or aliases, being able to set certain constants that the compiler replaces during compile, avoids cluttering the m. array and the associated runtime costs.

Single line version of for, for each, and while, much like the if variant in BRS, just a personal preference I'd like to see.

An internal 'null' check that handles both "<unitialized>" and invalid. String checking is inefficient anyway, and any internal routine would be much better than the 'return Type(Item)<>"<uninitialized>" and Item<>Invalid' I use and have repeatedly seen in others code.

Dev mode compiler blocks that don't compiie when not in the dev sandbox, avoids runtime checks, even though they admittedly have no real run-time cost.

The ability to preset an array size on associative arrays to avoid progressively resizing for large arrays, like we can on basic arrays. I don't actually know how these are internally implemented, so this might be a meaningless request.

If I was reaching for the unreasonable I'd add...

Multithreading, which I simulate now with a getmessage wrapper method that loops an array of micro-granular state machines to allow background processes, I know this would be a massive restructuring.

Linq, which every c# programmer here knows and I assume appreciates, but that would be rather excessive and in some cases impractical.
FlixRaider channel
 
sjb64
Topic Author
Posts: 108
Joined: Thu Apr 16, 2015 1:13 pm
Location: Memphis, TN

Re: Brightscript requests

Tue Oct 20, 2015 12:53 pm

Forgot one...

A values function on associative arrays, like the new keys function. I have a function that does this as I assume many others do too, but this could be done better in an internal function than us scanning the keys and looking up the associated values.

Id say array sorting too but I know there are too many variants. I have shell sorts I use for arrays and for object arrays by field, and NewManLiving recently posted some good quick and insertion sort routines, so this probably would be a quagmire to make a language construct.
FlixRaider channel
 
User avatar
TheEndless
** Valued Community Member **
Posts: 9231
Joined: Mon Oct 04, 2004 10:15 am
Location: US
Contact:

Re: Brightscript requests

Tue Oct 20, 2015 1:13 pm

sjb64 wrote:
Single line version of for, for each, and while, much like the if variant in BRS, just a personal preference I'd like to see.

This is technically possible using colons...
While True : some simple code : End While

sjb64 wrote:
An internal 'null' check that handles both "<unitialized>" and invalid. String checking is inefficient anyway, and any internal routine would be much better than the 'return Type(Item)<>"<uninitialized>" and Item<>Invalid' I use and have repeatedly seen in others code.

One could argue that you should never have uninitialized variables in your code, and a runtime error is the correct response, but that's a different discussion.. ;)

sjb64 wrote:
Multithreading, which I simulate now with a getmessage wrapper method that loops an array of micro-granular state machines to allow background processes, I know this would be a massive restructuring.

This is available as a Task node in the new SceneGraph SDK coming in 7.0.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
 
sjb64
Topic Author
Posts: 108
Joined: Thu Apr 16, 2015 1:13 pm
Location: Memphis, TN

Re: Brightscript requests

Tue Oct 20, 2015 1:21 pm

TheEndless wrote:
This is technically possible using colons...
While True : some simple code : End While

Yeah, I use that often, just find it a bit hacky, esp. if there is even the smallest of if statements in the loop, really trips it up

TheEndless wrote:
One could argue that you should never have uninitialized variables in your code, and a runtime error is the correct response, but that's a different discussion

Agreed, but that check is one I've see even in code from Roku itself. Again, using a string to compare to seems hacky. Just to be curious changed my code to an invalid check alone and a walkthrough of the app behaved fine, since my code relies heavily on arrays. But still seems safer to have the <uninitialized> since there is no exception handing options in BRS other than Run/Eval. Maybe a point I should have added to my list.

TheEndless wrote:
This is available as a Task node in the new SceneGraph SDK coming in 7.0.

Thanks, I'll take a look at that.
FlixRaider channel
 
User avatar
RokuKC
Posts: 315
Joined: Wed Sep 10, 2014 10:44 am
Location: Roku HQ

Re: Brightscript requests

Tue Oct 20, 2015 4:21 pm

sjb64 wrote:
A few items I'd like to see added to BRS.


It's great to see the suggestions and "pain points" called out. Keep 'em coming... :)
 
User avatar
TheEndless
** Valued Community Member **
Posts: 9231
Joined: Mon Oct 04, 2004 10:15 am
Location: US
Contact:

Re: Brightscript requests

Tue Oct 20, 2015 5:02 pm

sjb64 wrote:
TheEndless wrote:
One could argue that you should never have uninitialized variables in your code, and a runtime error is the correct response, but that's a different discussion

Agreed, but that check is one I've see even in code from Roku itself.

I have it in my code as well, but don't tell anyone.. ;) I'm just not convinced there's any legitimate scenario where you could have an uninitialized variable in your code and not want to know about it.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
 
sjb64
Topic Author
Posts: 108
Joined: Thu Apr 16, 2015 1:13 pm
Location: Memphis, TN

Re: Brightscript requests

Wed Oct 21, 2015 6:05 am

TheEndless wrote:
I'm just not convinced there's any legitimate scenario where you could have an uninitialized variable in your code and not want to know about it.

The way you worded that I had no valid argument in my defense. That routine is now no longer in my code, although invalid checks in appropriate places still of course are. It mainly had to do with that background task loop that fires hundreds of times per second and could start on a given state machine before I had initialized it. But you're right, that's on me to manage, which a runtime error would point out any misstep.

But adding an exception handler I'd would like to officially add to my list of requests. Being able to ping my server with a log of error details of any RT errors that happen in the field would be invaluable, even if the routine didn't offer any reentry options, but was only a death throes intercept.
FlixRaider channel
 
EnTerr
** Valued Community Member **
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: Brightscript requests

Sat Oct 24, 2015 6:29 pm

(re single-line loops)
sjb64 wrote:
TheEndless wrote:
This is technically possible using colons...
While True : some simple code : End While
Yeah, I use that often, just find it a bit hacky, esp. if there is even the smallest of if statements in the loop, really trips it up

That's not hacky at all, it's the honest-to-goodness way to do WHILE/FOR loops. And it works - as long as you don't use IFs - but that's a different story.

The tripping you observed, it's due to broken(ish) "IF" statement. I planted into it when i was trying to do an automated line-by-line profiler - and bitched about it in this thread - viewtopic.php?f=34&t=73411 . The reason behind the mess - i am guessing - is because the difference between 1-line and multi-line `IF` has never been formalized and so it was left to the de-facto/hacky parser implementation. (I likely would have put a bright-line separation between the two `IF` versions, based on whether there is a "THEN" afterwards, i.e. if there is THEN, it's a one-liner - otherwise it's a multi-line. But now is too late because of the existing B/S codebase that uses it every which way).
 
sjb64
Topic Author
Posts: 108
Joined: Thu Apr 16, 2015 1:13 pm
Location: Memphis, TN

Re: Brightscript requests

Thu Oct 29, 2015 11:51 am

EnTerr wrote:
But now is too late because of the existing B/S codebase that uses it every which way).

Every channel, other than sideloaded, is packaged on the Roku servers. If they ever did want to create a potentially breaking change, they could literally syntax check the change against every known public and private channel in an automated test if they chose to. Would love to see a PC based syntax checker anyway, but they'd end up having to create versions for Windows, Linux, and Mac, which probably just isn't worth it.
FlixRaider channel

Who is online

Users browsing this forum: No registered users and 9 guests