Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
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)
Assistant Professor:
Tell me a few "functions" in C++ STL algorithm header
Me:
*starts off with the first one that came to my mind*
sort()
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 -
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 -
Several minutes waiting for site to work after clicking on "required cookies only". Is this really what privacy laws were aiming for?19
-
>starts a new project
>new project is kernel
>clinl.tiff
>implements a big bunch of C++ stl
>wants to implement a FS
>needs ATA-Drivers
>ofuck.vmw
>Writes Ata drivers
>Ata drivers don't work on ACPI systems
>i_want_to_kill_kevin.fossil
>implements ACPI according to osdevwiki
>doesn't work
>decides to read the acpi specs4 -
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.”
http://harmful.cat-v.org/software/...3 -
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.
FUUUUCK!
On the bright side, I learned how to use valgrind (which is awesomely awesome).4 -
How awesome is that! NASA's Mars rover software is available on Github: https://github.com/nasa-jpl/.... Also impressive: Github uses WebGL to render 3D previews of STL files! https://github.com/nasa-jpl/....
21st century, baby!4 -
I'm struggling to write a function that finds a subsequence in a sequence. I made a fucking programming language and String::find is where I get stuck. Fucking fuck.
Impostor syndrome hitting hard today27 -
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?9 -
This is the kind of shit that I don't want to write.
The kind of shit that should be in an STL so I never have to include it in a project.
Because it doesn't belong in a project.
And it doesn't belong in a dependency tree either.
It belongs in a language. -
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 -
kinda sick of my friends giving me super basic advice when I mention my mess of 3d printer files
'group similar things together'
'have folders for main projects with nested sub projects'
'put the slicer project file with the stl files for the specific model'
I'm not fucking 5 I've lived long enough to have some level of basic common sense.
Worst part is they forget we've had this conversation and next time I even mention my files they bring up the exact same fucking comments EVERY damn time8 -
!rant
After 4 - 5 months of learning webD, I am trying to build my first fullstack web application (simple chat one ).
My stack :
FRONTEND:
Vue.js + Materialize
Backend:
Express ( handling routes )
Mongoose/MongoDB ( Database )
Socket.io ( web sockets for real time connection )
JWT
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 -
took me years to learn js, php, c# and I ended up now learning and debugging STL... This twisted logic is soo painfull3
-
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!
-Josh
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. -
I've been working with Node and Typescript for a while now, and I wrote a wide array of very general utility functions. Examples include:
- Array.filter but you also get the residue array, it can also leave holes in both arrays if you want to join them later
- Array zipping and unzipping to and from tuples (especially valuable when you're manipulating the prop set with Object.entries() in a HOC
- Array maximum selection, with an optional mapper
- Cancelable promises, lazy promises, a promise that resolves when a given function on an object is called (excellent for DOM events), a timeout promise.
- A typed event with both immediate and microtask listeners depending on whether you need state guarantees (this idea I took from a Github gist and upgraded it)
I want to put them on NPM so I don't have to write them and their tests again, and so that if I ever think of an improvement it's easier to propagate it. Do you think I should release them as tiny individual packages which would be nice from a versioning standpoint, or should I make them into a compilation which would be a lot less work for me (and therefore would probably result in better documentation and more tests)?4 -
<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=" ? -
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.
-
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?5 -
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 -
!dev
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 -
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 -
Yet another unusual take for the Orchid STL: Unicode codepoints aren't a part of the string library.
For the purposes of a high level language, the unit of text is a grapheme. Strings can be converted between Unicode and binary blobs. In a binary, indices address bytes. In text, indices address graphemes. For example, searching a string for a substring that consists of a single letter implies the added constraint that the letter must not have accents or other modifiers.
For storage and transfer optimization it's possible to discover the byte length of a string without converting it to binary2 -
In case you remember,
there lived a legendary coder named "Harsha Suryanarayana", popularly known as "Humblefool"
from India. He died in a car accident back in 2014.
The only thing that still keeps me wondering is why he always chose to code in Java( in coding competitions ) even though he knew C++ along with STL and was also aware of the advantages of using C++ over Java in competitive coding.7 -
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... -
"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! -
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