7 ms·
Idiomatic Clojure with LightTable
- jonase 13y agoIf someone is interested in how kibit is implemented I've got some slides at http://jonase.github.io/kibit-demo/ http://jonase.github.io/kibit-demo/. It's quite easy and a good (I think) introduction to core.logic.
- JPKab 13y agoI'm reminded of the recent "What 4Chan thinks of HN": "Article that is actually interesting" 0 comments This is awesome. Thanks for sharing.
- peatmoss 13y agoTo be fair, the article is only an hour old, and it's not even seven o'clock on the left coast.
- sejje 13y agoIt's probably super relevant that the percentage of the community who has the ability to comment about neat Clojure code is extremely limited (1% maybe? perhaps even less) compared to the percentage that can comment on some techno-political drivel.
- deleted 13y ago[deleted]
- username223 13y agoTo be fair, the author should probably have added "GitHub", "GooGle", and a couple of other keywords to maximize ROI.
- thejosh 13y agoyou posted this pretty quick after the article. come back after a day to see if it actually turns out that way :)
- peatmoss 13y agoThat is quite impressive. I wish I'd have known about kibit 6 months ago. Since I'm still a Clojure novice, I guess I still stand to benefit from it. Moving from "can bang out technically workable code" to "effectively uses the whole range of core functions" is a long slog. Next time I'm writing Clojure I'll definitely be running kibit over it.
- agumonkey 13y agogoing off-road: more and more I wish for non lisps in s-exp syntax, so you can reuse pattern matching on ast and other niceties.
- S4M 13y agoJulia has that: http://docs.julialang.org/en/latest/manual/metaprogramming/ http://docs.julialang.org/en/latest/manual/metaprogramming/
- cjo 13y agothing is if you take a modern language and add s-expressions, then you may as well add macros and at that point there's a good chance it just became a lisp If you go here (http://www.paulgraham.com/icad.html http://www.paulgraham.com/icad.html) and search for the heading 'What Made Lisp Different' it may better explain it
- klibertp 13y agoYou don't need s-exps to have pattern matching on ast or macros, especially hygienic, pattern based ones. There's sweet.js and macros for python as examples. All you really need is an API for manipulating AST, be it built-in or 3rd party. S-exps are especially nice if you want defmacro-style macros, but I don't believe they should be used very much.
- senand 13y agoThat's awesome, thanks for sharing! I hope that with the recent addition of plugins, LightTable will also be able to provide code inspection à la IntelliJ IDEA, since that's the feature I miss most.
- lemming 13y agoshameless plug You could try Cursive (http://www.cursiveclojure.com http://www.cursiveclojure.com). It's pretty new but it's based on IntelliJ so we get a lot of features for free. We don't have a lot of inspections yet but they're coming soon (including kibit-in-the-editor type inspections).
- owenjones 13y agoThis is awesome, I've been excited about Lighttable since I first heard of it. I wish it was in time to back it. It get's better with every release, can't wait for the finished product.
- dopamean 13y agoI've been wanting to learn Clojure and recently bought the book Clojure Programming (not to be confused with Programming Clojure) and I'm curious to know if others believe it is a good idea for a Clojure novice such as myself (lisp and JVM novice too) to use kibit while learning. Any advice would be greatly appreciated. Thanks.
- mseebach 13y agoKibit looks neat, I haven't tried it. I think the generally applicable advice is to get comfortable with the core first, then add tools and libraries at the speed you're comfortable with, making sure that you understand what each component does.
- cgag 13y agoRunning `lein kibit` is super low effort once you've got lein set up, and even having used clojure for years it still reminds of features of clojure.core that I forgot pretty regularly. I think as a noob it would really help you in learning the core lib.
- wuschel 13y ago(Confession: I am a novice to clojure/scheme/JVM myself.) I admit that I have not tried kibit yet. However, LightTable/REPL is a great tool for this endeavour. If only clojure could have an error tracking report that would be comparable to the wonderful implementation that can be found with the python IDLE.. but I guess that is too much to ask?
- mrgoldenbrown 13y agoCan you elaborate on what you mean by "error tracking report" in IDLE? Either I'm missing something cool about IDLE or I am totally misunderstanding. Thanks!
- wuschel 13y agoSorry, what I meant was the TraceBack. It helped a great deal when learning programming and hunt those nasty bugs: Traceback (most recent call last): File "C:/Users/wuschel/Desktop/error-track.py", line 3, in <module> newstrin = teststrin + 3 TypeError: cannot concatenate 'str' and 'int' objects In clojure, you get those error reports in java lingo - I don't know how fast you can get use to that kind of error messages when you do not know Java. Now, this one is obvious, but it just should serve as an example: clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: b in this context, compiling:(null:4:1)
- wuschel 13y agoI find LightTable to be a great tool when it comes to get a first impression of clojure. Installing, configuring and getting the grasp of emacs, or configuring Sublime Text with SublimeREPL can be a lot of hassle under Windows based OS. LightTable helped me to save a lot of time here.
- ibdknox 13y agoI think this is one of my favorite features that we've added to Light Table recently and it shows one of the benefits of being connected to a running process of the language you're working with: you can use the tools of that language to write code for you. There's nothing that makes this Clojure specific - you could do these same things in any other language too.
- Derbasti 13y agoI would imagine that it works particularly well for lisps, since lisps can easily transform running code to source code and vice versa.
- ibdknox 13y agoactually the tools for doing this in other languages have gotten a lot better than they used to be. Using esprima you can do some pretty neat code rewriting in JavaScript and Python includes ast tools in the standard lib. Plus if more new languages start to include things like gofmt by default then we'll end up with more of this stuff as first class. Either way though, it's nearly always the case that the platform itself has the best tools for doing this, so at the very least if gives you the best possible chance. :)
- DanielRibeiro 13y agoOP here: thanks Chris for the amazing capabilities in Light Table. It is the piece of software I'm most excited about these days.
- ibdknox 13y agoYou are quite welcome! And that's what I love to hear - we're pretty excited too :)
- owenjones 13y agoJust had his conversation with a coworker, I've never felt comfortable editing any of the my other IDE's including my favorite VIM. Lighttable's datastructure based configuration makes it so nice. Thanks Chris & Co. keep up the awesome!
- jsoo4 13y agoGrep'd for "Rich Hickey" in these comments. Not a single occurrence. What gives? I thought this guy had a strong cult of personality following.
- owenjones 13y agoHmm every form I try and evaluate seems to be reduced to a one line function. Is this working as intented? Even in the example given it's reduced the function to a 1 liner, I assumed because it was short enough that it's still legible. Is this trying to tell me my functions are too long?
- ibdknox 13y agoClojure doesn't have a real code formatter unfortunately. I posted a slightly better version that preserves formatting if nothing changes and tries to use the clojure pprinter to format as best as it can.
- lispm 13y agoNot to mention that Symbolics Zmacs already did this. It for example has code conversions built-in to change code between various UI libraries or Lisp variants. ftp://ftp.ai.sri.com/pub/mailing-lists/slug/930331/msg00240.html
- jcrites 13y agoDoes LightTable have autocompletion for Clojure or might it in the future? How does autocompletion work for Lisp-like languages? I'm wondering if the verb-subject ordering makes it more difficult to build effective autocompletion. In languages with a syntax like C, code phrases benefiting from autocompletion focus on a particular thing in subject-verb-object order: obj.method(param); Consequently I can engage auto-completion by typing the following, where <cursor> is the location of the text cursor in the editor: obj.<cursor> I type variable name and the "dot" (or equivalent), and the IDE can make informed suggestions about methods to show: methods defined on obj, or methods taking obj's type as their first input. When writing code, I usually know what object I'm working on (autocompleting the variable name is useful but not crucial, since it's usually on preceding lines). What I want to know, and the area in which autocompletion helps me most, is finding out what methods are relevant to that specific object (e.g. defined by the object). When I'm writing quick prototype code, I use an approach that's almost like single static assignment: A a = new A(); B b = a.foo(); C c = b.bar(); Using autocomplete, I can explore objects and methods while staying within the IDE. When combined with in-IDE documentation, writing new code is extremely effective. How do you effectively autocomplete in a Lisp language? (<cursor> If I type that, there's no object yet, so what autocompletions can show up? A list of all functions? (<cursor> obj ...) If I type this line and move my cursor back to the first parenthesis, then it makes sense that autocompletion could understand the context, but moving the cursor backwards is inconvenient. It's not a fluent way to write code. I have not used autocompletion in Lisp-based languages. How do IDEs or REPLs solve this problem? It seems like a similar problem will affect pure-style functional programming languages like Haskell. Static typing is not the criterion, since Python has effective REPL autocompletion. Does the lack of a natural opportunity to present relevant autocompletion information inhibit the development of advanced editors for these languages?
- chongli 13y agoErik Meijer has complained about this in the past. The answer is that it require a change in thinking. Object-oriented programming encourages the programmer to think about objects first (duh) and later ask what methods are available to them. Functional programming is the opposite. You think of the verbs first; the nouns themselves are interchangeable. So the simple answer is this: (fo<cursor> Pressing tab (or whatever invokes your auto-complete) would pop up a list of options such as this: (foo (foo-bar (foo-bar-baz As for exploration, Clojure has tools such as doc and find-doc to help you search for a particular function.
- vorce 13y agoI imagine this could be super powerful for Elixir as well (which has awesome meta programming capabilities).