Fatvat: Data Persistence in GAE with Clojure If you want to persist stuff in Java, you've got a bewildering amount of choiceThere's even an entire book about making the right decision! (Persistence in the Enterprise) Google App Engine has gone with JDO using the Data Nucleus platform. When using Clojure it makes more sense to go with the lower-level api. So how do we store data in GAE? (ns news.savestory (:use (news appengine)) (:gen-class :extends javax.servlet.http.HttpServlet) (:import (com.google.appengine.api.datastore DatastoreServiceFactory Entity Key Query))) (defn store [data type] (let [entity (Entity. (.toString type))] (doseq [[k v] data] (.setProperty entity (.toString k) v)) (.put (DatastoreServiceFactory/getDatastoreService) entity) (.getKey entity))) (defn -doGet [_ request response] (let [body (.getParameter request "storyLink") title (.getParameter request "storyTitle")] (let [w (.getWriter response)] (.println w (store {:body body :title title} :story))))) Retrieving the data is much the same.
getting_started Minimal Install java -cp clojure-1.7.0.jar clojure.main user=> (+ 1 2 3) 6 user=> (javax.swing.JOptionPane/showMessageDialog nil "Hello World") Try Clojure online:TryClojure provides a brower-based Clojure REPLHimera provides a browser-based ClojureScript REPL Clojure Tools Community volunteers maintain Getting Started documentation for a number of different tools and approaches. Books There are now many excellent books about Clojure and ClojureScript. Online Books, Tutorials, and Resources Conferences Clojure/conj (usually in November)Clojure/west (usually in March)EuroClojure (usually mid-year)Clojure events
Clojure thoughts on langdev - show quoted text - On Sep 6, 10:07 am, AlamedaMike <mi...@aminoarrays.com> wrote: > This article: by one of JRuby's core developers might be of interest to Clojure- > minded people (CMPs -- a name I'd like to propose for members of our > little niche of the world). He discusses the guff that JRuby has been > getting from the CRuby folks. There are important differences. One of the (many) reasons I didn't implement an existing language is that doing so pits the ported version against the native version in irreconcilable ways. A ported language will always be dictated to by the 'native' version, always trail it in features, always struggle with the mapping of those features to the host VM of the port. To their credit, the JRuby guys have come up with a great implementation that at the end of the day may become the fastest, most powerful, and most acceptable to industry. Languages designed for the JVM (e.g. Which leaves the coolness factor.
functionaljava - Project Hosting on Google Code Functional Java is an open source library for applying Functional Programming concepts in the Java language. It also serves as a platform for learning these concepts by introducing them using a familiar language. The library is intended for use in production applications and is thoroughly tested using the technique of automated specification-based testing with ScalaCheck. Functional Java website Functional Java Examples Functional Java API Specifications Functional Java Community Download Functional Java Functional Java Builds First-Class Functions Functional Java provides generic interfaces and abstract classes that serve as first-class functions or closures, entirely within Java's type system (i.e. without reflection or byte-code manipulation). Functions are written with anonymous class syntax: // Regular StyleInteger timesTwo(Integer i) { return i * 2;} // Functional StyleF<Integer, Integer> timesTwo = new F<Integer, Integer>() { public Integer f(Integer i) { return i * 2; }} Product Types
Mark Volkmann's Clojure Page Mark Volkmann's Page This page contains resources related to the Clojure programming language. Article Change History Sounds Even Jennifer Aniston has quit using other programming languages and now prefers Clojure. Sound Clip #1 Sound Clip #2 Getting Started with Emacs - Clojure Documentation Thanks for the effort and the instructions given above. As a new entrant into clojure and to some extent to Emacs, I struggled a bit to install and get them working and had to refer many resources in web. To help people like me starting out in "Emacs + Clojure + Swank + Leiningen", I am putting together detailed set of instructions building on top of what is in the page above: DETAILED INSTRUCTIONS - for EMACS + CLOJURE : (emphasis on Windows - will apply to other OSs also): Emacs set up: 1. 2. 3. 4. Emacs Starter kit set up: 1. There are couple of points which might confuse a newbie. 1.1.An empty emacs.d directory gets created when you install emacs in your home directory. 1.1.1 for Unix ~/. is the home. 1.2 Package dependencies need to be added to init.el and .emacs file. 1.2.1 Either of them alone did not work for me. In init.el add: (require 'package) (add-to-list 'package-archives '("marmalade" . (package-initialize) In .emacs file add the contents given in top of the page. Install Leiningen:
Clojure, State, and Identity Clojure has been discussed here before. It fits in the Lisp family with S-expressions, macros, and functions as values. Like most Lisps, it's dynamically typed and impure. What I wanted to highlight is position paper of sorts that Rich Hickey has posted on Clojure's Approach to Identity and State. While some programs are merely large functions, e.g. compilers or theorem provers, many others are not - they are more like working models, and as such need to support what I'll refer to in this discussion as identity. Hickey also addresses the choice to not follow Erlang's model. There are other ways to model identity and state, one of the more popular of which is the message-passing actor model, best exemplified by the quite impressive Erlang. ... The essay is worth a read on a couple of levels of interest to LtU. At the specific level, the core approach is certainly worthy of discussion and alternative designs.
home A Brief Beginner’s Guide To Clojure by John Gabriele, last-modified: 2013-08 (using Clojure 1.5.1, Leiningen 2.2.0, and OpenJDK 7) The purpose of this brief guide is to provide an overview of the Clojure ecosystem while also helping new users quickly get up and running. This guide concerns the original, Java-based Clojure implementation. There are others. It’s not a Clojure language tutorial; there are already a number of good ones available (linked to later). This guide is not comprehensive; it’s just a handful of nicely-organized notes that I thought would be most useful to new Clojure users. The author (hi!) It’s intended that the chapters of this guide be read in order. This guide may contain errors. let me know (jgabriele at fastmail dot fm)
Tokenization, Part 6: Function Overloading In the last posting, we added the ability to filter a list of input tokens with a list of stop words, usually words that are so common that they aren’t interesting for many types of analysis. But because we don’t want to use a stop list every time, we didn’t add such filtering to the tokenize-str function. Today, we’ll do that. Function Overloading Clojure allows what can be called function overloading. (Actually, calling this function overloading is misleading. For reference, here is the current version of tokenize-str and an example of using it and filtering with a stop words list: (defn tokenize-str [input-string] (map to-lower-case (re-seq token-regex input-string))) (filter (complement stop-words) (tokenize-str "Input string here.")) To define tokenize-str as an overloaded function, wrap each set of arguments and the function body that belongs with it in parentheses: (defn tokenize-str ([input-string] (map to-lower-case (re-seq token-regex input-string)))) So how do we use this?
Casting SPELs with Clojure - Home - Anyone who has ever learned to program in Lisp will tell you it is very different from any other programming language. It is different in lots of surprising ways - This comic book will let you find out how Lisp's unique design makes it so powerful ! This tutorial was adapted for Clojure, an exciting new dialect of Lisp running on the Java Virtual Machine. Clojure's syntax and API resembles Common Lisp, but there are enough differences to write a dedicated version of this book. Most of the time, we will say "Lisp" instead of "Clojure", since most of the concepts presented apply to Lisp in general - we will point out the places where Clojure handles things a little different. Since Clojure is based on the JVM, you will need to have Java installed on your system. For the examples in this tutorial, simply unpack the archive, open a command line tool and switch to Clojure's main directory. java -jar clojure.jar Clojure 1.1.0 user=> This tutorial has small bits of Clojure code written in