|
chglcu posted:FTFY Lol same (except I don’t work in gamedev). I used to kinda like C++ but it just makes me tired these days. I’ve started poking a bit at rust which I’ve been very suspicious of but it does seem kinda nice... So far just IDE integration feels a million times nicer than for C++. And dependency handling with cargo is really nice but I expect some bullshit if you pull in something that depends on a C/C++ library
|
# ? Mar 5, 2021 17:44 |
|
|
# ? Jun 8, 2024 03:51 |
|
I read the rust book and I was super excited about it until I actually tried writing real code in it and I just felt like I was fighting the language. I probably need to give it another shot, but in the short time I spent with it, libraries seemed very immature and poorly documented. That, and I threw up in my mouth a little bit every time I saw the word 'rustacean'.
|
# ? Mar 5, 2021 17:53 |
|
I wish I had a better alternative to C++, but that's not happening any time soon. Everything I do is either legacy code where we're just stuck with what we've got, or writing an R package where no other reasonably performant language is really supported.
ultrafilter fucked around with this message at 18:06 on Mar 5, 2021 |
# ? Mar 5, 2021 18:01 |
|
chglcu posted:FTFY loving Pascal under Borland had the potential to be the less bullshit fillled alternative to C++, for a while its Turbo Pascal compilers produced code that ran neck and neck as fast as C++ without the giant cognitive load required not to gently caress it up in C++, but that company got taken over by insane enterprise suits more interested in peddling lovely enterprise CORBA style shovelware and pricing its toolchains far beyond amy hobbyists means and let Pascal die on the vine of history. Shame, back in the 90s Turbo Pascal and Delphi where absolute delights to use
|
# ? Mar 5, 2021 18:33 |
|
I will say that switching from R and Python, it was very liberating to just be able to write my own loops instead of looking for a pre-written function backed by C++ code which does my loop for me. (And not have it take forever to loop over a hundred million data points)
|
# ? Mar 5, 2021 20:23 |
|
duck monster posted:loving Pascal under Borland had the potential to be the less bullshit fillled alternative to C++, for a while its Turbo Pascal compilers produced code that ran neck and neck as fast as C++ without the giant cognitive load required not to gently caress it up in C++, but that company got taken over by insane enterprise suits more interested in peddling lovely enterprise CORBA style shovelware and pricing its toolchains far beyond amy hobbyists means and let Pascal die on the vine of history. Shame, back in the 90s Turbo Pascal and Delphi where absolute delights to use I always hated begin and end and typing := (although it's easier and clearer to read).
|
# ? Mar 5, 2021 20:46 |
|
cheetah7071 posted:I will say that switching from R and Python, it was very liberating to just be able to write my own loops instead of looking for a pre-written function backed by C++ code which does my loop for me. (And not have it take forever to loop over a hundred million data points) Everything's fun and peachy in a compiled language until you have to touch a string
|
# ? Mar 5, 2021 20:54 |
|
Insurrectum posted:Everything's fun and peachy in a compiled language until you have to touch a string Also, yeah, not having to worry about the performance of a loop is great. But having to write loops every time I want to loop over something is extremely tiring. My biggest complaint about C++ is that it forces me to spend a lot of time thinking about things that I don't care about. That's gotten better with the modern standard library but it's still not all the way there yet.
|
# ? Mar 5, 2021 21:14 |
|
Volguus posted:I always hated begin and end and typing := (although it's easier and clearer to read).
|
# ? Mar 6, 2021 00:00 |
|
Remember, the only thing between you and code:
|
# ? Mar 6, 2021 04:06 |
|
code:
|
# ? Mar 6, 2021 05:14 |
|
code:
|
# ? Mar 6, 2021 05:19 |
|
This is perhaps a silly question but is there a convenient term for referring to objects allocated on the stack (without using 'new') and objects allocated on the heap (using 'new')? Or is it "RAII Objects vs Instantiated Objects" or something?
|
# ? Mar 7, 2021 23:25 |
|
It's kinda weird and a blurry line in C++ because objects can call new themselves - a vector has its elements in the heap even if the vector itself is stack-allocated. I would call them stack-allocated and heap- or dynamically allocated.
|
# ? Mar 7, 2021 23:33 |
|
Jeffrey of YOSPOS posted:It's kinda weird and a blurry line in C++ because objects can call new themselves - a vector has its elements in the heap even if the vector itself is stack-allocated. I would call them stack-allocated and heap- or dynamically allocated. What if I want to avoid confusion when I am also discussing using a heap data structure (std::make_heap etc)?
|
# ? Mar 7, 2021 23:38 |
|
Just enforce a rule that heaps are always stack-allocated and stacks are always heap-allocated. You'll never be confused again.
|
# ? Mar 7, 2021 23:41 |
|
Automatic vs dynamic storage
|
# ? Mar 7, 2021 23:48 |
|
alright, if im on linux, writing a program for windows and using mingw to compile it, how would i go about specifying the application entry point to be WinMain? When I try compiling it normally, it whines about a few things not being defined (they are defined later in the code, but called in the code before WinMain, which leads me to believe it's just trying to go from top to bottom rather than starting at WinMain) To be specific, here's the code I'm trying to compile - I'm just using the example from the Windows API documentation to get poo poo working (so I don't just assume everything is my own bad code): code:
|
# ? Mar 8, 2021 02:43 |
|
hbag posted:alright, if im on linux, writing a program for windows and using mingw to compile it, how would i go about specifying the application entry point to be WinMain? When I try compiling it normally, it whines about a few things not being defined (they are defined later in the code, but called in the code before WinMain, which leads me to believe it's just trying to go from top to bottom rather than starting at WinMain)
|
# ? Mar 8, 2021 02:57 |
|
roomforthetuna posted:Prototype/declarations should match the instantiations. Compilation goes from top to bottom, the execution entry point is a completely different thing which it doesn't sound like is your problem. ...So it's a case of the documentation being wrong? https://docs.microsoft.com/en-us/windows/win32/winmsg/using-window-classes Thanks, Microsoft.
|
# ? Mar 8, 2021 02:58 |
|
BOOL is a typedef for int and C functions have a default return type of int so that's a valid declaration.
|
# ? Mar 8, 2021 03:02 |
|
Are you specifying to use the windows subsystem? Without that, I think it’ll create a console executable which would use main as the entry point instead of WinMain. Without seeing your actual error output, it’s hard to say if that’s related. Not sure what the switch for mingw would be.
|
# ? Mar 8, 2021 03:21 |
|
chglcu posted:Are you specifying to use the windows subsystem? Without that, I think it’ll create a console executable which would use main as the entry point instead of WinMain. Without seeing your actual error output, it’s hard to say if that’s related. Not sure what the switch for mingw would be. yep. i tried this: i686-w64-mingw32-gcc file.cpp -Wl,-subsystem,windows - and what i got was an error whining about InitApplication and InitInstance not being defined
|
# ? Mar 8, 2021 03:30 |
|
hbag posted:yep. i tried this: i686-w64-mingw32-gcc file.cpp -Wl,-subsystem,windows - and what i got was an error whining about InitApplication and InitInstance not being defined With it being a .cpp file, it could be being compiled as c++ and the default int return type thing doesn’t apply there, as far as I know, so the mismatched prototypes causing a problem could make sense.
|
# ? Mar 8, 2021 03:37 |
|
chglcu posted:With it being a .cpp file, it could be being compiled as c++ and the default int return type thing doesn’t apply there, as far as I know, so the mismatched prototypes causing a problem could make sense. really? i thought the windows API was only C++, not C guess i'll try compiling it as C and see what happens
|
# ? Mar 8, 2021 03:38 |
|
hbag posted:really? i thought the windows API was only C++, not C Win32 is actually a C API (C89 with some MS extensions, I believe), though it can be used from C++. Some other windows libraries use C++, but the core API is C.
|
# ? Mar 8, 2021 03:45 |
|
chglcu posted:Win32 is actually a C API (C89 with some MS extensions, I believe), though it can be used from C++. Some other windows libraries use C++, but the core API is C. ah, right, thanks - im not on my laptop (that the code is on) right now but i'll give it a try when i get on it in an hour or so
|
# ? Mar 8, 2021 03:47 |
|
getting closer i think
|
# ? Mar 8, 2021 04:27 |
|
hbag posted:...So it's a case of the documentation being wrong? Your new error looks familiar, I think you get that from not doing int WINAPI WinMain.
|
# ? Mar 8, 2021 05:43 |
|
roomforthetuna posted:Yeah, even if the "default return type in C is int" thing holds true, the fact that BOOL is typedeffed as int is an implementation detail that's supposed to have been made irrelevant by the typedef (it should be possible to change the underlying type of BOOL and have all correctly written code still compile and work), so though it will compile in a C compiler it is still incorrect of them to write it that way. And also, if you're going to rely on the default int return type you really ought to be doing it in the declaration *and* the implementation for consistency, so that documentation is crappy for two reasons, though technically "it will work". Aaaand now I'm getting this: [whoops nevermind that was a typo on my part] hbag fucked around with this message at 11:55 on Mar 8, 2021 |
# ? Mar 8, 2021 11:28 |
|
the ACTUAL new error seems to be this:
|
# ? Mar 8, 2021 11:57 |
|
hbag posted:the ACTUAL new error seems to be this: It looks like it thinks your calls to InitApplication() and InitInstance() are actually declarations of variables, and it's complaining that you didn't specify what their type is. Likely you need a declaration of those functions above the point where they're called. e: ah, you're declaring them near the top, but not specifying their return type.
|
# ? Mar 8, 2021 15:50 |
hbag posted:the ACTUAL new error seems to be this: Two things in those linker errors: You are missing the MainWndProc function entirely, you need to a window procedure for the program to work. Additionally, it looks like you're missing one or more system libraries for linking, since it's complaining about _imp__GetStockObject@4 (that's a GDI function). Make sure you're linking both the KERNEL32, USER, and GDI libraries. You really should fix the prototypes of your InitApplication() and InitInstance() functions to include the return type BOOL, if nothing else to make good habits.
|
|
# ? Mar 8, 2021 16:23 |
|
hbag posted:the ACTUAL new error seems to be this: Generally when you run into errors at that level Google+StackOverflow will be your friend. I just searched for "undefined reference to MainWndProc" and the top result was about building a Windows target with mingw, encountering that error, and had an answer, so it might be exactly the answer you need.
|
# ? Mar 9, 2021 05:53 |
|
roomforthetuna posted:So now that you're getting "undefined reference to MainWndProc", which is now a link-time error, it's something closer to the libraries or toolchain. It isn't, MainWndProc is a user implemented callback, not an OS supplied function.
|
# ? Mar 9, 2021 06:14 |
|
pseudorandom name posted:It isn't, MainWndProc is a user implemented callback, not an OS supplied function.
|
# ? Mar 9, 2021 06:23 |
|
Does anybody know how C++20's iterator concepts work? I've been trying to find information on how to construct a custom iterator for C++20's concepts, but I just haven't been able to find anything online describing the changes. Is it some new style of designing your iterator class, or is it just an enhancement on top of the current method of tagging your iterator_category and providing your standard difference_type, value_type, etc, properties? Or is it just too early to think about this because no STL implementation has bothered with it yet?
|
# ? Mar 9, 2021 19:17 |
|
I seem to recall some random trivia that, if you want to represent a 3D Vector as a struct, it can be advantageous to actually store 4 values:code:
What do y'all think?
|
# ? Mar 10, 2021 02:19 |
|
giogadi posted:I seem to recall some random trivia that, if you want to represent a 3D Vector as a struct, it can be advantageous to actually store 4 values: Are you sure this isn't because of quaternion math? Rotating vectors is really easy when the number of dimensions is a power of two, so the usual way it's handled is to pretend your vector is four-dimensional, rotate it, and then go back to ignoring the fourth dimension. It's used all the time in computer graphics.
|
# ? Mar 10, 2021 02:26 |
|
|
# ? Jun 8, 2024 03:51 |
|
cheetah7071 posted:Are you sure this isn't because of quaternion math? Rotating vectors is really easy when the number of dimensions is a power of two, so the usual way it's handled is to pretend your vector is four-dimensional, rotate it, and then go back to ignoring the fourth dimension. It's used all the time in computer graphics. I’m not sure - I always thought the fastest way to rotate a 3d vector is just to multiply with a 3x3 rotation matrix. Like, you can directly rotate a vector with a quaternion but it’s about as fast as converting the quat into a rotation matrix and just rotating that way. But I might be wrong!
|
# ? Mar 10, 2021 02:30 |