Clojure Alchemy: Reading, Evaluation, and Macros By this point, you probably have a magical understanding of Clojure. In the same way that alchemists thought of each chemical substance as a force of nature with no rational relationship to other chemicals, your alchemical elements are "form", "special form", "evaluates", and the like. This chapter will serve as your periodic table. Once you understand these fundamentals, you'll be ready to go full circle and obtain Clojure enlightenment, transcending code/data duality. 1. The philosopher's stone — the supreme obsession of alchemsists — was not just a wonder tool for transmuting base metals into gold; it was also a metaphor for transcending duality and reaching enlightenment. The key to Clojure enlightnment is that Clojure evaluates data structures. (def addition-list (list + 1 2))(eval addition-list); => 3 That's right, baby! (+ 1 2) ; <= that's a representation of a list(map first '([0 1] [3 4])) ; <= that's a representation of a list, too! 2. The key takeaways here are: 3. Whoa! 4. 4.1.
Learn REST: A Tutorial RESTful Web Services: A Tutorial More than a decade after its introduction, REST has become one of the most important technologies for Web applications. Its importance is likely to continue growing quickly as all technologies move towards an API orientation. Every major development language now includes frameworks for building RESTful Web services. As such, it is important for Web developers and architects to have a clear understanding of REST and RESTful services. This tutorial explains REST architecturally, then dives into the details of using it for common API-based tasks. While REST stands for Representational State Transfer, which is an architectural style for networked hypermedia applications, it is primarily used to build Web services that are lightweight, maintainable, and scalable. Features of a RESTful Services Every system uses resources. Representations Messages URIs Uniform interface Stateless Links between resources Caching Representations Listing One: JSON representation of a resource. Messages HTTP Request or
Moving things with Clojurescript and your phone accelerometer | Samrat Man Singh Now let's get to actually moving things. We'll use a canvas element of width and height both 300 pixels. (def width 300)(def height 300 We'll store the x and y coordinates of our blob in an atom, (def state (atom {:x (/ width 2) :y (/ height 2)})) Our draw function will draw our blob into the x and y coordinates: (defn draw [] (let [canvas (.getElementById js/document "canvas") ctx (.getContext canvas "2d") [r g b] [200 0 0] x (:x @state) y (:y @state)] (.clearRect ctx 0 0 width height) (set! .clearRect above clears the canvas and .fillRect draws a square with length 50px. Let's also show the x and y coordinates: (defn show-coords [] (let [x (:x @state) y (:y @state)] (dommy/set-text! As before let's add our event listener, (.addEventListener js/window "devicemotion" (fn [event] (let [a (. The interesting thing above are the two swap! We'll have the canvas re-drawn every 100 milliseconds: (defn ^:export init [] (.setInterval js/window draw 100) (.setInterval js/window show-coords 100))
Latency Compensating Methods in Client/Server In-game Protocol Design and Optimization Overview Designing first-person action games for Internet play is a challenging process. Having robust on-line gameplay in your action title, however, is becoming essential to the success and longevity of the title. In addition, the PC space is well known for requiring developers to support a wide variety of customer setups. Often, customers are running on less than state-of-the-art hardware. While broadband has been held out as a panacea for all of the current woes of on-line gaming, broadband is not a simple solution allowing developers to ignore the implications of latency and other network factors in game designs. Your game must behave well in this world. Basic Architecture of a Client / Server Game Most action games played on the net today are modified client / server games. With this in mind, the typical client / server game engine architecture generally looks like this: The server has a somewhat similar loop: Contents of the User Input messages Client Side Prediction Lag Compensation
Vim and Ctags - Andrew's blog Ctags is an old tool, just like vim, and it works wonders for code navigation. Since I was recently told that TextMate doesn’t have ctags integration out of the box, I figured I’d make an article explaining it. Even if you’ve used it before, I’ll describe some of my own workflow, so you might learn something interesting anyway. What is ctags? Ctags is a tool that extracts important constructs from the code you’re working on. Installation and simplest use case Setting up the environment is pretty simple. If you’re on a Mac and using a package manager, you could do a brew install ctags or port install ctags.On Linux, I’ve yet to see a package manager that doesn’t provide ctags.On Windows, just download the binary from the homepage and install away. Assuming the executable is in your PATH (it might not be if you’re running Windows), you can simply go to a directory with some code and run: The program will walk through the directory recursively, tagging all source files it encounters. Summary
What Every Programmer Needs To Know About Game Networking | Gaffer On Games Introduction Hi, I’m Glenn Fiedler and welcome to Networking for Game Programmers. Have you ever wondered how multiplayer games work? From the outside it seems magical: two or more players sharing a consistent experience across the network like they actually exist together in the same virtual world. But as programmers we know the truth of what is actually going on underneath is quite different from what you see. Peer-to-Peer Lockstep In the beginning games were networked peer-to-peer, with each each computer exchanging information with each other in a fully connected mesh topology. The basic idea is to abstract the game into a series of turns and a set of command messages when processed at the beginning of each turn direct the evolution of the game state. Of course this is an overly simplistic explanation and glosses over many subtle points, but it gets across the basic idea of how networking for RTS games work. But for other genres, the state of the art has moved on. Client/Server
The ClojureScript Compilation Pipeline The ClojureScript Compilation Pipeline this is the fifth entry in an n-part series explaining the compilation techniques of Clojure. In honor of the upcoming Clojure’s Google Summer of Code projects I present some discussion of the ClojureScript compiler pipeline. I talked about this in my ClojureWest talk, but a little more discussion is welcomed. Much of what I say here also applies to Clojure’s pipeline except that the details around data structures and actual programmatic interfaces are different. The ClojureScript pipeline survey This is the ClojureScript compiler pipeline: You put Clojure code in one end and out comes JavaScript from the other end. The compiler is made of numerous phases the first of which is devoted to reading strings and converting them into Clojure data structures. You can see how the reading phase works by observing the following in a Clojure REPL: You can see E is a data structure. The next compilation phase is the macro expansion phase.
Client-Server Game Architecture - Gabriel Gambetta Client-Server Game Architecture · Client-Side Prediction and Server Reconciliation · Entity Interpolation · Lag Compensation · Live Demo Introduction This is the first in a series of articles exploring the techniques and algorithms that make fast-paced multiplayer games possible. If you’re familiar with the concepts behind multiplayer games, you can safely skip to the next article – what follows is an introductory discussion. Developing any kind of game is itself challenging; multiplayer games, however, add a completely new set of problems to be dealt with. Interestingly enough, the core problems are human nature and physics! The problem of cheating It all starts with cheating. As a game developer, you usually don’t care whether a player cheats in your single-player game – his actions don’t affect anyone but him. Multiplayer games are different, though. Authoritative servers and dumb clients You also don’t trust the player with its position in the world. Dealing with networks Summary