Skip to content

Add the C, CPP, JavaRS, KotlinC, KotlinSync, PHP, Ruby Getting Started Code - #3

Open
tmcneil-mdb wants to merge 3 commits into
mainfrom
Migrate-Getting-Started
Open

Add the C, CPP, JavaRS, KotlinC, KotlinSync, PHP, Ruby Getting Started Code#3
tmcneil-mdb wants to merge 3 commits into
mainfrom
Migrate-Getting-Started

Conversation

@tmcneil-mdb

@tmcneil-mdb tmcneil-mdb commented Aug 20, 2026

Copy link
Copy Markdown

Description

Adds the remaining six Get Started sample applications — C, C++, Java Reactive
Streams, Kotlin Coroutines, Kotlin Sync, PHP, and Ruby — mirroring the existing
go/hello-world, node/hello-world, python/hello-world, dotnet/hello-world,
and java/hello-world samples. Each app connects to a MongoDB deployment using
the connection string in the MONGODB_URI environment variable, seeds a few
sample product documents into the get_started.products collection, then
queries and prints one of them.

  • c/hello-world/ — sample app, CMake build (mongoc 2.0), README, .gitignore
  • cpp/hello-world/ — sample app, CMake build (mongocxx 4.0), README, .gitignore
  • java-rs/hello-world/ — sample app, Maven build (mongodb-driver-reactivestreams via mongodb-driver-bom 5.9.1, Project Reactor 2025.0.0, Java 21), README, .gitignore
  • kotlin-coroutine/hello-world/ — sample app, Maven build (mongodb-driver-kotlin-coroutine 5.9.1, Kotlin 2.1.0), README, .gitignore
  • kotlin-sync/hello-world/ — sample app, Maven build (mongodb-driver-kotlin-sync 5.9.1, Kotlin 2.1.0), README, .gitignore
  • php/hello-world/ — sample app, Composer manifest (mongodb/mongodb 2.0, ext-mongodb 2.0), README, .gitignore
  • Added the C, C++, Java Reactive Streams, Kotlin Coroutines, Kotlin Sync, and PHP,
    entries to the root README

This supersedes the following PRs, which targeted the wrong repository:

README changes

  • Added Windows commands throughout

Testing

All six samples were run end to end on macOS by following the documented
setup steps in each README, connecting to an Atlas deployment and confirming
the expected product document was printed.

JIRA

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds six MongoDB getting-started samples across C, C++, Java Reactive Streams, Kotlin, and PHP. Ruby is advertised but not implemented.

Changes:

  • Adds sample applications that seed and query products.
  • Adds build manifests, setup guides, and ignore rules.
  • Expands the root client-library index.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Adds client-library links.
c/hello-world/README.md Documents C setup and usage.
c/hello-world/hello-world.c Implements the C sample.
c/hello-world/CMakeLists.txt Configures the C build.
c/hello-world/.gitignore Ignores C build output.
cpp/hello-world/README.md Documents C++ setup and usage.
cpp/hello-world/main.cpp Implements the C++ sample.
cpp/hello-world/CMakeLists.txt Configures the C++ build.
cpp/hello-world/.gitignore Ignores C++ build output.
java-rs/hello-world/README.md Documents reactive Java usage.
java-rs/hello-world/src/main/java/HelloWorld.java Implements the reactive Java sample.
java-rs/hello-world/pom.xml Configures Java dependencies and execution.
java-rs/hello-world/.gitignore Ignores Maven output.
kotlin-coroutine/hello-world/README.md Documents coroutine sample usage.
kotlin-coroutine/hello-world/src/main/kotlin/HelloWorld.kt Implements the coroutine sample.
kotlin-coroutine/hello-world/pom.xml Configures coroutine dependencies and build.
kotlin-coroutine/hello-world/.gitignore Ignores Maven output.
kotlin-sync/hello-world/README.md Documents Kotlin Sync usage.
kotlin-sync/hello-world/src/main/kotlin/HelloWorld.kt Implements the Kotlin Sync sample.
kotlin-sync/hello-world/pom.xml Configures Kotlin Sync dependencies and build.
kotlin-sync/hello-world/.gitignore Ignores Maven output.
php/hello-world/README.md Documents PHP setup and troubleshooting.
php/hello-world/src/HelloWorld.php Implements the PHP sample.
php/hello-world/composer.json Declares PHP dependencies.
php/hello-world/.gitignore Ignores PHP-generated files.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread README.md
Comment thread cpp/hello-world/main.cpp
#include <charconv>
#include <cstdlib>
#include <iostream>
#include <string>

@mongoKart mongoKart left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude feedback! Also kicked off a Copilot review.

);

public static void main(String[] args) {
String uri = System.getenv("MONGODB_URI");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System.getenv("MONGODB_URI") is passed straight to MongoClients.create(uri) with no null check; if the user skips the export MONGODB_URI step (the exact failure the README tells them to check for), the app dies with a raw NPE/IllegalArgumentException stack trace instead of the friendly message the C, C++, and PHP versions print.

Mono.from(products.deleteMany(new Document())).block();
Mono.from(products.insertMany(SAMPLE_PRODUCTS)).block();

Document product = Mono.from(products.find(eq("name", "Wireless Mouse")).first()).block();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

product.toJson() derefs the result of find(...).first() unguarded; the Kotlin siblings use product?.toJson(). If the insert is silently filtered (e.g. a stale/different get_started.products state or a name mismatch), this is an NPE rather than "no output".

)

fun main() = runBlocking {
val uri = System.getenv("MONGODB_URI")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same unchecked System.getenv("MONGODB_URI") passed to MongoClient.create(uri); missing-env-var case fails with an opaque exception instead of the guarded message used in the other languages.

)

fun main() {
val uri = System.getenv("MONGODB_URI")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same unchecked System.getenv("MONGODB_URI") passed to MongoClient.create(uri); missing-env-var case fails with an opaque exception instead of the guarded message used in the other languages.

Comment thread cpp/hello-world/main.cpp
// Seed the collection so the app has data to query. Clearing the
// collection first keeps results consistent across repeated runs.
products.delete_many({});
products.insert_many(sample_products());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

products.delete_many({}) and insert_many(...) return values are discarded and find_one failure falls through with no output at all; combined with no else branch, a failed seed prints nothing and exits EXIT_SUCCESS, so the README's "verify MONGODB_URI" advice is the only signal a user gets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants