5 ms·
I could not imagine choosing Rust for the use case described. I think it's one of the worst possible choices! Python has so many advantages for throwaway code
by millstone 6y ago
I could not imagine choosing Rust for the use case described. I think it's one of the worst possible choices!
Python has so many advantages for throwaway code with quick iteration. Duck typing. Easy string indexing. Bignum arithmetic by default. Trivial mutable globals. Default parameters. Trivial to make reference cycles. Access variables by name. Exceptions. And the big one is eval().
- procparam 6y agoCan you say more about how you use eval() during prototyping?
- chaps 6y agoIt can be nice when you're working running code in a repl and don't want to maintain state/code between repl sessions. If you just print the data to stdout, you can just eval it and not have to deal with writing one-off cacheing. It's similar to the use case of pdb where you're forcing yourself into the middle of ten different functions. But print statements are easily added, easily removed, and so is eval.
- nicbou 6y agoDon't forget access to a huge range of mature, well-documented libraries and a large standard library.
- dmurray 6y agoThat's what makes the article noteworthy. There are a thousand articles of various quality out there telling you some variation on "dynamic languages are useful for prototyping and scripting, Rust/C/Java really shines in large codebases / when performance or reliability or security is important". It didn't convince me, though. There were a lot of "this tool or library or feature exists in Rust", but no comparative advantage over other languages more compelling than this: > This certainly is in part because I’m more proficient in Rust than in Python. It’s also because the Rust mental model is closer to how my brain works than the Python one.
- nextos 6y agoGood type systems don't get in your way. I have often built prototypes in Scala and I felt the type system was speeding me up rather than slowing me down.
- kenhwang 6y agoI'd say that's more credit to Scala than the norm for most typed languages. Scala is an insanely productive language if you're up to speed on it.
- mumblemumble 6y agoI don't want to disparage the pragmatic value of the features on your list, but they all pale in comparison to the one true killer feature for fast development cycles: a REPL.
- gowld 6y agoREPL == eval.
- mumblemumble 6y agoeval is useful for making a repl, but there are languages with a repl and no eval (Haskell comes to mind), and there are languages like PHP that have eval but no (built-in) repl.
- millstone 6y agoAgreed, how'd I miss that!
- war1025 6y ago> the one true killer feature for fast development cycles: a REPL. I've been a python dev for about a decade. I do use the REPL a couple times a week, but I wouldn't really call it "essential". How do people use it that makes it so valuable? Usually I just use it when trying to figure out how to parse some text or check what methods or properties are available on an object. Really nothing that I couldn't do in a test suite or the code itself.
- deleted 6y ago[deleted]
- xapata 6y agoIf you're not writing your code in a design that lets you run parts of it every few minutes (or more frequently), you're missing out. Best way to avoid bugs in your module: don't put them in there. Find out in the REPL before you put code in the .py file. Also, it's more important the more data-dependent your code is.
- m45t3r 6y agoAlso I really like Python stdlib for those kinda of throwaway scripts. While `cargo` is a far better tool than `pip` for dealing with dependencies, if you don't need to dependencies at all it is even easier, and most times when using Python I don't really need to install any third party libraries even when doing non-trivial stuff (i.e.: sometime ago I did a script that scrapped a page for a download link for some APK and sideloaded it to my Android smartphone). Someone also said the REPL, and while the REPL in Python is not as powerful as, i.e.: Clojure, it is still something that feels essential for a exploratory workflow that is the scripts case. Testing is not the same, it is much slower to interact, specially when you just want to check a hypothesis (also, most scripts I don't want to write tests, they will probably break anyway in a few months like the example of web scrapping I said above).
- heavyset_go 6y ago> Someone also said the REPL, and while the REPL in Python is not as powerful as, i.e.: Clojure, it is still something that feels essential for a exploratory workflow that is the scripts case. Check out IPython if you haven't, the REPL is a game changer.
- sullyj3 6y agoWhat features make it a game changer for you? For me it felt like just a small quality of life improvement, but I've never delved that deeply into its feature set.
- heavyset_go 6y ago- readline functionality and history - Hints and completions behind the Tab key - Syntax highlighting as you type, along with auto-indentation - Dynamic introspection with "?" and "??" - Being able to run shell commands with "!" and capturing their output with "!!" - Magic commands behind "%" and "%%" - File system navigation
- m45t3r 6y agoI know IPython, and yeah, it is very nice. But most of the time I just to test something fast the default REPL is already enough.
- greggman3 6y agoHmmm, python is not installed by default on Windows. Python3 is not installed by default on MacOS. Installing them is 30+meg and now your system is "infected" with python3 (I know if you use python every day this isn't an issue to you but as someone that's not a python expert and has run into version conflicts it's no fun). So, AFAIK rust will generate a standalone exe, python, out of the box, will not so I want to give someone else my throw away solution, not requiring them to install python to use it might be a win?