The Synchronous Blog

A blog about reactive programming languages.

Posts Tagged ‘sdl

Céu v0.7

leave a comment »

The new version of Céu is released!

What’s new in v0.7:

  • Added support for functions and class methods (we relied on C for defining new functions).
  • Experimental support for interrupt service routines.
  • Experimental microkernel for Arduino.
  • Experimental `input/output´ requests.

Céu in a Box (CiB) is a Linux-based distribution that comes pre-installed with the Céu Programming Language environment:

The distribution contains the compiler together with bindings for the Arduino, TinyOS, and SDL platforms.

CiB is distributed as a single .ova file to be used with VirtualBox.

Advertisements

Written by francisco

April 3, 2014 at 5:30 pm

The “Rocks!” game in Céu & SDL

leave a comment »

The “Rocks!” game is a spaceship shooter game for 2 simultaneous players on the same Android tablet:

https://play.google.com/store/apps/details?id=org.droid_in_the_sky.rocks

The game is completely written in Céu & SDL and uses the new dynamic extensions of the language.

The code is open source and is extensively commented. I plan to write a tutorial from it:

https://github.com/droid-in-the-sky/rocks

The game also compiles to run in the desktop.

Here’s a running session of the game (with a much faster speed):

Written by francisco

October 8, 2013 at 6:40 pm

Posted in Examples, News

Tagged with , , , , ,

Céu v0.6

leave a comment »

The new version of Céu is released!

What’s new in v0.6:

  •     Added support for asynchronous threads.
  •     Added support for the C preprocessor.
  •     Added tuple types for events.

Céu in a Box (CiB) is a Linux-based distribution that comes pre-installed with the Céu Programming Language environment.

The distribution contains the compiler together with bindings for the Arduino, TinyOS, and SDL platforms.

CiB is distributed as a single .ova file to be used with VirtualBox.

Written by francisco

August 20, 2013 at 11:45 am

Stress-testing Céu with SDL

with one comment

For a glimpse at the runtime costs of Céu, I created a simple application with SDL that animates 10000 rectangles on the screen.

My hypothesis is that lines of execution in Céu (a.k.a trails) are cheap and should be used carelessly, even for simple activities such as waiting for a single event and terminating. This way, the testing application in Céu has a peek of 40000 trails active at the same time, which are all visited by the scheduler on every frame.

I compare the implementation in Céu with a simpler application in C to serve as a benchmark.

The application in raw C is damn simple:

  • Declares a vector of 10000 rectangles.
  • Initializes each to 10×10 width/height, a random (x,y) position, and a random x velocity.
  • Animates them continuously, restarting from left when reaching the right side of the screen.
  • Achieved FPS = 120 .

The video shows the expected behavior, and the code, the full implementation.
(The video was adapted to 5000 rectangles to enable screencasting).

The application in Céu is considerably more complex (video and code):

  • The program has 5 lines of execution:
    1. On SDL_QUIT event: terminates the application.
    2. Every frame: clears the screen.
    3. Every 40ms: creates 30 new Rect organisms.
      • after 30s: kills all of them at once and restart the process
    4. Every frame: updates the screen.
    5. Every second: calculates the FPS.

    (technically they are 7 lines of execution because (3) and (5) are split in two)

  • The class Rect has 4 lines of execution:
    1. Every 200ms: varies the rectangle width, height, r, g, b (with a random epsilon).
    2. Every frame: animates the rectangle respecting its velocity, terminating when it reaches the end of the screen.
    3. Every frame: redraws the rectangle on screen.
    4. On termination: runs a simple finalizer (which maintains the number of organisms alive).
  • Achieved FPS = 107 . (when 10000 rectangles are on screen)

The main differences between the two implementations are marked in bold above and are summarized as follows:

  • The rectangles in Céu are allocated dynamically: in the peek, we have 750 rectangles being allocated (in the left side) and reclaimed (in the right side) every second.
  • Each rectangle on screen (10000 at most) has 4 active trails, all of which are visited by the scheduler every frame (4 x 10000 = 40000 lightweight threads active at the same time).
  • Finally, every 30 seconds the program restarts the spawning loop, killing all 10000 active organisms at once, running the associated finalizers, and reclaiming all memory.

Céu is a source-to-source compiler that generates single-threaded ansi-C code. This way, the generated code for the test application, although incomprehensible, can be compiled with gcc and tested in any computer that has SDL2:

  % gcc download_code.c -lSDL2
.

Conclusion

The simple SDL application in C is used as a benchmark to compare to a more complex application written in Céu, which shows a decrease around 10% in FPS.

Although the application in C could be re-implemented to achieve the same functionality (for a more strict comparison), the initial numbers are already satisfactory and make the point that the trail-oriented programming style of Céu is realistic, even in a highly dynamic scenario.

http://www.ceu-lang.org/

Written by francisco

June 6, 2013 at 12:04 am

Céu “organisms”

leave a comment »

I’m about to release the version 0.4 of Céu (already available on github [1] and a dedicated VM [2]).

The language had many improvements [3], but by far, the addition of a “class” system was the most significant.

A powerful abstraction functionality is a must to augment the scope of the language from constrained embedded systems to mobile and desktop platforms.

I’ve been playing with Céu + SDL [4] for a while and came up with this idea of mixing objects (interface+explicit state) with trails (subprograms+implicit state) into a single functionality (an “organism”).

The videos that follow go through the most important concepts of Céu, starting from the basics of synchronous parallel compositions, up to the class system with scoped objects that are automatically reclaimed by the language run-time.

 

Céu basics

 

Céu with SDL

 

Céu organisms

 

Céu dynamic organisms

 

[1] https://github.com/fsantanna/ceu

[2] http://www.ceu-lang.org/CiB-0.4.ova

[3] http://www.ceu-lang.org/wiki/index.php?title=C%C3%A9u_in_a_Box (see HISTORY)

[4] http://www.libsdl.org

Written by francisco

May 10, 2013 at 12:30 pm

Posted in Concepts, News

Tagged with , , , , ,

Céu v0.2

leave a comment »

The new version of Céu is released!

Céu in a Box (CiB) is a Linux-based distribution that comes pre-installed with the Céu Programming Language environment.

The distribution contains the compiler together with bindings for the Arduino, TinyOS, and SDL platforms.

CiB is distributed as a single .ova file to be used with VirtualBox.

Written by francisco

September 26, 2012 at 7:32 pm