3 ms·
I'll probably start a language war with this comment, I sure hope not. I'm not exactly sure what you mean with just "static", I'm assuming static types. But wo
by capableweb 6y ago
I'll probably start a language war with this comment, I sure hope not.
I'm not exactly sure what you mean with just "static", I'm assuming static types. But wouldn't a language with static types and a repl not be as powerful as if it was dynamic instead? In the end, you want to be able to redefine everything via the repl in your runtime, and if there is types to be checked all the time and the compiler has to do extra steps for each eval, it'll get in your way and make it harder to monkey-patch things.
- taeric 6y agoIt is a bit more complicated. Sbcl, as an example, does check types on defun statements. Some it will just warn about, but some will prevent the completion.
- agumonkey 6y agoIt was so not about comparing, but learning c/c++ is often a less fun experience due to either the write / compile / debug cycle or the heavy tooling required. A c/cpp repl would make people fiddle around and have a rapid intuition. Then they go without.
- rlonstein 6y agoIt exists! Cling- https://root.cern/cling/ https://root.cern/cling/ (and the earlier Cint- http://www.hanno.jp/gotom/Cint.html http://www.hanno.jp/gotom/Cint.html) I used to occasionally use them for local experimenting with libraries and language features.
- emidln 6y agoI don't think monkey patching is required. Although without a dedicated interpreter, you can just do what sbcl does under the hood and maintain what is essentially a tempfile and keep compiling that and reporting the output for every new line/block of code. (I don't know how sbcl actually works, being a lisp I presume it doesn't actually use a tempfile but instead a list in memory of the code the user submitted and then invokes the compiler as needed for new input including the output state as available symbols.) A cycle that went something like: 1. Write the line to a file 2. Compile file with default flags 3. Run binary in gdb causing gdb to dump certain interest info (stack info, variable contents, etc) 4. Read the sections/symbols and merge this data into the gdb data (maybe get it from gdb) 5. Dump this data into your reply and refresh waiting for user input. You could have a few basic commands in the repl: Modify the compiler args Add/remove/edit a line Attach gdb. Emacs or vim could easily do this, and I suspect there are people who already do almost exactly this. You could also just use any editor/ide with debug integration and keep a scratch file around...
- capableweb 6y ago> I don't think monkey patching is required We're talking about a repl here, not just a basic shell. You'll need to be able to redefine functions and everything else at runtime so a repl is all you need to run your program. A lisp with a standard repl is running miles around any editor/ide with debugger support, as the workflow with repls, especially ones that can nest on exception and so on, is much faster.
- tikej 6y agoJulia is kind of nice example of what’s possible with dynamic language and static types.
- eigenspace 6y agoJulia does not (semantically) have static types. It just proves that you don't need static typing to have an incredibly rich and useful type system, and you don't need static types to have top notch performance.
- nextos 6y agoExactly, in case of Julia I think it all boils down to multiple dispatch and ahead-of-time compilation. But it's still dynamic!
- pjmlp 6y agoSuch REPLs exist since XDE for Mesa in Xerox PARC, and there are some for C++, C#, F#, OCaml, Haskell, Java, among others.