How to write and execute programs in terminal/command prompt? - ide

For example:
http://www.youtube.com/watch?v=tKTZoB2Vjuk (# 5 min)
I have no idea how one would go about writing code and making it work without an IDE but it seems like a useful thing to know how to do. Thanks!

Open an editor. Edit the code. Invoke the compiler. Run the executable.
Can't say much more without further details on your part.
What they're showing in the video though is the Python REPL.

Related

Show me your ID(E)!

I often work on very small pieces of code, on the order of max 100 lines, especially in scenarios when I learn something new and just play with the code, or when I debug.
Because I frequently change code and want to see how that changes the contents of my variables and output, it is tedious to either
1) hit the debug button, wait for the debugger to start (in my case I use PyCharm as an IDE) and then inspect the output
or
2) insert some prints for the variables that I want to observe and compile the code (slightly faster than starting the debugger).
To eliminate this time consuming workflow, where I constantly hit the compile or debug button every few seconds, is there an IDE where I can set a watch to a few variables and then each time I change in my source code a single character (or, alternatively, every half a second) the IDE automatically compiles everything and I will see then new values of my variables?
(Of course while I intermediatelychange the code the compilation will give errors, but that is ok. This feature would be a big time saver. Maybe PyCharm has it already implemented? If not, ideally I would hope for a language agnostic IDE, similar to PyCharm, where variants for Java etc. also exist. If not, since I code in Python, a Python IDE would also be great.)
This might not be exactly what you are looking for but PyCharm (and IntelliJ and probably others) can run tests automatically when code changes.
In the PyCharm Run toolbar look for "Toggle auto-test" button.
For example in PyCharm you can create test cases that just runs the code you're interested in and prints the variables you need.
Then create a run configuration that runs only those tests and set it to run automatically.
For more details see PyCharm documentation on rerunning tests.
The Scala plugin for IntelliJ has exactly what you need in the form of "worksheets," where every expression is automatically recompiled when its value or the value of anything it references is changed.
Since (based on your usage of PyCharm), I assume you're using Python primarily, I think Jupyter notebook is your best bet. Jupyter is language agnostic but began as specific to python (it was called IPython notebook for this reason).
I have not tried it, but this guide purports to show to get Jupyter to work with PyCharm
EDIT: Here is another possibility called vim worksheet; I haven't tried it, but it purports to do the same thing as Scala worksheets, but in vim, and for a number of languages, including Python.
The python Spyder IDE (comes with Anaconda) has this feature. When you hit run, you can see all of the variables at the top right of the screen and you can click on them to see their values (this is very helpful with Numpy Arrays too!).
If your interest is in the actual workflow improvement:
I used to program like you, looking at what my variables changed to, and design or debug my code based on such modifications, however is way to inefficient and costly to set what variables to watch over and over again and besides when if it bugs, you have to go all over again for the debugging process.
I changed my design process to better my workflow and adopted Test Driven Development (TDD), with it you can look at tools for you specific implementations or IDEs but the principles and workflow stay with you, with it you stop looking on how the variables changed and instead focus on what the functions should do, meaning faster iteration (with real time tools for testing), easier debugging and far more better, safe refactoring.
My favorite tool for it is Cucumber, and agnostic tool (for IDE or programming language) which help you test your code scenarios and at the same time documenting your features.
Hope it helps, i know its a very opinionated answer but it's an honest advices for improvement in ones workflow.
You should try Thonny. It is developed by Institute of Computer Science of University of Tartu.
The 4 features which might be of help to you are below (verbatim from the website):
No-hassle variables.
Once you're done with hello-worlds, select View → Variables and see how your programs and shell commands affect Python variables.
Simple debugger.
Just press Ctrl+F5 instead of F5 and you can run your programs step-by-step, no breakpoints needed. Press F6 for a big step and F7 for a small step. Steps follow program structure, not just code lines.
Stepping through statements
Step through expression evaluation. If you use small steps, then you can even see how Python evaluates your expressions. You can think of this light-blue box as a piece of paper where Python replaces subexpressions with their values, piece-by-piece.
Visualization of expression evaluation
Faithful representation of function calls.
Stepping into a function call opens a new window with separate local variables table and code pointer. Good understanding of how function calls work is especially important for understanding recursion.

How are you supposed to use text editors without debugging tools?

The thing I haven't been able to understand is how I am supposed to use a plain ol' text editor like TextWrangler or Atom to code, as opposed to a full-blow IDE like Xcode or Visual Studio. There are no debugging tools, so you can't know if you made an error, and their isn't autocomplete (prebugging, heh heh) which makes it much easier to make mistakes. I feel like I am missing something; how do people debug with their text editor workflow?
Using a text editor without debug tools forces you to write beautiful code that works first time 100% of the time. Each line of code is carefully crafted and does exactly what you expect it to do.
I personally use VIM for all my programming, it takes a while to learn but it's definitely worth it.
You end up writing code which is easy to read, because you have to read and re-read you code before you run it.
Debugging is more than just pressing a button and someone else software tells you whats wrong with yours. It's about deeply understanding your code and exactly what it is doing. I'll admit that sometimes finding a missing comma can be a pain, but the tradeoff is definitely worth it.
At the end of the day it depends on whether you just want to turn out 800 line of code an hour, or if you want to build software which is robust and easily extendable by anybody.
Atom and almost all this ide VIM ...
their is a plugins https://atom.io/packages
You install what plugins that you want
I believe that this is the power of this editors. You decide what plugins you want.
For atom for example
linter https://atom.io/packages/linter is a tool for visualize errors.
autocomplete https://atom.io/packages/autocomplete is a tool for auto complete.
The only difference is you have to compile manually.
If the error happens at compile time, the compiler will tell you, otherwise you have to find & fix the error yourself.
For the auto-complete, it's still available in most text editors(Atom, notepad++ etc...), however it's not always as good as intellisense.

running grails unit tests in vim

Im trying to find a way to run my grails unit/integration tests in vim without having to leave my editor. Is there a good plugin for that? I took a lot of tips from here http://www.objectpartners.com/2012/02/21/using-vim-as-your-grails-ide-part-1-navigating-your-project/ but I dont want to have to switch to just see the output.
I tried it with a keymap but grails has to start up each time. Any ideas? How do you guys do this?
I also found this https://github.com/hoffoo/vim-grails-console but couldn't get it set up properly.
Thanks!
I've started to use Tim Pope's vim-dispatch plugin to execute tests in a shell and then report the results back to vim. You can see my version of executing a grails test in my dotfiles repo, specifically, in grailsScripts
In order for the plugin to report back to vim, you need to set an errorformat. I've battled with vim's errorformat for quite awhile and ultimately landed on using a combination of reformatting the output with a groovy script and using errorformat to highlight file paths. The result is that you see the entire grails output in the error list, but can hit enter on lines with file paths and go to the line in question. It's not perfect, but it works.
If you are interested in using that method, you'll want to also get the following files from my dotfiles:
.vim/tools/filters.groovy
.vim/compiler/grails.vim
Note that these scripts work in my setup, but I haven't made them into a plugin yet, so your mileage may vary. I hope it helps!

Existing solutions to test a NSIS script

Does anyone know of an existing solution to help write tests for a NSIS script?
The motivation is the benefit of knowing whether modifying an existing installation script breaks it or has undesired side effects.
Unfortunately, I think the answer to your question depends at least partially on what you need to verify.
If all you are worried about is that the installation copies the right file(s) to the right places, sets the correct registry information etc., then almost any unit testing tool would probably meet your needs. I'd probably use something like RSpec2, or Cucumber, but that's because I am somewhat familiar with Ruby and like the fact that it would be an xcopy deployment if the scripts needed to be run on another machine. I also like the idea of using a BDD-based solution because the use of a domain-specific language that is very close to readable text would mean that others could more easily understand, and if necessary modify, the test specification when necessary.
If, however you are concerned about the user experience (what progress messages are shown, etc.) then I'm not sure that the tests you would need could be as easily expressed... or at least not without a certain level of pain.
Good Luck! Don't forget to let other people here know when/if you find a solution you like.
Check out Pavonis.
With Pavonis you can compile your NSIS script and get the output of any errors and warnings.
Another solution would be AutoIT.
You can compile your install using Jenkins and the NSIS command line compiler, set up an AutoIT test script and have Jenkins run the test.

What is everything involved from typing in code to executing a program?

I realized, when just asking a question, I don't understand all the components that are part of the coding process.
This seems a silly question, but I can't find a definitive answer on Google, Wiki, nothing.
What exactly are all the parts called, and how do they work and intertwine? I'm talking whatever you type code into, whatever checks that for errors, compiles it, and runs it.
I'd appreciate any links, repeats, etc. I apologize for such a bland, stupid question.
EDIT: Well, I'm trying to start Perl, so anything about Perl would help. Like, how to use Notepad++ and eventually compile Perl.
Write code
Run code in one of two ways[*]
Compiled languages (C, C++, D, Java, C#)
Compile the code into an executable file with the compiler tool.
Run the executable
Interpreted languages (Perl Python Ruby Lua Haskell Lisp & more)
Run the code in an interpreter, e.g., perl foo.pl
Debug code.
edit: Since the question was refined to be the Perl development cycle...
You will need an editor and a 'shell', which is used to command the system with. In particular, you want a 'command-line interface'. On Windows, you start this with running cmd.exe on the Run dialog (Windows + R is the shortcut).
You see a strange black and white box with a blinking cursor, reminding you of ancient systems redolent of gurus and wizards. You panic and refer to Google, getting a web page. Finding the command to change directory and list files is recommended...
Upon arriving at the directory where you stored your Perl file, you issue the command perl myfilename.pl, where myfile.pl is the file you saved. As is common for programming, you find some errors that appear to be incomprehensible, and you refer to Stackoverflow.com once again...
* I have elided, glossed, and moved past many of the details, as this is an introductory question. A full discussion is known as "senior-level course on compilers".