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?
Quite often my experience when learning a new language is "Am I doing this right? Or even close to right?"
If kibit can turn your code into idiomatic Clojure then you have a tool for exploring your solutions and how close they look to Clojure as it might be written by a native.
It can also prompt questions "Why do it this way rather than this way?" which could be a good learning opportunity.
I see no harm, only benefit.
Matt
write the best code you can -> run kibit -> spend an hour reading the docs and every blog post you can find about a feature you didn't know about -> repeat
write the best code you can -> run kibit -> show off your awesome code, you're a rockstar!
here's a short video demoing coding in clojure and other jvm languages:
Lighttable's datastructure based configuration makes it so nice.
Thanks Chris & Co. keep up the awesome!
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?
(let [entry (.getEntry my-map)
key (.getK|
Here you can't easily tell that you want the key of your map entry here since the MapEntry class isn't imported. I'm planning some improvements where I'll walk up the AST from the completion point and get the types of all variables on the way and propose all methods from them, but that requires type inference which I don't have yet (although it's on the list). IntelliJ has also really shown how you can push the bar here with some lateral thinking, they propose chained method calls etc based on the type, so there's a lot of cleverness you can do with a little thought (and a good test suite).Completion for functions etc is obviously easier although in the case of protocols the problem is similar - you'll get all the protocol methods suggested since they're just fancy functions, but you won't get proper context-sensitive completion unless you've put the object implementing the protocol after the symbol you're completing - the most you can hope for is some sort of error message later that what you've entered doesn't look consistent.
Edit: one thing I forgot to mention is that in the completion list for methods we show the full signature as well as the list of all classes that have a method with that signature, which helps a lot in choosing the right method.
(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. new <cursor>
What would tab show you? All the possible objects?You at least need a base to get started.. in lisp, it's not uncommon to have functions defined as (character-move), so (character-<tab>) works well. But even without that, since lisps use functions at its root instead of objects, it makes sense to know the ones you want to use.
If you go here (http://www.paulgraham.com/icad.html) and search for the heading 'What Made Lisp Different' it may better explain it
"Article that is actually interesting" 0 comments
This is 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.
You could try Cursive (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).
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?
It get's better with every release, can't wait for the finished product.
ftp://ftp.ai.sri.com/pub/mailing-lists/slug/930331/msg00240.html