5 ms·
I don't know much about Zig, but it shares a problem with Rust in that neither have a built-in REPL. I'd like to learn Rust, but every time I try to, I am a bi
by bmitc 4y ago
I don't know much about Zig, but it shares a problem with Rust in that neither have a built-in REPL.
I'd like to learn Rust, but every time I try to, I am a bit overwhelmed by its complexity, both in syntax and overall feature set.
- throwaway17_17 4y agoDo you mean you want an interactive environment to just write small code samples while learning? Or do you want to do your development after learning in a REPL? I think those are two very different goals. As to Zig and Rust’s lack of REPL, they are both ahead of time compiled to executable languages. It is not super common for REPLs to be developed with any real frequency or faithfulness. (this is a little different in the functional world for some reason, Haskell, ML, etc have very thorough REPLs, and Koka’s REPL is great).
- lolinder 4y agoREPLs make a lot of sense in the functional world where everything is an expression. These languages tend to encourage writing lots of small, referentially transparent functions, which are easy to write and test in a REPL. Because the referentially transparent, when you're happy with them, you can copy what you wrote directly into your code. I think you don't see it used as much in the imperative world because each line of code tends to depend a lot on context that isn't immediately available. When you make a mistake in the REPL, you probably altered state, which means you have to run everything again from scratch to know if your corrected flow actually works. If you're going to run everything again anyway, you may as well just be working in a file with a proper text editor and a good test framework. (An exception to this might be Ruby, whose Smalltalk heritage gives it a good interactive programming legacy to build on.)
- Tozen 4y agoYet strangely Vlang has had REPL since at least back from 2020 (https://youtu.be/Pvbv4b9TibA https://youtu.be/Pvbv4b9TibA), a year after the language was released. Don't think it's as impossible as it is being made out to be here. Just like comparatively, Vlang had a self-hosted compiler the first year it came out, but Zig did not achieve this until this year (which is around 6 years after its release).
- codazoda 4y agoInteresting perspective. I’ve never used a REPL much. I did a bit of commercial Python and rarely used it there and I built my career on PHP, which kinda has one, but not a very usable one. I found the REPL to be a distraction. I just want to write code in my favorite text editor and then interpret or compile it. I’m a bit old school, I realize.
- bmitc 4y agoREPLs are awesome, but I have to admit that interactive notebooks are even awesome...r. For Elixir, I use its REPL called IEx frequently, but it can be cumbersome iterating on functions, especially since Elixir requires functions to be in modules and the REPL does not define a top-level module like some other languages' REPLs do. Although Elixir does allow one to recompile modules without having to restart IEx. But I have found that using Livebook, Elixir's interactive notebook application, is much more efficient for creating test code or prototyping modules. Then I can just copy and paste the module and/or functions back into my Elixir project. Livebook also allows you to attach Livebook to a Mix project. .NET Interactive, which is a polyglot notebook and supports F#, is what I use for F# development as well. I personally feel any modern language needs REPL and notebook support, of some kind. Notebook technology is pretty underutilized in my experience, particularly for learning and documentation.
- bobbylarrybobby 4y agoRust doesn't have a repl (well it kind of does: the rust compiler slack bot that runs code you ask it to...), but if you use rust-analyzer the feedback cycle is just as fast. There's also https://play.rust-lang.org/ https://play.rust-lang.org/ for testing short bits of code in a persistent editor.
- culi 4y agoReplit has support for Rust: https://replit.com/new/rust https://replit.com/new/rust
- zozbot234 4y agoThe evcxr project https://github.com/google/evcxr https://github.com/google/evcxr is implementing what amounts to an experimental Rust REPL. (Though there's inherently something a bit weird about a REPL for C/C++-like languages, where the phase separation between compile- and run-time is so inherent to the programming model.)
- flohofwoe 4y agoAFAIK good live coding support (e.g. hot code reload) is a goal for Zig which arguably is much more useful than a REPL for a compiled language.
- Tozen 4y agoREPL for V programming language (https://youtu.be/Pvbv4b9TibA https://youtu.be/Pvbv4b9TibA).
- hansvm 4y agoI use godbolt as a repl for both Zig and Rust. I cannot recommend it highly enough. It's not a true repl, but it evaluates your code on the fly and shows the generated assembly. It's useful in a lot of the same ways a real REPL is.