> Furthermore parsing JSON or YAML gives you the basic data types like lists and dictionaries. Parsing XML gives you an AST that requires a lot more effort to turn into data in your domain. More precisely: in XML,…
`rmdir /s /q` in a command prompt is significantly faster than Windows Explorer. Yes C: is slow due to filters and Dev Drive is faster; but this difference can only be felt when using the command line; Windows Explorer…
In our compiler (in a code analysis tool), we have #pragma immutable_macro __attribute__ After this pragma, any attempt to #define/#undef the macro "__attribute__" will be silently ignored. This lets us (or our…
It's a normal command called "View: Reopen Closed Editor".
Yes `int` acts as if it was a subtype of `float`: https://typing.python.org/en/latest/spec/special-types.html#...
But in Python the type checker does not complain about `x: float = 0`, because for the purpose of type checking (but not at runtime), `int` is considered a subtype of `float`:…
In most languages, `x: float = 0` involves an implicit conversion from int to float. In Python, type annotations have no impact on runtime behavior, so even though the type checker accepts this code, `type(x)` will be…
Don't forget the compatibility issues: Fil-C isn't really usable if you mix C with other languages in the process. It's especially problematic to have multiple different garbage collectors; so given the desire to reuse…
When accessing individual elements, 0-based and 1-based indexing are basically equally usable (up to personal preference). But this changes for other operations! For example, consider how to specify the index of where…
> make sure not to sign into your Microsoft account or link it to Windows again That's not so easy. Microsoft tries really hard to get you to use a Microsoft account. For example, logging into MS Teams will…
That loop isn't N²: if there are long sequences of dashes, every iteration will cut the lengths of those sequences in half. So the loop has at most lg(N) iterations, for a O(N*lg(N)) total runtime.
cygwin is a POSIX-emulating library intended for porting POSIX-only programs to Windows. That is: when compiling for cygwin, you'd use the cygwin POSIX APIs instead of the Windows APIs. So anything compiled with cygwin…
If you need `0..=n`, you can't write `0..(n+1)` because that addition might overflow.
But the source character set remains implementation-defined, so compilers do not have to directly support unicode names, only the escape notation. Definitely a questionable choice to throw off readers with unicode…
The article is using the Python C API directly. pybind11 is a C++ wrapper that makes the Python API more friendly to use from C++ (e.g. smart pointers instead of manual reference counting)
> But if i is indeed put immediately after, then the function should indeed return 5 for n=3. That's not how compilers work. The optimization changing `return i;` into `return 0;` happens long before the compiler…
The problem with `setenv` is that people expect one process to have one set of environment variables, which is shared across multiple languages running in that process. This implies every language must let its…
How exactly would that help in this situation? If both Rust and C have independent standard libraries loaded into the same process, each would have an independent set of environment variables. So setting a variable from…
Yes, that is typically the way to go. Collecting a call stack only requires unwinding information (which is usually already present for C++ exceptions / Rust panics), not full debug symbols. This gives you a list of…
Caution with these functions: in most cases you need to check not only the error code, but also the `ptr` in the result. Otherwise you end up with `to_int("0x1234") == 0` instead of the expected `std::nullopt`, because…
> All noexcept does is catch any exception and immediately std::terminate. While that's a possible implementation; the standard is a bit more relaxed: `noexcept` may also call `std::terminate` immediately when an…
The GC does matter. Most applications are completely fine with having a garbage collector, but they are not fine with having multiple garbage collectors! Mixing multiple garbage collected languages is a recipe for…
There are some static analysis tools that can check this. Cert's SIG30 rule page has a list: https://wiki.sei.cmu.edu/confluence/display/c/SIG30-C.+Call+... Also there's…
> If a compiler is certain there's UB should it format the developer's hard drive immediately, or does it have to wait until the program is run before formatting to be standards compliant? The standard has enough…
You don't need a distro with ancient glibc; you can instead create a cross-compilation toolchain. We used https://crosstool-ng.github.io/docs/ to create a cross-compilation toolchain that runs on modern debian, but…
> Furthermore parsing JSON or YAML gives you the basic data types like lists and dictionaries. Parsing XML gives you an AST that requires a lot more effort to turn into data in your domain. More precisely: in XML,…
`rmdir /s /q` in a command prompt is significantly faster than Windows Explorer. Yes C: is slow due to filters and Dev Drive is faster; but this difference can only be felt when using the command line; Windows Explorer…
In our compiler (in a code analysis tool), we have #pragma immutable_macro __attribute__ After this pragma, any attempt to #define/#undef the macro "__attribute__" will be silently ignored. This lets us (or our…
It's a normal command called "View: Reopen Closed Editor".
Yes `int` acts as if it was a subtype of `float`: https://typing.python.org/en/latest/spec/special-types.html#...
But in Python the type checker does not complain about `x: float = 0`, because for the purpose of type checking (but not at runtime), `int` is considered a subtype of `float`:…
In most languages, `x: float = 0` involves an implicit conversion from int to float. In Python, type annotations have no impact on runtime behavior, so even though the type checker accepts this code, `type(x)` will be…
Don't forget the compatibility issues: Fil-C isn't really usable if you mix C with other languages in the process. It's especially problematic to have multiple different garbage collectors; so given the desire to reuse…
When accessing individual elements, 0-based and 1-based indexing are basically equally usable (up to personal preference). But this changes for other operations! For example, consider how to specify the index of where…
> make sure not to sign into your Microsoft account or link it to Windows again That's not so easy. Microsoft tries really hard to get you to use a Microsoft account. For example, logging into MS Teams will…
That loop isn't N²: if there are long sequences of dashes, every iteration will cut the lengths of those sequences in half. So the loop has at most lg(N) iterations, for a O(N*lg(N)) total runtime.
cygwin is a POSIX-emulating library intended for porting POSIX-only programs to Windows. That is: when compiling for cygwin, you'd use the cygwin POSIX APIs instead of the Windows APIs. So anything compiled with cygwin…
If you need `0..=n`, you can't write `0..(n+1)` because that addition might overflow.
But the source character set remains implementation-defined, so compilers do not have to directly support unicode names, only the escape notation. Definitely a questionable choice to throw off readers with unicode…
The article is using the Python C API directly. pybind11 is a C++ wrapper that makes the Python API more friendly to use from C++ (e.g. smart pointers instead of manual reference counting)
> But if i is indeed put immediately after, then the function should indeed return 5 for n=3. That's not how compilers work. The optimization changing `return i;` into `return 0;` happens long before the compiler…
The problem with `setenv` is that people expect one process to have one set of environment variables, which is shared across multiple languages running in that process. This implies every language must let its…
How exactly would that help in this situation? If both Rust and C have independent standard libraries loaded into the same process, each would have an independent set of environment variables. So setting a variable from…
Yes, that is typically the way to go. Collecting a call stack only requires unwinding information (which is usually already present for C++ exceptions / Rust panics), not full debug symbols. This gives you a list of…
Caution with these functions: in most cases you need to check not only the error code, but also the `ptr` in the result. Otherwise you end up with `to_int("0x1234") == 0` instead of the expected `std::nullopt`, because…
> All noexcept does is catch any exception and immediately std::terminate. While that's a possible implementation; the standard is a bit more relaxed: `noexcept` may also call `std::terminate` immediately when an…
The GC does matter. Most applications are completely fine with having a garbage collector, but they are not fine with having multiple garbage collectors! Mixing multiple garbage collected languages is a recipe for…
There are some static analysis tools that can check this. Cert's SIG30 rule page has a list: https://wiki.sei.cmu.edu/confluence/display/c/SIG30-C.+Call+... Also there's…
> If a compiler is certain there's UB should it format the developer's hard drive immediately, or does it have to wait until the program is run before formatting to be standards compliant? The standard has enough…
You don't need a distro with ancient glibc; you can instead create a cross-compilation toolchain. We used https://crosstool-ng.github.io/docs/ to create a cross-compilation toolchain that runs on modern debian, but…