{"id":621,"date":"2013-08-16T19:36:49","date_gmt":"2013-08-16T23:36:49","guid":{"rendered":"http:\/\/wcarss.ca\/log\/?p=621"},"modified":"2013-08-16T19:36:49","modified_gmt":"2013-08-16T23:36:49","slug":"agh-c","status":"publish","type":"post","link":"https:\/\/wcarss.ca\/log\/2013\/08\/agh-c\/","title":{"rendered":"agh c++"},"content":{"rendered":"<p>I come from the land of python, where the grass is green and the trees are leafy. I&#8217;m writing a game in C++ for fun, because I&#8217;ve never had to do serious work with C++, and so far&#8230; it seems like a nightmare-zone.<\/p>\n<p>First, there&#8217;s the crufty syntax, full of useless symbols. That&#8217;s a known cost though, visible to any passer-by. Second, there&#8217;s type definitions &#8212; I have to figure out specific types just to hold outputs of functions, which I&#8217;m only going to pass to other functions. But there are advantages and disadvantages to declarative, strongly typed systems, and I knew about this already, so I can&#8217;t really complain. Then the final straw: there are no list, tuple, or map types. You think I should use the STL? You&#8217;re right &#8212; that&#8217;s precisely what I ought to do.<\/p>\n<p>Except: the STL requires layer upon layer of confusing boilerplate, and in order to navigate it, you have to really know your C++ shit inside and out. Today, I wanted to remove some unwanted elements from a vector. Several StackOverflow question-reads later, I think the best route is to create a functor (loosely, an object wrapping a function) to use with an iterator to pass into a function to pass into another function. After all that, I have little knowledge of the big-O algorithms underlying these pieces of my code. I&#8217;ve also written a dozen lines for what I think of as &#8216;l.remove(e)&#8217;, and I&#8217;m wading through complex STL errors to figure out simple syntactical issues.<\/p>\n<p>Worst of all: it doesn&#8217;t even work yet. &#8216;std::remove&#8217; will remove elements equal to a given value, but doesn&#8217;t handle functors, while &#8216;std::remove_if&#8217; can handle a functor, but messes up my iterator somehow so the vector doesn&#8217;t truncate.<\/p>\n<p><span style=\"line-height: 1.6;\">Imagine a compilable and interpretable dynamically-typed (or at least type-inferred) language with minimal syntax and useful built-in types possessing relevant comprehensions. Now, imagine that it has bindings to popular open source game development libraries. Why can&#8217;t that be a thing?<\/span><\/p>\n<p>I&#8217;m sure that 90%+ of my issues are coming from not having a sufficiently well-developed mental model of the C++ landscape, and if I knew my way around, I wouldn&#8217;t be having these problems, but I don&#8217;t. I didn&#8217;t expect to have to learn how to walk again when I&#8217;m already intimately familiar with C, with Python, and with reasonable program design. It&#8217;s not a different paradigm, it&#8217;s just that everything is harder here.<\/p>\n<p>A different take on the situation is that the things that I&#8217;m annoyed by are showing me weaknesses in my own comprehension. Details I ought to be comfortable with are so commonly swept under the rug that I&#8217;ve forgotten they were even there, and now that I have to think about them, I&#8217;m more prepared to whine than solve the problems. So I&#8217;ll just keep on with it, I suppose, but there may yet be more whining.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I come from the land of python, where the grass is green and the trees are leafy. I&#8217;m writing a game in C++ for fun, because I&#8217;ve never had to do serious work with C++, and so far&#8230; it seems like a nightmare-zone. First, there&#8217;s the crufty syntax, full of useless symbols. That&#8217;s a known [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[62],"_links":{"self":[{"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/posts\/621"}],"collection":[{"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/comments?post=621"}],"version-history":[{"count":3,"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/posts\/621\/revisions"}],"predecessor-version":[{"id":625,"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/posts\/621\/revisions\/625"}],"wp:attachment":[{"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/media?parent=621"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/categories?post=621"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wcarss.ca\/log\/wp-json\/wp\/v2\/tags?post=621"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}