[erlang-questions] announce SEGB-0.1

James Churchman jameschurchman@REDACTED
Fri Feb 11 22:23:56 CET 2011


js is so full of quirks... ( and therefore using it as a server side backend is a perfect idea :-) ) not using "var" makes it look up the scope hierarchy to see if it can find the same name variable and if not then use window.the_var_name but using var has other effects (for example it changes the meaning of code written above it the variable name matches in the same scope.. which can mean adding new code that accidentally reuses a variable name in code above can have very odd effects, usually making it have the value undefined)

> I actually have no idea how long data persists in javascript, especially code.

i am not even sure that people implementing ie 6 knew.... as far as i know some styles of code will never have their variables garbage collected even tho its impossible to access them! in that case it works on the principle that you will reload / quit the browser before the machine runs out of ram :-)



On 11 Feb 2011, at 20:20, Joe Armstrong wrote:

> 
> 
> On Fri, Feb 11, 2011 at 8:43 PM, James Churchman <jameschurchman@REDACTED> wrote:
> looks really cool!
> 
> two things tho, 
> 
> 1) i cant get it to work, i get when visiting http://localhost:1234/generic.html
> Uncaught ReferenceError: SVG is not defined
> in chromium 
> and 
> generic.html:20ReferenceError: Can't find variable: SVG
> in safari :-)
> 
> maybe its because i dot have genuine chrome on my mac, but the function SVG() does not exist
> 
> Oops - I've fixed this - thanks. SVG was a private library that I was playing with
>  
> 
> and 2)
> 
> im fairly sure that this in the docs is not quite correct
> var glob = new Array();
> 
> To persist a variable outside the scope of eval we can evaluate: eval('var glob[Name] = ...'); sinceglob is defined outside of the scope of eval its value will be persisted outside the scope of eval.
> 
> 
> I think that eval always runs at the scope that its at, but putting in "var" restricts the scope to either the eval or two the scope that its in (eg the function). I think its the latter. Simply leaving out the var statement (as it does in the code :-) ) makes it global (eg attach to the window object)
> 
> I didn't know that. I tried eval("var foo=.....") follow by an
> access to var via eval("...x(foo) ..") and concluded that foo
> was not known to the garbage collector and removed. I didn't try
> the eval("foo = ..") variant.
> 
> I actually have no idea how long data persists in javascript, especially code. I assume data structures are garbed away
> if they are not reachable form the DOM or the top level of
> all javscript that has been loaded, but how to remove a js script
> is a mystery ...
> 
> /Joe
> 
> 
>  
> 
> 
> james
> 
> On 11 Feb 2011, at 18:08, Joe Armstrong wrote:
> 
>> Announcing SEBG-0.1
>> 
>> SEBG = Simple Erlang Browser Graphics
>> 
>> This is a system to push graphics to a browser.
>> 
>> Using this you can make interactive graphics in a websockets enabled browser
>> in a few lines of code.
>> 
>> It consists of a simple web server. The browser
>> opens a web socket and the web server spawns a process to
>> handle the socket. I set up a middle man to handle the socket.
>> Thereafter the handler can push asynchronous messages to the browser.
>> 
>> These message contain Javascript expressions. All the code in the
>> browser does is wait for a message, eval it and wait for the next message.
>> 
>> Then I make sure jquery and Raphael are loaded, after which
>> I send Javascript messages to the browser contain Javascript expressions
>> that create SVG objects by calling library functions in Raphael
>> 
>> The code for all of this is surprisingly simple, and it is very easy to push
>> asynchronous message to the browser.
>> 
>> I have also included a number of suggests for projects based on this.
>> This list often gets request for suitable problems to solve. Building on
>> this simple code it should be possible to implement simple multi-user
>> games and so on. Being able to push asynchronous messages to the browser
>> makes like very easy.
>> 
>> Have a look. The code is at
>> 
>> https://github.com/joearms/SEBG
>> 
>> Cheers
>> 
>> /Joe
> 
> 



More information about the erlang-questions mailing list