3 ms·
One of the best ways to get people to support optional typing in dynamic languages is to make sure their tools can read those types and provide metadata. Progr
by breckinloggins 13y ago
One of the best ways to get people to support optional typing in dynamic languages is to make sure their tools can read those types and provide metadata.
Program verification is cool, but enabling "intellisense" on a hash is even cooler.
- pbiggar 13y agoIndeed. I'm hoping the IDE support will include emacs - it can already do loads of cool things connected to nrepl, but completion on a hash would be amazing.
- seanmcdirmid 13y agoDoes emacs support language aware intelliense (auto complete) for any language? I thought the common case was support through CTAGs.
- rayiner 13y agoIt does for several languages (Dylan, Common Lisp, Java, etc). If you've got a compiler with an API, like say Clang, you can talk to it from Emacs Lisp.
- seanmcdirmid 13y agoHow does Emacs plug into a statically typed language like Java? Does a compiler like Clang have an interactive/heuristic based mode suitable for use in a language-aware editor? Or do they just assume the code is in a good state and run the compiler when feedback is desired?
- barrkel 13y agoA compiler designed to support things like code completion can have an explicit API. For example, it may be asked to parse the code until the cursor location, the do a longjmp back out (or throw an exception, or whatever) with symbolic information about that location in the code. If the parser error recovery is decent (and there is some effort put into this in most substantial front ends, since it's key to good error messages in large projects with long compile times, where recompile on every error fix isn't a great experience), the code doesn't need to be in a good state.
- seanmcdirmid 13y agoThat might work...but does it work in practice (i.e. do you have an example where this is being used?). I've found that most IDEs support two kinds of compilers: the compiler used to generate code and find type errors, and a "presentation" compiler to provide interactive feedback that is error tolerant and can run in incomplete contexts. Java works this way, Scala worked this way (at least when I was working on the plugin), C# has a lot of infrastructure separate from the compiler to support its use in Visual Studio. A lot of work goes into this infrastructure beyond "writing a decent compiler," and emacs very simple language-aware interface didn't seem to support it very well (when I looked ~8 years ago).
- rayiner 13y agoSee: http://www.skybert.net/emacs/java http://www.skybert.net/emacs/java. With Java, Emacs can just talk to the Eclipse Java Compiler, since it exposes an API. Same thing with Clang--it exposes an API which is used by XCode to support interactive feedback, and Emacs can consume it too. The Open Dylan compiler was originally intended to interface tightly with the Open Dylan Windows IDE, and that interface has been repurposed to interface with Emacs.
- seanmcdirmid 13y agoCool, are these APIs buffer based or area based? I mean, when you make a change, do you get the message: the buffer has changed, or is there an area-based damage-repair cycle as in Eclipse or Visual Studio?
- barrkel 13y agoThat might work...but does it work in practice (i.e. do you have an example where this is being used?). It is how the Delphi compiler works in the IDE. I used to work for Borland, then Embarcadero, on the compiler front end. When the compiler is running for code completion (kibitz mode, it calls it), it does a lot less work. No codegen, no type analysis of function bodies (begin / end blocks are entirely skipped), unless the cursor location is discovered to be inside a function body, whereupon the it rewinds and does more complete analysis. Normally takes no more than a few milliseconds to finish.
- arohner 13y agoYes, at least in clojure and CL. In Clojure, you use nrepl. Emacs (and several other IDEs) have clients which open a socket connection to your running clojure process. While editing a function, emacs will say "tell me about `my.namespace/foo`". It then shows arity and argument name info for the fn. It's basically the same UX as you're used to in Java, except the info comes from asking the running process, rather than parsing statically.
- tikhonj 13y agoI know of two modes for OCaml: TypeRex[1] and Merlin[2]. I've used both, and they both work reasonably well. The problem with TypeRex is that it requires changing your build, so it's not an easy option for companies that have some sort of custom build system in place. Happily, by the time I got around to working at a company like that, somebody had written Merlin which does not need anything like that. It even worked with js_of_ocaml, which was very impressive. I thought it was a very good tool. [1]: http://www.typerex.org/ http://www.typerex.org/ [2]: http://kiwi.iuwt.fr/~asmanur/blog/merlin/ http://kiwi.iuwt.fr/~asmanur/blog/merlin/ Emacs also has good support for a few other languages. Haskell has ghc-mod[3] and scion[4], for example. [3]: http://www.mew.org/~kazu/proj/ghc-mod/en/ http://www.mew.org/~kazu/proj/ghc-mod/en/ [4]: https://github.com/nominolo/scion https://github.com/nominolo/scion Similarly, there is ENSIME[5] for Scala. [5]: https://github.com/aemoncannon/ensime https://github.com/aemoncannon/ensime You can also use eclim[6] with Emacs, which integrates with Eclipse to offer rich functionality for Java. [6]: https://github.com/senny/emacs-eclim https://github.com/senny/emacs-eclim Of course, Emacs has language-aware editing for Emacs Lisp by default :). You can get similar support for most other popular dynamically typed languages as well. So yes, Emacs does support plenty of languages like that, although almost always through a plugin. Happily, with the new package manager, installing and managing plugins is now trivial.
- Paradigma11 13y agofor f#: https://github.com/rneatherway/fsharpbinding/blob/master/emacs/README.md https://github.com/rneatherway/fsharpbinding/blob/master/ema...
- calpaterson 13y agoYes, you can make it work for at least Java (JDE, I think?) and Python (I forget the mode, it's to do with Pymacs).
- ambrosebs 13y agoWhat is intellisense on a hash?
- pbiggar 13y agoAutocompletion on the keys of a hash.
- ambrosebs 13y agoOh right, a hash map. That would be very cool, and probably feasible to implement.
- brandonbloom 13y agoI know that in several communities, "hash" and "hash map" are synonymous. However, in Clojure hash maps are only one of several map implementations. We have implementations backed by linear array scans, prefix trees, and other data structures too. The word "hash" a shorthand for the noun-phrase "hash code" (aka "digest") and a verb for the process of creating hash codes.
- breckinloggins 13y agoOops. Sorry about that; I was still thinking in Ruby (day job) mode!
- deleted 13y ago[deleted]