@Suser thinks I have a good perspective on transitioning from scripting (in my case, Ruby) to programming (in C++). This post deals particularly with Ruby and C++, but some facets are broadly applicable.
Why
Before I list some differences between scripting and programming, I will specify a few reasons to not “just stick with Python”.
- Compiled languages are faster than scripting languages.
- What happens if, during a legal pentest, a victim’s machine doesn’t have
/usr/bin/python
installed? - Familiarizing yourself with a wide range of tools (languages are tools) will make you a better programmer, thinker, and problem-solver.
Some Big Differences
In general, the shift from scripting to what some purists might call “grown-up programming” is hard at first. A statically-typed (for the most part) language like C++ demands more of the coder; programming requires more forethought for types.
C++'s compiler errors are fairly convoluted. It takes hundreds of hours with C++ to pick out the patterns of each error. Once up the learning curve, you realize common errors and avoid them. I’m sure that there exist other languages similar to C++, with respect to paradigms and typing, that have clearer, friendlier error messages.
Coming from Ruby, I did not know about integer overflow. Learn about integer overflow.
Another particular thing about C++ that throws off a long-time scripter is [function prototyping](https://en.wikipedia.org/wiki/Function_prototype). While this is fixed in newer languages, C++ still requires the programmer to provide at least a [function declaration](http://en.cppreference.com/w/cpp/language/function) before any calls to a function are made.
The following is an example of a function declaration (sometimes called a function prototype).
int do_something(int something);
While this is a function definition:
int do_something(int something) {
return something * 42;
}
C++ makes the programmer more aware of how exactly data is passed around. You come to learn about pointers, references, and how the two are used in code.
Perhaps the biggest change from scripting to programming (in C++, or C) is that C and C++ give the programmer loose access to memory. The programmer can change bits and bytes on a whim. This also leaves more room for error. C++ is moving away from (the excessive use of) raw pointers.
Learning Tips
The following suggestions are my own mixed in with what was said in IRC at the time of this writing. Note that they apply to people who already know how to code in at least one language.
- Look at lots of code examples. Read through them; understand what they do. A good source of code is GitHub.
- Port a project over from whatever language you last used.
- Dig deep into the standard library. Learn how to use it and recognize the implementations underneath. This helps you understand some of your new language’s quirks.
Conclusion
I look forward to any discussion(s) this writing prompts.