Is there any DSL (Domain Specific Language) implemented in Clojure ?
Like any Lisp dialect, Clojure draws a very fuzzy line between API and DSL and therefore the term doesn't hold the same mystique that it does in other languages. Lisp programmers tend to write their programs as layers of DSLs, each layer serving those above it. Having said that, here are a few that you could say display non-trivial levels of DSL-ness (in no particular order):
Enlive (HTML templating)
LazyTest (Unit testing)
fnparse (parser generator)
Midje (testing & mocking)
byte-spec (binary-formats)
Vijual (graph layout)
Trammel (constraint programming)
Cascalog (Hadoop w/ datalog syntax)
Incanter (R-like environment)
Sandbar (HTML sessions, forms, auth)
ClojureQL (SQL)
mini-kanren (embedded logic programming)
Leiningen (build tool)
sexpbot (IRC bot with plugin arch)
SQL DSL in Clojure, a bit old but may be a showcase
An useful talk on thinking about how to build DSLs using clojure from the 2010 clojure-conj conference by the creator of Enlive, Christophe Grand: http://blip.tv/clojure/christophe-grand-not-dsl-macros-4540700 (slides are here).
I would also count the design of Ring as in the domain of DSL design. See the talk by Ring's creator, Mark McGranaghan: http://clojure.blip.tv/clojure/mark-mcgranaghan-one-ring-to-bind-them-4724955 (slides)
Related
Is/are there existing C++ NLP API(s) out there? The closest thing I have found is CLucene, a port of Lucene. However, it seems a bit obsolete and the documentation is far from complete.
Ideally, this/these API(s) would permit tokenization, stemming and PoS tagging.
Freeling is written in C++ too, although most people just use their binaries to run the tools: http://devel.cpl.upc.edu/freeling/downloads?order=time&desc=1
Try something like DyNet, it's a generic neural net framework but most of its processes are focusing on NLP because the maintainers are creators of the NLP community.
Or perhaps Marian-NMT, it was designed for sequence-to-sequence model machine translation but potentially many NLP tasks can be structured as a sequence-to-sequence task.
Outdated
Maybe you can try Ellogon http://www.ellogon.org/ , they have GUI support and also C/C++ API for NLP too.
if you remove the restriction on c++ , you get the perfect NLTK (python)
the remaining effort is then interfacing between python and c++.
Apache Lucy would get you part of the way there. It is under active development.
Maybe you can use Weka-C++. It's the very popular Weka library for machine learning and data mining (including NLP) ported from Java to C++.
Weka supports tokenization and stemming, you'll probably need to train a classifier for PoS tagging.
I only used Weka with Java though, so I'm afraid can't give you more details on this version.
There is TurboParser by André Martins at CMU, also has a Python wrapper. There is is an online demo for it.
This project provides free (even for commercial use) state-of-the-art information extraction tools. The current release includes tools for performing named entity extraction and binary relation detection as well as tools for training custom extractors and relation detectors.
MITIE is built on top of dlib, a high-performance machine-learning library, MITIE makes use of several state-of-the-art techniques including the use of distributional word embeddings and Structural Support Vector Machines[3]. MITIE offers several pre-trained models providing varying levels of support for both English and Spanish, trained using a variety of linguistic resources (e.g., CoNLL 2003, ACE, Wikipedia, Freebase, and Gigaword). The core MITIE software is written in C++, but bindings for several other software languages including Python, R, Java, C, and MATLAB allow a user to quickly integrate MITIE into his/her own applications.
https://github.com/mit-nlp/MITIE
I've recently been much impressed by the work of Chris Granger and his Light Table. This question is not about light table though, but more about the "BOT" architecture he described using in his blog post "The IDE as a value" :
http://www.chris-granger.com/2013/01/24/the-ide-as-data/
Now, I'm pretty new to clojure but would like to better explore this way of programming: Behavior, Object, Tag:
(behavior* :read-only
:triggers #{:init}
:reaction (fn [this]
(set-options this {:readOnly "nocursor"})))
(object* :notifier
:triggers [:notifo.click :notifo.timeout]
:behaviors [:remove-on-timeout :on-click-rem!]
:init (fn [this]
[:ul#notifos
(map-bound (partial notifo this) notifos)]))
(object/tag-behaviors :editor.markdown [:eval-on-change :set-wrap])
Where can I find clojure code that uses that style and those composition principles?
BOT sounds like the Light Table "proprietary" flavor of Entity-Component-System (ECS) architecture. I would start with wikipedia entry and then go to this post with code examples in ActionScript (we are in the world of games).
There are also some examples in the Clojure context.
Note: I'm a backend (Java) developer by trade and work in Clojure in my spare time, so forgive me for my ignorance.
I'm trying to get my head around Clojurescript and how it could potentially fit in with projects I'm working on, or plan to work on in the future. As I've grown up with the "classic" web development mindset (e.g. Clojure running the backend, distributing data to the frontend via JSON to be processed in JS or returning a HTML page for the browser to render), I'm having trouble trying to understand how Clojurescript might make things better than this model.
Could anyone explain to me what the general approach to Clojurescript/Clojure development would be, seeing as the "Clojurescript One" project moniker signifies that application development will be unified under one language (as such)
What tasks would normally be done in the Clojurescript portion of the application?
What tasks would normally be done in the Clojure (e.g. backend) portion of the application?
Any help would be appreciated, or if anyone can point me towards some diagrams or explanations or anything - that would be great too!
I think Clojure/ClojureScript applications will be structured very similarly to X backend technology + JavaScript.
One big benefit with architecting applications with Clojure and ClojureScript - a richer data format than JSON (you can represent hash-maps and sets with arbitrary keys) without losing compactness.
JavaScript is a fine, fine language but ClojureScript offers quite a few benefits. It's semantically simpler (functional), ships with a rich standard library, a robust battle tested application library (Google Closure), and all the benefits you get from the tasteful application of syntactic abstraction via macros.
That said, it's still very much alpha software and the tooling still needs a lot of work.
A bit of background about me, I have developed with Clojurescript, JQuery, Vaadin, Servlets, JSP, and many other web technologies.
1) Clojurescript is much harder to learn than any other web technology I have used as you need, Java, Clojure, Closure (with an s ;), Closure Lib, and Closurescript specific knowledge.
2) Clojurescript doesn't make sense for a small app. It only makes sense when you will have ALOT of client side processing
3) Clojurescript's only use as far as I see is as a better javascript (which is why it is better suited to larger apps) as the minifier part of Clojurescript is available for javascript too
4) Only the client end would be written in Javascript, the server would be in Clojure/Java servlets
Maybe Ganelon micro-framework (which incidentally I am author of) will suit your needs - the execution model is similiar to Vaadin's: server-side Clojure code pushes UI updates to the browser through AJAX/JavaScript, but we don't store application state in session by default.
The demo and docs are available at http://ganelon.tomeklipski.com/
For me, clojure and clojurescript offers cleaner code than mixed stack. There is only one language to think of and code is quite easy to read.
At the backend clojure does things that java usually would do. Input validation, saving to database and above all, implementing business logic. Our backend also validates incoming / outgoing data by types using prismatic schemas.
Frontend in short: We get pretty code using ClojureScript and it is fast to write. We are using ClojureScript version of material-ui when writing UI components. We have to write less code when compared to the JavaScript and I find our UI component code to be easier to read than JavaScript counterpart. One of the main reasons is shorter closing tags and less noise by coding language. Development with ClojureScript is quite fast.
Of course ClojureScript is used for simple imput validation like RegExp for phone numbers etc.
One of the disadvantages of clojure which you have probably noticed is long lines after giving proper names to the functions. I havent found silver bullet how to cope with that.
As dnolen said: ClojureScript is still developing. It is way better now than it was 6 months ago, so you'll have to keep checking its maturity now and then.
I have been following clojure for some time, and some of its features are very exciting (persistent data structures, functional approach, immutable state). However, since I am still learning, I would like to understand how to apply in real scenarios, prove its benefits and then evolve and apply for more complex problems. i.e. what are the easy wins with clojure (e.g. in an e-commerce setup) that can be used to learn as well as ascertain its benefits.
I have investigated clojure based web frameworks, but I am not keen on them, as they need hand-written javascript (as against gwt). So for me, it is more about backend processing. Can someone explain where they applied clojure (in real deployments), and how did it prove useful (and the cons, if any, of using clojure)
Further analysis:
Lazy evaluation is an oft example of power of Lisp. Clojure being a Lisp, offers the same advantage. So, a real world example of such an application (in context of clojure) would help me gain insight.
You have mentioned that you work with CSV files. I found these to be very helpful, because I had to parse a csv file -- used clojure-csv; then extract certain columns from that csv file using sequence functions; interleave http form field names using zipmap; and then make http calls to an ASP application using clj-http.client.
(def accumail-url-keys ["CA", "STREET", "STREET2", "CITY", "STATE", "ZIP", "YR", "BILL_NO", "BILL_TYPE"] )
.
.
.
(defn ret-params
"Generates all q-parameters and returns them in a vector of vectors."
[all-csv-rows]
(reduce
(fn [param-vec one-full-csv-row]
(let [q-param (zipmap accumail-url-keys one-full-csv-row)
accu-q-param (first (rest (split-at 3 q-param)))
billing-param (first (split-at 3 q-param))]
(conj param-vec [accu-q-param billing-param])))
[]
all-csv-rows))
That project was an accelerated Clojure learning exercise.
Two sites 4Clojure.com and http://www.cis.upenn.edu/~matuszek/cis554-2010/Assignments/clojure-01-exercises.html are good places to start working on Clojure exercises. You can build on those.
Also the Clojure Google Group is a very helpful place to get information.
The Univ of Penn CIS exercises, as simple as they might seem, have given me a lot to digest, especially getting the skeleton of a tree, and recently the skeleton problem got a long discussion in the Google Clojure group.
Good luck.
cmn
I've heard of two Clojure based web application frameworks: Webjure and Compojure. Can someone let me know which is better?
Now you can add Ring to the list. All of these frameworks are very new and likely to evolve (or die) quickly, but Compojure does seem to be the most actively developed based on the past 6 months or so.
"Better" is too subjective a question to get a definitive answer to. Try them all and see what works.
Compojure has been working very well for me so far. I like the simplicity of the design, the flexibility and the fact that it encourages a nice idiomatic functional style.
Sample server:
(use 'compojure)
(defroutes my-app
(GET "/index.html"
(html
[:h1 "Hello World!!"]
[:body "This is some text"]))
(ANY "*"
[404 "Page not found"]))
(run-server {:port 80}
"/*" (servlet my-app))
Note that Compojure uses Ring internally.
I second Rayne's recommendation on Moustache.
Right now, we are using Ring (base layer, middleware), Moustache (routing), Hiccup (html generation). We just began using Compass for CSS (http://compass-style.org/). So far, I'm happy with this collection of small libraries rather than a big "complete stack" framework (Django, Rails, ect...).
Now, there is also a new one named Noir build on top of compojure. Really recommended, especially with Heroku.
Compojure seems to be getting the most buzz right now. Not necessarily indicative of quality, but the one with the most eyes will probably evolve the fastest.
There is also Moustache, which is what I use in TryClojure, along with Ring. It's pretty awesome.
Compojure is based on Ring, which is a low-level framework that doesn't attempt to hide much of HTTP. It's similar to WSGI (Python) or Rack (Ruby). Ring has a concept of middleware, small pieces of code that can do something meaningful with an HTTP request and/or response, such as dump header infos, manage cookies etc. Compojure is a higher-level framework, somewhat similar to Ruby's Sinatra. Its aim is to provide a convenient API (or DSL, if you prefer) for most tasks a Web app developer faces. It's usually used together with an HTML generation library, such as Hiccup.
I haven't heard much about Webjure in the last few months, I'm not sure it's in active development (but I'd be interested to find out more). It precedes Ring, AFAICT, which seems to have become somewhat of a standard for Clojure Web frameworks.
I've been building a project for my own use using Compojure and it has worked out great. It doesn't really get in the way very much and lets you focus on what's important, your problem domain. The project is about 1100 lines of clojure just to give you an idea of the size.