Affichage des articles dont le libellé est lisp. Afficher tous les articles
Affichage des articles dont le libellé est lisp. Afficher tous les articles

mercredi 10 février 2016

frictionless Java with .. clojure

Late realization: you can use clojure with Java. Not with Java. For Java. We all know clojure java interop is good, but that's not what is at play(sic). See, Java is verbose (duh), compiled (duhbl) and mute. On the other hand, clojure, being a lisp with a repl, is real-time, short and generic, and doesn't even require `print` to inspect values most of the time. So instead of writing long main println-full methods, compiling, running, parsing the output ... you just import some java classes and start poking around. Frustration: gone. Even better, clojure is human friendly, has clojure.reflect/reflect to inspect classes and/or instances; clojure.pprint/pprint for quick formatting needs. If java bytecode came with docstrings and javadoc... clojure repl would be a better IDE than Eclipse. And it's probably a few lines away to scrape some remote or local html set and get going. People probably delegate that to manual browsing or a text editor extension. Anyway, my java project makefiles [1] have now a `repl:` rule to enjoy Java without Java (sorry dude).

[1] yes, I like IDE-free projects so a makefile with a few rules. I even learned about jdb, because yeah, text mode java debugging !

mercredi 21 août 2013

I though I'd like Clojure ...

I've been following this language and community from a distance, with wide open loving eyes. It had nice abstraction underneath, far less mutation than vintage~ Lisps, some ~syntactic niceties (words like first, rest instead of acronyms).

But coding in it felt had too much. I guess that's what Rich Hickey said, it's on the pragmatic side of things. All it brings has value on day to day problem solving. And I'm still fresh out college scheme/ml courses. But that's the thing, if I had to iterate on the lisp idea, I'd bring it closer to ML, not closer to ruby/perl (that's how I felt for the last few days). Using sml I felt my mind was constrained just enough to find abstract recursive solutions. In clojure I'm floating in a river of gems in brownian motion.

It's shallow criticism, not even criticism, just firsthand expression. I'm probably not smart enough to dive in it in 3 days and understand its idioms. This dialect different enough from lisp/schemes that my brain needs more time (says more about my brain than clojure vs others) . When finished with other things (SICP, 4clojure) I'll do a medium-- sized project in it (something I've never done on my own actually). Hoping the function based, mutation free idioms will lift me above my current limitations, whereas other languages feels comfortable doing one liners, I can never write systems in them. Maybe clojure shines at helping your mind scale above non-trivial exercises.

(lambda (k) ...)

mardi 20 août 2013

The loop/recur constructs in clojure are really nasty, and not in a good way. Let's say it will force your brain to re-evaluate its knowledge on recursive processes.
 (fn [n]
      (loop [i 0
           a [1 1]]
      (cond (< n 3) a
            (= i (- n 2)) a
            :else (recur (inc i)
                         (conj a (apply + (drop i a))))))


Blame it on Sun's JVM.

ps: this is probably the ugliest guess-fested fibonacci function I've ever seen (and written). So far.

samedi 15 juin 2013

jonesforth #0

Trying to learn how to write small Forth interpreter (1), I find a very detailed tutorial (thanks web.archive.org again)(2). It's literal documented assembly you should be able to run through gcc to get native code. Except it doesn't. But someone uploaded it on github (3), so maybe this issue has been documented or fixed. No luck but there's an old blog post with comment mentionning problems close to mine. They're solution actually work (although I don't know gcc options enough to really understand why)(5).

1. http://lambda-the-ultimate.org/node/2452
2. http://web.archive.org/web/20090209003017/http://www.annexia.org/_file/jonesforth.s.txt
3. https://github.com/chengchangwu/jonesforth/
4. http://rwmj.wordpress.com/2010/08/07/jonesforth-git-repository/#comment-6591
5. you will need to recompile without the “-Wl,-Ttext,0″ option to GCC

mercredi 27 mars 2013

Coursera proglang epilog

Done with proglang. Lost many points because of I'm an unorganized idiot who can't recall a deadline. Unlike the scala course, proglang rules are stricter, 50% penalty right away. Anyway, got new insights and good understandings on all assignments. Both courses seems to be 2nd year college level. It's time for graduate level courses on programming. I'm revisiting old courses I took but failed (either in concept understanding or grades or both), and also starring at brown CS1730, idu C311, ...

There are initiatives for study groups about SICP, or advanced interpretation/compilation from coursera.proglang forum. Interesting, but I don't know how it's gonna be organized.

I also need 2nd-3rd year level classes in physics, chemistry, ee. And I want to take MIT classes about advanced data structures lead by E.Demaine.

That's for long term future. Short term is job hunting season opening. And right now I'm kinda blue. I liked the #coursera-pl @ freenode irc channel. All the guys here were cool (from the old timers gurus to the youngsters). I don't like to part.

Also, the sourceforge migration of some ocaml lib to github, pitched by xtrmz_ from #coursera-pl. A little push for the ocaml ecosystem, which some past teachers are so fond of.

-

samedi 7 avril 2012

bash_it color generator cost me 8 seconds at login



  • trying bash_it
  • sluggish login time
  • need : bash debug using -x, set PS4
  • trace -> inspect under vim
  • discover fancy color name generator
  • perlishly lispy thing
  • large set of nested, args eating, function aggregating bits of term code on the output
  • very DSL
  • followed by a cute 30-something calls to generate a set of {,bold,underline,blah}color variables.

I may be wrong, it seems this stacking of functions is not very cheap, at least not on my VM on a core duo. When I trace the login, thousands of calls, 90% are color related, mostly identical. I feel like looking at the naive recursive Fibonacci function.

Anyway disabling colors made bash-it invisible (sic) again.

cheat url summary :

- PS4 string to see stack >>> http://wiki.bash-hackers.org/scripting/debuggingtips
- Trace, tee log a script >>> http://www.commandlinefu.com/commands/view/3310/run-a-bash-script-in-debug-mode-show-output-and-save-it-on-a-file
- Mass comment in vim >>> http://vim.wikia.com/wiki/Commenting_out_a_range_of_lines

and the original project :

- bash-it >>> https://github.com/revans/bash-it