Hacker Newsnew | past | comments | ask | show | jobs | submit | embeng4096's commentslogin

Is there an example of the generic programming that you've found useful?

The extent of my experience has been being able to replace functions like convert_uint32_to_float and convert_uint32_to_int32 by using templates to something like convert_uint32<float>(input_value), and I didn't feel like I really got much value out of that.

My team has also been using CRTP for static polymorphism, but I also feel like I haven't gotten much more value out of having e.g. a Thread base class and a derived class from that that implements a task function versus just writing a task function and passing it xTaskCreate (FreeRTOS) or tx_thread_create (ThreadX).

Typed compile-time computation is nice, though, good point. constexpr and such versus untyped #define macros.


The generic algorithms that come with the C++ standard library are useful. Once you get used to using them you start to see that ad-hoc implementations of many of them get written repeatedly in most code. Since most of the algorithms work on plain arrays as well as more complex containers they are still useful in embedded environments.

std::array can sometimes give you the best of both worlds for stack allocation in that you statically constrain the stack allocation size (no alloca) while guaranteeing that your buffers are large enough for your data. You can also do a lot of powerful things with constexpr that are just not possible with arrays. It is very convenient for maintaining static mappings from enums to some other values.

You've never used a template for a data structure and you've never used a destructor to free memory?

I took a brief skim through so apologies if I missed that it was mentioned, but wanted to bring up the Embedded Template Library[0]. The (over)simplified concept is: it provides a statically-allocated subset (but large subset) of the C++ standard library for use in embedded systems. I used it recently in a C++ embedded project for statically-allocated container/list types, and for parsing strings, and the experience was nice.

[0]: https://www.etlcpp.com/


So I use C++ heavily in the kernel. But couldn't you just set your own allocator and a couple other things and achieve the same effect and use the actual C++ STL? In kernel land, at the risk of simplifying, you just implement allocators and deallocators and it "just works", even on c++ 26.

Do you typically just compile with -fno-rtti -fno-exceptions -nostdlib ?

Last time I did embedded work this was basically all that was required.


+1 to this and your above points (the embedded team I'm on has started using C++ over the last year or so).

I've definitely learned a lot, and I like the portability of CMake for cross-platform use (our team uses all 3 of Windows, Mac, and Linux). My experience sounds much like yours: there've been a lot of times where using the vendor's flavor of Eclipse-based IDE (STM32CubeIDE, Renesas e2studio, etc) would have saved us a lot of discovered work, or extra work adapting the "happy path" to CMake and/or C++.

Using C++ and/or CMake is fine when it's part of the happy path and for simpler things e.g. STM32CubeMX-generated CMake project + simple usage of HAL. For more complex things like including MCUboot or SBSFU, etc, it's forced me to really dig in. Or even just including FreeRTOS/ThreadX, we've created abstractions like a Thread class on top -- sometimes it's nice and convenient, others it feels like unnecessary complexity, but maybe I'm just not used to C++ yet.

One clear, simple example is needing to figure out CMake and Ninja install. In an Eclipse-based IDE, you install the platform and everything Just Works(tm). I eventually landed on using scoop to install CMake and Ninja, which was an easy solution and didn't require editing my PATH, etc, but that wasn't the first thing I tried.


AO3 also allows downloads of different formats including epub. I often download the epub (or use fichub for other sites) and read on the Epub Reader app. If I want to read on my Kindle app or my physical Kindle, I'll send the epub to my Amazon library via email.

Former band kid who also just got a digital keyboard. Ime learning to read the staff just came from putting in the time on the instrument, but I’m also looking for ways to speed that up. I had the idea of making flashcards and even putting it into an SRS like Anki to see if I can make the process of (re-)learning the staff faster and make it stick. If you come across anything that would help I’m interested too!


I just came across this checklist the other day: https://andrew-quinn.me/digital-resiliency-2025-checklist/

In addition to the short checklist, the author has a lengthy blog post describing its implementation in his life: https://andrew-quinn.me/digital-resiliency-2025/


I just switched to EndeavourOS for 95% of my home computer needs last week (I left my Windows install on a separate drive for gaming and especially those that require super invasive anticheat, e.g. AAA multiplayer FPS) and it has been a wonderful experience so far.


Would creating a `main.py` with the dependencies installed either as a uv project or inline work for you?

One thing I did recently was create a one-off script with functions to exercise a piece of equipment connected to the PC via USB, and pass that to my coworkers. I created a `main.py` and uv add'ed the library. Then when I wanted to use the script in the REPL, I just did `uv run python -i main.py`.

This let me just call functions I defined in there, like `set_led_on_equipment(led='green', on=True)` directly in the REPL, rather than having to modify the script body and re-run it every time.

Edit: another idea that I just had is to use just[0] and modify your justfile accordingly, e.g. `just pything` and in your justfile, `pything` target is actually `uv run --with x,y,z ipython`

Edit edit: I guess the above doesn't even require just, it could be a command alias or something, I probably am overengineering that lol.

[0]: https://github.com/casey/just


Wow, I really relate to this. It got to the point where I was reading self-help about social skills and such, and tried to follow the "always say yes" like you did and "never eat alone" type fluff advice. People had lots of good things to say about me, and I even tried doing things like writing those things down in a gratitude journal or taking screenshots of the texts, etc, to help shift my mindset (unsuccessfully). I still have the low self-confidence and people-pleasing you talk about to this day.

To your last point, I'm feeling much better when not pushing myself so hard to be social but the question I'm grappling with now is somewhat selfish but about how to make sure I have support? E.g. I had a friend who just went through a cancer diagnosis and a lot of us friends and his community rallied for him. It also made me wonder about what happens if I get very sick, or lose my job and don't have a professional network to reach out to or personal/friendship support, or just if my car breaks down at 1am or something, or just being very lonely without real close friends.

How are you reconciling this sort of thing in your own life?


To be honest, I don't have a good answer.

Indeed, I don't have the friend network since I stopped forcing myself to be social. Most people don't call again if you don't answer their calls for a few months [1].

I too witnessed people calling their friends for help in hard situations (like car broke down at 1am) and wondered who I could call if that happened to me.

I have a family and extended family who are very supportive. That is my social safety net, and they would help in any serious issue like money, car broke down at 1am, etc. This is a part of our culture where I live (It's not the US.) If you don't have that, it gets trickier.

For example, if you live in a different city than your family (which is a historically new phenomenon) you can't rely on them for car breakdown at 1 am situation.

Setting aside family, I think, for life-and-death issues (e.g. cancer) even people who know you at a superficial level (e.g. classmates, colleagues) would be willing to help, at least where I live.

For middle sized issues (car breakdown at 1am) I could call exactly 1 friend in my hometown, and 1 another in the city I study. They are close friends who like me as the person I am. They are content with our low-effort low-contact friendship. If you want advice, I think if you meet enough people (that's the hard part ofc) you'll eventually find one of these. Funnily one of these friends is extremely social, the sort of person you'd expect to greatly succeed in politics.

For smaller matters (e.g. an assignment in college) I have to admit I refrained from asking people for most anything ever since I stopped being forcibly social. This did lead to some (small) losses over time.

I live by the principle of "never ask any more than you gave to a person". Though it's not uncommon to see NT people who barely know each other confidently ask for small favors, offering nothing in return, simply because they don't have the social anxiety that I do.

1: I know it's rude. But iykyk the anxiety.


I also feel similarly about owing people things. I think it does tend to bind people together to have a history of giving to each other and receiving but like you mention, it can be anxiety-inducing as well.

Thanks for the advice, I know there's not really a "perfect" solution, I was just curious about how you've approached it in your own life so I appreciate you sharing.


This is really cool to see posted! Today I learned. I’ve used uart and RTT both but this is taking things a step further. Always love to see useful embedded content like this online and on hacker news


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: