salmanahmad / dog Goto Github PK
View Code? Open in Web Editor NEWThe Dog Programming Language
Home Page: http://www.dog-lang.org
License: Apache License 2.0
The Dog Programming Language
Home Page: http://www.dog-lang.org
License: Apache License 2.0
Code:
DEFINE view_homepage FOR user DO
LISTEN TO user FOR goals
LISTEN TO user FOR logins
ON goal DO
ASK user TO create_account
ELSE ON login DO
PRINT "LOGIN"
#ASK user TO login
END
END
Crash follows after "PRINT 'LOGIN'"
NoMethodError - undefined method _id' for nil:NilClass: /Users/samanthaainsley/dog/lib/dog/runtime/server.rb:347:in
block in initialize'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:1211:in call' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:1211:in
block in compile!'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:785:in []' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:785:in
block (3 levels) in route!'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:801:in route_eval' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:785:in
block (2 levels) in route!'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:822:in block in process_route' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:820:in
catch'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:820:in process_route' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:784:in
block in route!'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:783:in each' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:783:in
route!'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:886:in dispatch!' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:719:in
block in call!'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:871:in block in invoke' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:871:in
catch'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:871:in invoke' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:719:in
call!'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:705:in call' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in
context'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in call' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in
call'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb:16:in call' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/rack-protection-1.2.0/lib/rack/protection/json_csrf.rb:17:in
call'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/rack-protection-1.2.0/lib/rack/protection/base.rb:47:in call' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in
call'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.4.1/lib/rack/logger.rb:15:in call' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.4.1/lib/rack/head.rb:9:in
call'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/showexceptions.rb:21:in call' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:1334:in
block in call'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:1416:in synchronize' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.2/lib/sinatra/base.rb:1334:in
call'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/thin-1.4.1/lib/thin/connection.rb:80:in block in pre_process' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/thin-1.4.1/lib/thin/connection.rb:78:in
catch'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/thin-1.4.1/lib/thin/connection.rb:78:in pre_process' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/thin-1.4.1/lib/thin/connection.rb:53:in
process'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/thin-1.4.1/lib/thin/connection.rb:38:in receive_data' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in
run_machine'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in run' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/thin-1.4.1/lib/thin/backends/base.rb:63:in
start'
/Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/thin-1.4.1/lib/thin/server.rb:159:in start' /Users/samanthaainsley/.rvm/gems/ruby-1.9.2-p320/gems/thin-1.4.1/lib/thin/server.rb:145:in
start'
/Users/samanthaainsley/dog/lib/dog/runtime/server.rb:399:in run' /Users/samanthaainsley/dog/lib/dog/runtime.rb:311:in
start_stop_server'
/Users/samanthaainsley/dog/lib/dog/runtime.rb:119:in run' /Users/samanthaainsley/dog/lib/dog/runtime.rb:85:in
run_file'
/Users/samanthaainsley/dog/bin/dog.rb:343:in run' /Users/samanthaainsley/dog/bin/dog.rb:68:in
run'
/Users/samanthaainsley/dog/bin/dog.rb:42:in run' /Users/samanthaainsley/dog/bin/dog.rb:607:in
include dog
define fibonnaci: x_1 with: x_2 do
repeat 20 do
print: x_1
x_1 = x_1 + x_2
x_2=x_1-x_2
end
end
i = fibonnaci: 0 with: 1
print: i
0.0
1.0
1.0
2.0
3.0
5.0
8.0
13.0
21.0
34.0
55.0
89.0
144.0
233.0
377.0
610.0
987.0
1597.0
2584.0
4181.0
true
*Note: When the print statement at the end is removed, the true disappears. *
In server.rb
, we have the line:362
items = ::Dog::StreamObject.find({"track_id" => track.id})
to fetch the correct notify
s and asks
for a given track when it is GET
ed.
Unfortunately, this doesn't seem to be working, as currently the items
is being populated with items from the parent scope.
This is after I get a success: true
for creating a resource.
In the Twitter example, after creating a tweet
, I get the listen
in items for GET
ing a particular track listed in the listen
's items.
Yeah, it's circular. And complicated.
Create the equivalent of dog.sh for Windows users.
General syntax:
do
throw 3.14159 # Can throw any value.
catch error
// Only one catch block. If you want to dispatch based on the type of the exception, implement it yourself.
throw // Throw without a value will re-throw the current exception
ensure
// Always runs
end
The catch and ensure can be attached to any do block, even the blocks that represent control structures and functions:
define returns_pi do
throw 3.14159
catch error
i = error
ensure
return i
end
In terms of implementation, the Signal
class should be augmented to have an error
field that will get propagated up until it is caught.
Add an API method that will check if a user object represents a user that is registered with the system or not. In other words, have an API method that indicates if the user is an anonymous user or not.
DEFINE rank_k_teachers FOR shell ON me, teachers USING k = 5 DO
PERFORM "python ranking.py"
RETURN teachers_list
END
Throws an error at compile time.
Not urgent.
track.continue
is still being used on server.rb:413
, presumably it needs to be replaced.
NoMethodError - undefined method `continue' for #<Dog::Track:0x007f8ac29ed708>
There is weird behavior when you LISTEN TO null FOR my_variable
. Explore this at some point.
Compiling this code:
package package
define foo: bar do
dog.print: bar
end
dog.print: "Hello!"
Creates a .class files that seems wrong: [package]$dot$foo$colon$.class
Create a proper installer for Dog that targets the appropriate platforms. Keep in mind that it may be easiest to redistributed the JVM.
SAVE salman TO karma
and then
SAVE salman TO karma
leads to the person object
salman { .., "communities" => [ "karma", "karma" ] , .. }
Update the API to be socket based. The new API will have the following end points:
GET dog/task/<id>
POST dog/task/<id>/<channel>
SOCKET dog/task/subscribe/<id>
When a viewport renders a template for a task, the client libraries will auto subscribe for changes to the task.
When the client sends a listen the API will "queue" up the listen invocation but then return immediately. The runtime executes on another "thread" from the API server.
Whenever changes are made to the task, a "ping" is sent to all clients subscribed to the task's channel.
Whenever the client receives a "ping" over the socket, it will reload (pull) the task and update any "viewports" that are rendering a template for the task.
Viewports render templates for a task. Whenever a task changes, the viewport will auto-reload the task. Viewports' task can be hardcoded, for example, many applications will have a viewport that will always load the "root" task, but they can also be set programmatically and reloaded()
. When a viewport sends a listen to the server, and there are updates to that task, the entire viewport is replace with the new template. This is true for both on
and on each
waits.
There is also a nested {{viewport}}
helper that will allow nested templates for tasks that are displayed
to the clients.
Create a standard library for manipulating Dog arrays.
This code fails and it probably shouldn't:
package my_package
include dog
define adder: arg do
return 5 + arg
end
i = adder: "hello!"
print: i
Update the scheduler to work better with distributed workloads. Right now the scheduler spawns threads to deal with concurrency. The runtime should have a configuration capability to set a maximum number of system threads. When the runtime exceeds that limit it queues the thread so any "node" in a cluster can schedule it.
This features would require adding an atomic "scheduled" or "pending" state to the StackFrame class.
Implementing the distributed worker queue may be a perfect fit for Mongo's capped collections.
This also includes seemingly simple enhancements including:
It would be great to make this match the Dog code.
So we want it to be pluralized, and we also want to use the array to indicate hierarchy, though the latter is low-pri.
So
LISTEN FOR tweets
would turn into
{
name: [ 'tweets' ]
...
}
Incidentally, this also works great with hard to pluralize items like
LISTEN FOR octopii OF octopus
Revive the Dog REPL from the Ruby source tree.
Some inspiration:
Rust
Julia
Ioke
Sweet.js
Create the standard string library for dog.
Allow Dog to run without the persistent mode enabled. This means that after the applications closes, all of the data is lost and while it is running it does not incur the MongoDB overhead (200mb database initialization, disk I/O, etc.).
This could actually be useful for many utility scripts that will be needed in the Dog source tree. The more things written in Dog, the better.
Right now when you attempt to dog compile
an empty file it gives an error saying the file is empty. I think this should be a warning and allow other files to still be compiled.
Will need to be encrypted with a nonce.
When implementing predicates (see Issue #35) I intentionally left out the unary not operator because there was no straight forward and natural way to negate a MongoDB query expression. I attempted to implement a syntax transformer that walked the query and switched the operators ($gte becomes $lt, etc.) but it did not seem to work well with $elemMatch.
I still think that it may be possible but it is a lot of work for something that may not get much use so I am tabling it for now and we can come back to it later.
Whenever a client connects to the API we ensure an associated session_id
. The session_id
is stored in Mongo as a document with the follow schema:
{
session_id: <oid>,
user_id: <oid>,
last_activity: <date>
}
The session_id
is associated with any data that is passed into a Dog program and developers can access this id. They can also associate a real user with the session.
The sessions will eventually timeout after some amount of times. Perhaps, 1 hour? They could also be implemented as a TTL collection in Mongo.
Needs to be a part of stream to register listeners for new tracks.
Cleans up API links between ASK
, LISTEN
and ON EACH
.
In Twitter example, this means not having to defer listening for new tweets till LISTEN
is used.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.