5 ms·
I keep meaning to dive into Rust, but it feels like they've removed so many useful things in the name of safety. I mean, I get it, these are all things which c
by fullstop 6y ago
I keep meaning to dive into Rust, but it feels like they've removed so many useful things in the name of safety.
I mean, I get it, these are all things which can be used to very easily cause chaos and shoot yourself in the foot. I look at code that I've written, though, and see so many challenges to writing the same thing in Rust.
I spend 99% of my time in embedded Linux or bare metal, though, so maybe my view point is a bit skewed.
There seem to be very few GUI libraries which can be used in Rust as well. I'll keep checking https://areweguiyet.com/ https://areweguiyet.com/
- ChrisSD 6y agoIf you want to use a tool that pastes code fragments in arbitrary places you can. However, I'm not clear on the benefit over something that's aware of its context, or at the very least AST aware.
- qppo 6y agoEven modern C++ has eschewed macros for virtually every use case, the only reason I've had to use them (legitimately) has been conditional compilation and some compiler/platform specific issues. Like if you're doing #define PI 3.14159 you're asking to get chirped in code review.
- rightbyte 6y agoYe, everyone know it is: #define PI 3.1415927410125732421875 that is the float closest to pi or that there is the GNU extension USE_FUNKY_DEFINES-something with M_PI for cmath. (I know you meant constexpr:ions).
- Const-me 6y agoLong time ago when computers were 32-bit I used to write something like this in C++: inline double pi() { __asm fldpi; } On old enough compilers, this will get you 80-bit version of pi, more precision than even double. Completely useless now, modern compilers no longer emit x87 code.
- asveikau 6y agomath.h has M_PI in posix.
- qppo 6y agoThe point is that using macros for constants is frowned upon in modern codebases, just like all other use cases for macros that break type safety and the one definition rule.
- asveikau 6y agoYes, I understand the point. But to your comment in a literal sense, if I were doing code review I would probably suggest using M_PI. Which happens to be a macro. Which actually highlights that many things you want to use for practical purposes are C rather than C++, predate innovations such as const or namespaces, etc. It's possible and common to understand the downsides and still reach for the macro.
- steveklabnik 6y agoJust because we don't have textual substitution doesn't mean we don't have macros. We have a lot of macros! (It took me a while to write back to you because I am busy writing bare-metal embedded Rust, btw. Including using some macros!)