You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fcfca3b
Browse filesBrowse the repository at this point in the historyBrowse files
Add Gemini live sessions, mentor skill installer, and a C++ example
- google/gemini now has a real live-session runtime (build_google_payload,
stream_google), wired into run/review/cards alongside anthropic/openai/
ollama/llamacpp. Default model updated from the retired gemini-2.5-pro to
the rolling gemini-flash-latest alias.
- mentor skill installs the Claude Code / opencode skill from the CLI itself
(symlinks the repo from a git checkout, copies SKILL.md+templates+
references from a pip/pipx install) so that install path is not exclusive
to install.sh, which now delegates to it instead of duplicating the logic.
- examples/cpp.google.transcript.md: a live Gemini tutoring session transcript
on C++ (smart pointers vs raw pointers), demonstrating the new provider.
Docs (README, docs/commands.md, docs/providers.md, docs/skill.md,
references/providers.md) and CHANGELOG updated to match. 107/107 self-tests
passing.
**you:** I know C already, pointers and structs, want to learn modern C++ for a small game engine hobby project.
8
+
9
+
**mentor:** Welcome. I am Prof. Idris Ibrahim. It is a pleasure to meet you.
10
+
11
+
Coming from C gives you a tremendous head start: you already understand memory layout, pointers, and the cost of indirection. That said, C++ is not merely "C with classes." In fact, your biggest challenge will likely be unlearning several manual C habits in favor of modern C++ idiom—letting the type system and lifetime rules do the heavy lifting for you so your game engine doesn't become a swamp of manual memory tracking and silent bugs.
12
+
13
+
Before we chart our path toward your engine, I have three quick questions to calibrate our starting point:
14
+
15
+
1.**Diagnostic:** In your C work, when you allocate a dynamic array or manage a resource (like a file handle or a texture), how do you typically ensure it gets cleaned up safely? Have you ever encountered the concept of **RAII** (Resource Acquisition Is Initialization)?
16
+
2.**Scope:** What kind of engine are you planning to build (e.g., a simple 2D engine using a library like SDL, a software rasterizer, a 3D OpenGL/Vulkan engine, or primarily a core system like an Entity Component System)?
17
+
3.**Pace:** Roughly how many hours a week do you plan to invest in writing code and discussing it here?
18
+
19
+
Tell me about these three, and we will map out a concrete syllabus.
20
+
21
+
**you:** Can you explain what a smart pointer is compared to a raw pointer, with a tiny example?
22
+
23
+
**mentor:** In C, a pointer is just an integer holding a memory address. It has no brain: it does not know if it owns the memory, how large the allocation is, or when it should be freed.
24
+
25
+
A **smart pointer** in modern C++ is a small object (usually a lightweight struct/class template) that wraps that raw address. It behaves syntactically like a pointer—you can still use `*p` and `p->`—but it has an automated destructor. When the smart pointer leaves its scope (such as hitting a `return` statement or the closing curly brace `}`), it automatically frees the memory it points to.
26
+
27
+
Here is the contrast:
28
+
29
+
### The C / Raw Pointer Way
30
+
```cpp
31
+
voidrun_c_style() {
32
+
int* data = (int*)malloc(sizeof(int));
33
+
*data = 42;
34
+
35
+
if (some_error_condition()) {
36
+
// Danger: If you exit early here and forget to free,
37
+
// you have leaked memory.
38
+
return;
39
+
}
40
+
41
+
free(data); // Must manually remember this every time
42
+
}
43
+
```
44
+
45
+
### The Modern C++ Way (`std::unique_ptr`)
46
+
```cpp
47
+
#include<memory>
48
+
49
+
voidrun_modern_cpp() {
50
+
// Allocates an int on the heap and wraps it in a smart pointer:
51
+
std::unique_ptr<int> data = std::make_unique<int>(42);
52
+
53
+
if (some_error_condition()) {
54
+
return; // Safe! 'data' falls out of scope, memory is freed automatically.
55
+
}
56
+
57
+
// No free() or delete!
58
+
// When the function ends, 'data' goes out of scope and frees the memory.
59
+
}
60
+
```
61
+
62
+
Notice what is missing in the second example: there is no manual cleanup call.
63
+
64
+
Now, to make sure this clicks before we look deeper:
65
+
66
+
**If `data` is allocated inside an `if` block:**
67
+
```cpp
68
+
{
69
+
std::unique_ptr<int> data = std::make_unique<int>(100);
70
+
}
71
+
// <-- Right here
72
+
```
73
+
**In your own words, what happens to that heap memory the exact moment execution passes that closing brace `}`?**
0 commit comments