beautypg.com

Introduction – BrightSign BrightScript 2 Reference Guide User Manual

Page 5

background image

5

Introduction

Roku BrightScript is a powerful scripting language that makes it easy and quick to build
media and networked applications for embedded devices. The language has integrated
support for Roku Objects, a library of lightweight components. The APIs of the platform
(device) the BrightScript is running on are all exposed to BrightScript as Roku Objects.

This document specifies the syntax of the language. To write useful applications, you
should also refer to the Roku Object Reference Manual for the device you are targeting
code for. This manual is designed for people that have some experience programming
software. It is a reference guide, not a tutorial.

BrightScript compiles code into bytecode that is run by an interpreter. This compilation
step happens every time a script is loaded and run. There is no separate compile step that
results in a binary file being saved. In this way it is similar to JavaScript.

BrightScript statement syntax is not C-like; in this way it is similar to Python or Basic or
Ruby. BrightScript Objects and named entry data structures are Associative Arrays; in
this way it is similar to JavaScript or Lua. BrightScript supports dynamic typing (like
JavaScript), or declared types (like C or Java). BrightScript uses “interfaces” and
“components” for its APIs; similar to “.Net” or Java.

BrightScript is a powerful bytecode interpreted scripting language optimized for
embedded devices; in this way it is unique. For example, BrightScript and the Roku
Object architecture are written in 100% C for speed, efficiency, and portability.
BrightScript makes extensive use of the “integer” type (since many embedded processors
don‟t have floating point units). This is different from languages like JavaScript where a
number is always a float. BrightScript numbers are only floats when necessary.

If you want to get a quick flavor of BrightScript code, see the Appendix of this manual
for the game “snake”.

BrightScript is optimized to be the “glue” that connects underling components for
network connectivity, media playback, and UI screens into user friendly applications with
minimal programmer effort.