r/programming • • Dec 08 '13

C++ has become a scripting language

http://voices.canonical.com/jussi.pakkanen/2013/10/15/c-has-become-a-scripting-language/
0 Upvotes

11 comments sorted by

15

u/RaptorDotCpp Dec 08 '13

I totally disagree with this article. Is Java a scripting language by their definition? Yes. Do I agree with their definition of a scripting language? Not at all. A scripting language is not a language in which it is easy to write complex functionality in a few lines. It's not a framework or a bunch of libraries. It's an interpreted language.

Just because C++11 makes it easier to do what scripting languages are usually used for, does not mean it's a scripting language. It's still an extremely powerful tool that needs to be handled with more care and caution than say Python or Ruby.

4

u/[deleted] Dec 08 '13

C++ can be interpreted.

14

u/eric987235 Dec 08 '13

Any language can be interpreted.

3

u/corysama Dec 08 '13

Better yet: Version 2 from the same group gives you an LLVM JIT compiled C++ REPL! http://root.cern.ch/drupal/content/cling

1

u/RaptorDotCpp Dec 08 '13

Interesting!

8

u/passwordeqHAMSTER Dec 08 '13

Ignoring include boilerplate and the like leaves us with roughly ten lines of code.

Yes, ignoring the feature that makes the blog moot...

4

u/xpolitix Dec 08 '13

Use the right tool for the job. C++ is a powerful system language. Using it as scripting language is possible but you'll be wasting 80% of your time to get 20% of what other scripting languages could deliver in that time.

5

u/Rotten194 Dec 09 '13 edited Dec 09 '13
#include<string>
#include<vector>
#include<algorithm>
#include<fstream>

using namespace std;

int main(int argc, char **argv) {
  ifstream ifile(argv[1]);
  ofstream ofile(argv[2]);
  string line;
  vector<string> data;
  while(getline(ifile, line)) {
    data.push_back(line);
  }
  sort(data.begin(), data.end());
  for(const auto &i : data) {
    ofile << i << std::endl;
  }
  return 0;
}

Python version:

with open(sys.argv[2], 'w') as o_file, open(sys.argv[1]) as i_file:
    o_file.write('\n'.join(list(sorted(i_file.read().split()))))

C++ is a scripting language. Mhmmm.

2

u/[deleted] Dec 08 '13

I understand the point you're trying to make, but I don't think you can call C++ a "scripting language" just yet.

2

u/eric987235 Dec 08 '13

C++ is a scripting language because it has built-in libraries that manage their own memory? Yeah, no.

1

u/hackingdreams Dec 09 '13

Ah yes, Canonical blog. That explains everything about this post.