Live data from Hacker News

C++: A language for next generation web apps

stevehanov.ca

81–90 of 99 posts

Re: C++: A language for next generation web apps

#81
post #71

What has not been mentioned at all: how C++ webapps will spell the end of XSS and SQL injection as hackers refocus on the much more interesing but almost-forgotten buffer overflow vulnerabilities. Oh joy!

Such vulnerabilities still exist in PHP, Python and Ruby, because they are written in C. And they are much easier to exploit because almost every web app uses one of these languages.

Re: C++: A language for next generation web apps

#82

To be fair, after coming back to C++ after years in the world of Python and Haskell, it's not as bad as I remembered. C++ is actually a moderately effective functional programming language. With reasonable knowledge of the standard data structures, and using BOOST, one can actually write fairly expressive and effective C++ code. Most of the time, I feel like all I'm doing is writing a much more verbose version of Pyt…

Your experience with Python and Haskell has most likely made you a far better C++ programmer than you were before.

This is absolutely the case.

I'm now used to first class functions, currying, etc. C++ actually has them, hidden in the stl and boost::function. Whatever I can't do using those, I can usually do by creating a family of classes which only implement operator() (I've only needed to do this once or twice, and it might have been avoidable).

Due to using a language with native dicts (and syntactic sugar), they are now part of my vocabulary. This means I immediately reach for std::map or boost::unordered_map when it makes sense.

Similarly, python generators and haskell lazy lists have made view sequences as reasonable objects to generate and iterate over. Custom iterators are just the same thing with added verbosity.

If I never used higher level languages, I'd still be treating C++ as C with objects.

Re: C++: A language for next generation web apps

#83

Earlier quoted context omitted.

I don't get the constant complaints about the GIL. Letting your Python program run on 2 cores will make it 2x faster at best. Rewriting it in, say, Javascript or Lisp or Haskell or Java will make it run 2-50x faster on one core. After you get your 50x speedup, then you can worry about the 4x you'll get from buying 3 more processor cores. (And oh yeah; it's only shared-memory concurrency that things like the GIL affec…

I can only tell you why _I_ am constantly complaining about the GIL. It's because I would like to use a Python/C combination for in-memory data analysis. C gives me the speed and memory efficiency and Python gives me the ease of use and the web stuff. There is no 50x speedup to be had as it doesn't get any faster than C. The only significant speedup will come from parallelism. 8 cores this year, 16 next year and prob…

Python C extension modules can release the GIL while they're running which allows for true concurrency. See this Google code search http://www.google.com/codesearch?q=python.org+lang%3Ac+Py_BE... for example usage.

Re: C++: A language for next generation web apps

#84
post #71

What has not been mentioned at all: how C++ webapps will spell the end of XSS and SQL injection as hackers refocus on the much more interesing but almost-forgotten buffer overflow vulnerabilities. Oh joy!

Such vulnerabilities still exist in PHP, Python and Ruby, because they are written in C. And they are much easier to exploit because almost every web app uses one of these languages.

Nonsense. Just because the Python interpreter is written in C does not mean that you can overrun Python strings and smash the stack like you can w/ C strings.

Re: C++: A language for next generation web apps

#85

To be fair, after coming back to C++ after years in the world of Python and Haskell, it's not as bad as I remembered. C++ is actually a moderately effective functional programming language. With reasonable knowledge of the standard data structures, and using BOOST, one can actually write fairly expressive and effective C++ code. Most of the time, I feel like all I'm doing is writing a much more verbose version of Pyt…

So, what is great, modern C++ code to read?

It's a book but Accelerated C++ by Koenig and Moo has been well reviewed.

Re: C++: A language for next generation web apps

#86
post #59

Earlier quoted context omitted.

I doubt it takes seconds to test a hello world program in Ruby. However, to test a hello world Rails application is a different story, as you have to start up the web server, which takes seconds (even though it eventually just serves a simple page).

Not necessarily the web server. Standard `rake test:units` (or even `ruby test/units/model_test.rb`) takes the whole Rails stack so it adds up.

You're right and I agree. But let's be careful not to equate Rails with Ruby. Rails tests may have a slow startup time, but Ruby tests do not and other Ruby web framework tests may not.

Re: C++: A language for next generation web apps

#87

Earlier quoted context omitted.

Your experience with Python and Haskell has most likely made you a far better C++ programmer than you were before.

This is absolutely the case. I'm now used to first class functions, currying, etc. C++ actually has them, hidden in the stl and boost::function. Whatever I can't do using those, I can usually do by creating a family of classes which only implement operator() (I've only needed to do this once or twice, and it might have been avoidable). Due to using a language with native dicts (and syntactic sugar), they are now part…

In C++, I'm more likely to write a struct/class which implements operator() than an actual function. It lets me write code like this, which does mutate state, but I put it off as long as possible:

  xformerlist& lbrace = node.children.front().xformations;
  xformerlist& rbrace = node.children.back().xformations;
  fn_and row_and_flat(&shared_variable::is_row, &shared_variable::is_flat);
  const sharedset& flat_ins = filter(row_and_flat, set_union_all(in, inout));
  const sharedset& flat_outs = filter(row_and_flat, set_union_all(out, inout));
  const sharedset& flat_all = set_union_all(flat_ins, flat_outs);
  make_conditions > make_gen_in_row(parcond, conds, local_depths);
  make_conditions > make_gen_out_row(parcond, conds, local_depths);

  append(lbrace, fmap(make_gen_in_row, flat_ins));
  append(rbrace, fmap(make_gen_out_row, flat_outs));
I imagine that code would give a lot of people fits. In my current project, I ran with a more functional approach to C++. I don't know if I'll keep everything I've used in this programming style, but I certainly will keep some of it.

Re: C++: A language for next generation web apps

#89
post #88

Objc is probably a better candidate because it is so dynamic?

See http://news.ycombinator.com/item?id=1046516

  Web apps in Objective C --- the second-least safe programming language
  on the market. Oh please, oh please, build your next huge application
  in this. College tuition for my kids is freaking me out.
Post reply on HN