Re: Does Pedestal have a future in the long run

2013-11-11 Thread Brenton
I would like to clarify a few things.

All of the comments below are about Pedestal app.

Pedestal is a continuation of ClojureScript One. The reason that we didn't 
continue to commit changes to that project was because of all of the 
documentation.

Pedestal has changed a lot from the beginning and continues to change. This 
change has definitely been moving toward a goal and I think we are getting 
very close to that goal. Once Pedestal is stable it will be simpler, 
smaller and easier to understand and use in a variety of ways. I agree with 
many of the comments above about what a finished project should look like. 
This is not a finished project. At this point, increasing adoption is not 
the goal. If you are looking at Pedestal now then you are an early adopter 
and you accept the risks that go along with being an early adopter. You are 
on the bleeding edge. Sometimes there is a lot of blood on the bleeding 
edge.

If you are looking for something that is finished and stable then do not 
look at Pedestal. We will indicate stability with version numbers. When you 
see a release of version 1.0 then you may want to have another look. A 1.0 
release will not happen until we have thorough reference documentation.

There has been a lot of change because we really do care about this and 
want to get it right. We will continue to do this until we as a team 
believe that we have got it right.

Brenton

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: A "ClojureScript One" Question: Why is so much html created on the client side.

2012-08-10 Thread Brenton
Hello John,

ClojureScript One is an example of a single-page application. This means 
that you get one page load from the 
server and everything else happens in the browser without any further page 
loads. The initial page that
is loaded is dynamically generated on the server. Any other updates to the 
page are performed from JavaScript
by manipulating the DOM.

If you are making requests to the server for every new page then it makes 
sense to dynamically generate HTML
there. The whole point of a single-page application is to make the 
application more responsive by reducing both the
number of requests and the amount of data that is transferred over a 
network.

Imbedding HTML templates in JavaScript means that those templates are only 
transferred over the network once.

I hope this helps,
Brenton

On Friday, August 10, 2012 6:21:00 AM UTC-4, john wrote:
>
> Hello,
> I am just trying to understand the best practices in "ClojureScript One".
>
> One thing that strikes me is that most html gets put (with the help of 
> macros using enlive) in the actual cljs page.
>
> As someone who hasn't done web-applications for years I myself would have 
> created as much dynamic html content 
> as possible on the server. But yet "ClojureScript One" seems to prefer to 
> have all html in maps and render it on the client?
>
> I also looked at Chris Granger's "crate" library and it seems to also 
> follow this principle.
>
> Since I consider Chris Granger and Brento Ashworth to be web experts I 
> would just like to know the disadvantages of having
> most html rendered on the server?
>
> Many Greetings 
> John
>   
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Future milestones of ClojurescriptOne ?

2012-06-08 Thread Brenton
There will be further releases of ClojureScript One.

As we work on ClojureScript projects for clients, we are learning a lot 
about what works well and what doesn't. In the future, we will use what we 
have learned to make improvements to ClojureScript One.

We also plan to move some of the included libraries out into separate 
projects.

Thanks for your interest.

Brenton

On Saturday, June 2, 2012 5:09:11 PM UTC-4, Murtaza Husain wrote:
>
> Hi,
>
> Are there any plans to release further milestones of ClojureScriptOne, its 
> an awesome project, and a great learning tool. I see the current milestone 
> of M003 has also not been released.
>
> Thanks,
> Murtaza
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: ClojureScript: browser REPL omitting namespace in generated JS

2012-03-02 Thread Brenton
Thanks Stuart,

Looks like the problem might be here:

https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/repl.clj#L117

I'll dig into this this weekend.

On Mar 2, 6:30 pm, Stuart Campbell  wrote:
> Done!http://dev.clojure.org/jira/browse/CLJS-157
>
> On 3 March 2012 01:15, David Nolen  wrote:
>
>
>
>
>
>
>
> > Please open a ticket in JIRA. Thanks!
>
> > On Fri, Mar 2, 2012 at 4:50 AM, Stuart Campbell  wrote:
>
> >> Hello,
>
> >> I'm encountering a problem where the browser REPL sometimes omits the
> >> ClojureScript namespace in its generated JavaScript, e.g. (def x 42)
> >> compiles to ".x = 42" instead of "foo.x = 42".
>
> >> I've put together a minimal project, with steps to reproduce, on GitHub:
> >>https://github.com/harto/cljs-eval-test
>
> >> It looks to me like compiling a set of ClojureScript files (using
> >> cljs.closure/build) causes some side-effect that prevents the problem. See
> >> the GitHub README for details.
>
> >> I'm on Mac OS X 10.5 with Java 1.6.0_26.
>
> >> Regards,
> >> Stuart
>
> >>  --
> >> You received this message because you are subscribed to the Google
> >> Groups "Clojure" group.
> >> To post to this group, send email to clojure@googlegroups.com
> >> Note that posts from new members are moderated - please be patient with
> >> your first post.
> >> To unsubscribe from this group, send email to
> >> clojure+unsubscr...@googlegroups.com
> >> For more options, visit this group at
> >>http://groups.google.com/group/clojure?hl=en
>
> >  --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure.test on ClojureScript?

2012-02-26 Thread Brenton
Shantanu,

I have been experimenting with this in ClojureScript One. The latest
version is in the M003 branch.

The example that Stuart links to is a complex integration test. Here
is an example of some unit tests which test ClojureScript code.

https://github.com/brentonashworth/one/blob/M003/test/one/test/dispatch.clj

The idea is to keep writing tests in Clojure using clojure.test but
add the ability to easily evaluate some forms in a JavaScript
environment. This allows you to have one test suite for a Clojure/
ClojureScript project with integrated test results. The same technique
could be used with other test frameworks.

In the above example, you set up the test namespace in the same way
you would with Clojure tests.

You then have the `in-javascript` macro which sets up the
ClojureScript namespace and allows you to define functions that you
can call from ClojureScript in the tests below. All ClojureScript in
the tests below will be evaluated in the namespace that you set up
here.

In your tests, when you want to evaluate something in the JavaScript
environment, you wrap that form in the `js` macro.

If you checkout this branch you can run tests in three ways:

1) `lein test` will run all the tests as it normally would. The
current setup will launch a browser which can be used as the
evaluation environment.

2) You can run tests from a Clojure REPL:

(dev-server)
(require 'one.test)
(require 'clojure.test)
(require 'one.test.dispatch)

(def ee (one.test/browser-eval-env))

;; go to the development or fresh page

(binding [one.test/*eval-env* ee]
  (clojure.test/run-tests 'one.test.dispatch))

3) If you are in a ClojureScript REPL, you can run the tests with:

(run-tests 'one.test.dispatch)

In each case you need to have a JavaScript environment in which to
evaluation things. In case 1 this is created for you. In case 2 you
have to manually set it up. In case 3 it uses the active ClojureScript
REPL's environment.

This is all very experimental. I hope it gives you some good ideas for
where to start.

Thanks,
Brenton



On Feb 25, 11:34 pm, Shantanu Kumar  wrote:
> Hi,
>
> Has anybody got clojure.test working with ClojureScript? Is it planned
> for clojure.test to eventually work on ClojureScript?
>
> Shantanu

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: New Version of ClojureScript One

2012-01-28 Thread Brenton
Christofer,

This is a problem with the current version of Leiningen. There are a
couple of ways to work around the problem. Here is one:

Create a new Leiningen project.

lein new delete-me
cd delete-me

Open project.clj and change

:dependencies [[org.clojure/clojure "1.3.0"]]

to

:dependencies [[org.clojure/clojure "1.2.1"]]

Save this file and then run

lein deps

You can now delete this project. The whole point was to get
clojure-1.2.1 into your local maven repository. lein should now work
in ClojureScript One and with any other Clojure 1.3 projects.

This issue will be fixed in Leiningen soon.

Brenton

On Jan 27, 1:05 pm, Christofer Jennings  wrote:
> I get the error below when I run ClojureScript One's 'lein bootsrap'. Any 
> ideas?
>
> I'm pretty new to Clojure. This is my first time using Leiningen and first 
> attempt at using ClojureScript. ... pretty hopeless :-)
>
> Mac OSX 10.7.2
> Clojure 1.3.0
> java version "1.6.0_29"
> Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527)
> Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
>
> Exception in thread "main" java.lang.RuntimeException: 
> java.lang.NoSuchMethodError: 
> clojure.lang.KeywordLookupSite.(ILclojure/lang/Keyword;)V
>         at clojure.lang.Util.runtimeException(Util.java:165)
>         at clojure.lang.Compiler.eval(Compiler.java:6476)
>         at clojure.lang.Compiler.eval(Compiler.java:6431)
>         at clojure.core$eval.invoke(core.clj:2795)
>         at clojure.main$eval_opt.invoke(main.clj:296)
>         at clojure.main$initialize.invoke(main.clj:315)
>         at clojure.main$script_opt.invoke(main.clj:339)
>         at clojure.main$main.doInvoke(main.clj:426)
>         at clojure.lang.RestFn.invoke(RestFn.java:457)
>         at clojure.lang.Var.invoke(Var.java:413)
>         at clojure.lang.AFn.applyToHelper(AFn.java:172)
>         at clojure.lang.Var.applyTo(Var.java:518)
>         at clojure.main.main(main.java:37)
> Caused by: java.lang.NoSuchMethodError: 
> clojure.lang.KeywordLookupSite.(ILclojure/lang/Keyword;)V
>         at leiningen.util.paths$native_arch_path.(paths.clj:32)
>         at leiningen.util.paths__init.load(Unknown Source)
>         at leiningen.util.paths__init.(Unknown Source)
>         at java.lang.Class.forName0(Native Method)
>         at java.lang.Class.forName(Class.java:247)
>         at clojure.lang.RT.loadClassForName(RT.java:2030)
>         at clojure.lang.RT.load(RT.java:417)
>         at clojure.lang.RT.load(RT.java:398)
>         at clojure.core$load$fn__4610.invoke(core.clj:5386)
>         at clojure.core$load.doInvoke(core.clj:5385)
>         at clojure.lang.RestFn.invoke(RestFn.java:408)
>         at clojure.core$load_one.invoke(core.clj:5200)
>         at clojure.core$load_lib.doInvoke(core.clj:5237)
>         at clojure.lang.RestFn.applyTo(RestFn.java:142)
>         at clojure.core$apply.invoke(core.clj:602)
>         at clojure.core$load_libs.doInvoke(core.clj:5271)
>         at clojure.lang.RestFn.applyTo(RestFn.java:137)
>         at clojure.core$apply.invoke(core.clj:602)
>         at clojure.core$require.doInvoke(core.clj:5352)
>         at clojure.lang.RestFn.invoke(RestFn.java:408)
>         at leiningen.core$loading__4414__auto__.invoke(core.clj:1)
>         at leiningen.core__init.load(Unknown Source)
>         at leiningen.core__init.(Unknown Source)
>         at java.lang.Class.forName0(Native Method)
>         at java.lang.Class.forName(Class.java:247)
>         at clojure.lang.RT.loadClassForName(RT.java:2030)
>         at clojure.lang.RT.load(RT.java:417)
>         at clojure.lang.RT.load(RT.java:398)
>         at clojure.core$load$fn__4610.invoke(core.clj:5386)
>         at clojure.core$load.doInvoke(core.clj:5385)
>         at clojure.lang.RestFn.invoke(RestFn.java:408)
>         at clojure.core$load_one.invoke(core.clj:5200)
>         at clojure.core$load_lib.doInvoke(core.clj:5237)
>         at clojure.lang.RestFn.applyTo(RestFn.java:142)
>         at clojure.core$apply.invoke(core.clj:602)
>         at clojure.core$load_libs.doInvoke(core.clj:5271)
>         at clojure.lang.RestFn.applyTo(RestFn.java:137)
>         at clojure.core$apply.invoke(core.clj:604)
>         at clojure.core$use.doInvoke(core.clj:5363)
>         at clojure.lang.RestFn.invoke(RestFn.java:408)
>         at user$eval1.invoke(NO_SOURCE_FILE:1)
>         at clojure.lang.Compiler.eval(Compiler.java:6465)
>         ... 11 more
>
> Thanks for all the cool stuff!
> ,chris
>
> On Jan 26, 2012, at 3:34 AM, Sam Aaron wrote:
>
>
>
>
>
>
>
>
>
> > On 25 Jan 2012, at 22:27, Brenton wrote:
>
> >> ClojureScript will continue to change rapidly. W

Re: ClojureScript One - Getting Started with ClojureScript

2012-01-25 Thread Brenton
This is not an issue with One but with Leiningen. Others have run into
the same problem:

https://github.com/technomancy/leiningen/issues/375

https://github.com/dakrone/clojuredocs-client/issues/6

Another work-around is to make sure you have clojure-1.2.1 in your
local maven repository.

On Jan 25, 7:23 pm, Raju Bitter  wrote:
> I don't have a $CLASSPATH set, and no ~/.clojure folder, so there
> shouldn't be any conflicting Clojure JAR file on the classpath.
>
> - Raju

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: New Version of ClojureScript One

2012-01-25 Thread Brenton
> One quick question - why do you still rely on git checkouts of ClojureScript 
> and Domina - especially now ClojureScript is available on maven?

ClojureScript will continue to change rapidly. We are already
depending on a newer version than the one in Maven. Also, I don't
think that Domina has a release yet.

For times when we only need a source dependency and only at
development time, I like this approach to dependencies. I plan to
continue improving support for this in Leiningen and using it as much
as i can.

For more of the rationale, see 
https://github.com/brentonashworth/one/wiki/Dependencies.

You rock!

Brenton

On Jan 25, 4:15 pm, Sam Aaron  wrote:
> Very nice :-) I've got some quality code reading ahead of me...
>
> One quick question - why do you still rely on git checkouts of ClojureScript 
> and Domina - especially now ClojureScript is available on maven?
>
> Sam
>
> ---http://sam.aaron.name
>
> On 25 Jan 2012, at 20:40, Brenton wrote:
>
>
>
>
>
>
>
> > We have released a new version of ClojureScript One.
>
> > The most significant changes are:
>
> > No more scripts! Everything now works through Leiningen. We have added
> > support for retrieveing git dependencies via Leiningen.
>
> > Allow connections to the REPL form remote machines.
>
> > See the change log:
>
> >https://github.com/brentonashworth/one/wiki/Change-Log
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureScript One - Getting Started with ClojureScript

2012-01-25 Thread Brenton
With the recent update, we no longer have a script/cljs-repl.

You would now use:

lein repl
(go)

to accomplish the same thing.

In your case, you can use:

lein repl
(binding [*open-url-script* x]
  (go))

Brenton

On Jan 25, 3:19 pm, Raju Bitter  wrote:
> clojure.java.browse/open-url-in-swing is called a fallback method, and
> then the ClojureScript app is not rendered correctly.
>
> http://bit.ly/yPagHl
>
> I'll see if I can create a workaround for that.
>
> - Raju

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


[ANN] New Version of ClojureScript One

2012-01-25 Thread Brenton
We have released a new version of ClojureScript One.

The most significant changes are:

No more scripts! Everything now works through Leiningen. We have added
support for retrieveing git dependencies via Leiningen.

Allow connections to the REPL form remote machines.

See the change log:

https://github.com/brentonashworth/one/wiki/Change-Log

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojurescript One: distinguishing event sources / multiple widget instances

2012-01-18 Thread Brenton
The event-id can be any Clojure value. When you fire an event, you
need to make sure that there is enough information in this value to
properly dispatch to a reactor.

react-to takes an event predicate function which is called with the
event-id. If the function returns true then the reactor will handle
the event.

So, as you say, you would need to have a distinguishing id so that
this event predicate function can determine if it should react.

As David and Fogus point out, this is very slow at the moment. The
interesting question is: can we have the flexibility of arbitrary
event-ids and event predicate functions and make it fast?

On Jan 17, 10:08 pm, kovas boguta  wrote:
> Pretty basic question here.
>
> Suppose I want to have 2 copies of the form in the same application.
>
> How will the event handlers know which form the events are coming
> from, and which form needs to be modified in response to those events?
>
> More generally, what if I have N copies of some widget that all have
> the same structure, but different instance data. For example, a list
> of tweets, where each tweet has "favorite" button.
>
> My current impression is that I'd have to architect the event routing
> myself, making sure some distinguishing ID is carried around
> throughout.
>
> Is this accurate?
>
> What is the recommended way to handle this situation?
>
> Thanks,
> Kovas

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Cannot access variables without namespace in ClojureScript repl.

2012-01-15 Thread Brenton
I think the problem here is with the ClojureScript REPL and single-
segment namespaces.

We found a couple of problems with the ClojureScript REPL while
working on One and will address them soon. If you confirm that this is
the problem, please let us know. Also, feel free to add an issue to
JIRA with the steps to reproduce.

Thanks,
Brenton

On Jan 15, 6:57 am, Takahiro Hozumi  wrote:
> Hi,
> In my browser repl, which follows the ClojureScript wiki[1], I must
> specify variables with namespace even if `in-ns` is used, but I
> noticed that I don't have to do in the repl of ClojureScript One[2].
>
> Am I the only one who cannot access variables without namespace?
> What makes the diffirence?
>
> log:
> ClojureScript:cljs.user> (in-ns 'myns)
>
> ClojureScript:myns> myns/mydiv     ;;with a namespace
> #<[object HTMLDivElement]>
>
> ClojureScript:myns> mydiv             ;;without a namespace
> "Error evaluating:" mydiv :as ".mydiv;\n"
> #
> SyntaxError: Unexpected token .
>     athttp://localhost:8080/cljs/clojure/browser/repl.js:21:158
>
> [1]https://github.com/clojure/clojurescript/wiki/Emacs-%26-inferior-lisp...
> [2]https://github.com/brentonashworth/one/wiki/Development
>
> Thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojurescript One: (def fiv 5) compiles to ".fiv = 5;\n" ?

2012-01-13 Thread Brenton
I can't reproduce this problem. What you are showing here should work.

The following steps work for me:

script/cljs-repl
ClojureScript:cljs.user> (in-ns 'one.sample.view)
ClojureScript:one.sample.view> (def fiv 5)
(def fiv 5)
5

On Jan 13, 9:36 am, László Török  wrote:
> Hi,
>
> first of thank you putting this together. As I'm working my way through the
> documentation, I'm experiencing a strange error.
>
> I have a Clojurescript REPL up and running in Emacs (tested with (js/alert
> "..")) and I try
>
> ClojureScript:one.sample.view> (def fiv 5)
>
> I get this:
>
> (def fiv 5)
> "Error evaluating:" (def fiv 5) :as ".fiv = 5;\n"
>
> and a long stacktrace.
>
> Similarly, this works:
>
> ClojureScript:one.sample.model> @one.sample.model/state
>
> this doesn't:
>
> ClojureScript:one.sample.model> @state
>
> So it seems every unqualified (local) symbol gets a leading . (dot). What
> am I doing wrong?
>
> Thanks!
>
> --
> László Török

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureScriptOne HelloWorld problem

2012-01-13 Thread Brenton
The ClojureScript REPL will hang if it is not connected to the
browser. Make sure you are on the development page of ClojureScript
One, which is the only page that will allow a REPL connection. If you
are already there then just refresh the page.

The best way to start a ClojureScript REPL is described here:

https://github.com/brentonashworth/one/wiki/Quick-Start

Brenton

On Jan 13, 9:51 am, Huft  wrote:
> Ah - RTFM - difference between Clojure- and Clojurescript- REPLs -
> thanks
>
> So now I have the Clojurescript REPL running; but entering '(js/alert
> "hello")' just causes the REPL to hang [doesn't return]
>
> On Jan 13, 2:41 pm, László Török  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > you're probably still in the Clojure REPL, read "Manually starting a
> > ClojureScript REPL"
>
> > and then refresh the development view in your browser and you're all set.
>
> > L
>
> > 2012/1/12 Huft 
>
> > > Hi,
>
> > > New to Clojure, excited to take a peek at ClojureScriptOne. Installed
> > > it, now running script/run; repl appears, application visible at
> > > localhost:8080, clicked 'Development'.  Now trying to enter forms at
> > > the repl, as per
>
> > >https://github.com/brentonashworth/one/wiki/Getting-started
>
> > > However if I type:
>
> > > (js/alert "hello")
>
> > > at the repl, I get:
>
> > > CompilerException java.lang.RuntimeException: No such namespace: js,
> > > compiling:(NO_SOURCE_PATH:1)
>
> > > Apologies for n00b question, but can anyone help me out ?
>
> > > Thanks.
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Clojure" group.
> > > To post to this group, send email to clojure@googlegroups.com
> > > Note that posts from new members are moderated - please be patient with
> > > your first post.
> > > To unsubscribe from this group, send email to
> > > clojure+unsubscr...@googlegroups.com
> > > For more options, visit this group at
> > >http://groups.google.com/group/clojure?hl=en
>
> > --
> > László Török
>
> > Skype: laczoka2000
> > Twitter: @laczoka

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureScript One - "No such namespace" error when following "Getting Started" instructions

2012-01-13 Thread Brenton
You are trying to evaluate ClojureScript in a Clojure REPL.

The easiest way to get a ClojureScript REPL is to run:

script/cljs-repl

If you start a ClojureScript REPL manually then you always need to
load/reload the development page afterwords to establish the
connection.

On Jan 12, 5:07 pm, utel  wrote:
> The amount of effort that's gone into ClojureScript One initiative is
> very impressive!
>
> Just one question. I've tried following the instructions on the 
> page:https://github.com/brentonashworth/one/wiki/Getting-started
>
> All goes well until the step where I evaluate the expression (js/alert
> "hello")
>
> Then I get the following error:
> CompilerException java.lang.RuntimeException: No such namespace: js,
> compiling:(NO_SOURCE_PATH:1)
>
> I've tried it on both Linux and OS X 10.7  (both with jdk 1.6.0_29)
> and in both cases get the error above.
>
> It may be that I've missed something obvious!
>
> Any help appreciated.
>
> Thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureScript One - Getting Started with ClojureScript

2012-01-12 Thread Brenton
It looks like you don't have Clojure. Did you run script/deps? Do you
have anything in the lib directory?

Try running it again.

Brenton

On Jan 12, 4:28 pm, abaitam  wrote:
> I am dying to try this. However, the script/run script (on MAC) gives
> me this error message:
>
> Exception in thread "main" java.lang.ClassNotFoundException:
> clojure.main
>         at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
>         at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
>         at java.lang.Class.forName0(Native Method)
>         at java.lang.Class.forName(Class.java:169)
>         at jline.ConsoleRunner.main(ConsoleRunner.java:73)
>
> I appreciate any help.
>
> On Jan 11, 2:27 pm, Brenton  wrote:
>
>
>
>
>
>
>
> > Today we are releasing ClojureScript One. A project to help you get
> > started writing single-page applications in ClojureScript.
>
> >http://clojure.com/blog/2012/01/11/announcing-clojurescript-one.html
>
> >http://clojurescriptone.com/
>
> >https://github.com/brentonashworth/one
>
> > This project is the result of a lot of hard work from the people at
> > Relevance. Thanks everyone.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureScript One and remote development

2012-01-12 Thread Brenton
Yes.

On Jan 12, 3:24 pm, Stan Dyck  wrote:
> On 01/12/2012 11:44 AM, Brenton wrote:
>
> > This can also be solved by not hard-coding "localhost" in
> > one.sample.core as it is now.
>
> > There are functions in goog.uri.utils to help with this.
>
> > This is on our list of things to do.
>
> > Brenton
>
> Is not hard-coding port 8080 also on this list? This would be a "nice to 
> have" for me.
>
> StanD.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureScript One and remote development

2012-01-12 Thread Brenton
This can also be solved by not hard-coding "localhost" in
one.sample.core as it is now.

There are functions in goog.uri.utils to help with this.

This is on our list of things to do.

Brenton

On Jan 12, 2:30 pm, Ryan Waters  wrote:
> I ran into an issue with remote development and ClojureScript One and
> thought I'd share with others who potentially will run into the same
> issue.
>
> If I want to access ClojureScript One on ComputerA from ComputerB then
> I have to tunnel or port forward my request to ComputerA's
> localhost:8080.  That's pretty self-evident.  However, I couldn't get
> (cljs-repl) stuff to live update.  Instead the repl prompt would hang
> and I nothing would change in my browser.  It turns out the long poll
> XHR request runs over port 9000 so you need to forward or tunnel both
> 8080 and 9000 for everything to be happy.
>
> This can be accomplished, e.g, with the following from ComputerB:
>
> ssh -N -L localhost:8080:localhost:8080 -L
> localhost:9000:localhost:9000 user@computera
>
> - Ryan

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureScript One - Getting Started with ClojureScript

2012-01-12 Thread Brenton
We cannot share that information because it was a client project. It
wasn't really a translation process. We simply attempted to solve the
same problem with different tools. I do realize that seeing them side-
by-side would be interesting but we just can't do it.

Issue 22 is not related to this.

On Jan 12, 11:46 am, Daniel Jomphe  wrote:
> Will we be able to read the account of the experience of translating the
> app from CoffeeScript to ClojureScript?
>
> And/or reading both code bases.
>
> Not sure if this account is covered 
> byhttps://github.com/brentonashworth/one/issues/22

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


[ANN] ClojureScript One - Getting Started with ClojureScript

2012-01-11 Thread Brenton
Today we are releasing ClojureScript One. A project to help you get
started writing single-page applications in ClojureScript.

http://clojure.com/blog/2012/01/11/announcing-clojurescript-one.html

http://clojurescriptone.com/

https://github.com/brentonashworth/one

This project is the result of a lot of hard work from the people at
Relevance. Thanks everyone.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Problem Running ClojureScript on OpenJDK

2011-10-03 Thread Brenton
If you have been having problems the ClojureScript and OpenJDK, please
try the current master branch of ClojureScript.

I would be interested to know what problems still remain, if any,
after these changes.

On Oct 2, 11:07 pm, db  wrote:
> Here's what the patch looks like for openjdk-6 with the latest master,
> where the mozilla-specific lines have moved to the rhino.js file:
>
> diff --git a/src/clj/cljs/repl/rhino.clj b/src/clj/cljs/repl/rhino.clj
> index cbe4f2a..15c5bf1 100644
> --- a/src/clj/cljs/repl/rhino.clj
> +++ b/src/clj/cljs/repl/rhino.clj
> @@ -27,6 +27,7 @@ goog.require = function(rule)
> {Packages.clojure.lang.RT[\"var\"
>            linenum (or line Integer/MIN_VALUE)
>            ctx (sun.org.mozilla.javascript.Context/enter)]
>        (try
> +        (.setOptimizationLevel ctx -1)
>          {:status :success
>           :value (.evaluateString ctx (:global repl-env) js filename
> linenum nil
>          (finally
>
> This works for me on openjdk6, but will not work on openjdk7 because
> it doesn't ship with Rhino.  For openjdk7, it looks like a separate
> version of Rhino needs to be downloaded.
>
> On Oct 2, 4:36 pm, Stefan Kamphausen  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I hope, people are aware that Oracle considers OpenJDK to be the standard
> > choice for Linux users now and removed the special distributor's license.  
> > Seehttp://robilad.livejournal.com/90792.html
>
> > Kind regards,
> > Stefan

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


ClojureScript REPL Changes

2011-10-03 Thread Brenton
Several improvements have been made to the ClojureScript REPL.

In ClojureScript, the method of printing output will be different for
each evaluation environment. There is now a var named *print-fn* in
cljs.core which will need to be explicitly set to a function that can
print in the target environment. If you would like to ignore all
printed output you could do this:

(set! *print-fn* (constantly nil))

The print function that you specify takes one argument, the value to
be printed. What you do with that value is totally up to you and your
environment. Sane defaults are set when running the REPL with Rhino or
the browser.

We are now using Rhino version 1.7R3 instead of whatever version of
Rhino is bundled with Java. This provides the following benefits:

* better error messages
* nice JavaScript stacktraces
* it's faster
* it isn't tied to a particular VM (should fix the problems people
were seeing on OpenJDK)

You will need to rerun script/bootstrap to download the Rhino jar and
install it in your lib folder. Windows people will need to do this
manually.

http://www.mozilla.org/rhino/download.html

For the browser-connected REPL, we can now print to the REPL. This
means that the browser-connected REPL works exactly like an old-
fashioned Clojure REPL.

For example, you can now do this:

ClojureScript:cljs.user> (time (reduce + (range 1000)))
"Elapsed time: 222 msecs"
499500

If your application is printing things while running then this printed
output will be printed in the REPL. Of course, you can set the *print-
fn* to do whatever you like.

Finally, when using Chrome and Firefox for evaluation, you will now
see JavaScript stacktraces in the REPL.

If you have been using the browser-connected REPL then you will need
to delete the .repl folder before using the new changes.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Passing ClojureScript objects to JavaScript functions

2011-08-11 Thread Brenton
There is an issue for this:

http://dev.clojure.org/jira/browse/CLJS-37

and work is being done to come up with a good solution. The comment in
the issue is outdated. There was some discussion last week about how
best to do this. I can't remember the details but I know that doing
anything automatically is out. I think it will either be a macro or a
reader-macro and will only create js objects out of literals or
expressions which can be evaluated to a literal.

Brenton

On Aug 10, 9:04 pm, Kevin Lynagh  wrote:
> What is the best way to pass Clojure vectors and maps to JavaScript
> functions?
>
> Currently when I need to call a JavaScript function that takes an
> array I do something like
>
>     (js/my_js_fn (.array (vector 1 2 3)))
>
> and I pass Clojure maps like
>
>     (js/my_js_fn (.strobj (hash-map "a" 1 "b" 2)))
>
> This feels a bit gross, since I'm digging into the implementation
> details.
>
> Is there a recommended way to do this yet?
> Some kind of reader macro (say @@) would be okay, turning
>
>     (js/my_js_fn @@(vector 1 2 3))
>
> into
>
>     (js/my_js_fn (.array (vector 1 2 3)))
>
> at read time.
>
> Ideally though, the compiler would automatically convert ClojureScript
> objects into JavaScript native objects when they're passed to a
> function in the js/ namespace.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Distributing ClojureScript Libraries packaging/dependencies

2011-08-09 Thread Brenton
There isn't an official way to do this now but you can package a
ClojureScript library (of .cljs files) into a jar and add it to the
classpath. Once on the classpath, the namespaces in the library can
then be required and used just as you would currently use clojure.set
or clojure.string.

ClojureScript finds everything that it needs on the classpath. This
means that you could also package up ClojureScript and it's
dependencies into a single jar and then add it as a dependency to
another project. You can then use the tools from the REPL or write
your own scripts to do compilation.

On Aug 8, 12:09 pm, Eric Merritt  wrote:
> Hello All,
>
> Are there any thoughts yet on distributing ClojureScript libraries?
> ClojureScript does whole program optimization, it needs the
> sources. Copying the sources into your main project isn't really a
> solution, not a long term solution at the very least.
>
> At the very least it would be nice of the clojurescript compiler could
> build from multiple locations (I will be embarrased if this is already
> the case). I suspect that ClojureScript is going to get built into to
> various build systems at some point shortly (lein, cake, etc). Then it
> will be a matter of providing some type of package and dependency
> system. Again I suspect very strongly that this is going to piggyback
> on the existing dependency mechenism. I am mostly interested in
> hearing what people are thinking.
>
> Thanks,
> Eric

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Howto automate tests w/ ClojusreScript?

2011-08-08 Thread Brenton
> load('out/goog/base.js');
> load('bkeeping.js');

This should be:

load('out/goog/base.js');
load('out/goog/deps.js');
load('bkeeping.js');


On Aug 8, 11:05 pm, Timothy Washington  wrote:
> Sorry, I should have been clearer.
>
> In a JS shell (v8, for example), after running... *load('bkeeping.js');* , I
> expect to have a *bkeeping* object. But that's not there. So I tried a *
> goog.require('bkeeping.js');* , and a '*bkeeping*' object still wasn't
> there.
>
> Basically, I'd like to able to run compiled JS code in a JS shell. But I'm
> coming up short (with and without compiler optimizations) in v8, rhino and
> SpiderMonkey.
>
> Any ideas?
>
> Tim Washington
> twash...@gmail.com
> 416.843.9060
>
> On Mon, Aug 8, 2011 at 10:28 PM, Timothy Washington wrote:
>
>
>
>
>
>
>
> > Hey all,
>
> > I'm digging into ClojureScript at the moment, and am trying to figure out
> > how to automate generated JS code in a shell, like v8.
>
> > In ClojureScript, I have been able to to pull in Google Closure's "*
> > goog.testing.jsunit*" package. Next step is to take the generated JS code
> > (optimized or not), and be able to automate tests in a JS shell, like v8,
> > SpiderMonkey, rhino, etc. This is where I run into problems. In the
> > directory in which I ran "cljs", I run v8, then load "*out/goog/base.js*"
> > (analogous to what you'd do in a browser). "*bkeeping.js*" is generated
> > from "*bkeeping.cljs*". goog.require breaks at first, until I try it with
> > fubar'd namespace. Then I retry goog.require, and it works. However, I don't
> > see the results of the unit test run.
>
> > Any ideas of what I'm missing?
>
> > Thanks for any help
>
> > Tim
>
> > *OUTPUT*
>
> > webkell@ubuntu:~/Projects/bkell/test/cljs$ cljsc bkeeping.cljs >
> > bkeeping.js
>
> > webkell@ubuntu:~/Projects/bkell/test/cljs$ v8
>
> > V8 version 3.5.3
>
> > > load('out/goog/base.js');
>
> > > load('bkeeping.js');
>
> > …
>
> > *
> > *
>
> > *> goog.require("bkeeping"); *
>
> > *out/goog/base.js:517: Error: Undefined nameToPath for goog.string*
>
> > *            throw Error('Undefined nameToPath for ' + requireName);*
>
> > *                  ^*
>
> > *Error: Undefined nameToPath for goog.string*
>
> > *    at Error (unknown source)*
>
> > *    at visitNode (out/goog/base.js:517:19)*
>
> > *    at visitNode (out/goog/base.js:512:13)*
>
> > *    at Object.writeScripts_ (out/goog/base.js:530:9)*
>
> > *    at Object.require (out/goog/base.js:280:12)*
>
> > *    at (shell):1:6*
>
> > …
>
> > > goog.require("xx");
>
> > out/goog/base.js:287: Error: goog.require could not find: xx
>
> >         throw Error(errorMessage);
>
> >               ^
>
> > Error: goog.require could not find: xx
>
> >     at Error (unknown source)
>
> >     at Object.require (out/goog/base.js:287:15)
>
> >     at (shell):1:6
>
> > *> goog.require("bkeeping");*
>
> > *Source "bkeeping.cljs" *
>
> > (ns bkeeping
>
> >   (:require [goog.testing.jsunit :as testing]))
>
> > ;;(defn ^:export run-tests []
>
> > (defn run-tests []
>
> >   (testing/assertFalse false, "PASSED falsity")
>
> >   (testing/assertTrue true, "PASSED truthiness")
>
> > )
>
> > (run-tests)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureScript broken

2011-08-07 Thread Brenton
> WARNING - dangerous use of the global this object

These warnings should now be gone (thanks to Fogus).

On Aug 7, 3:19 pm, ataggart  wrote:
> Great.
>
> BTW, are these warnings expected:
>
> $ cat > hello.cljs
> (ns hello)
> (defn ^:export greet [n]
>   (str "Hello " n))
> $ bin/cljsc hello.cljs '{:optimizations :advanced}' > hello.js
> Aug 7, 2011 12:17:42 PM com.google.javascript.jscomp.LoggerErrorManager
> println
> WARNING: /Users/ataggart/projects/clojurescript/out/cljs/core.js:3564:
> WARNING - dangerous use of the global this object
> {return this.call(null,(args[0]));
>         ^
>
> Aug 7, 2011 12:17:42 PM com.google.javascript.jscomp.LoggerErrorManager
> println
> WARNING: /Users/ataggart/projects/clojurescript/out/cljs/core.js:3566:
> WARNING - dangerous use of the global this object
> {return this.call(null,(args[0]),(args[1]));
>         ^
>
> Aug 7, 2011 12:17:42 PM com.google.javascript.jscomp.LoggerErrorManager
> printSummary
> WARNING: 0 error(s), 2 warning(s)
>
> If so, it might be worth noting that in the quick start documentation lest
> someone get worried.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureScript broken

2011-08-07 Thread Brenton
Those warnings have been around for a couple of weeks now. In that
sense they are expected. I will see what I can find out about them.

On Aug 7, 3:19 pm, ataggart  wrote:
> Great.
>
> BTW, are these warnings expected:
>
> $ cat > hello.cljs
> (ns hello)
> (defn ^:export greet [n]
>   (str "Hello " n))
> $ bin/cljsc hello.cljs '{:optimizations :advanced}' > hello.js
> Aug 7, 2011 12:17:42 PM com.google.javascript.jscomp.LoggerErrorManager
> println
> WARNING: /Users/ataggart/projects/clojurescript/out/cljs/core.js:3564:
> WARNING - dangerous use of the global this object
> {return this.call(null,(args[0]));
>         ^
>
> Aug 7, 2011 12:17:42 PM com.google.javascript.jscomp.LoggerErrorManager
> println
> WARNING: /Users/ataggart/projects/clojurescript/out/cljs/core.js:3566:
> WARNING - dangerous use of the global this object
> {return this.call(null,(args[0]),(args[1]));
>         ^
>
> Aug 7, 2011 12:17:42 PM com.google.javascript.jscomp.LoggerErrorManager
> printSummary
> WARNING: 0 error(s), 2 warning(s)
>
> If so, it might be worth noting that in the quick start documentation lest
> someone get worried.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureScript broken

2011-08-07 Thread Brenton
Sorry. I didn't notice that you were compiling a single file. That is
a different problem from the one I was referring to.

You were right about the cause as well. That particular problem is now
fixed.

Thank you for reporting it.

On Aug 7, 11:52 am, ataggart  wrote:
> Alas, the current bug is in the head of master, and is unrelated to either
> advanced-mode or the absence of the destination file.
>
> Rather it appears to be due to the fact that the quick start doesn't pass an
> output file to cljsc, but rather redirects stdout to the destination file.
>  When that occurs, compile-file is called, output-file is null.  The
> previous version had an (if outputfile ...) check, the current one does not.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureScript broken

2011-08-07 Thread Brenton
The problem existed from Friday at about 10AM until Saturday morning
when it was found and fixed. It only occurred when compiling something
in advanced mode for the first time, which is probably why it was
missed. There are some tests in place but we haven't yet got to the
point where everything is automated. We are working toward that goal.

On Aug 7, 4:03 am, ataggart  wrote:
> After introducing clojure to co-workers on Friday, one of them tried the
> ClojureScript quick start.
>
> He got this far:
>
> $ bin/cljsc hello.cljs '{:optimizations :advanced}' > hello.js
> Exception in thread "main" java.lang.NullPointerException
> at clojure.java.io$as_relative_path.invoke(io.clj:391)
> at clojure.java.io$file.invoke(io.clj:403)
> at cljs.closure$compile_file.invoke(closure.clj:279)
> at cljs.closure$eval1164$fn__1165.invoke(closure.clj:322)
> at cljs.closure$eval1095$fn__1096$G__1086__1103.invoke(closure.clj:202)
> at cljs.closure$eval1151$fn__1152.invoke(closure.clj:335)
> at cljs.closure$eval1095$fn__1096$G__1086__1103.invoke(closure.clj:202)
> at cljs.closure$build.invoke(closure.clj:725)
> at user$eval1293.invoke(cljsc.clj:21)
> at clojure.lang.Compiler.eval(Compiler.java:6406)
> at clojure.lang.Compiler.load(Compiler.java:6843)
> at clojure.lang.Compiler.loadFile(Compiler.java:6804)
> at clojure.main$load_script.invoke(main.clj:282)
> at clojure.main$script_opt.invoke(main.clj:342)
> at clojure.main$main.doInvoke(main.clj:426)
> at clojure.lang.RestFn.invoke(RestFn.java:457)
> at clojure.lang.Var.invoke(Var.java:413)
> at clojure.lang.AFn.applyToHelper(AFn.java:172)
> at clojure.lang.Var.applyTo(Var.java:518)
> at clojure.main.main(main.java:37)
>
> That was embarrassing.
>
> Looks like a null check was dropped in this commit
> be81580202ba2347ba1fea1535118b8131cfab15
> .
>
> So, I step back one revision to 7f70ce1e07fd36b3dbf1696807e5b7a83f7283cf and
> try again...
>
> $ bin/cljsc hello.cljs '{:optimizations :advanced}' > hello.js
> Exception in thread "main" java.lang.RuntimeException: No such var:
> comp/dependency-order-visit, compiling:(cljs/closure.clj:373)
> at clojure.lang.Compiler.analyze(Compiler.java:6176)
> at clojure.lang.Compiler.analyze(Compiler.java:6118)
> at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3444)
> at clojure.lang.Compiler.analyzeSeq(Compiler.java:6352)
> at clojure.lang.Compiler.analyze(Compiler.java:6157)
> at clojure.lang.Compiler.analyze(Compiler.java:6118)
> at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3437)
> at clojure.lang.Compiler.analyzeSeq(Compiler.java:6352)
> at clojure.lang.Compiler.analyze(Compiler.java:6157)
> at clojure.lang.Compiler.analyze(Compiler.java:6118)
> at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3444)
> at clojure.lang.Compiler.analyzeSeq(Compiler.java:6352)
> at clojure.lang.Compiler.analyze(Compiler.java:6157)
> at clojure.lang.Compiler.analyze(Compiler.java:6118)
> at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5513)
> at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:5814)
> at clojure.lang.Compiler.analyzeSeq(Compiler.java:6350)
> at clojure.lang.Compiler.analyze(Compiler.java:6157)
> at clojure.lang.Compiler.analyzeSeq(Compiler.java:6338)
> at clojure.lang.Compiler.analyze(Compiler.java:6157)
> at clojure.lang.Compiler.analyze(Compiler.java:6118)
> at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5513)
> at clojure.lang.Compiler$FnMethod.parse(Compiler.java:4949)
> at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3570)
> at clojure.lang.Compiler.analyzeSeq(Compiler.java:6348)
> at clojure.lang.Compiler.analyze(Compiler.java:6157)
> at clojure.lang.Compiler.analyzeSeq(Compiler.java:6338)
> at clojure.lang.Compiler.analyze(Compiler.java:6157)
> at clojure.lang.Compiler.access$100(Compiler.java:37)
> at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:492)
> at clojure.lang.Compiler.analyzeSeq(Compiler.java:6350)
> at clojure.lang.Compiler.analyze(Compiler.java:6157)
> at clojure.lang.Compiler.analyze(Compiler.java:6118)
> at clojure.lang.Compiler.eval(Compiler.java:6410)
> at clojure.lang.Compiler.load(Compiler.java:6843)
> at clojure.lang.RT.loadResourceScript(RT.java:357)
> at clojure.lang.RT.loadResourceScript(RT.java:348)
> at clojure.lang.RT.load(RT.java:427)
> at clojure.lang.RT.load(RT.java:398)
> at clojure.core$load$fn__4636.invoke(core.clj:5377)
> at clojure.core$load.doInvoke(core.clj:5376)
> at clojure.lang.RestFn.invoke(RestFn.java:408)
> at clojure.core$load_one.invoke(core.clj:5191)
> at clojure.core$load_lib.doInvoke(core.clj:5228)
> at clojure.lang.RestFn.applyTo(RestFn.java:142)
> at clojure.core$apply.invoke(core.clj:602)
> at clojure.core$load_libs.doInvoke(core.clj:5262)
> at clojure.lang.RestFn.applyTo(RestFn.java:137)
> at clojure.core$apply.invoke(core.clj:602)
> at clojure.core$require.doInvoke(core.clj:5343)
> at clojure.lang.RestFn.invoke(RestFn.java:408)
> at user$ev

Re: Including additional js in clojurescript compilation

2011-07-30 Thread Brenton
Any Google Closure compliant JavaScript can be pulled into the build
process by using the :libs option.

For example:

(build src {:libs ["/foo/bar"]})

would include any JavaScript files under /foo/bar in the build
process.

On Jul 30, 7:02 am, David Powell  wrote:
> The closure-template tools let you take a template, and pre-process it to
> something like:
>
> hello3.soy.js:
>
> goog.provide('example.templates');
> goog.require('soy');
> goog.require('soy.StringBuilder');
> [...]
> example.templates.welcome = function(opt_data, opt_sb) {
> [...]
>
> In my clojurescript, I can put:
>
> (:require [example.templates :as temp])
>
> ...but when I compile the clojurescript with optimizations, I get an error
> from the closure compiler because it doesn't know where to find the
> example.templates.
>
> Is there any way of specifying additional javascript files or paths for
> clojurescript to pass to the closure compiler?
>
> --
> Dave

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureScript on Windows

2011-07-30 Thread Brenton
The problems with paths on Windows have been fixed and ClojureScript
now has batch files for cljsc, repl, and repljs. There is also a page
in the wiki to help Windows users get started.

https://github.com/clojure/clojurescript/wiki/Windows-Setup

Support for Windows will come from the community so if you care about
this then please do pitch in and help.

On Jul 25, 10:59 am, Timothy Baldridge  wrote:
> Is there a documented way to get ClojureScript working on Windows?
> While I'm familiar with Linux, and use it in several server
> environments, all my development is on Windows, so I don't really have
> access to a Linux box for development.
>
> Timothy
>
> --
> “One of the main causes of the fall of the Roman Empire was
> that–lacking zero–they had no way to indicate successful termination
> of their C programs.”
> (Robert Firth)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Generated nodejs code from ClojureScript doesn't include some functions

2011-07-28 Thread Brenton
> This is an ongoing source of problems and should probably work  
> differently (date/time check?)
>
> Rich

There is now an issue for this. CLJS-41.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Generated nodejs code from ClojureScript doesn't include some functions

2011-07-28 Thread Brenton
Anthony,

Did you try deleting the output directory where generated JavaScript
files are stored? If core lib JavaScript files exist in this directory
they will not be re-compiled.

On Jul 27, 10:59 pm, Anthony Grimes  wrote:
> I guess I should have added that it's not just rand that isn't being
> included. It's all of the recently added functions. Check the commit log.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Alright, fess up, who's unhappy with clojurescript?

2011-07-25 Thread Brenton
James,

The reason you are experiencing resistance is because you are
proposing changes to things that will never change. Rich came up with
the Rationale before designing ClojureScript and long before writing
any code. All of the design work was informed by this. You are arguing
that there should be a different rationale which would mean starting
over from scratch.

Imagine that I invite you come work on a house that I am building
which has already been framed. Furthermore, imagine that I welcome
your input as to how the construction should progress. If your input
is, "I think we should build the house on top of the mountain over
there" or "There should be two bedrooms downstairs instead of one" you
are going to get shut down. Those decisions were made a long time ago
and it's too late to change now.

If you look at "The Library Problem" section of the Rationale
document, you will see the specific problem that ClojureScript
addresses and why the Closure compiler was chosen as the solution to
that problem. Your argument seems to be, "that isn't a problem". If
you don't think that is a problem then you are looking for something
other than ClojureScript and are welcome to pursue it.

Brenton

On Jul 25, 5:54 am, James Keats  wrote:
> Right, Rich, please allow me to reply to the points you mentioned; I
> declined from doing so last night as I sensed some unintentionally
> irritated feelings, which I hope have eased a bit by now. I believe
> all my posts in this discussion are purely technical concerns and I
> believe them to be valid. I am most definitely not a troll as some
> have suggested; I would've had to do a ridiculous amount of homework
> over a long, long period of time and been a psychic to predict this
> event (I've only found out clojurescript in the past couple of days),
> and I do not believe in any way I'm making an attempt at humor in the
> technical arguments I'm making.
>
> On Jul 24, 10:28 pm, Rich Hickey  wrote:
>
> > On Jul 24, 11:19 am, James Keats  wrote:
>
> > > Alright, to be honest, I'm disappointed.
>
> > I'll make sure you get a refund then.
>
> > Seriously, this is like being disappointed an action movie was an
> > action movie instead of a comedy. Your expectations are a complete
> > mismatch for the intentions of ClojureScript.
>
> "clojure's rocks... javascript reaches"
>
>
>
> > > First of all, congrats and good job to all involved in putting it out.
> > > On the plus side, it's a good way to use the Google Closure javascript
> > > platform.
>
> > > On the minus, imho, that's what's wrong with it.
>
> > > Google Closure is too Java.
>
> > Actually, it's too JavaScript. Some JS proponents want to disavow its
> > pseudo class model, but it certainly is part of the design of
> > JavaScript. And it has some particular advantages over the other
> > strategies, as outlined here:
>
> >http://bolinfest.com/javascript/inheritance.php
>
> Rich, the "pseudo class model" with the new keyword is a syntactic
> obfuscation, semantically javascript is prototypical inheritance. It's
> class free. In addition to the pseudo class inheritance advocated by
> google closure and the prototypical inherent in javascript, others
> like Doug Crockford advocated functional inheritance.
>
> Now I have watched and read enough of your output and for example
> Stuart Holloways talk about protocols to know that you've railed in
> your adovacy of clojure against classes and inheritance, and find it
> ironic that now you posit a link by an advocate of it citing it as
> advantageous. In any case, as I've mentioned, I have been aware of
> this article for nearly a year now, it failed to convince me back then
> and it still does; most of the arguments in it concern the closure
> compiler, an obeisance to which by the regular developer who doesn't
> have the needs and resources of google, I feel in this day and age of
> ample memory and bandwidth and fast javascript engines, is premature
> optimization gone berserk (seriously, folks, people are streaming HD
> video, 1.5 gbps fiber optic broadband is being rolled out in London
> and soon other cities worldwide and 4G mobiles are upon and we're
> fretting over mere tens of KB that gets cached after first time and
> basing our development around minimizing it?!), and the remainder of
> the arguments are in support of classes and inheritance.
>
>
>
> > > It's not idiomatic JavaScript.
>
> > There's no such thing as idiomatic JavaScript. There are a lot of
> > different conventions used by different libraries.
>
> 

Re: clojurescript and external libs

2011-07-24 Thread Brenton
Jack,

You can use the :libs key in the options which are passed to build.

For example, there is a directory of third party libraries in "closure/
library/third_party/closure" which may be pulled in like this:

cljsc src {:libs ["closure/library/third_party/closure"] ...other
options...} > ouptput.js

You may now require things from this library and use the standard
interop mechanisms. The JavaScript files from these libraries will be
pulled into the build process and run through the Closure compiler
with the rest of your code. The library files must conform to the
Google Closure standards and use the Closure dependency system (i.e.
goog.provide and goog.require).

This feature is not documented yet and may change in the future.

As a related issue, if you would like to include third party
ClojureScript files in your project, they only need to be put on the
classpath.

P.S.

js* is not for doing interop. It for implementing nasty stuff at the
very bottom and for temporarily working around problems until
ClojureScript is finished.

On Jul 24, 12:35 pm, Jack Moffitt  wrote:
> I'm exploring clojurescript and wondering how to use an external
> library? In my particular case, I was trying to use Soy from Closure
> Templates.
>
> I realize that arbitrary third party libraries will need to fit into
> the Closure Compiler ways, and part of my exploration is trying to
> port some of my own to them, but my first roadblock was figuring out
> how to get clojurescript to see them at all.
>
> Is there a simple example of this anyone can share? Or a pointer to
> the code would probably help as well.
>
> jack.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Can't find clojure.main in clojurescript's script/repl on Windows

2011-07-21 Thread Brenton
That clojure.jar file is clojure 1.3.

Something is wrong with the classpath.

Here are a couple of things to try:

- when using a batch file the classpath must be delimited with
semicolons instead of colons
- try replacing lib/* with an explicit list everything that is in lib
- something like lib/clojure.jar;lib/goog.jar;lib/compiler.jar

Just some thoughts

On Jul 21, 5:50 pm, Tamreen Khan  wrote:
> Hmm, I have clojure.jar, but not clojure-1.3.jar in clojurescript/lib
>
>
>
>
>
>
>
> On Thu, Jul 21, 2011 at 5:49 PM, Tamreen Khan  wrote:
> > Yes. It worked fine.
>
> > On Thu, Jul 21, 2011 at 5:48 PM, Devin Walters  wrote:
>
> >>  Did you run script/bootstrap?
>
> >> You need a clojure-1.3 jar in your clojurescript/lib directory.
>
> >> On Thursday, July 21, 2011 at 4:45 PM, Tamreen Khan wrote:
> >> > Hi everyone, I'm trying to get the repl for Clojurescript to start under
> >> Windows but keep running into the following error:
>
> >> > Exception in thread "main" java.lang.NoClassDefFoundError: clojure/main
> >> > Caused by: java.lang.ClassNotFoundException: clojure.main
> >> >  at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
> >> >  at java.security.AccessController.doPrivileged(Native Method)
> >> >  at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
> >> >  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> >> >  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
> >> >  at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
> >> > Could not find the main class: clojure.main. Program will exit.
>
> >> > I've tried both running the script under cygwin and putting the contents
> >> into a batch file and running it with cmd.exe (it shouldn't be a problem
> >> since script/repl just contains one command which starts the java runtime
> >> with a few options). I've even tried changing the forward slashes in the
> >> command to backslashes.
>
> >> > Also, I'm running these commands from the clojurescript root directory.
> >> Even though it probably won't affect it I've set CLOJURESCRIPT_HOME as 
> >> well.
> >> Any ideas?
>
> >> >  --
> >> >  You received this message because you are subscribed to the Google
> >> >  Groups "Clojure" group.
> >> >  To post to this group, send email to clojure@googlegroups.com (mailto:
> >> clojure@googlegroups.com)
> >> >  Note that posts from new members are moderated - please be patient with
> >> your first post.
> >> >  To unsubscribe from this group, send email to
> >> > clojure+unsubscr...@googlegroups.com (mailto:
> >> clojure+unsubscr...@googlegroups.com)
> >> >  For more options, visit this group at
> >> >http://groups.google.com/group/clojure?hl=en
>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "Clojure" group.
> >> To post to this group, send email to clojure@googlegroups.com
> >> Note that posts from new members are moderated - please be patient with
> >> your first post.
> >> To unsubscribe from this group, send email to
> >> clojure+unsubscr...@googlegroups.com
> >> For more options, visit this group at
> >>http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: BUG REPORT: ClojureScript : Portable Path Support

2011-07-21 Thread Brenton
> generated JS has path problems on windows

Until this gets fixed you can work around this particular problem by
using one of the available optimizations.

cljsc src {:optimizations :simple} > twitterbuzz.js

You may also use :whitespace or :advanced in place of :simple above.

This will produce one JavaScript file with no goog.addDependency
calls.

In the index.html file, remove all of the script tags except for the
one that pulls in twitterbuzz.js

On Jul 20, 10:12 pm, pmbauer  wrote:
> Per instructions from redinger and jgehtland (patch addressing one issue
> attached).
>
> Three separate issues so far re: path support on windows
>
> * compiler path regex is not portable, cljs/compiler.clj:1096 (see attached
> patch, thanks amalloy for the assist)
>
> * generated JS has path problems on windows
> goog.addDependency(*
> "..\..\..\..\..\..\..\/C:/tmp/clojurescript/samples/twitterbuzz/out/cljs/core.js"
> *, ['cljs.core'], ['goog.string', 'goog.string.StringBuffer', 'goog.object',
> 'goog.array']);
>
> * helper launch scripts on windows (under cygwin), more a feature than bug
>
>  portable-path-regex.diff
> < 1KViewDownload

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: sessions in Ring, Sandbar, Compojure, etc...

2011-05-11 Thread Brenton
Shree,

I would suggest that you try to use only Ring first. Once you get how
it works, take a look at Sandbar and see if that may work better for
you in specific situations.

The session code in Sandbar is stable. It will not change much in the
next release. In fact it may become its own project by then.

Here is one small application that shows how to use both styles in one
app. I hope you find this helpful.

http://github.com/brentonashworth/sandbar/blob/master/src/examples/sessions/session_with_reload.clj

Brenton

On May 9, 11:24 pm, Shree Mulay  wrote:
> For the life of me, I can't get sessions to work, immaterial of which
> tutorial I try and get going???  Is there any tutorial out there that
> explicitly explains everything for a newb like me? After several
> round, I did successfully get form params to work! YEAH! But now, I'd
> like to create a login so that the user can login and have state - but
> I can't get SESSIONS TO WORK???
>
> frustrated!,
>
> shree

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: 2D graphics options with Clojure?

2011-04-30 Thread Brenton
Stu,

Just a quick thought, you can use Java2D for the images and then iText
to create the PDFs.

Brenton

On Apr 29, 9:26 pm, stu  wrote:
> Hi,
>
> I'm developing a Clojure project that loads and creates a bunch of
> simple 2D geometry (lines, polygons, beziers, text etc). I need to
> create in a batch-style way high quality 2D renderings of that
> geometry, firstly as PNG files and secondly as PDF files.
>
> What are my options for doing this from Clojure?
>
> So far I can see it might be done with Java2D as I think this can be
> used server-side to create the PNG files, but not sure about the
> PDFs.  I believe I can use Incanter's wrapping of the Processing
> libraries for the PNG and again I'm not sure about the PDF option.
>
> The Cairo toolkit is also an option via the Gnome Java bindings and
> Java interop?
>
> Are there other options that I'm missing that anyone would like to
> report on?
>
> Thanks in advance,
>
> Stu

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ANN: Clojure Atlas (preview!)

2011-04-19 Thread Brenton
Great work Chas!

I can't wait to try it out (and pay for it).

On Apr 19, 9:19 am, Chas Emerick  wrote:
> Today, I’m opening up a “preview” site for Clojure Atlas [1], a new side 
> project of mine that I’m particularly excited about.
>
> Clojure Atlas is an experiment in visualizing a programming language and its 
> standard library.  I’ve long been frustrated with the limitations of text in 
> programming, and this is my attempt to do something about it.  >From the site:
>
> While Clojure Atlas has a number of raisons d’être, it fundamentally exists 
> because I’ve consistently thought that typical programming language and API 
> references – being, in general, walls of text and alphabetized links – are 
> really poor at conveying the most important information: not the minutiae of 
> function signatures and class hierarchies, but the stuff that’s “between the 
> lines”, the context and interrelationships between such things that too often 
> are only discovered and internalized by bumping into them in the course of 
> programming. This is especially true if we’re learning a language and its 
> libraries (really, a never-ending process given the march of progress), and 
> what’s standing in our way is not, for example, being able to easily access 
> the documentation or signature for a particular  known function, but 
> discovering the mere existence of a previously-unknown function that is 
> perfect for our needs at a given moment.
>
> This is just a preview – all sizzle and no steak, as it were.  I’m working 
> away at the ontology that drives the visualization and user experience, but I 
> want to get some more early (quiet) feedback from a few folks to make sure 
> I’m not committing egregious sins in various ways before throwing open the 
> doors to the world.
>
> In the meantime, if you’re really interested, follow @ClojureAtlas [2], 
> and/or sign up for email updates [3] on the site.
>
> - Chas
>
> [1]http://clojureatlas.com
> [2]http://twitter.com/ClojureAtlas
> [3]http://clojureatlas.com/subscribe
>
> P.S. This is a ML repost of my announcement 
> @http://cemerick.com/2011/04/19/clojure-atlas-preview/

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Noob Question - Clojure number rounding

2011-03-23 Thread Brenton
You may also consider using java interop here.

(defn round [s n]
  (.setScale (bigdec n) s java.math.RoundingMode/HALF_EVEN))

=> (round 3 78.37898794)
=> 78.379

see

http://download.oracle.com/javase/1.5.0/docs/api/java/math/BigDecimal.html

Brenton

On Mar 23, 11:08 am, JDuPreez  wrote:
> I'm trying to round a decimal number like 78.37898794 to say 78.379,
> without converting it to a string. I've been struggling to get this
> right and to get info on it. The closest that I've found is to use:
> format "%.3f". But format converts the number to a string. Not exactly
> what I'm trying to do.
>
> How can I do this in Clojure, or where is info on how to do it? Thanks
> for your help.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Release.Next Version Number

2011-02-24 Thread Brenton
I think we can all agree that the world would be a better place if
every project strictly followed semantic versioning and if people
interpreted version numbers accordingly. It would be a triumph of
science over mysticism. But we know that people don't do this and that
is why we are having this conversation. For some languages, taking
into account what people are used to doing is an important concern
(Java, C++). But I don't think that is Clojure's philosophy. Come on
people, it's a Lisp. It would have never been a Lisp if Rich cared
what the gut reaction of the masses would be. The core philosophy of
Clojure is to do it right (even if that is not popular) and then
convince people as to why this is the right way to do things. Clojure
isn't a Trojan horse, it's a beacon of hope. Let's continue that
tradition and not do something based on gut reactions. Let's do it
right and call it the backward incompatible version 2.0 that it is.
Maybe it will inspire other projects to do the same.

Brenton

On Feb 22, 6:27 pm, Christopher Redinger 
wrote:
> As you can see on the Release.Next Planning page [1], there is an open 
> question about whether or not the next version of Clojure should be 1.3 or 
> 2.0. The issue at hand is that we are introducing backwards incompatible API 
> changes. Not looking to start a debate at this point, but just taking a 
> temperature reading from the community. If you care about what the next 
> version number of Clojure is - could you please cast a vote in the poll here:
>
> https://spreadsheets.google.com/a/thinkrelevance.com/viewform?hl=en&f...
>
> Thanks!
>
> [1]http://dev.clojure.org/display/design/Release.Next+Planning
>
> --
> Christopher Redingerhttp://clojure.com

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: generic (works for any seq) levenshtein distance

2011-02-16 Thread Brenton
Laurent,

When I have some time, I will take another look at my code to see if I
can get an accurate levenshtein distance without adding significant
complexity. I am optimistic.

I'll let you know what I find.

Thanks again for sharing your code.
Brenton

On Feb 16, 2:12 am, Laurent PETIT  wrote:
> Hi Brenton!
>
> 2011/2/16 Brenton 
>
> > Laurent,
>
> > I have been doing some work on a diff library for Clojure sequences (I
> > need to get back to it and finish it up).
>
> >http://github.com/brentonashworth/clj-diff
>
> > The main goal of this library is to compute sequential diffs quickly.
>
> While mine goals was really just to first see how I could express the
> algorithm using higher order functions and clojure datastructures / sequence
> abstraction, even internally.
>
> > Whenever I see someone doing something similar I like to compare
> > performance just in case you know something that I don't.
>
> Fair enough ;)
>
> > Other algorithms usually perform well on small sequences but then
> > break down as the sizes grow. For example, I did a quick test of this
> > algorithm on two 10,000 character strings and your algorithm took 80
> > seconds while mine computed the edit distance is 120 ms.
>
> It could be interesting to plot some more intermediate results between 10
> character strings comparisons and 10,000, so that we can see if this is just
> a problem of a constant factor, or a divergence in big O complexity.
>
> Please note that my algorithm is very close in implementation (and thus
> big-O complexity, unless I've made a mistake) to the one described on the
> wikipedia page.
> It's not an "approximate" levenshtein distance, it is the levenshtein
> distance.
>
> Do you know what the performance of your version could become if you really
> implemented the computation of the levenshtein distance by really computing
> and comparing all edit paths ?
>
> (Not saying that strictly sticking to levenshtein distance/algorithm is a
> rational goal, just trying to compare apples with apples)
>
> > While my library is primarily concerned with diffs and edit distance,
> > I did add a levenshtein-distance function which attempts to compute
> > this distance from a previously computed minimum edit path. It is not
> > always accurate because there may be many minimum edit paths with
> > shorter or longer levenshtein distances. If the algorithm is modified
> > slightly so that the edit path with the minimum levenshtein distance
> > is chosen then it would be able to do both.
>
> > I can't take credit for the algorithm, I just implemented what I read
> > in a paper. But I do think this approach will get the job done as
> > quickly as possible. Of course there is a lot more code to read than
> > your very impressive ten lines.
>
> You're welcome,
>
> Cheers,
>
> --
> Laurent

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: generic (works for any seq) levenshtein distance

2011-02-15 Thread Brenton
Laurent,

I have been doing some work on a diff library for Clojure sequences (I
need to get back to it and finish it up).

http://github.com/brentonashworth/clj-diff

The main goal of this library is to compute sequential diffs quickly.
Whenever I see someone doing something similar I like to compare
performance just in case you know something that I don't.

Other algorithms usually perform well on small sequences but then
break down as the sizes grow. For example, I did a quick test of this
algorithm on two 10,000 character strings and your algorithm took 80
seconds while mine computed the edit distance is 120 ms.

While my library is primarily concerned with diffs and edit distance,
I did add a levenshtein-distance function which attempts to compute
this distance from a previously computed minimum edit path. It is not
always accurate because there may be many minimum edit paths with
shorter or longer levenshtein distances. If the algorithm is modified
slightly so that the edit path with the minimum levenshtein distance
is chosen then it would be able to do both.

I can't take credit for the algorithm, I just implemented what I read
in a paper. But I do think this approach will get the job done as
quickly as possible. Of course there is a lot more code to read than
your very impressive ten lines.

Cheers,
Brenton




On Feb 15, 2:38 pm, Laurent PETIT  wrote:
> Hi,
>
> Was playing with levenshtein (argh, where do I place the h -sorry mister
> levenshtein-), and thougth it could be interesting to share my current
> result here, to get some feedback.
>
> The following version works with any seq-able (not only Strings), but
> hardwires function = for equality testing of seq values (rather good default
> IMHO), but also hardwires the cost of 1 for either element insertion,
> deletion, or swap.
>
> It is functional, it does not use arrays, nor a MxN matrix, just the
> required data for computing a given "row" of the "virtual matrix" (e.g. the
> previous row)
>
> I'm quite sure it can still be improved for better readability and
> performance without loosing any of the above mentioned characteristics :
>
> https://gist.github.com/828413
>
> Cheers,
>
> --
> Laurent

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ANN: ClojureQL 1.0.0 finally released as public beta

2010-11-26 Thread Brenton
Lau,

I agree that it is a lot of work and no one person can do it all well.
I think that the main thing that needs to happen at this point is that
you, as the brains behind ClojureQL, should spend a little time
thinking about the best way for people to contribute back end
implementations. Maybe there is something that can be done to CQL to
make this easy. For example, maybe we add a "dialect" key to the
database connection map and then have the functions which will need
change be multimethods which dispatch on that key (dispatching on the
classname or subprotocol may not always be good enough. For example,
newer versions of SQL Server may provide better optimizations.). This
will allow others to have a path for implementing new back ends as
they need them and not be that much additional work for you. It could
also be designed so that people can provide back end implementations
as separate projects so that they don't even need to be included in
ClojureQL.

I'm sure you will come up with something on par with the rest of
ClojureQL.

Great work! I didn't like the first ClojureQL but I love it now. Now I
have to figure out how what to do with Carte.

Brenton

On Nov 25, 10:27 am, LauJensen  wrote:
> There's some valuable food for thought in this thread.
>
> My major problem with support various backends is the amount of work
> thats involved. Every single backend needs to play nice with all the
> primitives defined in Relational Algebra and that are implemented in
> ClojureQL. I believe that the SQL92 standard takes us very far down
> the middle road, but I realize that it wont take us all the way.
>
> ClojureQL is actually two sets of primitives. Firstly its the RA stuf
> (select, project, join, etc) and then internally there is a number of
> primitives defined which help translate the RTable record into a query
> string. At the highest level only two functions need to be changed in
> order to effectively replace the entire compiler: to-sql and build-
> join. These call each other to build complex queries. If these were
> supplied as plugins, I think most backends could be fully supported
> simply by providing these two methods. They are not trivial however,
> so anybody interested in contributing should check out whats already
> there.
>
> Still thinking this through but the input is appreciated!
>
> Lau
>
> On Nov 25, 6:14 pm, rickmode  wrote:
>
> > Allowing implementation-specific and optimized SQL only via strings
> > and not via a mechanism within ClojureQL allows its use in specific
> > applications but effectively prevents use for libraries and
> > frameworks. Indirect use of ClojureQL could yield unacceptable
> > performance with no elegant fix.
>
> > On Nov 24, 11:28 pm, LauJensen  wrote:
>
> > > Hi Brenton,
>
> > > Yes the OFFSET/LIMIT syntax differs from backend to backend. However
> > > in some instances (like MySQL/PostgreSQL) they have ensured
> > > compatability so that the same statement will run on several DBs
> > > although the syntax might not be considered 'native'. For something
> > > like Oracle there actually isnt a syntax for LIMIT so instead they do
> > > something like
>
> > > SELECT * FROM (
> > >   SELECT
> > >     ROW_NUMBER() OVER (ORDER BY key ASC) AS rownumber,
> > >     columns
> > >   FROM tablename
> > > )
> > > WHERE rownumber <= n
>
> > > But as you can see it would be trivial to express this in terms of
> > > ClojureQL:
>
> > > (defn oracle-take
> > >   [tname limit]
> > >   (-> (table (str "(SELECT ROW_NUMBER() OVER (ORDER BY key ASC)"
> > >                   " AS rownumber,columns"
> > >                   " FROM " (to-tablename tname) ")"))
> > >       (select (where (<= :rownumber limit)))
> > >       (project ["*"])))
>
> > > (to-sql (oracle-table :users 10))
> > > ["SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY key ASC) AS
> > > rownumber,columns FROM users) WHERE (rownumber <= ?)" 10]
>
> > > From the outset it has been my ambition to make ClojureQL extremely
> > > composable and as far as possible allow users to directly insert
> > > strings into the query to allow for backend specific customization.
> > > The entire design-plan of this customization is not yet thought out so
> > > input is welcomed. To me, flexibility and leaving with the power to
> > > the user is the key to wide adoption across various backends.
>
> > > Lau
>
> > > On Nov 24, 11:42 pm, Brenton  wrote:
>
> > > > > ClojureQ

Re: ANN: ClojureQL 1.0.0 finally released as public beta

2010-11-24 Thread Brenton
> ClojureQL does not take the backend in to account. This is the one
> feature from the old CQL that I didn't want to carry over because it
> would be impossible for me to cater to all backends. If you hit
> specific problems, let me know and I'll see what we can do.
>
> We adhere to SQL92 and test everything on MySQL and Postgres. If
> you're in a situation where thats not good enough, its always possible
> to supply part of your expression as a string.

Lau

Off the top of my head, I know that the LIMIT syntax for SQL Server is
totally different. A lot of the apps that I write end up getting
deployed using Oracle and SQL Server. If you plan for CQL to be widely
used I think you will need to take backends into account. You don't
need to implement them all yourself, but you should provide a way so
that others can implement them when they need to.

Brenton

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Sandbar Dependencies Problem

2010-10-21 Thread Brenton
[sandbar "0.3.0-SNAPSHOT"] is all you need. That is the latest version
and includes everything including the defform code you are looking
for.


On Oct 21, 5:25 am, nickikt  wrote:
> I can find  [sandbar.core "0.3.1"], [sandbar/sandbar-session "0.2.5"]
> and other on clojars. I would rather work with the new versions (not
> start a poject with outdated dependencies). Witch of the jars do I
> need to do something like your defform example in the new version?
>
> On Oct 21, 2:23 am, Brenton  wrote:
>
> > Nickikt ,
>
> > All of the stuff covered in that blog post is in Sandbar 0.3.0-
> > SNAPSHOT. You will need to add [sandbar "0.3.0-SNAPSHOT"] as a
> > dependency.
>
> > There are also lots of working examples in the project on GitHub.
>
> >http://github.com/brentonashworth/sandbar/tree/master/src/sandbar/exa...
>
> > Specifically, here is one for creating forms with defform:
>
> >http://github.com/brentonashworth/sandbar/blob/master/src/sandbar/exa...
>
> > Hope this helps,
>
> > Brenton
>
> > On Oct 20, 3:38 pm, nickikt  wrote:
>
> > > I want to make a little Webstuff with Clojure. Wanted to use Sandbar
> > > formes and looked at the 
> > > blogposthttp://formpluslogic.blogspot.com/2010/09/taming-html-forms-with-cloj
>
> > > There is kind of a mismatch between blog, implementation and
> > > documentation.
>
> > > For the Blogpost i need something like this.
>
> > > (ns TimeParser.core
> > >   (:use [compojure.core :only [defroutes GET]]
> > >             [sandbar.core]
> > >             [sandbar.stateful-session :only [wrap-stateful-session
> > >                                                                  set-
> > > flash-value!]]
> > >         [sandbar.validation :only [build-validator
> > >                                                  non-empty-string
> > >                                                  add-validation-
> > > error]])
> > >   (:require [compojure.route :as route]
> > >                  [appengine-magic.core :as ae]
> > >                  [sandbar.forms :as forms]))
>
> > > Here is my project.clj:
>
> > > (defproject TimeParser "1.0.0 Snapshot"
> > >   :description "A simple website that parses a SAP file"
> > >   :dependencies [[org.clojure/clojure "1.2.0"]
> > >                              [org.clojure/clojure-contrib "1.2.0"]
> > >                              [compojure "0.5.2"]
> > >                              [hiccup "0.2.6"]
> > >                              [sandbar/sandbar-core "0.3.1"]
> > >                              [sandbar/sandbar-session "0.2.5"]] ;(i
> > > didn't find anymore sandbar stuff on clojars)
> > >   :dev-dependencies [[appengine-magic "0.2.0"]
> > >                                      [swank-clojure "1.2.1"]
> > >                                      [clj-stacktrace "0.2.0"]])
>
> > > Does somebody know how the project.clj needs to look like (or if I
> > > need to change the ns stuff)
>
> > > Thx Nickikt
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Sandbar Dependencies Problem

2010-10-20 Thread Brenton
Nickikt ,

All of the stuff covered in that blog post is in Sandbar 0.3.0-
SNAPSHOT. You will need to add [sandbar "0.3.0-SNAPSHOT"] as a
dependency.

There are also lots of working examples in the project on GitHub.

http://github.com/brentonashworth/sandbar/tree/master/src/sandbar/example/

Specifically, here is one for creating forms with defform:

http://github.com/brentonashworth/sandbar/blob/master/src/sandbar/example/forms/complex.clj

Hope this helps,

Brenton

On Oct 20, 3:38 pm, nickikt  wrote:
> I want to make a little Webstuff with Clojure. Wanted to use Sandbar
> formes and looked at the 
> blogposthttp://formpluslogic.blogspot.com/2010/09/taming-html-forms-with-cloj
>
> There is kind of a mismatch between blog, implementation and
> documentation.
>
> For the Blogpost i need something like this.
>
> (ns TimeParser.core
>   (:use [compojure.core :only [defroutes GET]]
>             [sandbar.core]
>             [sandbar.stateful-session :only [wrap-stateful-session
>                                                                  set-
> flash-value!]]
>         [sandbar.validation :only [build-validator
>                                                  non-empty-string
>                                                  add-validation-
> error]])
>   (:require [compojure.route :as route]
>                  [appengine-magic.core :as ae]
>                  [sandbar.forms :as forms]))
>
> Here is my project.clj:
>
> (defproject TimeParser "1.0.0 Snapshot"
>   :description "A simple website that parses a SAP file"
>   :dependencies [[org.clojure/clojure "1.2.0"]
>                              [org.clojure/clojure-contrib "1.2.0"]
>                              [compojure "0.5.2"]
>                              [hiccup "0.2.6"]
>                              [sandbar/sandbar-core "0.3.1"]
>                              [sandbar/sandbar-session "0.2.5"]] ;(i
> didn't find anymore sandbar stuff on clojars)
>   :dev-dependencies [[appengine-magic "0.2.0"]
>                                      [swank-clojure "1.2.1"]
>                                      [clj-stacktrace "0.2.0"]])
>
> Does somebody know how the project.clj needs to look like (or if I
> need to change the ns stuff)
>
> Thx Nickikt

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ANN: Mycroft, a Clojure inspector

2010-09-22 Thread Brenton
Thanks Stuart and Relevance,

For newer versions of Leiningen, dev dependencies go under lib/dev.
That is where jline ends up. In script/repl you only load libraries
from the lib directory so jline doesn't end up on the classpath and,
well, you know what happens after that.

Looking forward to using this.

Brenton

On Sep 22, 11:11 am, Stuart Halloway 
wrote:
> Mycroft is a generic JVM browser written in Clojure. Version 0.0.2 is now 
> available on clojars, and the project is 
> athttp://github.com/relevance/mycrofton Github.
>
> Mycroft can be embedded as a dev dependency in your own projects. Give it a 
> try! Feedback welcome.
>
> Stu
>
> Stuart Halloway
> Clojure/core team at Relevancehttp://clojure.comhttp://thinkrelevance.com

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Simple things should be simple

2010-09-09 Thread Brenton
Mike,

While evaluating Clojure, just remember, you don't have use it for
everything. When you need something simple, as in your examples, then
use cgi. When you need to do something more complex then Clojure can
help.

You cannot deploy a .clj script on a running Tomcat (yet). When you
install Tomcat, you have a ROOT context into which you can place .html
and .jsp files and they will be dynamically loaded. This gives you
about the same functionality as you would get from php and apache.

Even though Clojure doesn't already have what you are looking for it
would not be difficult to make it work. For example, you could create
a generic web app that would have an embedded REPL as well as the
ability to dynamically load code from external files. You would then
just need to install Tomcat (which is easy) and drop this war into it.
Form then on out you would just create simple .clj scripts and drop
them into a directory. You could also connect to the REPL and
dynamically add and remove code from the application. This hasn't been
done yet because I don't think many people would find it useful.

Clojure is new so when you see something missing, build it. That is
why all of this other stuff is so simple, someone built it.

Brenton


On Sep 9, 10:40 am, Mike Meyer  wrote:
> On Thu, 9 Sep 2010 09:41:09 -0700 (PDT)
>
> Brenton  wrote:
> > Mike,
>
> > Your point has been made, simple things are simple. When you need to
> > print "hello world" you don't need to bring Clojure into the picture.
> > You could have given a much simpler example of needing to print "hello
> > world" on the command line. echo "hello world" is much simpler than
> > what you would need to do in Clojure.
>
> The thing is, I'm evaluating clojure - that's what drags clojure into
> it. If I wasn't interested in using clojure, I'd never have asked the
> question. Printing "hello world" is just a simple, well-understood
> example application. There are *lots* of applications worth putting on
> the web that aren't much more complicated than that. I chose it to
> emphasis how much extra work the environment that clojure seems to be
> inextricably linked with adds.
>
> > When faced with any problem to solve, you have to look at the tools
> > you have available and then determine what the simplest solution will
> > be. In your case, all of the software you need is already installed,
> > configured and running. So it's simple. If you gave me a system with
> > Tomcat installed, configured and running then I could do the exact
> > same thing. It has nothing to do with Java, it has to do with what you
> > are given to work with.
>
> I thought I *gave* you all those things to work with when I said "not
> counting the web server and whatever else it needs to be ready to run
> applications." Could you show me (or point me to an web page showing)
> how I'd go from a simple .clj script to an application running on
> Tomcat that's been installed and is ready to run applications? If
> that's as simple as the apache/cgi example, I'll be very happy.
>
>       --
> Mike Meyer           http://www.mired.org/consulting.html
> Independent Network/Unix/Perforce consultant, email for more information.
>
> O< ascii ribbon campaign - stop html mail -www.asciiribbon.org

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Simple things should be simple

2010-09-09 Thread Brenton
Mike,

Your point has been made, simple things are simple. When you need to
print "hello world" you don't need to bring Clojure into the picture.
You could have given a much simpler example of needing to print "hello
world" on the command line. echo "hello world" is much simpler than
what you would need to do in Clojure.

When faced with any problem to solve, you have to look at the tools
you have available and then determine what the simplest solution will
be. In your case, all of the software you need is already installed,
configured and running. So it's simple. If you gave me a system with
Tomcat installed, configured and running then I could do the exact
same thing. It has nothing to do with Java, it has to do with what you
are given to work with.

For David Nolan's example above, what you are getting compared to how
much code you have to write is actually quite amazing. And when you
start that way, the answer to the question "What if I wanted to do X?"
is usually much simpler.

And I agree with everything Zach said above.

Brenton

On Sep 9, 9:22 am, Mike Meyer  wrote:
> On Thu, 9 Sep 2010 09:03:38 -0700 (PDT)
>
> Zach Tellman  wrote:
> > Lines of code are a terrible metric for language complexity.  If I
> > write a function and abstract away half the code, have I made Clojure
> > twice as simple?
>
> Ah, I'm sorry - I'm not looking at *language* complexity. I'm looking
> at the complexity of the java/clojure *environment*. It seems to take
> a lot non-clojure boilerplate to do *anything* in java-land than seems
> reasonable to me. But I don't know javaland very well, which is why I
> asked for other people's opinions.
>
> > If you want to really evaluate Clojure, write a non-trivial
> > application and see whether the complexity is still manageable.  Code
> > golf doesn't tell you anything.
>
> Been there, done that. More than once. Well, maybe, depending on your
> definition of "trivial".http://blog.mired.org/
>
> Clojure great. No questions about that. WAR files, CLASSPATHs, having
> to wrap *every little command* in it's own script - that's what I'm
> looking at.
>
>       --
> Mike Meyer           http://www.mired.org/consulting.html
> Independent Network/Unix/Perforce consultant, email for more information.
>
> O< ascii ribbon campaign - stop html mail -www.asciiribbon.org

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: wrap-reload and sandbar session

2010-09-09 Thread Brenton
Rob,

Ring stores session data in an atom. Reloading re-defines the atom to
be empty. Sandbar uses Ring's session store. I have made a small
change to Ring in my branch which fixes this problem. See
http://github.com/brentonashworth/ring/commit/ebcdb3ec8adfc5c82d5fd6031f444a105701a8e0.
I don't see any problems with this change and will submit it as a
patch on the Ring mailing list and see what the people over there
think it. Maybe there is another way around this problem.

So, the work-around would be to fork Ring. Make this change in your
branch and then do lein jar && lein install. Then in your project
remember to do lein clean && lein deps. This will get what you want
working in development and is still compatible when you go to
production.

Brenton

On Sep 8, 5:32 pm, Rob McBride  wrote:
> Hi,
>
> It seems that when using ring's wrap-reload to automatically load changes,
> sandbar session seems to not work. Has anyone else noticed this? Is this a
> possible bug?
>
> I've added ring's wrap-reload to session_demo.clj and the demo breaks.
>
> Any work arounds? I would love to be able to use wrap-reload, it is a
> definite time saver.
>
> Thanks,
> -Rob
>
> --
> Please avoid sending me Word or PowerPoint attachments.
> Seehttp://www.gnu.org/philosophy/no-word-attachments.html

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: A secretly Clojure web framework?

2010-09-04 Thread Brenton
Here are some resources to get you started with Ring/Compojure web
development.

http://mmcgrana.github.com/2010/03/clojure-web-development-ring.html
http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applications.html
http://mmcgrana.github.com/2010/08/clojure-rest-api.html
http://weavejester.github.com/compojure/

Examples can also be very helpful.

Very simple examples

http://github.com/abedra/clojure-web
http://github.com/brentonashworth/sandbar-examples

Larger example

http://github.com/briancarper/cow-blog

Brenton

On Sep 4, 7:30 pm, HB  wrote:
> Thank you all guys, I'm really happy and proud to be around.
>
> Shantanu,
> Stuart, Abhishek and Brenton said every thing I was thinking about and
> much more:
> Lack of coherent design, sometimes it is really hard to get help,
> documentation is rare.
>
> I don't know even how to getting started with Compojure to build a web
> application.
>
> I definitely agree with Brenton, I'm thinking about a minimal
> framework (first things come to mind):
> 1. Clean and friendly URLs (like Django and Rails).
> 2. Templates neutral.
> 3. Persistence neutral.
> 4. Ajax lib neutral (like Django).
> 5. Definitely not component-based.
> 6. Rest support.
>
> (Btw Brenton, your post worth its weight in gold, thank your for
> writing).
> And yes Sean, this ideas looks amazing.
> I really want to help and participate in one of these projects you all
> mentioned but I'm pretty new to Clojure and I don't know how I can
> fit.
>
> On Sep 4, 8:26 pm, Shantanu Kumar  wrote:
>
> > On Sep 4, 8:51 pm, HB  wrote:
>
> > > My wish is vanquished :)
> > > But I really wish if Relevance will work on a web framework since it
> > > is in a unique position to achieve this (having the brightest Clojure
> > > folks).
> > > I read that Relevance embracing the "20%" principle like Google, this
> > > is also will help you Relevance folks.
> > > Have a nice day all.
>
> > HB,
>
> > I am interested to know what deficiencies do you see in present state
> > of affairs in Clojure web development space. It would be something
> > useful to discuss. There are libraries, such as:
> > 1. Ring+Clout+Compojure, Ring+Conjure, Ring+Moustache etc as web
> > controllers
> > 2. Enlive, Hiccup, Gulliver, Clj-StringTemplate, Cfmljure etc for web
> > template stuff
> > 3. c.c.sql, clj-record, ClojureQL, SQLRat for relational databases
> > 4. Sandbar, Conjure, Compojure-REST for additional web stuff
> > 5. clj-http, clj-apache-http for client-side HTTP
> > 6. Lein-WAR, Maven-Clojure plugin WAR artifact for production
> > deployment
>
> > What do you think is missing? Development-environment/IDE integration?
> > REST support? Caching, security, SEO, AJAX? WebSockets? Ready-made web-
> > UI components for rapid prototyping? Feel free to describe in detail.
>
> > Regards,
> > Shantanu

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: A secretly Clojure web framework?

2010-09-04 Thread Brenton
> The best thing we can do for Clojure web development right now is
> start developing web applications in Clojure, find the pieces that are
> missing, and fill them in.

This is the best advise I have heard in a while. We need to just start
doing it. If something that we need is missing then there is a great
opportunity for you to contribute. If you try to use a library and
find a problem, then either fix it or let the author know about the
problem. As the author of Sandbar, I wasn't even aware of with-keyword-
params but because Stuart and Aaron ran into this problem, I was made
aware of it and happily fixed it. New libraries tend to solve the
exact problems of the author so if you can use something in a
different environment and then provide feedback, you are performing a
great service.

> Clojure is a very different language from
> Ruby, and we will have to grow our own best practices.

Finding our own best practices is the big task ahead of us. The
flexibility of Compojure and Clojure can lead to vastly different ways
of doing things. I think this is a point where Relevance and Clojure/
core can show some real leadership. They will be doing a lot more
Clojure projects than the average developer over the coming years and
they have some of the top Clojure people. We will be able to learn a
lot from their experience.

> I can't see a way things like Django style user management or admin screens
> can be done by libraries.
> Frameworks are also very good for rapid prototyping. You usually pay
> for such power with inflexibility but Rails and Django seem to hit a
> sweet spot where you can develop a website fast and still run a
> business on them.

I think that this can be done in libraries. It will not be easy but it
will be much easier that doing it in Python or Ruby and will come at
less of a cost. Why? Because, if you are doing things right in
Clojure, your data is not hidden away in Objects behind mini-
languages. This makes it much easier to come up with generic solutions
to problems. For example, in 90% of my applications I need the same
exact user management component. I have created a way to simply add
this component to my application by adding a set of parametrized
routes. This gives me a paged table that can be filtered and sorted as
well as forms for adding, editing and deleting. All I need to
implement is a set of functions that define how to work with the data.
I will release this at some point but it still needs a little work to
be generally useful.

Final thought: As we move forward I think we need to be careful about
wanting a framework. We do need to have a common base that we can all
work from, which I believe we have in Ring/Compojure, but we don't
need to have something like Rails. A framework tries to make
everything easy. I believe this is folly. After using a framework for
too long, you start to forget about all the parts that the framework
hides from you and this diminishes your ability to solve problems in
the best possible way. When starting to solve a new problem, I want to
start thinking at the lowest level that I am willing to work, then add
libraries for the things that I want to make easy. We need to have a
common base, best practices and good libraries.

Brenton

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Typical usage of Compojure

2010-09-04 Thread Brenton
HB,

Welcome to Clojure. I come from the same background as you and can
tell by the questions that you are asking that you are going through
all of the same phases that I went through. As someone once said "It
is better to be at the bottom of a ladder that you want to climb than
at the top of one you don't". You are currently at the bottom of a
great ladder.

There is nothing about Compojure that makes it more suited for small
or large applications. You can do both equally well (or poorly). The
word "micro" is used because it is small.

The key to writing large applications is modularity. Compojure excels
at this. The benefits that you get from using Clojure with Compojure
for web applications will increase as the project gets larger. Being
able to compose routes and use macros to eliminate common patterns in
your code are the two biggest wins.  You will also find that much more
of your code will be easily reusable, either in the same project or
other projects. You may even spin off an open source library or two.

Which brings me to my final point. Clojure web development is still in
its early days but I believe that it will eventually be a far better
way to build web applications than anything else we are doing today.
The reason lies in Clojure's capacity for allowing developers to write
reusable code. When you are using only functions, maps and vectors and
have a well defined way of managing state, you will find that much of
the code you write is reusable. I am often shocked when looking at a
large section of code that I have written and realizing that there is
nothing about this code that is particular to my project. This means
that it will be much easier for us as a community to share code. Over
time, common problems will be solved and we will all write less code
and be able to focus on solving the problems unique to our business.
We will be able to do this using only libraries, without resorting to
frameworks, patterns or code generation.

Brenton

On Sep 4, 8:44 am, HB  wrote:
> Hey,
> If Compojure is micro web framework like Sinatra, does this means it
> is not suitable for large web applications?
> (since Sinatra isn't suitable for large applications, it is mainly
> used for very small applications and particularly to create some kind
> of an API).
> Thanks for help and time.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Problem with Sandbar and Clojure 1.2

2010-08-20 Thread Brenton
Sandbar 0.2.4 depends on Clojure 1.1.0 and Clojure Contrib 1.1.0. If
your project only depends on Clojure 1.2.0 and not Contrib 1.2.0 (and
you are using an automated build tool) then you may end up with
Contrib 1.1.0 in your classpath. This will cause the problem you are
experiencing. To fix the problem, you will need to add Contrib 1.2 as
a dependency. Sandbar 0.2.4 was AOT compiled but I tested it against
1.2 and it does work. Meikel is correct that there is no reason for
this library to be AOT compiled so I have created version 0.2.5 where
this is the case.

Version 0.3.0-SNAPSHOT is being developed against 1.2 and has some
improvements related to 1.2 and the newer versions of Ring and
Compojure. It is currently a moving target and being such, there is a
lack of documentation but if you would like to use it you can refer
the example applications at 
http://github.com/brentonashworth/sandbar/tree/master/src/sandbar/example/.

Finally, I have just created a user group for Sandbar in order to
field questions like this: http://groups.google.com/group/sandbar-library

Brenton

On Aug 20, 2:13 am, Nebojsa Stricevic 
wrote:
> I'm building a Clojure web app that I would like to migrate to 1.2.
> I've tried to empty source files and then delete one by one :use
> and :require, and I think error is connected with Sandbar lib (0.2.4).
> REPL prints this error:
>
> java.lang.NoSuchMethodError: clojure.lang.RestFn.(I)V (core.clj:
> 1)
>
> Greets,
>
> --
> Neboj¹a Strièeviæ

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Protocols not changing the caller's contract

2010-08-13 Thread Brenton
Greetings,

Suppose that I create a function that is designed to receive a map as
a parameter:

(defn add-ten [m]
  (+ 10 (:amount m)))

but then later I want to make this function part of a protocol

(defprotocol AddTen
  (add-ten [this]))

but I still want it to work when someone passes a plain map to add-
ten. The only thing that I can think of would be the following:

(extend-protocol AddTen
  clojure.lang.IPersistentMap
  (add-ten [this] (+ 10 (:amount this

It feels wrong to refer to clojure.lang.IPersistentMap as if I am
relying on an implementation detail. Is there a better way to do
this?

I'm in the middle of writing blog post about protocols (in order to
improve my own understanding of them) where I try to illustrate the
point that you can code against maps then switch to protocols and
records without changing the caller's contract.

Thanks for your help,
Brenton

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Why does using a dynamic binding make a function impure?

2010-07-19 Thread Brenton
Hi Paul,

Pure functions have two properties: they cannot produce side effects
and the return value is a function (in the mathematical sense) of its
arguments and nothing else. There are two corresponding questions that
you can ask when looking at a function to determine if it is pure.

1) When I call this function with the same arguments, do I always get
the same result?
2) Is it true that the only reason you would ever call this function
is to obtain the value that is returned from it?

If the answer to both of these questions is Yes, then you are looking
at a pure function.

Consider the following code:

(defn calc [x y] (+ x y))
(defn foo [x y] (calc x y))

Both are pure. If I call (foo 1 1) I will always get 2. There are no
side effects. Same for calc.

However, any caller can do this:

(binding [calc #(* 10 %1 %2)] (foo 1 1))

Does this mean that the function foo in now impure? No. It just means
that someone is abusing Clojure and looking for trouble.

An impure version of our code would look like this:

(declare *something*)
(defn calc [x y] (+ x y))
(defn foo [x y] (calc (/ x *something*) y))

The earmuffs are the idiomatic Clojure way of indicating that
something is intended to be dynamically bound. The caller must bind
*something* to a value or this code will not work. This is what
"Programming Clojure" means when it states: "Functions that use
dynamic bindings are not pure functions..", it is not referring to
functions which use binding internally (as in your example) but to
functions which depend on values that are dynamically bound outside of
said function.

If we wanted to have a default value for something, we could write:

(def *something* 42)
(defn calc [x y] (+ x y))
(defn foo [x y] (calc (/ x *something*) y))

In this case, there is nothing objective about foo that makes it pure
or impure. If *something* where a constant then it would be a pure
function, but if it is intended to be rebound, it is not. You only
know that is it impure based on the intention that is communicated by
the developer and the idiomatic use of earmuffs.

In summary: In some cases it is obvious, in others we only know by
intention and in call cases we can abuse Clojure and make every
function impure.

Brenton

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ANN: Deview - Better test results

2010-07-15 Thread Brenton
> I might even go so far as to suggest
> making it wrap the built-in test task using hooks; have you considered
> that?

lein-difftest now uses hooks to modify the behavior of "lein test".
Huge improvement in the code - much simpler and no copying.

> I'd rather wait on integrating it directly into Leiningen itself until
> it's seen some more widespread use as a plugin, but it is definitely
> not off the table for the future.

It may be better to keep this as a plugin since it is more tightly
coupled to clojure.test. Leiningen is test package agnostic. As other
test frameworks emerge, different plugins can be created to use and
improve upon them.

> Another option is to use ANSI color codes to markup the text and
> display it in the terminal.

I have added some coloring (using clansi) to make the important bits
stand out. I am not sure that this is an improvement.

Thanks for the input.

Brenton



-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ANN: Deview - Better test results

2010-07-14 Thread Brenton
On Jul 14, 5:17 pm, Brian Carper  wrote:
> I'm looking here:  
> http://github.com/clojure/clojure/blob/master/src/clj/clojure/test.cl...
>
> Looks like that function's signature changed a couple weeks 
> ago:http://github.com/clojure/clojure/commit/a9d9ddb6ad4f86809d44f8e3370a...
>
> --Brian

Thank you Brian,

I fixed this problem. The new version, 1.1.1, is now on Clojars and
GitHub.

Please let me know if you have any more problems.

Brenton

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ANN: Deview - Better test results

2010-07-14 Thread Brenton


On Jul 14, 2:59 pm, Brian Carper  wrote:
> For peons like myself who still run tests from a REPL and want to see
> plaintext diffed output, apparently you can use this library and do
> (difftest.core/run-tests 'some-ns) instead of (clojure.test/run-test
> 'some-ns) and it seems to work well.
>
> Minor bug, on line 36 in difftest/core.clj [1], (ct/testing-vars-str)
> should probably be (ct/testing-vars-str m), I'm getting an exception
> otherwise:
> java.lang.IllegalArgumentException: Wrong number of args (0) passed
> to: test$testing-vars-str
>
> Thanks
> --Brian
>
> [1]http://github.com/brentonashworth/lein-difftest/blob/master/src/difft...

Brian,

Great point on using it from the REPL. I have added an example of this
to the usage section of the README.

I'm not sure what's going on with that error. As you can see from [1],
testing-vars-str takes no args. Also, I don't get an error message
when running as a Leiningen plugin or from the REPL.  Let me know if
you think of anything else that might be causing this problem. I
hacked this together today so I am sure there is something I'm
missing.

P.S.

I just pushed version 1.1.0 which uses clj-stacktrace for better
stacktraces on test errors.

[1] 
http://github.com/richhickey/clojure/blob/fbe0183713b92b2f96a68e2a0d0d654bb7ce93ff/src/clj/clojure/test.clj#L286

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ANN: Deview - Better test results

2010-07-14 Thread Brenton
On Jul 13, 9:40 pm, Phil Hagelberg  wrote:
> Unfortunately since I spend all my time in the terminal, (for remote
> pairing) I can't really use a web-based interface like this for normal
> work. Do you have any plans to create a command-line client? How hard
> would it be?
>
> Alternatively, do you know how much work it would be to wire difform
> directly into clojure.test so you'd get readable results from a
> standard "lein test" run?

I have created a new project named lein-difftest.

http://github.com/brentonashworth/lein-difftest

It is a Leiningen plugin that works with Leiningen 1.2. It works
exactly the same as "lein test" but will use difform to show diffs
when there is a test failure.

It currently doesn't do anything with stacktraces but I will add that
as an option.

Would it be better to create a patch for Leiningen so that this would
be the default behavior of "lein test"?

Brenton

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ANN: Deview - Better test results

2010-07-13 Thread Brenton
Phil,

Could you give me a little more detail as to why you can't use it? I
also work from the command line and this works very well for me. I
thought that this would work well for remote pairing. Do you work from
sources on your machine or from a server? Either way you should be
able to add the server to your project. The client can run from
anywhere. You can run one centralized client or one for each team
member. The main advantage of the web interface is that you have so
many more options for displaying information.

Having said that, if you cannot use it as it is or if you and others
think that a command line version would be better, then I would be
happy to do it. That would be much easier than what I have already
done.

Would you prefer a command line "client" so that you would still run
the server from your project and you could have any number of clients
connect to the same test server; or would it be better to just have a
Leiningen plugin that runs tests and formats the results with difform
and clj-stacktrace? Either would we fairly easy given the work I have
already done.

Brenton

On Jul 13, 9:40 pm, Phil Hagelberg  wrote:
> On Tue, Jul 13, 2010 at 12:33 PM, Brenton  wrote:
> > Deview is a tool for running tests in Leiningen projects which use
> > clojure.test. Test results are much better than plain text. Any
> > exception, either at compile time or in a test failure, is filtered
> > using clj-stacktrace. For other failures a diff of the two forms is
> > displayed.
>
> > I hope someone else finds this as useful as I do.
>
> This is really cool!
>
> Unfortunately since I spend all my time in the terminal, (for remote
> pairing) I can't really use a web-based interface like this for normal
> work. Do you have any plans to create a command-line client? How hard
> would it be?
>
> Alternatively, do you know how much work it would be to wire difform
> directly into clojure.test so you'd get readable results from a
> standard "lein test" run?
>
> -Phil

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


ANN: Deview - Better test results

2010-07-13 Thread Brenton
Hello Group.

Another child (aleph being the other) of the June Bay Area Clojure
Meetup. At the meetup, George Jahad presented difform; a tool for
displaying the diff of two forms. I decided to take this to the next
level.

Deview is a tool for running tests in Leiningen projects which use
clojure.test. Test results are much better than plain text. Any
exception, either at compile time or in a test failure, is filtered
using clj-stacktrace. For other failures a diff of the two forms is
displayed.

I hope someone else finds this as useful as I do.

Blog post: 
http://formpluslogic.blogspot.com/2010/07/better-clojure-test-results-with-deview.html

The project: http://github.com/brentonashworth/deview

Brenton

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Exceptions

2010-06-29 Thread Brenton
Nicolas,

Check out error-kit in contrib.

Brenton

On Jun 29, 7:26 am, Nicolas Oury  wrote:
> Dear all,
>
> Is there a high level facility in Clojure to create your own exceptions?
> I know you can use genclass/proxies and extend Throwable/Exception but it
> seems very (too?) close to the host language
> whereas the concept of exceptions is shared among most potential hosts.
>
> It would seems reasonable to have a few macros (defexception, deferror,
> defthrowable for example...) to abstract away
> from the JVM (for clarity and portability) while keeping the same underlying
> mechanism (for compatibility with the host).
>
> Has anyone tried anything like that? Is there a big problem with such an
> approach?
>
> Best regards,
>
> Nicolas.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: State of Clojure web development

2010-06-24 Thread Brenton
1. Have you written, or are you writing, a web application that uses
Clojure? What does it do?

I am an independent contractor and do a lot of corporate intranet web
applications. All of my clients support Java. Each year I write a few
new applications and spend a lot of time maintaining old Java
applications. The first new application that I wrote this year was
pure Clojure. It was a very simple application for collecting ideas
from employees. It was great to be able to use Lisp and yet integrate
and deploy into a Java environment. The application was deployed to
WebSphere as a war file, connects to an SQL Server database and uses
the company's LDAP Java libraries. I plan to use Clojure for all new
projects.

I also work for a research group with a bunch of statisticians
building web based tools based on the work that they do. Usually
taking some nasty spreadsheet that someone has created and turning it
into a web application. Clojure (functional programming) with Incanter
will be a perfect fit for this type of project.

2. Which libraries or frameworks are you using? Which versions?

[org.clojure/clojure "1.1.0"]
[org.clojure/clojure-contrib "1.1.0"]
[compojure "0.4.0-RC3"]
[hiccup "0.2.3"]
[sandbar "0.2.4"]
[enlive "1.0.0-SNAPSHOT"]
[carte "0.1.0"]
[inflections "0.3"]

I am also working on Sandbar and Carte. Sandbar provides middleware to
allow one to work with the session as if it were a global map with put
and get functions. It also provides middleware for authentication and
authorization. Carte is non-object oriented relational mapping. Both
are very new.

3. What made you choose Clojure to develop web applications in? What
are the strengths of Clojure web development?

1. Functional programming is a better fit than OO for web
applications.
2. Lisp is as DRY as you can get. Every other environment that I have
worked in, you get to some point where you can no longer create
abstractions and have to resort to design patterns, code generation or
non-primary language configuration. I don't see this ever happening
with Clojure.
3. It is just Java. Easy deployment into any Java container. Clients
get a Java app and there is much rejoicing.
4. Mutable objects as a default are bad, even for web applications.
5. Interactive REPL development.
6. Ring and Compojure are exactly what I want as the foundation for my
web applications: simple, small and extensible. Middleware is
wonderful.

4. What do you think are the current weaknesses of web development in
Clojure? What could be improved?

Packaging and deployment seem to be the big problem at this point. I
have a lot experience with Java web applications so it is not that
difficult for me to create a war for deployment but I can see that
someone without a Java background would be completely confused by
this. I would love to see a tool that can package my app into a war
including a REPL server.

It would also be nice to have easily accessible, thorough,
documentation for Ring and Compojure with example code that goes
beyond the most simple cases. The community is young and so there is a
lack of shared knowledge about best practices when developing larger
applications.

One of the things that I like about Clojure web development (the
flexibility) also causes some concern. In my opinion, the best thing
about Rails is that any developer who knows Rails can go to any Rails
project and know where everything is. The conventions of Rails have
also contributed greatly to Rails' ability to grow and innovate. I
don't know what the solution is, just wanted to bring this up.

5. Anything else you want to comment on?

Many thanks to Mark and James for all of your work on Ring and
Compojure. Without these two libraries there wouldn't be much Clojure
web development going on. Also, thanks for keeping it simple and not
trying to do too much.

On Jun 23, 2:23 pm, James Reeves  wrote:
> Hello there!
>
> Chas Emerick's recent "State of Clojure" survey [http://bit.ly/dtdAwb]
> indicated that a significant proportion of Clojure users are beginning
> to use Clojure for web development. A recent Hacker News posting
> [http://bit.ly/91Bu5J] seems to corroborate these results, with
> several Clojure-based web applications already out in the wild.
>
> As one of the main developers of Ring and Compojure, I'd be very
> interested to hear more about how people are using Clojure to build
> web apps. To this end, I have a few questions I'd like to quiz Clojure
> web developers about:
>
> 1. Have you written, or are you writing, a web application that uses
> Clojure? What does it do?
>
> 2. Which libraries or frameworks are you using? Which versions?
>
> 3. What made you choose Clojure to develop web applications in? What
> are the strengths of Clojure web development?
>
> 4. What do you think are the current weaknesses of web development in
> Clojure? What could be improved?
>
> 5. Anything else you want to comment on?
>
> Please reply to this thread with your answers, and thank you very much
>

Re: Requesting Feedback on new Relational Mapping lib for Clojure

2010-06-23 Thread Brenton
Thank you for your ideas, feedback and criticisms.

rb and Jeff

Future versions of Carte will not force you to list the column names
but will retrieve them from the database.

Jeff

The model macro produces a map which may then be merged with other
model maps so you could define the model in various places. That feels
more like an object oriented approach and Carte is not trying to be
object oriented. It seems natural in a more bottom-up style to define
everything in one place.

I like that queries are just data but I also see how they can be a
little hard to read. I am considering using a macro for queries that
would allow table names to be written as symbols instead of keywords.
My main concern is to ensure that queries behave in the same way as
the rest of Clojure.

Thanks again,
Brenton

On Jun 20, 9:36 am, rb  wrote:
> Hi Brenton:
>
> I think it would be nice if rather than specifying the columns of each
> table in the call to the model macro, it was extracted from the
> database directly.
>
> Raph
>
> On Jun 14, 6:14 pm, Brenton  wrote:
>
> > Hello group.
>
> > I have been working on a relational mapping library for Clojure named
> > Carte.
>
> >http://github.com/brentonashworth/carte
>
> > The current version is what I would consider to be a working prototype
> > and I would love to get feedback from the community before I do much
> > more work on this. The project includes a rather lengthy README.
> > Mainly, I am interested in constructive criticism of the ideas and
> > examples contained in the README but if you would like to jump into
> > the code and critique that, that would be great.
>
> > This is my idea of an idiomatic Clojure relational mapping library. Do
> > you think I am on the right track? If not, what would that look like?
> > What would Rich do?
>
> > This project is being developing for my own immediate needs but I
> > would be interested in improving it outside of the scope of my work
> > based on your feedback.
>
> > Thank you,
> > Brenton

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Requesting Feedback on new Relational Mapping lib for Clojure

2010-06-14 Thread Brenton
Hello group.

I have been working on a relational mapping library for Clojure named
Carte.

http://github.com/brentonashworth/carte

The current version is what I would consider to be a working prototype
and I would love to get feedback from the community before I do much
more work on this. The project includes a rather lengthy README.
Mainly, I am interested in constructive criticism of the ideas and
examples contained in the README but if you would like to jump into
the code and critique that, that would be great.

This is my idea of an idiomatic Clojure relational mapping library. Do
you think I am on the right track? If not, what would that look like?
What would Rich do?

This project is being developing for my own immediate needs but I
would be interested in improving it outside of the scope of my work
based on your feedback.

Thank you,
Brenton

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


deftype feature or bug?

2010-04-20 Thread Brenton
Hello group,

I am working with edge Clojure and, as of today, noticed that
deftype's behavior has changed (which is expected as it is still
alpha). The version in question is:

clojure-1.2.0-master-20100420.150114-37.jar

Here is my REPL interaction which demonstrates the difference:

user> (defprotocol HelloWorld (say-hello [this]))
HelloWorld
user> (deftype HelloJoe [] HelloWorld (say-hello [this] "Hello Joe"))
user.HelloJoe
user> (def hello (HelloJoe))
; Evaluation aborted
Expecting var, but HelloJoe is mapped to class user.HelloJoe
user> (def hello (user.HelloJoe.))
user> (say-hello hello)
"Hello Joe"

Before today (def hello (HelloJoe)) would not cause an error.

Is this a bug or a new feature of deftype?

Thanks,
Brenton

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: installing libraries

2010-03-27 Thread Brenton
Glen,

This doesn't really answer your specific question but if you are going
to be graphing data from Clojure then the best library to use would be
Incanter http://github.com/liebke/incanter.

It uses the same Java library as Dejcartes for creating charts,
JFreeChart, and is very easy to use. Plus there is a lot more to it
than just charting.  The documentation is also fantastic.

I'm not sure if you are new to Clojure but if you are, you may want to
check out labrepl (http://github.com/relevance/labrepl) which makes it
easy to get started with Clojure and includes Incanter.

Forgive me if you already knew all of this.

Kind Regards,
Brenton

On Mar 27, 2:55 pm, Glen Rubin  wrote:
> I want to start graphing some data i am woking with.  I found and
> downloaded a library called dejcartes for this 
> purposehttp://www.markmfredrickson.com/code/
>
> I am absolutely clueless as how to install this beast...my knowledge
> of java is extremely.  i see there are a bunch of jar files as well
> clojure ones too!  are there any tutorials on installing 3rd party
> libraries out there??
>
> thx for any advice!

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

To unsubscribe from this group, send email to 
clojure+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


Re: Help me make this more idiomatic clojure

2010-02-11 Thread Brenton
Sorry, you are not commenting out a line of code but ignoring the next
form.

On Feb 11, 12:49 pm, Brenton  wrote:
> You can also you #_ to comment out a line of code
>
> #_(.vm detach)
>
> so that you don't have to put )) on the next line.
>
> Brenton
>
> On Feb 11, 10:39 am, Greg Bowyer  wrote:
>
> > Hi all, long time lurker first time irritant.
>
> > I have been playing with clojure for a little while, and finding it most
> > excellent; however my lack of lisp thinking keeps leading me to write
> > ugly code.
>
> > I have the following code in java:
>
> > --
> > static final String CONNECTOR_ADDRESS =
> > "com.sun.management.jmxremote.localConnectorAddress";
>
> > VirtualMachine vm = VirtualMachine.attach(id);
> > String connectorAddress =
> > vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS);
>
> > // no connector address, so we start the JMX agent
> > if (connectorAddress == null) {
> >     String agent = vm.getSystemProperties().getProperty("java.home") +
> >         File.separator + "lib" + File.separator + "management-agent.jar";
> >     vm.loadAgent(agent);
>
> >     // agent is started, get the connector address
> >     connectorAddress =
> >         vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS);
>
> > }
>
> > -
>
> > I have translated this into the following clojure form
>
> > ---
> > (defn obtain-local-connection [vmid]
> >    (let [vm (VirtualMachine/attach vmid)]
> >      (let [aquire-connector
> >        #(.. vm (getAgentProperties) (getProperty
> > "com.sun.management.jmxremote.localConnectorAddress"))]
> >        (if (aquire-connector) aquire-connector
> >            (do
> >              (. vm (loadAgent
> >                (apply str
> >                  (interpose java.io.File/separator
> >                    (list (.. vm (getSystemProperties) (getProperty
> > "java.home"))
> >                        "lib" "management-agent.jar")
> >              (aquire-connector
> >      ;(. vm detach))
> > ))
> > ---
>
> > My question would be is there a better way to express this ?
>
> > Many thanks
>
> > -- Greg Bowyer

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Help me make this more idiomatic clojure

2010-02-11 Thread Brenton
You can also you #_ to comment out a line of code

#_(.vm detach)

so that you don't have to put )) on the next line.

Brenton

On Feb 11, 10:39 am, Greg Bowyer  wrote:
> Hi all, long time lurker first time irritant.
>
> I have been playing with clojure for a little while, and finding it most
> excellent; however my lack of lisp thinking keeps leading me to write
> ugly code.
>
> I have the following code in java:
>
> --
> static final String CONNECTOR_ADDRESS =
> "com.sun.management.jmxremote.localConnectorAddress";
>
> VirtualMachine vm = VirtualMachine.attach(id);
> String connectorAddress =
> vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS);
>
> // no connector address, so we start the JMX agent
> if (connectorAddress == null) {
>     String agent = vm.getSystemProperties().getProperty("java.home") +
>         File.separator + "lib" + File.separator + "management-agent.jar";
>     vm.loadAgent(agent);
>
>     // agent is started, get the connector address
>     connectorAddress =
>         vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS);
>
> }
>
> -
>
> I have translated this into the following clojure form
>
> ---
> (defn obtain-local-connection [vmid]
>    (let [vm (VirtualMachine/attach vmid)]
>      (let [aquire-connector
>        #(.. vm (getAgentProperties) (getProperty
> "com.sun.management.jmxremote.localConnectorAddress"))]
>        (if (aquire-connector) aquire-connector
>            (do
>              (. vm (loadAgent
>                (apply str
>                  (interpose java.io.File/separator
>                    (list (.. vm (getSystemProperties) (getProperty
> "java.home"))
>                        "lib" "management-agent.jar")
>              (aquire-connector
>      ;(. vm detach))
> ))
> ---
>
> My question would be is there a better way to express this ?
>
> Many thanks
>
> -- Greg Bowyer

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: small code review..

2010-02-11 Thread Brenton
Martin,

It's very simple, I like it.

There two things that stand out to me, both having to do with
readabiliby.

Instead of using (def score) you should use (declare score). declare
exists for the purpose of making forward declarations. That one is
black and white. You have to do it.

The other I am not so sure about. You create a function named sum
which calls (reduce + rolls). I think that an experienced Clojure
programmer would rather just see
(reduce + (take 2 rolls)) rather than (sum (take 2 rolls)). There are
two reasons you may want to create the sum function. One bad and one
not so bad. The first is that you think reduce + is confusing and so
you are creating a name that makes more sense to you. The second is
that you are going to be using it a lot and you want to save 5
keystrokes. I have issue with the first reason. When an experienced
Clojure dev sees (reduce + (take 2 rolls)) there is only one foreign
idea to think about, namely rolls. When they see (sum (take 2 rolls))
the complexity has increased because they now they have two foreign
ideas to think about. Another way to think about it is that when I see
(reduce + (take 2 rolls)) I know exactly what it does. When I see (sum
(take 2 rolls)), I don't know what it does. sum could be some crazy,
messed up side effecting function that could cause all kinds of
problems. In your code it is easy to check that sum is correct but
what if it was implemented in another file?

I only point this out because I find myself doing this all the time.

Brenton

On Feb 11, 9:19 am, Martin Hauner  wrote:
> Hi,
>
> I'm doing my first steps in Clojure and I would like to get some
> feedback on my implementation of the Bowling Game Kata. The code is
> herehttp://softnoise.wordpress.com/2010/02/07/the-bowling-kata-in-clojure.
> I can post the code here if that's preferred.
>
> I'm mostly interested if there is anything in my code one would/should
> never do that way.
>
> Thanks
>   Martin

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: newbie encountering java.lang.OutOfMemoryError: Java heap space

2010-02-10 Thread Brenton
Aviad,

You don't get a speedup because you are never calling the memoized
function with the same arguments. In your code, n is different each
time.

memoize basically creates a map of arguments to results. When you call
the function with args that it has seen before it bypasses actually
calling the underlying function and just returns the results.

If you really wanted to use memoize here then you use it on the vl
function.

Brenton

On Feb 10, 9:54 am, Aviad Reich  wrote:
> Thank you all!
>
> your advice were indeed very helpful!
>
> I eventually solved it using memoization. and indeed keeping only
> (http://clojure-euler.wikispaces.com/Problem+014- lxmonk if you're
> interested)
>
> This indeed is a great community, so let me try another (related) question.
>
> Comparing my solution with an identical one - but without memoization
> produces a faster result.
> I understand that caching all the results has some overhead, but how come it
> isn't balanced with the speedup from the cached values?
>
> Again,
> Thanks!
>
> Aviad
>
> On 10 February 2010 19:40, Greg  wrote:
>
> > Hi Aviad,
>
> > Disclaimer: I haven't read the book, nor do I know Clojure very well.
>
> > However, based on your question (which I did read) and Brenton's hint, it
> > seems to me like the solution will involve a lazy sequence, which is a
> > frequent tool to use whenever you're dealing with a problems that involve a
> > lot of memory.
>
> > - Greg
>
> > On Feb 10, 2010, at 10:13 AM, Aviad Reich wrote:
>
> > thank you.
> > I have "-server" and "-Xmx1024m" set in my 'swank-clojure-extra-vm-args,
> > but the problem remains.
>
> > Aviad
>
> > On 10 February 2010 15:57, Joop Kiefte  wrote:
>
> >> (Disclaimer: never tried myself)
> >>http://hausheer.osola.com/docs/5
>
> >> 2010/2/10 Aviad R 
>
> >> Hi all.
>
> >>> I'm trying to learn clojure with the excellent "Programming Clojure"
> >>> and projecteuler.net. I am encountering the java heap space error, and
> >>> can't find a workaround, nor a smarter way to write my code (which I
> >>> am certain exist).
>
> >>> Trying to solve Problem 14 (some spoilers might be ahead, for those
> >>> wanting to solve it in the future).
>
> >>> The problem and my code are inhttps://pastee.org/hj3sh
>
> >>> here is the problem:
> >>> I am trying to produce a map of one O(million) key-value pairs using a
> >>> recursive function.
>
> >>> I can produce a map of the first 10 numbers in ~1300 msecs, with
> >>> 217211 keys.
> >>> However, for 15 and up, I get java.lang.OutOfMemoryError: Java
> >>> heap space.
>
> >>> so, I assume my code is ok on efficiency, but the recursion is too
> >>> deep.
>
> >>> am I right? can anyone suggest a way to overcome this problem?
> >>> any additional tips and thoughts on the code would be of great help to
> >>> me, as I am making my first steps in clojure.
>
> >>> Thank you,
> >>> Aviad
>
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "Clojure" group.
> >>> To post to this group, send email to clojure@googlegroups.com
> >>> Note that posts from new members are moderated - please be patient with
> >>> your first post.
> >>> To unsubscribe from this group, send email to
> >>> clojure+unsubscr...@googlegroups.com
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/clojure?hl=en
>
> >> --
> >> Communication is essential. So we need decent tools when communication is
> >> lacking, when language capability is hard to acquire...
>
> >> -http://esperanto.net -http://esperanto-jongeren.nl
>
> >> Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004
>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "Clojure" group.
> >> To post to this group, send email to clojure@googlegroups.com
> >> Note that posts from new members are moderated - please be patient with
> >> your first post.
> >> To unsubscribe from this group, send email to
> >> clojure+unsubscr...@googlegroups.com
> >> For more options, visit this group at
> >>http://groups.google.com/group/clojure?hl=en
>
> > --
> > You receive

Re: Noob question: rebinding using def

2010-02-10 Thread Brenton
chaosprophet,

Clojure wants you to think in terms of sequences instead to loops.
Instead to looping through cat-all and keeping track of the sum, you
want to use map and reduce.

(reduce + (map #(probability-of-category-given-document % tokens) cat-
all))

Brenton

On Feb 10, 7:14 am, chaosprophet  wrote:
> Hi guys,
> I'm new to both clojure and functional programming and as an exercise
> in learning Clojure, I decided to write a naive bayes categorizer. I
> have a piece of code wherein I have a doseq inside which i am calling
> a function which returns a value. What I would like to do is have the
> value returned by the function to be added to a particular binding
> (variable), so that at the end of the doseq, I'll have a total sum of
> all values returned. Right now im doing this by using def to rebind
> the value. The exact code I'm using is:
> (def prob-sum 0)
> (doseq [cat cat-all]
>                 (def prob-sum (+ prob-sum 
> (probability-of-category-given-document
> cat tokens
>
> I know that using def to rebind is not good practice and I should
> probably be using ref. However, this executes only in a single thread,
> so I'm not sure if it would be appropriate to use ref.
> Also, I realize that I'm abusing the concept of data immutability, but
> in this case I really need this to be mutable. However, I have a gut
> feeling that I'm not really approaching this in the right way (as in
> correct way to do it in a functional language), and I would really
> appreciate it if someone could set me upon the right track.
>
> Regards,
> chaosprophet

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: newbie encountering java.lang.OutOfMemoryError: Java heap space

2010-02-10 Thread Brenton
Aviad,

Welcome to Clojure.

I don't want to tell you how to solve it. That's all part of the fun.
But my hint to you would be that you don't need to keep all 1 million
lists in memory. In fact, you should be able to solve this problem by
only keeping three numbers in memory at any one time: The number that
has produced the longest chain, the size of the longest chain and the
size of the current chain you are working on.

Also, as I was recently reminded by this group, it is never a good
idea to use def within a function. This problem can be solved using
only pure functions.

Good luck,
Brenton

On Feb 10, 7:13 am, Aviad Reich  wrote:
> thank you.
> I have "-server" and "-Xmx1024m" set in my 'swank-clojure-extra-vm-args, but
> the problem remains.
>
> Aviad
>
> On 10 February 2010 15:57, Joop Kiefte  wrote:
>
> > (Disclaimer: never tried myself)
> >http://hausheer.osola.com/docs/5
>
> > 2010/2/10 Aviad R 
>
> > Hi all.
>
> >> I'm trying to learn clojure with the excellent "Programming Clojure"
> >> and projecteuler.net. I am encountering the java heap space error, and
> >> can't find a workaround, nor a smarter way to write my code (which I
> >> am certain exist).
>
> >> Trying to solve Problem 14 (some spoilers might be ahead, for those
> >> wanting to solve it in the future).
>
> >> The problem and my code are inhttps://pastee.org/hj3sh
>
> >> here is the problem:
> >> I am trying to produce a map of one O(million) key-value pairs using a
> >> recursive function.
>
> >> I can produce a map of the first 10 numbers in ~1300 msecs, with
> >> 217211 keys.
> >> However, for 15 and up, I get java.lang.OutOfMemoryError: Java
> >> heap space.
>
> >> so, I assume my code is ok on efficiency, but the recursion is too
> >> deep.
>
> >> am I right? can anyone suggest a way to overcome this problem?
> >> any additional tips and thoughts on the code would be of great help to
> >> me, as I am making my first steps in clojure.
>
> >> Thank you,
> >> Aviad
>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "Clojure" group.
> >> To post to this group, send email to clojure@googlegroups.com
> >> Note that posts from new members are moderated - please be patient with
> >> your first post.
> >> To unsubscribe from this group, send email to
> >> clojure+unsubscr...@googlegroups.com
> >> For more options, visit this group at
> >>http://groups.google.com/group/clojure?hl=en
>
> > --
> > Communication is essential. So we need decent tools when communication is
> > lacking, when language capability is hard to acquire...
>
> > -http://esperanto.net -http://esperanto-jongeren.nl
>
> > Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Implicit style streams in Clojure

2010-02-08 Thread Brenton
letfn is exactly what I was looking for.

Thank you.

On Feb 8, 12:15 pm, Michał Marczyk  wrote:
> Use let:
>
> (defn foo [...]
>   (let [helper (fn [...] ...)]
>     (helper ...)))
>
> or letfn:
>
> (defn foo [...]
>   (letfn [(helper [...] ...)]
>     (helper ...)))
>
> The latter allows you to introduce mutually recursive functions.
>
> Sincerely,
> Michał

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Implicit style streams in Clojure

2010-02-08 Thread Brenton
What is the Clojure best practice, if there is one, for writing a
function like this:


(defn integral [integrand initial-value dt]
  (def --integral (cons initial-value
  (lazy-seq (add-streams (scale-
streams integrand dt)
 
--integral
  --integral)


integrand is a stream of values.

I don't like the fact that --integral is visible outside of the
integral function but I don't know how else to implement this
efficiently. I am using -- here as a naming convention to identify
vars that are defined within other functions.

Also, what is general feeling about defs inside of functions?

Brenton

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure for system administration

2010-02-04 Thread Brenton
I have created a clj command on my system (using Ruby, 
http://gist.github.com/247899)
that will run a Clojure script or launch the REPL.

For example: "clj script.clj" or just "clj script" will run as script.
You may also pass args to the Clojure script like this "clj script
arg1 arg2". You may also pass arguments starting with "-X" through to
Java. I also have shorthands for other things like the arg -Xjmx is
converted to -Dcom.sun.management.jmxremote. Just typing clj at the
command line anywhere will start a REPL. I created this when I started
using Clojure to make it easier to work with and have been hacking on
it for a while. I add stuff all the time for my own convenience.

The basic idea is that you have a default classpath which is used when
you are not working within a project. If I execute clj within a
directory that contains a lib directory then it will put the jars in
lib on the classpath. If there is no lib directory then it will use
the default classpath. I explicitly set which jars are on the default
classpath but I think a better general purpose approach would be to
have a directory somewhere on your system that contains the default
jars. For example groovy has the .groovy/lib dir under ~ for this
purpose. This would allow you to easily add default jars without
modifying the clj script.

I also use a file named .cljrc.clj to configure the REPL. When the
script starts it will find the nearest parent dir that contains a file
named .cljrc.clj. When it finds this file it will run it and then
start the java process in that directory. I usually create a default
file in my root directory or ~ and one in each project. This file
usually contains an exit function to shutdown the REPL but you can
also configure the REPL here so that you don't have to do it each
time.

I created this before leiningen was available but I still use it and
the two work together very well. I also configure Emacs to use this as
my Clojure binary.

(setq swank-clojure-binary "clj")

What the others have said is still true. I only use Clojure for admin
stuff when the startup time is not a factor. But this clj script takes
away a lot of the pain of launching Clojure from the command line.

I hope this has more signal than noise.
Brenton

On Feb 4, 9:35 am, Phil Hagelberg  wrote:
> On Thu, Feb 4, 2010 at 8:33 AM, Stuart Sierra
>
>  wrote:
> > Clojure can certainly do these things; clojure-contrib contains many
> > file and io-related utilities.  But remember that Clojure, like any
> > Java program, takes more time to start up than "scripting" languages
> > like Perl/Bash/Ruby/Python, so it may be less suitable for programs
> > that you intend to run at the command-line.
>
> Also relevant is the fact that launching Clojure from the command-line
> is very inconvenient compared to scripting languages. If you want
> something simple you can just put on your path, you'll need to wrap it
> in a bash (or other language) script anyway to handle the classpath,
> etc. The combination of startup time and the need to roll your own
> bash script even for simple things has kept me from wanting to use
> Clojure as a perlish-replacement.
>
> -Phil

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Why is this code causing StackOverflowError?

2010-01-27 Thread Brenton
I was about to ask the same question on this list about this code
adapted from SICP section 3.5.3


(defn pi-summands [n]
  (cons (/ 1.0 n)
(lazy-seq (map - (pi-summands (+ n 2))


which causes a stack overflow when I run

(nth (pi-summands 1) 1)

but it looks like you have answered this question. To get the 10,000th
element from this list means that we have to keep  map calls on
the stack with all of their context. Is that correct?

Is it also true that the Scheme version of this code would have the
same problem?


(define (pi-summands n)
  (cons-stream (/ 1.0 n)
(stream-map - (pi-summands (+ n 2)


I would hope so. I don't want to get Scheme envy.

Thanks for your help,
Brenton

On Jan 26, 6:17 am, Nebojsa Stricevic 
wrote:
> Greetings,
>
> I'm new to Clojure and working my way through Project Euler problems
> for learning. I wrote function for calculating prime number below some
> integer value max. But it doesn't work for large numbers, causing
> StackOverflowError.
>
> (defn primes-below
>         "calculates all primes bellow max"
>         [max]
>         (loop [numbers (range 2 max) primes []]
>                 (if (empty? numbers)
>                         primes
>                         (let [p (first numbers)
>                               numbers (filter #(pos? (rem % p)) numbers)
>                               primes (cons p primes)]
>                           (recur numbers primes)
>
> (primes-below 200)
>
> I guess problem is not with loop-recur, or am I wrong?
>
> Thanks in advance.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Funding Clojure 2010

2009-12-14 Thread Brenton
Rich,

I second the idea that there should be some kind of status report so
that people can see what you need and how close we are to meeting the
goal.

Just having a Donate button on the site was not enough to get me to
contribute. But spelling it out like you have here pushed me over the
edge.  I think if people could see what the need was then they would
be willing to give more. Otherwise they may continue to think that
someone else will do it and so they don't need to.

It may also be good to have a web site set up where people/businesses
could actually make a monetary commitment per year and then those who
have donated could see what the commitment level is and then know if
perhaps they need to up their own commitment or try harder to get more
people involved or get creative and come up with other ideas for how
to raise money. Obviously not a job for you personally but for someone
else in the community to take up if you think it is a good idea. I may
be willing...

Brenton

On Dec 14, 6:33 am, Rich Hickey  wrote:
> Funding Clojure 2010
>
> Background
> --
>
> It is important when using open source software that you consider who
> is paying for it, because someone is. There is no such thing as free
> software.
>
> Sometimes open source software is developed under a license with
> undesirable properties (e.g. the GPL), such that people are willing to
> pay for a (proprietary) version of it that is not subject to that
> license. Both Monty Widenius [1] and Richard Stallman [2] have argued
> for the necessity of such a mechanism to fund open source software,
> lest there be insufficient resources for its development. Clojure
> doesn't use the GPL, thus conveying more freedom to its users, but
> precluding me from funding it via dual licensing.
>
> Some companies develop technology as a component of a proprietary
> product or service, absorbing it as a necessary expense, only to
> decide that it is not a core, unique, or advantage-bearing business
> function. They can reduce their costs in ongoing development by open
> sourcing it, deriving benefit from community contributions and letting
> them focus on their core business [3]. It is important to note that
> the bulk of the costs are often in the original development, and are
> paid for by the proprietary product or service. That is not the case
> for Clojure.
>
> Some open source is the product of academic research, and is funded by
> the academic institution and/or research grants [4]. That is not the
> case for Clojure.
>
> Some open source software is (partially) funded by proprietary
> support. It is important to note that often the support income does
> not in fact make it to the people who create the software. Such income
> models work best for support sold to conservative enterprises [5].
> That is not the case for Clojure.
>
> Some companies 'fund' open source software by dedicating some of their
> employees' time, or making investments, in its development. There must
> be some business value to the company for doing so (e.g. it helps them
> sell hardware [6]), and thus is ultimately paid for by their
> proprietary products/services. That is not the case for Clojure.
>
> There *are* companies that make software themselves, whose consumers
> see a value in it and willingly pay to obtain that value. The money
> produced by this process pays the salaries of the people who are
> dedicated to making it, and some profit besides. It's called
> "proprietary software". People pay for proprietary software because
> they have to, but otherwise the scenario is very similar to open
> source - people make software, consumers get value from it. In fact,
> we often get a lot less with proprietary software - vendor lock-in, no
> source etc. Most alarmingly, this is the only model that associates
> value with software itself, and therefore with the people who make it.
>
> Why don't people pay for open source software? Primarily, because they
> don't *have to*. I think also, partially, it is because open source
> software often doesn't have a price tag. I think it should. I'd like
> to pay for open source, and know the money is going to those who
> create it. I'd like companies to *expect* to pay for it. I'd like to
> see people make a living (and even profit!) directly making open
> source, not as a side effect of some other proprietary process, to
> dedicate themselves to it, and not have it be hobby/side work.
>
> Unfortunately, there seems to be no way to convey the full benefits of
> open source software while *forcing* people to pay for it. Only in the
> proprietary (including dual-license) model is there a direct
> connection between the consumers of software and the funding o

Re: concurrent tests?

2009-12-02 Thread Brenton
Hello Raoul,

I don't know if one of the blog posts that you are referring to was
mine. I did blog yesterday about running tests concurrently. I have
put the code that I use to run my tests on GitHib here:

http://github.com/brentonashworth/fpl-clojure-util

See the file test.clj

I use this with clojure.test. You can create tests using deftest from
clojure.test or you can use the def-test macro to define a test. This
will allow you to turn logging on and off by setting the *logging* var
to true or false.

It assumes that tests for namespace com.company.file.clj will be in
com.company.test_file.clj and located under the test project
directory. If you pass -seq when running the tests, they will be run
sequentially. If you pass the file name then only the tests for that
namespace will be run.

Finally, it runs each test namespace concurrently, not each test.

Anyway, this is what I use. I hope you find it helpful.

Brenton

On Dec 2, 1:59 pm, Raoul Duke  wrote:
> hi,
>
> i've seen some blog posts / code about using agents to use up
> cores/hyper-threading and speed up testing cycles. how might one do
> that with clojure.test{.tap}? like if somebody already has that in
> github somewhere i don't want to reinvent the wheel.
>
> thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: 2 upcoming NYC talks

2009-09-29 Thread Brenton

Stuart,

Can't make it to New York. It would be great if these talks could be
recorded and made available later. I am very interested in what you
are doing with Hadoop and also the part about "Storage options for
Clojure data structures".

Thank you,
Brenton

On Sep 28, 9:20 am, Stuart Sierra  wrote:
> Hi folks,
>
> I'm doing two talks about Clojure and Hadoop, one at Hadoop World NYC
> on Friday, October 2, and the other at the NoSQL meetup on Monday,
> October 5.  Details, links, and follow-ups athttp://stuartsierra.com/
>
> -SS
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Is knowing Java a prerequisite for using Clojure?

2009-09-17 Thread Brenton

Java does get a bad rap these days and it can be difficult to spend
time learning something that you are not excited about. Here is a
little more encouragement.

I was recently working on a Project Euler problem involving prime
number generation. My initial pure Clojure implementation took about
16 secs to run (This is actually fast compared to many other dynamic
languages using the same algorithm). I have some tests that run all of
my Euler solutions and this one was much slower than all the others so
I decided to work on speeding it up. I spent several of hours and got
it down to 5 seconds. I then decided I wanted to try out Clojure's
Java integration so I wrote a couple of simple static methods in Java
to replace the slower Clojure functions. Using the same algorithm but
in Java it runs in 300 ms. This took 10 minutes.

I think that the ease with which you can "drop down" to Java is one of
the best features of Clojure. I love not having to choose between
using a dynamic language and performance.

I hope this encourages you to learn some Java.

On Sep 17, 6:52 am, Hugh Aguilar  wrote:
> Thanks for the encouragement. I've already got the book.
>
> I suppose eventually I will have to learn Java. I have been putting it
> off because I hear a lot of Java-bashing from programmers, and have
> also noted that this is generally the impetus for the development of
> languages such as Clojure and Scala and the dozens of others. On the
> other hand, Java can't be any more difficult than C or C++ that I
> already know. With languages such as Factor or Python I am relying on
> the bindings to C and C++ programs, so with Clojure I would be relying
> on the bindings to Java programs, which might be an improvement.
>
> Can you recommend a book or online resource for learning what I need
> to know about Java? I saw the book "Learning Java" with the tigers on
> the cover and it looked pretty good, but also pretty extensive ---
> quite a lot to digest there, which might be why they put a large meat-
> eater on the cover.
>
> If anybody is interested, I can tell you what my intended application
> for Clojure is, and you can tell me about how you would go about such
> a project. I will just be writing toy programs initially, but I do
> actually have a specific purpose for Clojure in mind.
>
> On Sep 16, 11:34 pm, Krukow  wrote:
>
> > My recommendation would be: Don't wait learning Clojure! Start now,
> > buy Stuart's book "Programming Clojure". Once you get hungry for more
> > "real" problems, start reading up on Java - but don't waste time
> > learning too much about syntax and the many intricacies of Java
> > semantics; stick with the basics: classes, classpath, using jars and
> > standard APIs, etc. Really understanding Java takes forever.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Modeling Data Associations in Clojure?

2009-09-15 Thread Brenton

Thank you all for your input. I think I will follow Stuart's advice
and go with something like the following, again using the example data
above.

(use 'clojure.set)

(def policies (ref #{{:id 3 :name "x" :holder 7 :vehicle 11}
  {:id 4 :name "y" :holder 2 :vehicle
12}}))

(def vehicles (ref #{{:id 11 :make "Audi" :driver 7}
   {:id 12 :make "Toyota" :driver 2}}))

(def people (ref #{{:id 7 :name "Brenton"}
{:id 2 :name "John"}}))

(defn find-policy [id]
  (first (select #(= (:id %) id) policies)))

(defn get-field [map key table]
  (first (select #(= (:id %) (key map)) table)))

(defn get-holder [policy]
  (get-field policy :holder people))

(defn get-driver [vehicle]
  (get-field vehicle :driver people))

(defn get-vehicle [policy]
  (get-field policy :vehicle vehicles))

This feels very natural to use

(def p (find-policy 3))
(-> p get-vehicle get-driver)

I may consider using clj-record since it just uses macros to create
these kinds of functions for you.

Thanks again,
Brenton
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Modeling Data Associations in Clojure?

2009-09-14 Thread Brenton

I am starting to write a large web application using Clojure and
Compojure and am running into some design trouble while designing my
data model. To illustrate my problem I am going to make up some fake
data. Suppose you are writing an Insurance application which has the
tables Policy, Person and Vehicle. A policy has a person that is the
policy holder. A policy also has many vehicles. Each vehicle has a
person that is the primary driver. Most of the time the primary driver
is the same as the policy holder. If I were using one of the usual
object-relational mapping frameworks, (Hibernate, ActiveRecord) when I
load a policy I would get an object graph. If the person who is the
policy holder is the same as the person who is the primary driver of
the vehicle then the loaded Person object would be the same object. If
I change the address of the policy holder the primary driver's address
will also be changed.

How do people deal with this sort of thing in a Clojure application
(or any other functional language)? At first I thought that it would
be easy and I would just use nested maps. But this causes all kinds of
problems.  If I load the data into nested maps I now have two distinct
maps for the same person. If I change one of them, the other is not
updated. If I try to save this map back to the database, which person
map has the correct data? It is also awkward to update the person in
the first place. In Java you would just go policy.getPolicyHolder
().setAddress("..."). In Clojure you would have to do something like
(assoc policy :holder (assoc (:holder policy) :address "...")).

I have a feeling that there is a more "functional" way to do this sort
of thing. My question is, how to other people deal with this? The only
thing that I can think of is that I would avoid using nested maps to
model the database associations. I would load the policy into a map.
Then if I need the person, I would load that into a separate map. That
may be the correct functional approach. I was just asking in case
there is some really cool thing that people do that I don't know
about.

I had a look at clj-record to see how associations where handled. It
looks like nested maps are avoided here. Instead functions are created
to retrieve the associated data. Is the correct way of this this?

Thank you,
Brenton
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure-mode survey

2009-09-12 Thread Brenton

I was having the same problem as Jim and ended up just getting SLIME
working manually.

I wanted to get things set up like Vagif Verdi mentioned above so that
I can start the REPL from my own script and then connect to it from
emacs using slime-connect.

The good news is that I am using SLIME now and no longer using the
basic interaction.

If anyone is interested in how I did this or seeing my Clojure startup
script I wrote it down here.

http://formpluslogic.blogspot.com/2009/09/my-clojure-setup.html

Brenton



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure-mode survey

2009-09-11 Thread Brenton

I use clojure-mode.

I have a ruby script named clj that I use to start Clojure from the
command line and from emacs.

When I set up a new Clojure project I create the following files:

.cljrc.clj
bin/
src/
test/
lib/

The clj script does the following:

1) Put the standard Clojure jars in the classpath
2) Find the root of the project that you are working on by searching
up the directory structure for a .cljrc.clj file. .cljrc.clj contains
common functions like (exit) that will get loaded into the 'user
namespace. Creating this file in a directory establishes it as the
root of a Clojure project.
3) Add any jars within the lib directory to the classpath.
4) If clj has no parameters then start the REPL in the root of the
project directory, otherwise run a script and pass it any additional
parameters.

It is not perfect but I like it. I like that the same script is used
to run Clojure from the command line and from emacs. I don't want to
have to configure each in a different way.

I will try SLIME but if I can't do something like this then I may not
use it (unless there are other clear advantages).

Thank you Phil for providing clojure-mode.
Brenton




On Sep 7, 5:36 pm, Phil Hagelberg  wrote:
> I'm working on cleaning up the code for clojure-mode.el, which provides
> Clojure support for Emacs.
>
> It includes some functionality for interacting with subprocesses. This
> is a small subset of the functionality of the functionality included in
> SLIME, but it's simpler and easier to configure.
>
> However, now that clojure-mode has the M-x clojure-install command that
> sets up SLIME etc, I don't know if the built-in subprocess features are
> worth keeping around any more. Personally I have never used them or
> heard of anyone using them; I wonder if they are just legacy baggage.
>
> Would anyone be opposed to their removal?
>
> thanks,
> Phil
>
> http://technomancy.us

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---