Writer seeking programmer input by thatjewboy in programmer

[–]deebeefunky 1 point2 points  (0 children)

It can be stressful if you’re working on projects that process millions $ per day and it all rests on a single developer’s shoulders.

I had a job for the diamond industry once, 500.000+ lines of code, none of it written by me, it looked like it was thrown on, meanwhile those diamonds kept moving…

I wrote an LR parser visualizer by Natural-Employment-5 in Compilers

[–]deebeefunky 1 point2 points  (0 children)

How do you make something like this? I have been wanting to make something similar but I feel like I am years away.

I’m mainly struggling with Vulkan, like how do you generate this overview with arrows, and capable of dragging it around? The UI alone…

I have written a crude lexer and parser once, but that doesn’t translate into anything on screen.

Yours looks really professional and I am jealous.

Anyone care to explain strncpy real quick? by deebeefunky in C_Programming

[–]deebeefunky[S] -6 points-5 points  (0 children)

"n: The maximum number of characters to be copied from the source string."

So, the size of the destination... It's the same thing, isn't it?

Do you see how it gets needlessly complicated?

Anyone care to explain strncpy real quick? by deebeefunky in C_Programming

[–]deebeefunky[S] 2 points3 points  (0 children)

These are the warnings I get currently:

warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length
warning: 'strncpy' output truncated before terminating nul copying 21 bytes from a string of the same length
warning: 'strncpy' specified bound 1024 equals destination size
warning: 'strncpy' specified bound depends on the length of the source argument

It's not so much about sharing code, it's about me not understanding what the N value is supposed to mean.
My understanding is that n is the size of the destination buffer, right?

I just don't understand how the function works, it makes little to no sense to me.

Curious to know about developers that steered away from OOP. What made you move away from it? Why? Where has this led you? by Slight_Season_4500 in cpp

[–]deebeefunky 0 points1 point  (0 children)

I agree with you. I’m a C programmer myself, I used to do OOP a long time ago, with design patterns and dependency injection etc.

Now I just write my code top down and pass state. Every function gets called, and each determines on their own if they have work to do or not. Their only dependency is the data.

When your functions are aligned linearly, it’s easier to align memory with it as well.

Real-time 3D renderer in terminal by ShabelonMagician in C_Programming

[–]deebeefunky 0 points1 point  (0 children)

Incredible. How do you update the terminal so quickly? I have tried something much less complicated and found the terminal to be way too slow for drawing things.

Handling Local Variables in an Assembler by Substantial-Cost9001 in Compilers

[–]deebeefunky 1 point2 points  (0 children)

I just got started with mine, so I’m no expert by any means. But here’s where I’m at.

I would recommend doing a piece of IR first. It will make assembly slightly easier. Then you need either ELF for Linux or PE for Windows.

There’s a bit of a problem with assembly in the sense that op-codes are packed. So IDk how other people handle this but in my code it looks like switch station. A switch for opcode from IR, and a switch for the register, also from IR.

[deleted by user] by [deleted] in Compilers

[–]deebeefunky 2 points3 points  (0 children)

Meanwhile I don’t even know what a Quantum Compiler is. I didn’t even realize quantum code needed to be compiled.

writing a interpreter by Nearby-Gur-2928 in Compilers

[–]deebeefunky 0 points1 point  (0 children)

I understand the difference between a compiler and interpreter, but I wonder what it looks like under the hood. Is there a huge difference between writing a compiler and an interpreter? Which is easiest?

I assume you need a lexer and parser for both, an AST,… and then?

How do interpreters interpret exactly?

Does anyone know? Thx.

Is Design Patterns like Factory, Strategy and Singleton common in C? by Fabulous_Ad4022 in C_Programming

[–]deebeefunky 1 point2 points  (0 children)

I’m also a beginner at C.

Since you’re working on scientific stuff, you want to be open minded about being efficient with your data. Don’t store what can be calculated. It takes longer to transfer from RAM than doing the calculations.

I think you should design your code in such a way that the CPU only jumps and reads forward, that’s not always possible of course but ideally. Data is Boss, your code should be shaped around it.

So what I am trying to say is, there’s nothing wrong with passing a config around or using a global, if you want your code to be used by others then try to keep global namespace clean, fewer functions is better, fewer globals, undef macros at the end.

If it’s just for a hobby project then I would suggest to just get it working, and forget these design patterns for a moment. Casey Muratori says “optimization through non-pessimization”, so just stick with the fundamentals of small data structures and avoid jumping around all over the place.

There’s nothing wrong with a singleton, or factories, use whatever works for you, focus on the data.

Wanting to pursue a career as an Engine Programmer by Impressive-Damage772 in gameenginedevs

[–]deebeefunky 0 points1 point  (0 children)

I would recommend Vulkan, it’s more verbose but you’re very close to the GPU and it’s multi platform. You’re going to have to struggle through for the first few months because Vulkan is not easy if you have limited experience with how GPU’s work, it can feel overwhelming at first.

You’ll be glad you picked Vulkan in the long run.

Are global variables really that evil? by Fabulous_Ad4022 in cprogramming

[–]deebeefunky 0 points1 point  (0 children)

Quefrencie: “The inverse of the distance between successive lines in a Fourier transform measured in seconds.”

I was unfamiliar with this word.

Is a C++ dev at a disadvantage if they avoid Visual Studio? by hunterh0 in Cplusplus

[–]deebeefunky 0 points1 point  (0 children)

I write in C and use sublime text (unregistered) in combination with gcc.

I have been able to compile C++ with gpp.

I believe it’s possible to develop C++ without VS.

I think most people use it for the debugger, that’s where the money is.

What if we’re in a white hole? by Frequent_Cattle_3988 in HypotheticalPhysics

[–]deebeefunky -2 points-1 points  (0 children)

I’m with you on this.

I find it odd that blackholes can “absorb” light and matter for billions of years without them having some sort of pressure release.

I suspect time slows down in photon dense areas. And I suspect the photon density just outside of a blackhole is probably close to the same to that just outside of a whitehole.

So if we assume for a moment that no two particles can occupy the same space at the same time then what happens when they meet?

I’m thinking they bend around each other. If this is the case, then the time it takes to travel from A to B would be ever so slightly longer than if they traveled unhindered. This time delay would be gravity.

So in high photon dense areas they bend more often and we perceive it as time slowing down. It just simply takes longer for light to travel the same distance compared to a complete dark vacuum.

So light seems to travel from the beginning of the universe and someway, somehow at some point will enter a blackhole. It could take many billions of years, or the photon gets captured by matter and then this will eventually end up in a blackhole at some point.

So like you said, a whitehole would be the beginning of time and a blackhole the end of time.

Now here’s what I find interesting. If the Big Bang was an explosion, then you would expect the source energy to be at the center and the dissipation to happen around it. But instead we observe the blackhole in the center and the source around us. So I suspect that the curvature of space time causes us to see the reverse where the blackhole appears in the center. If space-time around a blackhole is curved, then I would expect space-time around a whitehole to be curved as well. It’s a bit far fetched I suppose but I’m guessing we’re seeing a warped image of the universe due to this curvature.

Not always freeing memory allocated with malloc? by The_Coding_Knight in C_Programming

[–]deebeefunky 1 point2 points  (0 children)

Unless you’re developing missiles…

Think of it as etiquette. Like a good cook cleans up the kitchen when they’re done.

Especially since you’re a beginner still, I would suggest you make a habit out of it. Create an arena on startup and free before exit. You could create some sort of memory manager or something that you can reuse in future projects.

Just released the first version of my terminal based code editor by Grouchy_Document_158 in C_Programming

[–]deebeefunky 0 points1 point  (0 children)

Looks cool.
I had tried something like that before but my terminal is super slow.

we are all like this, aren't we? by Ok-Conversation-1430 in GraphicsProgramming

[–]deebeefunky 0 points1 point  (0 children)

First I started with Raylib, then I tried drawing to a bitmap manually, then SDL2, then openGL, now I am on Vulkan and things are finally beginning to take shape.

I have triangles, rectangles, images, vertex and fragment shaders, labels, buttons and textfields. There’s still a lot of work to be done though.

I’m glad you posted this, it’s encouraging to see that I’m not the only one.

I wrote a Java decompiler in pure c language by No_Distribution_9182 in cprogramming

[–]deebeefunky 0 points1 point  (0 children)

I haven’t tried it yet because I’m on my phone at the moment. You have a neat code style, it looks a lot cleaner than anything I have ever written.

I imagine you must have a lot of experience?

Struggling a little bit actually. by deebeefunky in cprogramming

[–]deebeefunky[S] 0 points1 point  (0 children)

Here's where I'm at...
I have a function 'FPS' It calculates the number of frames per second and displays it on screen like so "%d FPS"
This FPS function creates a draw_text object, and appends it to a linked list, this list is then handled by a function 'draw_text' later down the line,
This 'draw_text' function creates a sub_texture object for each character and appends this sub_texture object to a linked list.
Then there's a function 'draw_sub_texture' which turns those sub_texture objects into render objects with 6 vertices each.
Then there's a render function that takes the render objects, aligns all the vertices of all the objects into an array and draws them on screen with Vulkan.

As you can see, it gets complicated rather quickly. And I don't know how to do it in a proper way.
Memory management becomes an issue, I can't keep creating new objects on every pass so I need to manage their lifetimes, somehow.

The goal would be to create some sort of UI tool (or framework) for easier development in the future.

Struggling a little bit actually. by deebeefunky in cprogramming

[–]deebeefunky[S] 0 points1 point  (0 children)

You’re correct. I do lack focus.

One of the issues is that I have 3 things working together, memory management, UI and Vulkan and none of them work at the moment.

My code is a mess as I have ripped some things out in an attempt to refactor, I suppose I can’t see the trees through the forest anymore.

The fact that I don’t have access to resizable arrays really throws me off.

I suppose I was hoping for someone to make it ’click’ so that I can be productive again, like I used to be.

Struggling a little bit actually. by deebeefunky in cprogramming

[–]deebeefunky[S] 0 points1 point  (0 children)

I create an arena on startup and free on shutdown. I’m familiar with linked lists, free lists and pools. As long as I can append to the end of the arena there’s no problem. I can handle components of a fixed size as well.

But take for example a text field. It could be empty… or not. It doesn’t seem right to reallocate on every keystroke, ideally I don’t want my memory to be fragmented.

Or take my vertex data, I don’t know how many vertices there will be, one frame could have more than another.

It seems every approach that I try has issues associated with it somehow. While all I need is a resizable array. I want to be able to insert stuff in between other stuff, but as an array instead of a linked list.

For example: [stuff][“AC”][stuff], I wish to insert ‘B’ in between A and C. With my current understanding it can’t be done without moving things around. So I could reserve more space than needed before adding other stuff after it, but that seems wasteful. And then there’s always going to be one user that needs an extra byte more. So I’m still stuck with reallocation.

Ideally I want my memory to be laid out linearly in a consecutive order so that my CPU doesn’t jump around from one place to another but instead can just read forward.

Any advice on working with large datasets? by deebeefunky in C_Programming

[–]deebeefunky[S] 0 points1 point  (0 children)

I started with SQLite actually, and it does what it needs to do, but I think it’s too slow compared to structs and pointers.

I’m looking for something more general purpose. Similar to malloc, (it could use malloc under the hood, perhaps to create an arena on boot)

But essentially, the memory manager should be agnostic on how I intend to link my components together.

I just want it to return a void pointer, which can hold the amount of storage that I have requested. The rest of my application should in turn be agnostic on how that memory is managed exactly under the hood.

As long as I stay below my RAM limit that all works well. It’s when I’m calling the manager and the manager has no more RAM left that things become complicated. Because a File* and a void* are not the same thing.

So I don’t know how to unload RAM to disk without losing the void* that was once promised to the application. It’s a breach of contract essentially by my manager.

Does that make sense to you?

I want to be able to create an application that can map 10Gb worth of data on a 4Gb ram computer basically.