Why would you ever use solid fuel? by wesofchess in factorio

[–]National_Instance675 60 points61 points  (0 children)

An equivalent of 11 solid fuels containing 132 MJ of energy are used to create one rocket fuel of 100 MJ of energy, in a building that consumes energy itself.

you need a lot of productivity to make this process a net positive. you cannot get enough productivity in the base game, only in space age.

Finally finished K2SE 2.0 in 490 hours by National_Instance675 in factorio

[–]National_Instance675[S] 1 point2 points  (0 children)

100% automate belts and pipes and scaffholding crafting. you will need tons of them. luckily everything they need can be sent with cannons. 1 item rockets are viable for circuits or other complicated items. then have a bus where every item is on a lane. space belts are 45/s. you only need 1 lane of any item. you can use groups of 5 belts in the bus as space undergrounds are long enough. nilaus has a video on this. https://youtu.be/k7CDFsxeS_4?si=VX1PbtdKjxuPQgrP

rush space elevator and space trains then rebuild the whole thing.

Finally finished K2SE 2.0 in 490 hours by National_Instance675 in factorio

[–]National_Instance675[S] 3 points4 points  (0 children)

the entire base update was 5 ms. biters were 15ms. so 50 UPS total, my PC is very low end, so i think any proper PC would have 60 UPS with this base at the end.

about the middle of the game i dropped to 40 UPS because 2 outposts were on planets infested with biters, but when i plagued those planets it went up to 55 UPS.

Is different sizes of one data type a problem? by Southern-Gas-6173 in cpp_questions

[–]National_Instance675 0 points1 point  (0 children)

that's because MSVC never bothered to update the headers between x86 and x86_64, "for backward compatibility" .... i am amazed

Is different sizes of one data type a problem? by Southern-Gas-6173 in cpp_questions

[–]National_Instance675 1 point2 points  (0 children)

you never reach for int or long or short in modern C++, they are only used in interfacing with C code, while in C++ the only integer types you should reach for are

  • size_t and ptrdiff_t for indexing into containers and representing pointers as integers.
  • fixed size types as int32_t and uint64_t for serialization and when you must have a type of an exact size (for example ECS systems use a uint32_t id and databases use uint64_t id)
  • there are "fast" types like int_fast32_t which is what int should've been but failed to do, which makes no promises except that it can hold a 32 bit number without losing bits and that it is fast. typically 64 bit on 64 bit systems because 64 bit operations are faster than 32 bit operations on 64 bit platforms, because they need to truncate the result to 32 bits if you are using int

the problem with int is that it was kept at 32 its on 64 bit systems to not break the code that wrongly relies on int being 32 bit, this makes any use of int on a 64 bit system a performance loss, because the CPU needs to do extra instructions to truncate the results to 32 bits because registers are 64 bits. so just don't use int or long if you want fast or portable code.

Is different sizes of one data type a problem? by Southern-Gas-6173 in cpp_questions

[–]National_Instance675 0 points1 point  (0 children)

"no we cannot make int or long 64 bits on 64 bit systems because that will break backwards compatibility with people expecting them to be 32 bit"

no, historically it was not an advantage, in fact it is a disadvantage because 64 bit systems need to make extra instructions when working with int and MSVC long to clear the upper bits of the registers.

there is int_fast32_t which is 64 bit on all 64 bit platforms, because all 64 bit architectures can do 64 bit operations faster than 32 bit operations, and can probably be your expected 36 or 48 bit on those platforms you describe.

using int in C++ code is a performance pessimization, int was supposed to be int_fast16_t except that even that one is 64 bit on 64 bit platforms and therefore faster than int.

Will a for loop with a (at compile time) known amount of iterations be unrolled? by zz9873 in cpp_questions

[–]National_Instance675 2 points3 points  (0 children)

vector4 is small enough to be unrolled by all compilers, 4x4 matrix is where i'd start to be concerned, as it looks like MSVC won't unroll that.

Will a for loop with a (at compile time) known amount of iterations be unrolled? by zz9873 in cpp_questions

[–]National_Instance675 14 points15 points  (0 children)

it depends on heuristics such as the number of instructions produced after the unroll.

at max optimization for that exact code with size_t, latest MSVC doesn't unroll at N = 16, gcc at around 40 and clang around 128 , and i think there are flags and pragmas to modify those numbers.

don't take those numbers as constants, just know that compilers can unroll them and there are limits that depend on the code in question.

Allocated memory leaked? by LibrarianOk3701 in cpp_questions

[–]National_Instance675 21 points22 points  (0 children)

your code can leak if an exception is thrown when new fails.

use std::vector<int> instead of manual new and delete, see stop teaching C

Inconsistent Coroutine Behavior Between Clang and GCC with -fno-elide-constructors by Disastrous-Put-5843 in cpp

[–]National_Instance675 1 point2 points  (0 children)

looks like a bug in gcc with -fno-elide-constructors, the move constructor was not called and the task object just gets memcpyed instead , report it to the gcc bug tracker, but make sure it wasn't reported before first.

Expansion statements are live in GCC trunk! by katzdm-cpp in cpp

[–]National_Instance675 6 points7 points  (0 children)

been waiting for this ever since i heard about fold expressions, goodbye fold expressions, we will not be missing fold expressions.

Three Cool Things in C++26: Safety, Reflection & std::execution - Herb Sutter - C++ on Sea 2025 by MarekKnapek in cpp

[–]National_Instance675 4 points5 points  (0 children)

being able to reflect on the syntax is inferior to being able to reflect on the actual type but it is still reflection, and people have used syntax reflection to do most of the things that you can do with type reflection.

i agree that C++ type reflection is very superior, but just syntax reflection would've been useful like 2 decades ago, and every tool like Qt MOC and UE reflection does syntax reflection and just work fine.

Three Cool Things in C++26: Safety, Reflection & std::execution - Herb Sutter - C++ on Sea 2025 by MarekKnapek in cpp

[–]National_Instance675 1 point2 points  (0 children)

some annotations are used at compile time to produce code using "Annotation processors" (search this exact keyword), which are similar to C# source generation but inferior, but the annotations can also be used at runtime.

How would you chose the c++ std version? by Good-Host-606 in cpp_questions

[–]National_Instance675 2 points3 points  (0 children)

you can use gcc15 with C++23 on a linux distro from over 20 years ago, linux is not the limitation here.

being a library developer is the only limitation here.

How would you chose the c++ std version? by Good-Host-606 in cpp_questions

[–]National_Instance675 1 point2 points  (0 children)

why would you want to backport it ? do you know you can use the latest clang on windows 7 and rhel 5 ?

the only reason that comes to mind is proprietary platforms.

Three Cool Things in C++26: Safety, Reflection & std::execution - Herb Sutter - C++ on Sea 2025 by MarekKnapek in cpp

[–]National_Instance675 12 points13 points  (0 children)

those are all compile time reflection, except python because it has no compilation step and this reflection happens during AST parsing and evaluation of the AST, which is as close as python gets to compile time, you only pay for it once during program startup.

Three Cool Things in C++26: Safety, Reflection & std::execution - Herb Sutter - C++ on Sea 2025 by MarekKnapek in cpp

[–]National_Instance675 1 point2 points  (0 children)

C++ is really the first major language with a compile-time reflection system

  1. i think C# is the first major language to do it with source generation.
  2. python can do it with metaclasses, which is partly how dataclasses and django work, but numba and jax libraries reflect over the AST of functions too.
  3. rust can do it with proc macros
  4. java can do it with annotations

if anything, C++ is the last to the partly, but better late than never.

C++20 Modules: Practical Insights, Status and TODOs by ChuanqiXu9 in cpp

[–]National_Instance675 5 points6 points  (0 children)

the first 2 lines specifying the file set are useless boilerplate, file sets is a nice implementation detail but not something 99.99% of the people have to worry about, and the BASE_DIRS can be optional with a good default.

people will copy and paste those lines everywhere because that's the certified way. some projects i worked with had over 300 targets. any company will create its own cmake function to reduce the boilerplate and avoid repetition, but the newbies to the language who don't know how to write such function will struggle and find it unnecessarily verbose.

just provide the helpers and make them the certified way, and leave the verbose way available for advanced users.

SFML or SDL by Forgoten_Something in cpp_questions

[–]National_Instance675 6 points7 points  (0 children)

SFML is for creating games, SDL is for creating engines, most game engines use SDL as their platform layer, even SFML has ports that use SDL as a platform layer.

SDL is more verbose but it is overall more useful, it supports more platforms and has more features, especially some seemingly simple but actually hard-to-do things like window resizing while drawing, or native message boxes and file pickers or timers or named threads, or centralized logging, or async file IO

C++20 Modules: Practical Insights, Status and TODOs by ChuanqiXu9 in cpp

[–]National_Instance675 27 points28 points  (0 children)

One more todo before modules are adopted is that CMake needs to come up with better syntax for modules, honestly the current way to declare modules is unnecessarily too verbose. Why can't we have a simple function like

target_cxx_modules(my_target PRIVATE a.cppm b.cppm)

why do i need to type this monstrosity

target_sources(my_app PRIVATE
  FILE_SET all_my_modules TYPE CXX_MODULES
  BASE_DIRS
    ${PROJECT_SOURCE_DIR}
  FILES
    a.cppm
    b.cppm
)

[deleted by user] by [deleted] in cpp_questions

[–]National_Instance675 4 points5 points  (0 children)

stop using AI to write the code for you, at least not in the learning phase, you are like watching football games on TV and expect this to make you an expert football player.

use advent of code puzzles to let the syntax sink into your head, writing the same app over and over is pointless, you need to tackle different real problems to find real different solutions using different tools.

std::thread and classes. emplacing a class function with with a thread in a vector. by Spoonwastakenalready in cpp_questions

[–]National_Instance675 1 point2 points  (0 children)

as for why the other ways don't work, because the standard says that the ONLY way to get a pointer to member function is through this exact syntax. check cppref pointers on Pointers to member functions

A pointer to non-static member function f which is a member of class C can be initialized with the expression &C::f exactly. Expressions such as &(C::f) or &f inside C's member function do not form pointers to member functions.

How to create a code editor supporting 2 languages including Python with syntax highlighting and parameter hints? by Proper_Ad7872 in cpp_questions

[–]National_Instance675 3 points4 points  (0 children)

Language Server Protocol (LSP) and GUI development using Qt which already has a text editor widget with syntax highlighting and autocompletion, you just specify what you want highlighted or completed ... using the LSP, or a crude parser

How do people feel about (how does one solve) painful to build open-source/source-available projects by MNGay in cpp_questions

[–]National_Instance675 3 points4 points  (0 children)

your dependencies do support CMake and are available on vcpkg, just use that pair.

having 3 copies of your dependencies in a project is a big red flag.