-
6 Dec 2011 6:54 AM #1Sencha - Community Support Team
- Join Date
- Nov 2008
- Location
- San Diego, Peoples' Republic of California
- Posts
- 2,040
- Vote Rating
- 7
Announcing SilkJS
Announcing SilkJS
I am pleased to announce SilkJS, a V8 based Swiss Army Knife (and HTTP server).
SilkJS currently compiles for Linux and Mac OSX, but should port trivially to any flavor of Unix. It was originally written for Ubuntu Linux and ported to OSX (a FreeBSD flavored Unix) in under 2 hours.
So what is it?
SilkJS is a C++ program that links with the Google V8 JavaScript engine and several other libraries. It provides as simple and direct as it can, methods that make calling operating system and those other libraries' functions from JavaScript context.
Running SilkJS is as simple as:
SilkJS simply loads the specified JavaScript file, compiles it, runs it, then calls a main() function provided by the script. Any additional arguments on the command line are passed to the main() function.Code:path_to/SilkJS some_javascript_file.js
SilkJS is not NodeJS. It merely provides the "glue" to the operating system and other library functions to make them callable from your JavaScript program.
I wrote an HTTP server almost entirely in JavaScript using SilkJS that's included with SilkJS. The HTTP server is a pre-fork model server, and it's very fast. I was able to run ab (apache benchmark) against it with 20,000 concurrent requests and it served a 13.3K file 50,000 times in under 3 seconds with no errors. It is several times faster than NodeJS at serving NodeJS' sample "hello, world" demo on the nodejs.org home page. It is 30x or more faster than Apache and PHP 5.3 at running real world server-side business logic.
I also wrote a console program in JavaScript using ncurses that technically minded webmasters will find quite useful. It refreshes the screen once per second, displaying in real-time the CPU usage, memory usage, disk activity, and virtual memory. With this program, you can tell if a busy WWW server is CPU, memory, and/or disk bound. Or if it's swapping heavily.
SilkJS comes with a number of library interfaces built-in. These include console I/O, file system I/O, the gd2 graphics library, MySQL, ncurses, networking, and process management (fork, wait, etc.).
nodejs.org is served by ngnix, not by nodejs. SilkJS can be viewed at http://silkjs.org/ and it is entirely served by SilkJS itself.
SilkJS may be downloaded and used freely from github at http://github.com/mschwartz/SilkJS.
Please see the Wiki http://github.com/mschwartz/SilkJS/wiki, it contains more details about building SilkJS, benchmarks, example programs, etc. Of particular interest to us ExtJS developers is the ORM, which fully supports ExtJS DataStore.
I've started a Google Group for supporting SilkJS at http://groups.google.com/group/silkjs
Check it out!SilkJS - Server Side JavaScript Swiss Army Knife and HTTP Server
Powerful, flexible, advanced charting for ExtJS and Touch: http://zingchart.com
Javascript rocks. Even on the server-side:
ExtJS Forums' Server-Side Javascript Social Group
-
6 Dec 2011 7:28 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
Dude... this is awesome! I have just converted my stuff from Apache to Node but will play around with this. When I do get time and any updates... expect some forking going on!
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
6 Dec 2011 7:49 AM #3Sencha - Community Support Team
- Join Date
- Nov 2008
- Location
- San Diego, Peoples' Republic of California
- Posts
- 2,040
- Vote Rating
- 7
To add to my previous post...
The idea of compiling and running the script on the command line, then calling its main() function is so you can load up your library or API, then actually run your main business logic.
So:
SilkJS comes with an installer (for Linux):Code:include('lib/Util.js'); // include more stuff... function main() { // call stuff in lib/Util.js }
It creates a /usr/local/bin/SilkJS binary, and /usr/share/SilkJS where it copies lib/ and appropriate other files.Code:./SilkJS Install.js
If you pass include() an absolute path, it looks for the file there, otherwise it looks in the current directory then /usr/share/SilkJS.
It also supports shebang:
chmod 755 ./hello.jsCode:#!/usr/local/bin/SilkJS // file is ./hello.js function main() { println('hello, world'); }
then you can run hello.js:
./hello.js
If you don't have access to Ubuntu, you can install it in VirtualBox (http://virtualbox.org). Download the ISO from http://ubuntu.com (I use the server version, not the desktop one).
The ORM works on top of MySQL. It's documented here: http://github.com/mschwartz/SilkJS/wiki/Schema.js.
The ORM is designed to work with ExtJS and DataStores, though it's flexible enough to do anything.SilkJS - Server Side JavaScript Swiss Army Knife and HTTP Server
Powerful, flexible, advanced charting for ExtJS and Touch: http://zingchart.com
Javascript rocks. Even on the server-side:
ExtJS Forums' Server-Side Javascript Social Group
-
6 Dec 2011 7:58 AM #4Sencha - Community Support Team
- Join Date
- Nov 2008
- Location
- San Diego, Peoples' Republic of California
- Posts
- 2,040
- Vote Rating
- 7
Not on the wiki yet is Jst.
The HTTP server will statically serve .html, .css, .js, .jpg, etc., files. If it sees a .jst extension on a file, it loads it and runs it.
What is Jst? It's a lot like JSP (or PHP), except the language is JavaScript AND you can call any function of any class you've done include() on in your main program.
<%Code:<% var title = 'Hello from Jst'; %> <html> <head> <title><%= title %></title> </head> <body> <h1>Users</h1> <ul> <% forEach(SQL.getDataRows('SELECT * FROM Users'), function(user) { %> <li><%= user.username %></li> <% } %> </ul> </body> </html>
// any JavaScript can go here
%>
<%= JavaScript expression %>
(emits result of the expression)SilkJS - Server Side JavaScript Swiss Army Knife and HTTP Server
Powerful, flexible, advanced charting for ExtJS and Touch: http://zingchart.com
Javascript rocks. Even on the server-side:
ExtJS Forums' Server-Side Javascript Social Group
-
6 Dec 2011 8:03 AM #5
-
8 Dec 2011 5:19 AM #6Sencha - Community Support Team
- Join Date
- Nov 2008
- Location
- San Diego, Peoples' Republic of California
- Posts
- 2,040
- Vote Rating
- 7
28 people watching the repository on github after 2 days.
SilkJS - Server Side JavaScript Swiss Army Knife and HTTP Server
Powerful, flexible, advanced charting for ExtJS and Touch: http://zingchart.com
Javascript rocks. Even on the server-side:
ExtJS Forums' Server-Side Javascript Social Group
-
8 Dec 2011 5:23 AM #7
-
8 Dec 2011 6:10 AM #8
Sweet Mike!
"be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
8 Dec 2011 6:40 AM #9Sencha - Community Support Team
- Join Date
- Nov 2008
- Location
- San Diego, Peoples' Republic of California
- Posts
- 2,040
- Vote Rating
- 7
26 of those 28 yesterday alone. 13 overnight.
I haven't even been doing any "marketing" of it yet. I'm hoping to have silkjs.org WWW site up this week and then I have people who run JS blog sites wanting to write about it.
For my next JSMag article, I will write about how to integrate SilkJS' ORM with ExtJS grids in 250 lines of code or less.SilkJS - Server Side JavaScript Swiss Army Knife and HTTP Server
Powerful, flexible, advanced charting for ExtJS and Touch: http://zingchart.com
Javascript rocks. Even on the server-side:
ExtJS Forums' Server-Side Javascript Social Group
-
9 Dec 2011 4:28 AM #10
I am mostly interested in applications for this project for developing / testing extjs app .
Can we use that for unit testing, for intellisense or for anything useful?My ODesk profile - https://www.odesk.com/users/~~b3b73482afb3f2c5


Reply With Quote


