3 ms·
I agree on the global variables. At least you can define functions in blocks of the same notebook file. e.g. [1] a = 2 [2] def square(x): return a 2
by FrojoS 8y ago
I agree on the global variables. At least you can define functions in blocks of the same notebook file.
e.g.
[1] a = 2
[2] def square(x):
return a 2
print square(a)
> 4
[3] b = 5
print square(b)
> 25
This is something that you can't do in MATLAB, which I still use primarily. In MATLAB you have to create a new file for each function. Which nulls the readability of the script (notebook) when you publish it, because the source of the functions is not included. So, if I write a MATLAB notebook that I want to publish and share, I end up avoiding to create functions for as long as possible and instead use copy paste ...
Currently, some of the main thing that keeps me with MATLAB regardless is:
a) It feels more responsive, probably because its a native app and not running in the browser.
b) I don't like to work in the browser. Its distracting.
c) I like the profiler, debugger and workspace (constant visual inspection of global variables in a separate window) of MATLAB which comes right out of the box. For python/Jupyter I have to set this up manually.
Note: MATLAB now has an 'interactive script' function that is similar to Jupyter, but it is so slow for > 100 loc, that it's completely useless. Even the Mathworks developers admit this. Instead I use %% to seperate my MATLAB scripts into executable blocks (ctrl + enter) and then use the 'publish' function to create a LaTex file which I can then compile to pdf. This creates vector based math formulas and figures (which 'publish to html / pdf' doesn't).
- chubot 8y agoHm that limitation sounds severe! Functions are essential. I actually don't remember that, but I last used MATLAB like 15 years ago! I've done a lot more data science than linear algebra in the last decade. It sounds like RStudio might be a better model for what we want: https://en.wikipedia.org/wiki/RStudio https://en.wikipedia.org/wiki/RStudio (click on the screenshot) It only works with R, but a lot of people say great things about it. I saw another commenter say that Jupyter is more like Mathematica notebooks, and RStudio is more like MATLAB. I think this sounds right. In the former, the interactive experience is more central. In the latter, you are developing a program, and the IDE helps you do it interactively. But the program is central. (At least this is true for R, it sounds like it might not be as true for MATLAB. But I know that pretty large programs are written in MATLAB.) For now I'm still sticking with my highly-custom shell-based workflow. But I do want to make interactive graphics less painful. Right now I juggle a web browser, a terminal, a text editor, and an R REPL!
- targafarian 8y agoIf you compare RStudio to matlab, then is Spyder for python more what you're interested in, an IDE with interactive code execution, variable inspection, and debugging? https://en.wikipedia.org/wiki/Spyder_%28software%29 https://en.wikipedia.org/wiki/Spyder_%28software%29
- david_garrison 8y agoYou can define functions in a MATLAB script. That was added in R2016b (september, 2016)