Tumgik
#Cplusplus
izicodes · 8 months
Text
Learning C++ | Log #1
Tumblr media
Friday 20th October 2023
I have been studying C++ for some time now, and I'm really happy with my progress. I really thought it was a super difficult programming language (I am jinxing it right now, aren't I?), but what I mean is that even the beginner stuff would be hard. But it's not!
Two days ago, I stumbled upon a website called Saymor Academy, buried seven pages deep in Google. I decided to check out the CS107: C++ Programming course, and I'm so glad I did! I've been learning so much, and it's been a blast, especially since I'm taking the course along with my friend over on Discord teaching me C++ too.
Learning can be challenging, but it's also incredibly rewarding. Once I master the basics, I'll be able to create all sorts of amazing things. I can't wait!
In the meantime, I'm just enjoying the journey~! So if you're ever thinking about learning C++, I highly recommend checking out Saymor Academy. It's a great resource, and it's a lot of fun!
☆ What I learnt today...
History of C++
Syntax
Comments
Data types
Variables
User Input
Tumblr media
⤷ ♡ my shop ○ my mini website ○ pinned ○ navigation ♡
148 notes · View notes
miquerinus · 9 months
Text
Tumblr media
Day 5 - 100 days of code with C++
One of the main or fundamental characteristics of any programming language is Functions, but why? Because functions help us maintain order, organization, and also greatly assist in inevitable future maintenance of our code. All the dynamics of programs are carried out through functions.
What are functions ?
But what are functions? Functions are generally small pieces or parts of code that exist outside the main scope of the program, meaning they are code snippets that are called by the function's identifier (name) and also by its return type for that functionality. Therefore, they are responsible for performing a specific task in our program, such as processing a piece of data or a certain number of data that other parts of the program do not handle.
Imagine a program that requests 3 grades to calculate the student's average. Although the program is simple, you can break it down or divide it into parts for future modifications.
Tumblr media
All functions must be specified by a type, meaning the type of data they will return. Return types in C++ basically come down to: integer, float, boolean, and void, with the latter not returning any value.
What Not to Do - Typical Errors
Do not give functions names that are not clear about their functionality. This makes the code harder to read and, consequently, more time-consuming when it comes to maintenance or corrections.
In C++, there is an order that functions must follow to avoid errors during compilation.
Tumblr media
Notice that now the program's organization has changed. 1) Incredibly, this will result in a compilation error. Why? Because the C++ compiler does not find the function mediaFunction() - now you might be thinking, "But why, since mediaFunction() is there in main()?" For the C++ compiler, there is an order.
But how do you solve this problem in C++? There are 2 options: a) You declare the function at the beginning of the code, or b) you place the function before main. However, there is a problem with this last detail. What if another function A calls function B, and function B calls function A?
We would have the same problem again. Therefore, what must be done is to declare a prototype of the function at the beginning.
Tumblr media
Conclusion:
From the little shown here about functions, it is clear that this is a fundamental skill for anyone aspiring to be a good programmer. I tried not to go into too many details because the intention is not to be a course on how to create, but at least to make it a little clear about the fundamental aspect of functions within any code.
17 notes · View notes
codingcorgi · 5 months
Text
Tumblr media Tumblr media
Days 34-42 of coding everyday for a year and man has it been busy 😮‍💨
First of all I've been working very hard in my C# class and I have been impressing my teacher as per usual. Then C++ has been going well learning the syntax of C++ has been a journey, because it's very different from what I'm used to with C#. Then I have been coding more of the Unity game my studio has been working on adding a difficulty system, and a main menu settings page. The UI is much to be desired, but I'm still learning.
The next few days I'll be working on more C# homework, practicing C++, and working on json files for the game to create viewers for the chat.
10 notes · View notes
devhubby · 11 months
Text
34 notes · View notes
b8horpet · 1 year
Text
Tumblr media
45 notes · View notes
lostjared · 5 months
Text
Old Acid Cam video
3 notes · View notes
ww92030 · 7 months
Text
Playable version of The Witness on a Protogen. (ESP32 Connected via LAN)
4 notes · View notes
aminiallight · 3 months
Text
I've released a clang tidy for C/C++ that finds division by non-constant values to help you search for possible division-by-zero in your codebase!
This is mostly a tool I built for myself to help with LMOD development but others might find it useful too
3 notes · View notes
blubberquark · 6 months
Text
Wish List For A Game Profiler
I want a profiler for game development. No existing profiler currently collects the data I need. No existing profiler displays it in the format I want. No existing profiler filters and aggregates profiling data for games specifically.
I want to know what makes my game lag. Sure, I also care about certain operations taking longer than usual, or about inefficient resource usage in the worker thread. The most important question that no current profiler answers is: In the frames that currently do lag, what is the critical path that makes them take too long? Which function should I optimise first to reduce lag the most?
I know that, with the right profiler, these questions could be answered automatically.
Hybrid Sampling Profiler
My dream profiler would be a hybrid sampling/instrumenting design. It would be a sampling profiler like Austin (https://github.com/P403n1x87/austin), but a handful of key functions would be instrumented in addition to the sampling: Displaying a new frame/waiting for vsync, reading inputs, draw calls to the GPU, spawning threads, opening files and sockets, and similar operations should always be tracked. Even if displaying a frame is not a heavy operation, it is still important to measure exactly when it happens, if not how long it takes. If a draw call returns right away, and the real work on the GPU begins immediately, it’s still useful to know when the GPU started working. Without knowing exactly when inputs are read, and when a frame is displayed, it is difficult to know if a frame is lagging. Especially when those operations are fast, they are likely to be missed by a sampling debugger.
Tracking Other Resources
It would be a good idea to collect CPU core utilisation, GPU utilisation, and memory allocation/usage as well. What does it mean when one thread spends all of its time in that function? Is it idling? Is it busy-waiting? Is it waiting for another thread? Which one?
It would also be nice to know if a thread is waiting for IO. This is probably a “heavy” operation and would slow the game down.
There are many different vendor-specific tools for GPU debugging, some old ones that worked well for OpenGL but are no longer developed, open-source tools that require source code changes in your game, and the newest ones directly from GPU manufacturers that only support DirectX 12 or Vulkan, but no OpenGL or graphics card that was built before 2018. It would probably be better to err on the side of collecting less data and supporting more hardware and graphics APIs.
The profiler should collect enough data to answer questions like: Why is my game lagging even though the CPU is utilised at 60% and the GPU is utilised at 30%? During that function call in the main thread, was the GPU doing something, and were the other cores idling?
Engine/Framework/Scripting Aware
The profiler knows which samples/stack frames are inside gameplay or engine code, native or interpreted code, project-specific or third-party code.
In my experience, it’s not particularly useful to know that the code spent 50% of the time in ceval.c, or 40% of the time in SDL_LowerBlit, but that’s the level of granularity provided by many profilers.
Instead, the profiler should record interpreted code, and allow the game to set a hint if the game is in turn interpreting code. For example, if there is a dialogue engine, that engine could set a global “interpreting dialogue” flag and a “current conversation file and line” variable based on source maps, and the profiler would record those, instead of stopping at the dialogue interpreter-loop function.
Of course, this feature requires some cooperation from the game engine or scripting language.
Catching Common Performance Mistakes
With a hybrid sampling/instrumenting profiler that knows about frames or game state update steps, it is possible to instrument many or most “heavy“ functions. Maybe this functionality should be turned off by default. If most “heavy functions“, for example “parsing a TTF file to create a font object“, are instrumented, the profiler can automatically highlight a mistake when the programmer loads a font from disk during every frame, a hundred frames in a row.
This would not be part of the sampling stage, but part of the visualisation/analysis stage.
Filtering for User Experience
If the profiler knows how long a frame takes, and how much time is spent waiting during each frame, we can safely disregard those frames that complete quickly, with some time to spare. The frames that concern us are those that lag, or those that are dropped. For example, imagine a game spends 30% of its CPU time on culling, and 10% on collision detection. You would think to optimise the culling. What if the collision detection takes 1 ms during most frames, culling always takes 8 ms, but whenever the player fires a bullet, the collision detection causes a lag spike. The time spent on culling is not the problem here.
This would probably not be part of the sampling stage, but part of the visualisation/analysis stage. Still, you could use this information to discard “fast enough“ frames and re-use the memory, and only focus on keeping profiling information from the worst cases.
Aggregating By Code Paths
This is easier when you don’t use an engine, but it can probably also be done if the profiler is “engine-aware”. It would require some per-engine custom code though. Instead of saying “The game spent 30% of the time doing vector addition“, or smarter “The game spent 10% of the frames that lagged most in the MobAIRebuildMesh function“, I want the game to distinguish between game states like “inventory menu“, “spell targeting (first person)“ or “switching to adjacent area“. If the game does not use a data-driven engine, but multiple hand-written game loops, these states can easily be distinguished (but perhaps not labelled) by comparing call stacks: Different states with different game loops call the code to update the screen from different places – and different code paths could have completely different performance characteristics, so it makes sense to evaluate them separately.
Because the hypothetical hybrid profiler instruments key functions, enough call stack information to distinguish different code paths is usually available, and the profiler might be able to automatically distinguish between the loading screen, the main menu, and the game world, without any need for the code to give hints to the profiler.
This could also help to keep the memory usage of the profiler down without discarding too much interesting information, by only keeping the 100 worst frames per code path. This way, the profiler can collect performance data on the gameplay without running out of RAM during the loading screen.
In a data-driven engine like Unity, I’d expect everything to happen all the time, on the same, well-optimised code path. But this is not a wish list for a Unity profiler. This is a wish list for a profiler for your own custom game engine, glue code, and dialogue trees.
All I need is a profiler that is a little smarter, that is aware of SDL, OpenGL, Vulkan, and YarnSpinner or Ink. Ideally, I would need somebody else to write it for me.
6 notes · View notes
devsnews · 1 year
Link
MIT computer scientists and their colleagues, however, believe they've found a way to have it all – the approachability of a high-level language with the speed of a low-level language. They've developed a Python compiler called Codon that turns Python code into native machine code without a runtime performance hit.
7 notes · View notes
frog707 · 9 months
Text
No bug is too old, no coder is too young ...
2 notes · View notes
izicodes · 5 months
Note
hello!!!! you’re one of the ppl on this app i look forward to a lot hehe 🫶🫶 ive been stuck on a c++ problem for a week now and the people i usually ask for help (my seniors) are busy with life so i currently feel that my coding progress has hit a serious roadblock 🥲🥲 can i reach out to you for help by dms? (in other words are you free enough to help me) thanks so much queen
-pri
Hiya!
I am so terrible at C++ I’m so sorry! I started learning for a mate but never really progressed in it 🥲
But they are C++ programmers on here that I follow, I’m pretty sure @zoeythebee uses C++ so they might help you!
Anyone else that is a C++ programmer that can help Pri, please reach out! Thank you so much!
Help you get the help you need! 🙋🏾‍♀️🙏🏾💓
*reminds me I should list the technologies I use on my pinned post so people know what I use and what I have no clue in 😭
**I do have the list of technologies I use on my pinned post nvm-
14 notes · View notes
terminalroot · 10 months
Video
youtube
Como Criar um App pra Web com Vue.js, TailwindCSS e C++
2 notes · View notes
codingcorgi · 5 months
Text
Tumblr media
Tumblr media
Day 18 of coding everyday for a year. I am having migraines lately so it's late again, but better late than never.
I worked on the view journals page and fixed some backend code. I still need to make it so that the journals save on the device.
Today other than doing HTML/CSS homework, I'll be working on getting Puppy Tasks Journal entries to save on the device. I also need to work on notifications.
4 notes · View notes
devhubby · 1 year
Text
20 notes · View notes
b8horpet · 1 year
Text
Tumblr media
image credit
10 notes · View notes