Live data from Hacker News

Try Clojure – An interactive tutorial in the browser

tryclojure.org

51–60 of 96 posts

Re: Try Clojure – An interactive tutorial in the browser

#51
post #13

Earlier quoted context omitted.

Thanks! https://tryclojure.org/ is working correctly. I'm figuring out why Netlify is not redirecting automatically.

For the record, http:// is redirecting to https:// for me currently. $ date -u Tue 22 Feb 2022 09:12:56 UTC

Are you certain that's not a client-side redirect a la Https Everywhere?

Re: Try Clojure – An interactive tutorial in the browser

#52

Earlier quoted context omitted.

For the record, http:// is redirecting to https:// for me currently. $ date -u Tue 22 Feb 2022 09:12:56 UTC

Are you certain that's not a client-side redirect a la Https Everywhere?

I'm not using Https Everywhere, but just to check I tried with curl and get a 301 redirect:

  $ curl -v http://tryclojure.org/ 2>&1 | grep "HTTP\|location"
  > GET / HTTP/1.1
  
I doubt that anything smart on the network is redirecting:

  $ dig a tryclojure.org
  tryclojure.org.         12      IN      A       206.189.50.215
  tryclojure.org.         12      IN      A       18.192.76.182

Re: Try Clojure – An interactive tutorial in the browser

#53
post #41

I was always wondering why something like this doesn't exist already! This is really great. Would it be possible to add `add-libs` from `tools.deps.alpha`? https://insideclojure.org/2018/05/04/add-lib/ Then you could add libraries at runtime directly from the REPL You could then pair it with a pastbin and share/run code snippets (with some URL shortener). Could you imagine the possibilities for bug reports for instan…

This environment is running with SCI ( https://github.com/babashka/sci ) and only in the browser. What you describe might be more suitable for an environment like replit: https://replit.com/new/clojure . SCI can be combined with Reagent, etc for online tutorials as well, or to build web apps, like you can see here: https://babashka.org/scittle/

When it comes to specifically dynamically loading external libraries - is there a reason SCI can't incorporate `add-libs`? I mean clearly some libraries wouldn't load and will break (like if it's using Java code or something), but I imagine it could work for a large subset of code.

I get there are a few ways to have a REPL in the browser, but it seems a bit primitive if you can't get any libraries in (short of copy pasting namespaces). I understand babashka includes some internally - so it makes it at least suitable for a subset of tasks. But I think this dynamic library loader is a more flexible solution (or I'm overlooking some technical hurdle here)

Re: Try Clojure – An interactive tutorial in the browser

#54

Earlier quoted context omitted.

Are you certain that's not a client-side redirect a la Https Everywhere?

I'm not using Https Everywhere, but just to check I tried with curl and get a 301 redirect: $ curl -v http://tryclojure.org/ 2>&1 | grep "HTTP\|location" > GET / HTTP/1.1 I doubt that anything smart on the network is redirecting: $ dig a tryclojure.org tryclojure.org. 12 IN A 206.189.50.215 tryclojure.org. 12 IN A 18.192.76.182

Netlify took a bit to get the certificate but now is redirecting correctly! Thanks

Re: Try Clojure – An interactive tutorial in the browser

#55
post #53

Earlier quoted context omitted.

This environment is running with SCI ( https://github.com/babashka/sci ) and only in the browser. What you describe might be more suitable for an environment like replit: https://replit.com/new/clojure . SCI can be combined with Reagent, etc for online tutorials as well, or to build web apps, like you can see here: https://babashka.org/scittle/

When it comes to specifically dynamically loading external libraries - is there a reason SCI can't incorporate `add-libs`? I mean clearly some libraries wouldn't load and will break (like if it's using Java code or something), but I imagine it could work for a large subset of code. I get there are a few ways to have a REPL in the browser, but it seems a bit primitive if you can't get any libraries in (short of copy p…

If you are running SCI on the JVM, then yes, it can do this, but this environment is running purely in your browser, no JVM back-end.

Re: Try Clojure – An interactive tutorial in the browser

#56

=>(map inc) function(b){return function(){function c(k,t){t=a.g?a.g(t):a.call(null,t);return b.h?b.h(k,t):b.call(null,k,t)}function d(k){return b.g?b.g(k):b.call(null,k)}function e(){return b.s?b.s():b.call(null)}var f=null,g=function(){function k(w,u,B){var p=null;if(2 The output is correct as far as I can tell but that's some pretty hairy Javascript right there. Edit: Formatted code.

That's returning a transducer which is hairy implementation wise regardless of compilation.

Re: Try Clojure – An interactive tutorial in the browser

#57
post #53

Earlier quoted context omitted.

When it comes to specifically dynamically loading external libraries - is there a reason SCI can't incorporate `add-libs`? I mean clearly some libraries wouldn't load and will break (like if it's using Java code or something), but I imagine it could work for a large subset of code. I get there are a few ways to have a REPL in the browser, but it seems a bit primitive if you can't get any libraries in (short of copy p…

If you are running SCI on the JVM, then yes, it can do this, but this environment is running purely in your browser, no JVM back-end.

Oh, does `add-libs` require the JVM?

I thought it was in effect fetching remote code, from git or wherever, and then executing it (or loading it) in the local environment.

I'm just curious to understand the situation better, but which part architecturally strictly needs the JVM? Even with babashka, or on this website, I don't think anything stops me from Frankensteining in an external library in a running REPL. I could technically fetch the content of a library's repo and then copy each file and run its contents (with the ns blocks) in the REPL. Then the library would become locally available (assuming it's a very plain Clojure library that is)

I assume `add-libs` is sort of a convenience wrapper for the same idea

Re: Try Clojure – An interactive tutorial in the browser

#58
post #57

Earlier quoted context omitted.

If you are running SCI on the JVM, then yes, it can do this, but this environment is running purely in your browser, no JVM back-end.

Oh, does `add-libs` require the JVM? I thought it was in effect fetching remote code, from git or wherever, and then executing it (or loading it) in the local environment. I'm just curious to understand the situation better, but which part architecturally strictly needs the JVM? Even with babashka, or on this website, I don't think anything stops me from Frankensteining in an external library in a running REPL. I cou…

I thought you were referring to https://insideclojure.org/2018/05/04/add-lib/ which is an experimental feature of tools.deps.alpha. But sure, there could be an (add-lib ...) function in this environment which loads some external code.

Re: Try Clojure – An interactive tutorial in the browser

#59

=>(map inc) function(b){return function(){function c(k,t){t=a.g?a.g(t):a.call(null,t);return b.h?b.h(k,t):b.call(null,k,t)}function d(k){return b.g?b.g(k):b.call(null,k)}function e(){return b.s?b.s():b.call(null)}var f=null,g=function(){function k(w,u,B){var p=null;if(2 The output is correct as far as I can tell but that's some pretty hairy Javascript right there. Edit: Formatted code.

It is minified and `map` supports different arities as well as dealing with chunked-sequences for performance reasons.

Re: Try Clojure – An interactive tutorial in the browser

#60
post #57

Earlier quoted context omitted.

Oh, does `add-libs` require the JVM? I thought it was in effect fetching remote code, from git or wherever, and then executing it (or loading it) in the local environment. I'm just curious to understand the situation better, but which part architecturally strictly needs the JVM? Even with babashka, or on this website, I don't think anything stops me from Frankensteining in an external library in a running REPL. I cou…

I thought you were referring to https://insideclojure.org/2018/05/04/add-lib/ which is an experimental feature of tools.deps.alpha. But sure, there could be an (add-lib ...) function in this environment which loads some external code.

rereading the link I guess there are some implementation specifics that are JVM. I'm not really familiar with CLJS to say how those translate - but in principle is sounds like it could work on both platforms
Post reply on HN