64 karma · joined Jun 8, 2020 (6y ago) · 35 submissions
comment 4mo ago · link · parent
comment 4mo ago · link · parent
1. Indexes instead of pointers. This allows you to avoid alignment of 8 bytes in your structure for x86_64.
2. Storing booleans out-of-band. Booleans cause padding all the time.
3. Struct of Arrays. Based on your question I assume you're familiar with it.
4. Store sparse data in hash maps. I remember one time when it allowed to eliminate inheritance.
5. Encoding the data instead of OOP/polymorphism. I haven't got an occasion to use it. The idea is to add extra tags to avoid boolean properties.
5.
Ask HN: Switching from backend development to graphics programming
1 points · by laladrik · 5mo ago · discuss
comment 5mo ago · link · parent
comment 5mo ago · link · parent
Unfortunately, I had the expectation that it should be as simple as making an HTML page. My failure to find a library or a framework to make GUI application made me learn a lot about how GUI works. I realized that making GUI for browser and for desktop are quite different problems. Browser makes easy what's difficult having a desktop oriented GUI framework - text rendering. However, the situation is fair the other around. GUI framework makes easy what's difficult in a browser - drawing arbitrary shapes. As a result, a web-frontend programmer struggles to figure out how to write some text having something like Qt, a GUI programmer tries to find the API to the bitmap in a browser.
It's fair noticed in the previous comments that a GUI framework brings a lot. That's because the problem is complex:
1. Create a window
2. Communicate with the window compositor (you do in WinAPI too btw). How to access the system tray and the child window.
3. Communicate with the operating system.
4. Handle the user input. Callback vs event streams. The user has 4 keyboards for some reason.
5. Rendering. Subpixels, shapes, different DPI. The user has 6 monitors.
6. Text rendering.
7. Widgets. Where probably the most difficult part is to make a textbox, because it involves the solutions of all previous steps.
The steps above touch only the visual part. There's also audio, accessibility, somebody wants the GUI framework to solve the networking.
After all of this research, I picked simply SDL for my project.
1. It's easy to compile.
2. It's small.
3. It relies on the subjectively common dependencies.
4. It's fairly straightforward to upgrade. Given that, you have to create a lot from scratch the part with updating is smaller comparing to a Qt-based solution.
5. It has batteries. My favorite is SDL_ttf which allowed me recently to implement selection of the text which is quite a bit through towards a textbox.
Having a project on SDL requires a lot of knowledge, but not a lot of code.
comment 5mo ago · link · parent
I have my own blog, but I'm unhappy with its design as well; therefore I'm not sharing it. Nevertheless, I find particularly challenging two things: 1. Make tables readable from a smartphone. There are a few tricks which allow you to make a responsive table. However, those tricks implies that you use <ul> or <div> instead of <table> which defeats the point of having a table. 2. I had an article where I needed to put a tiny mind map. Eventually I put it as a picture, because the solutions to draw a mind map with JavaScript made the page as twice as heavy.
comment 5mo ago · link · parent
Location: Ireland
Remote: Yes
Willing to relocate: No
Technologies: Rust, Go, C/C++, Postgres, RabbitMQ, Redis, GNU/Linux, Docker, Python.
Résumé/CV: https://alexmarkov.xyz/resume-long.html
Email: barber-stoic-come@duck.com
Senior Software Engineer with 15+ years of experience with strong system design skill. Deep knowledge of GNU/Linux to build high-load web systems serving millions of requests.comment 9mo ago · link · parent
comment 11mo ago · link · parent
15.
1 points · by laladrik · 11mo ago · 1 comment
comment 11mo ago · link · parent
1. https://www.youtube.com/watch?v=haes4_Xnc5Q&list=PLz9LbZJP-T...
comment 12mo ago · link · parent
comment 1y ago · link · parent
comment 1y ago · link · parent
21.
My First Complete Game(laladrik.xyz ↗)
6 points · by laladrik · 1y ago · 1 comment
comment 1y ago · link · parent
const App = struct {
fn init() @This() { return .{} }
};
const Connection = struct {
fn init() @This() { return .{} }
};
You get the following items in the navigation list: App::init
Connection::init
Essentially, it's a configuration of Telescope and Nvim-Treesitter. You can take the file from here https://laladrik.xyz/zig_document_symbols.lua. However, if you curious about the process of creating a custom Telescope menu and inspection of the source code with Tree-sitter, checkout the entire article.Also, while I working on it, I found that LuaJIT 2.1 compares strings as fast as integers. Eventually, I did a little research about it and published the results here https://laladrik.xyz/blog/luaStringComparison/
23.
Enhanced document symbol menu for Zig(laladrik.xyz ↗)
3 points · by laladrik · 1y ago · 1 comment
comment 1y ago · link · parent
Does GPU rendering mean that I have to involve OpenGL/Vulkan?
comment 1y ago · link · parent
> You describe that attempt in detail.
I appreciate if you put a quote, because I fail to find the description of the attempt in detail. In fact, instead of assuming that a vector is pinned I wrote this "I realized that the problem is related to the fact that vectors of children move in the memory if they don't have enough space to extend."
> The code you ended up with is still dangerous code, because your boxes are still not guaranteed to remain pinned in memory.
You are right, boxes are not pinned, but the data, which the point to, is pinned, isn't it? My pointers point to that part of memory.
comment 1y ago · link · parent
comment 1y ago · link · parent
Do you mean that b-tree might work here better?
> They’re just populating an array from a file when the program launches, then freeing the whole thing when the program terminates. It’s really not rocket science.
That's exactly why I consider indices.
> since they assumed memory allocated by vec would be pinned (it isn’t)
Could you tell me, please, where you read in the article that I assume it? I wrote in the article "I realized that the problem is related to the fact that vectors of children move in the memory if they don't have enough space to extend." and even made an animation for clarity https://laladrik.xyz/VectorMove.webm. However, if you see the assumption in the article, please, let me know. I correct it or elaborate.
comment 1y ago · link · parent
I don't have arguments against the point about Xlib. However, I struggle to use its alternative XCB. XCB doesn't have enough documentation to understand how to use it. In fact, I even looked at the source code of Qt and GTK, but the usage doesn't explain the XCB API. I'd really appreciate if you share with me the data you have. The only thing which I found recently is the wrapper from System76 https://pop-os.github.io/libcosmic/tiny_xlib/index.html. However, it's not a documentation still. I just hope to find some usages of the wrapper and communicate with the original API.
> if you ignore the existence of Wayland
How did you conclude it? I even mentioned it in the article. I don't use it - it's true. However, I can't wait to do it. I've been trying for a couple of years now. Regrettably, I experience various technical difficulties every time. As a result, I still use my i3.
> For something like fast visualizations, you should really go with something that does offscreen rendering and then blits the result.
Do you mean double buffering?
> though obviously modern tools should use GPU rendering
Would you mind elaborating on it?
comment 1y ago · link · parent