4 ms·
I periodically work on c++ instead of C and each time it follows a similar pattern where I learn about some new c++ trick, think it will make things better, wri
by 01100011 2y ago
I periodically work on c++ instead of C and each time it follows a similar pattern where I learn about some new c++ trick, think it will make things better, write my code, hit a compiler error, then spend the rest of the day learning why I can't do what I want. Granted, I usually am stuck at c++14, and some of the issues are fixed in future versions but still...
I really want to love C++. It gives me a more powerful C that theoretically should improve my output but in the end it carries so much cognitive baggage that I usually end up writing "C with classes" and move on.
- blastonico 2y agochatgpt or copilot helps a lot with that. I usually copy the text and let it decipher the thing for me.
- mithametacs 2y agothey’re still bad for generating any significant body of code. They’re a little bit better about deciphering errors. They’ll still bullshit* you and send you on wild goose chases. *hallucinate if you prefer
- matheusmoreira 2y ago> They’ll still bullshit you and send you on wild goose chases And confidently at that. It can't seem to find the backbone to say no to me either. If I say something like "wait, X doesn't seem to make sense, isn't it actually Y and Z?" it will agree and reformulate the answer as if Y and Z were correct just to placate me. I usually use the LLM to learn new things, I don't don't actually know if Y and Z apply.
- fooker 2y agoC++, like most technology, works better if you put in the work to learn about it. (Admittedly there are languages like python and ruby that buck this trend.)
- motorest 2y ago> C++, like most technology, works better if you put in the work to learn about it. There's also the impact of software entropy: if someone has little to no experience developing software and has to grow it by adding features and fixing bugs, over time their contribution to the project invariably results in degrading it beyond the point they can possibly salvage it. At that point, they blame the tools.
- Symmetry 2y agoSure, but the effort/reward ratio bears some consideration. I've put a lot more effort into learning C++ than any other programming language but I'd still say it's just the language I'm maybe 4th most proficient in.
- 01100011 2y agoProgramming languages are a means to an end. I'd rather have my cognition going towards solving the actual problem and not worrying about implementation details.
- zahlman 2y agoPython does work better if you put in that kind of work. Otherwise you'll get bit by the way mutable default arguments work[0] (or never learn to use it to your advantage), or by late binding of closures[1] (and maybe you'll pick up the awful habit of exploiting the confusing early binding of default arguments to make the `lambda`s that you constructed in a loop work properly[2]). Or you won't get the big picture of the descriptor protocol[3] and how method lookup[4] is related to the implementation of properties[5]. Or you won't get the fancy metaclass[6] thing that your favourite framework is expecting you to treat as an opaque abstraction[7], or how and when you might use a class decorator[8] instead of a metaclass to do that kind of metaprogramming. [0]: https://stackoverflow.com/questions/1132941 https://stackoverflow.com/questions/1132941 [1]: https://stackoverflow.com/questions/2295290 https://stackoverflow.com/questions/2295290 [2]: https://stackoverflow.com/questions/3431676 https://stackoverflow.com/questions/3431676 [3]: https://docs.python.org/3/howto/descriptor.html https://docs.python.org/3/howto/descriptor.html [4]: https://eev.ee/blog/2013/03/03/the-controller-pattern-is-awful-and-other-oo-heresy/ https://eev.ee/blog/2013/03/03/the-controller-pattern-is-awf... (yes, this was partly an excuse to get one of Zed Shaw's critics [9] into the discussion) [5]: https://stackoverflow.com/questions/3798835 https://stackoverflow.com/questions/3798835 [6]: https://stackoverflow.com/questions/100003 https://stackoverflow.com/questions/100003 [7]: e.g. https://medium.com/@miguel.amezola/demystifying-python-metaclasses-understanding-and-harnessing-the-power-of-custom-class-creation-d7dff7b68de8 https://medium.com/@miguel.amezola/demystifying-python-metac... - I didn't have a good link for this and didn't spend a long time searching, but this seems okay [8]: https://stackoverflow.com/questions/681953 https://stackoverflow.com/questions/681953 [9]: https://eev.ee/blog/2016/11/23/a-rebuttal-for-python-3/ https://eev.ee/blog/2016/11/23/a-rebuttal-for-python-3/
- gopalv 2y ago> then spend the rest of the day learning why I can't do what I want There's a point when learning's fun, I think the OP is still there. I wrote a bunch of realtime C++ in 2003, hated it. But last year, I wrote most of my code in C++ and liked it finally. Lambda and auto was the tipping point where I stopped hating it. Some templates thrown in, but mostly to avoid writing a lot of branches for variants of the same function. With lambdas I could now write the way I was initially taught programming, mostly by Lispy teachers channeling SICP. Didn't hate the allocations either with unique_ptr.
- hashishen 2y ago"Lispy teachers channeling SICP" made new audibly laugh
- cshokie 2y agoIf you haven’t already look up ‘if constexpr’ in cpp17 and newer. It lets you have compile time branches in a single function.
- mst 2y agoAlso requires, which initially looks batshit insane but is in fact really quite cool: https://www.think-cell.com/en/career/devblog/if-constexpr-requires-requires-requires https://www.think-cell.com/en/career/devblog/if-constexpr-re...
- Loranubi 2y ago> Unlike requires requires and requires { requires }, which are perfectly reasonable C++ code, requires requires { requires } is completely silly. Normal day in cpp land...
- spopejoy 2y agoHow on earth did C++ brainrot lead them to think that reusing that keyword was anything but a nightmare? The very first line of the article > Probably the two most useful features added to C++20 are requires and requires said without a trace of irony ... the whole thing reads like parody! I keep hearing that C++20 or whatever is getting so great but if so why would they specify such a dumpster fire of syntax???
- mystified5016 2y agoThis describes my C++ experience precisely. Initially I was a C# programmer learning C for embedded projects and it went exactly like this. C++ has a lot of really neat features that sure look powerful if your application aligns precisely. It seems like every time I try a new feature, what I want to do is always an edge case that doesn't work in my situation. I try for a few hours/days before I give up and just write it in C.
- bcrl 2y agoMy biggest disappointment with C++ is that the standard libraries are completely unsuitable for use in embedded systems where you have to control when, where and how many memory allocations occur. This is particularly important when the system level design choice is to perform all allocations at system startup, which is a common design pattern for high performance systems with real time characteristics. A high speed messaging system I worked on ran into this all the time. We couldn't use the standard implementations of things like heaps, hashes or queues because they don't have a way of making memory allocations occur at startup. It was quite common to have to re-implement those data structures when adding a new feature, as the stl or boost implementations were not suitable for this design pattern.
- swordzen 2y agoHave you tried override the allocators and destructors of your classes so you can do all allocations at startup?
- ahartmetz 2y agoI see a lot of bad code from people who have just learned about some feature and want to use it. Don't do that. Think of how to write your code, and then, if a feature solves a problem, use it. Problem->Solution, not the other way around. E.g. C++ templates are generally pretty awful, but sometimes, compile-time duck typing, or automatically adding padding based on sizeof(), etc, is very useful.