Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Get a devDuck
Rubber duck debugging has never been so cute! Get your favorite coding language devDuckBuy Now
Search - "stl"
University Final Viva for OOP with C++
(Yeah, that first line is a rant in itself for the likes of me and Mr. Torvalds)
Tell me a few "functions" in C++ STL algorithm header
*starts off with the first one that came to my mind*
AP: Huh? a I'm asking the Algorithms in C++ STL
Me: Yes, this is one of them Ma'am.
She looked at me as if I told her that I'm dating her daughter. It became clear she doesn't know about it and she'll gladly deduct my marks for getting it wrong. So I explained how Sort() is a hybrid of quicksort, heap sort and insertion sort. (Read about it an hour ago while doing a competitive programming question)
AP: Tell me the ones we did in class.
I haven't attended those classes, so I just told her the ones I knew.
After a couple more infuriating questions, which themselves sounded right from a book published in the 90's, she gave me 10/15.
This is what's wrong with India's Education system, even the teachers know only the stuff mentioned in the course hand-outs. Forget brownie points, you get screwed over by the teachers for actually knowing stuff and using it.8
>starts a new project
>new project is kernel
>implements a big bunch of C++ stl
>wants to implement a FS
>Writes Ata drivers
>Ata drivers don't work on ACPI systems
>implements ACPI according to osdevwiki
>decides to read the acpi specs4
I had a genuine respect for C++ developers back in 2001
Then this whole STL thing happened. Then C++11, C++14....C++17
Me now: Bitch do they even write code 🤣🤣11
Linus Torvalds on C++
“C++ leads to really really bad design choices. You invariably start using
the nice library features of the language like STL and Boost and other total and utter crap, that may help you program, but causes:
- infinite amounts of pain when they don't work (and anybody who tells me
that STL and especially Boost are stable and portable is just so full of BS that it's not even funny)
- inefficient abstracted programming models where two years down the road you notice that some abstraction wasn't very efficient, but now all your code depends on all the nice object models around it, and you cannot fix it without rewriting your app.”
I am working on an open source game project, and the most common way to draw things is using a class named ManagedSurface. The class is otherwise awesome, but it has a method called getBasePtr(x, y), which gives you a pointer to the requested coordinates. Fair enough (this is C++ without STL by the way).
But WHY THE HELL CAN I REQUEST ANY POINTER THAT I WANT, EVEN IF IT'S OUTSIDE THE SURFACE? Other cointainers have sanity checks, asserts and such, and the surface KEEPS TRACK OF IT'S WIDTH AND HEIGHT.
WAS IT SO FUCKING HARD TO ADD assert(x <= w); assert(y <= h);???
I spent 3 days on valgrind trying to find a heap corruption that manifested at random points in the code.
On the bright side, I learned how to use valgrind (which is awesomely awesome).4
Ok c++ professionals out there, I need your opinion on this:
I've only written c++ as a hobby and never in a professional capacity. That other day I noticed that we have a new c++ de developer at the office of which my first impression wasn't the greatest. He started off with complaining about having to help people out a lot (which is very odd as he was brought in to support one of our other developers who isn't as well versed in c++). This triggered me slightly and I decided to look into some of the PRs this guy was reviewing (to see what kind of stuff he had to support with and if it warranted his complaints).
It turns out it was the usual beginner mistakes of overusing raw pointers/deletes and things like not using various other STL containers. I noticed a couple of other issues in the PR that I thought should be addressed early in the projects life cycle, such as perhaps introduce a PCH as a lot of system header includes we're sprinkled everywhere to which our new c++ developer replies "what is pch?". I of course reply what it is and it's use, but I still get the impression that he's never heard of this concept. He also had opinions that we should always use shared_ptr as both return and argument types for any public api method that returns or takes a pointer. This is a real-time audio app, so I countered that with "maybe it's not always a good idea as it will introduce overhead due to the number of times certain methods are called and also might introduce ABI compability issues as its a public api.". Essentially my point was "let's be pragmatic and not religiously enforce certain things".
Does this sound alarming to any of you professional c++ developers or am I just being silly here?10
I'm working in a complex CMake/C++14 project.
Many libraries uses EASTL as STL replacement, works and compiles flawlessly.
Have to use Qt5 for an application which uses the libraries.
The EASTL Library fucking collapses
Compile fails, 1k of syntax errors somehow.
After hours trying to figure out without alterating the EASTL library (i don't want to maintain custom versions of 3rd party libraries, an complete burden to maintaining updated)
Remove all reference of Qt5 from the code and the build system.
It fucking compiles.
Isolate an minimal build which only uses CMake, EASTL and Hello World in Qt5.
1k of syntax errors again.
Spend hours trying to fix it, no avail, still fucking 1k syntax errors.
I'm past beyond of the project development where ALL the big libraries of the project uses EASTL extensively.
One day C++ will drive me into the depths of madness.2
After 4 - 5 months of learning webD, I am trying to build my first fullstack web application (simple chat one ).
My stack :
Vue.js + Materialize
Express ( handling routes )
Mongoose/MongoDB ( Database )
Socket.io ( web sockets for real time connection )
Had dreamt of this 2 months ago where I built a basic front end using html and css, and now porting it to Vue is like a breeze.
Wish me luck and let's hope it doesnot become one of the unfinished projects. ( My university semester exams are coming up , would have to complete this as fast as possible ). I am also learning DSA + STL and aim to learn basic python syntax before holidays so that I can focus my time on ML during them. It's so fucking overloaded that I have my doubts ::((4
How hard is it to make a custom steno-lithography API? And do I even need one?
Hi, all. My name is J.A and I am co-owner of 3DPrintedDreams with my best friend. (We are both 17.)
During a brainstorm of what should be the flagship feature of our shop should be. We decided to take user images, (exact specifications TBD), and then use an API to transform them into .stl files so my friend can print it on his 3D Printer.
I am asking how hard or "easy" would it be to make such an API and what would be the bottom dollar if I were to make a collab post here about it? If anyone would be willing to listen, I could explain how all this would work in relation to the full stack of my website.
p.s. I understand that experience costs money and I myself have experienced this, but, we spent most of our money on the Pallete 2 from Mosaic. (about $500).
HOWEVER, we still have some money left. If a suggested price is to much for us to pay up-front, 3DPrintedDreams is willing to pay you in installments dermined by mutual agreement.
Thanks for your time and have a nice day!
Co-founder of 3DPrintedDreams, LLC (Pending).15
I was trying to make a circular buffer in C++. I was also trying to expose iterators for using the buffer with STL algorithms. I kept trying to think about how to add the functions needed to manipulate the existing internal iterators to not exceed the bounds of the buffer. Then I realized I was "too close" to the problem. There was no way I could properly control the internal iterators of the storage vector I was using. Not without giving too much power to the user of my library. So I abstracted the iterators up one level. Hid all the details of the internal iterator and made a new iterator.
The solution of abstracting the iterator was not the epiphany. The epiphany was if you are struggling with how to solve a particular problem. You keep running into problems with how to represent something, there is too much power available at a particular representation, or the object you are trying to make work just don't fit. This is when you should consider abstracting a level up. Take a higher look at the problem and simplify the interface.
Abstraction could be a number of things. Divide and conquer, hiding details, specializing an object, etc. Whatever tool is needed to make the problem more consumable to your brain.
2 Days ago i started learning Rust, because i was planning to learn for years.
Well turns out, rust is even better than i thought! Rust's STL is basically a blessing, you have stuff like vectors, tcplisteners, etc. in there! So no more self-management of sockets which were necessary to write in c / c++ (without ext. libs)!
Fucking love that shit!! It's so great! :)6
<sarcasm> best advice?
Write microcontroller code in C++ even if the underlying OS won't understand. You can always decompile the program to C code and use the generated code.
Things he forgot to mention:
- cannot use most of C++ core functionality (basically no STL, no exceptions, all of C++11)
- have to get your code to compile twice (C++ and C afterwards)
- debugging that generated C code is a pain in the ass
- have to debug twice
Scaling a 3D STL File so the Tolerances are still the same but the Model is Like 300% scaled... Fucking hard...1
Suppose you made a tool for your STL that throws compile-time errors when trying to copy references, so your pointers remain tidy.
Suppose also that the language has a a turing-complete preprocessor that can be used to throw useful errors.
Then WHY THE FUCK DOES UNIQUE_PTR NOT OVERRIDE THE DEFAULT ERRORS WHICH TELL ME NOTHING ABOUT WHAT I FUCKED UP BUT PRETEND UNIQUE_PTR IS AT FAULT FOR NOT DEFINING "OPERATOR=" ?
At what point are you an expert in C++?
Herb Sutter's talk tilted "Back to Basics" (available on YouTube) contains the message "it's easy to forget that you're an expert" in the context of writing code that utilizes the latest complicated features of a language to squeeze out the last drop of performance.
So what makes someone an expert? Is it just writing production code? Is it groking the entire panel presented by a standards committee member? Is it contributing to the STL? Is it when you can write your own compiler while blindfolded and juggling rubber duckies in under 60 seconds?
What makes a person an expert in any language, for that matter?7
I had used a computer since the win 3.1 days and I fooled around with VB on win 95 or 98. I didn't know it was going to be my passion until i wrote a whole data structures library in c++ based on my double linked list i wrote for a class. I called it the ETL, for easy template library (like the STL was hard!!). Thats when i knew i had a knack for it and began really learning.
can someone recommend a free 3d modelling software to create printable stl-files for mechanical technical devices? i am not experienced with cad and freedcad gave me a hard time to start with.
educational or commercial use both can apply.3
So I thought I had a basic, high level understanding of C++ STL strings, pointers, copy constructors and stuff. In comes a dirname, a -D_GLIBCXX_USE_CXX11_ABI=0 and... Toto, I've a feeling we're not in Kansas anymore.
So what is happening? I copy a string expecting a deep copy, but then I do the dirname or manipulation on the copy and it messes up *both* strings. gcc/C++ I know you're a beast, but what's going on there? Thing is only possible if I cast away const from c_str - which of course is a doubtful operation - but there also seems to be some strange copy on write logic that the data pointers initially point to same memory location and only with first manipulation on the copy they start to point to different addresses.
I had no clue. And still don't have.4
String char replacement in C++ (according to SO):
Boost - replace_all(str1, str2);
C++ STL - 12 lines of code to iterate over the length of the string and store the result in a <char> vector.
Noooooooope. Thank God for Boost.1
"You shouldn't use STL as it's slower"
<<Writes std::array instead of double* >>
Oh look, the execution time and the instruction read is the same!
What the hell is wrong with the CLang standard libraries? Whose crazy idea was it to put memset and memcpy in the string library?
Note to self:
Variadic C++ templates combined with obfuscated combinations of stl containers put you on the right path to be a "compiler message decryption" archmage.
Especially when you use MSCV...
why doesnt the STL call my fking assigment op nor my copy ctor when i assign to a custom key of my unordered_map -.- does it fking memcpy????1