Cloud Code: A Game Changer for Programming
Hai Dalu introduces Cloud Code, a tool he believes will revolutionize programming for both programmers and designers. This series will span three episodes, covering basic demonstrations to advanced skills, with deeper dives into more games if the content proves popular. This first episode focuses on demonstrating the capabilities of Cloud Code through a real-time example, followed by experience sharing.
Real-time Demonstration: Switching Video Rendering from Cloud to Local
The demonstration revolves around modifying a simple video editor to change its video rendering process from the cloud to local execution. Previously, N8n plus Remotion was introduced. The goal is to replace the cloud-based Remotion rendering service with a local rendering setup for faster adjustments and cost savings.
Creating a Video Model
The first step involves creating a video model using Remotion's official model. While AI tools are powerful, a well-structured model remains crucial. The third model is recommended due to its understanding of React, Next.js, and Tailwind CSS.
Setting Up the Project
The project structure is examined in WebStorm. The relict package is installed to open the service. Initially, the service interface displays a player where text attributes can be modified and rendered into a video. However, the rendering process currently relies on a cloud-based service.
Implementing Local Rendering with Cloud Code
The objective is to make the "rendering video" action trigger local rendering instead of relying on the cloud service. This is achieved using Cloud Code. A new terminal is opened, and the project code warehouse is accessed. The command cloud back to the car
is executed.
Analyzing the Project with Cloud Code
The initial step when using Cloud Code on any project is to allow it to understand the entire project. This is achieved by using a specific command that scans the code warehouse, recording key details such as code style, project structure, main functions, and API interfaces. This information is stored in a cloud.md
file, a core module for Cloud Code operations.
Replacing AWS NEM with Local Rendering
The task is to replace AWS NEM with a function to adjust it to local rendering logic. The command change the video rendering to local rendering
is used. A crucial step is to have Cloud Code analyze the demand first before directly executing the modification. This approach of "analyze first, then execute" yields better results than immediate execution.
Reviewing and Executing the Proposed Changes
Cloud Code generates a rough result, outlining the rendering process, involved interfaces, document acquisition, core technology changes, and implementation plans (synchronization and one-step). The proposed changes are reviewed. Once the idea is approved, the execution begins.
Real-time Experience Sharing
The experience reveals the step-by-step execution of tasks. The process involves adapting the API schema and installing necessary dependencies like RemotionRenderer. Cloud Code also handles parameter type repairs.
Addressing Type Errors and Connecting to APIs
Cloud Code aids in resolving type errors, a previously disliked aspect of coding. It identifies the need for a random media API and prompts for network access to check remote files before proceeding.
Overcoming Challenges and Providing Guidance
The AI initially encounters compatibility issues in the Next.js construction environment, attempting to change the rendering logic unnecessarily. The user, acting as a "technical leader," intervenes and redirects Cloud Code, emphasizing the need for local operation only.
Verifying the Implementation
After Cloud Code completes the four-step process, the result is tested. While the video is rendered, the sample is missing. The user informs Cloud Code about the missing sample after the local rendering. Cloud Code identifies a potential issue with the local rendering webpack configuration and its handling of Taiwan's CSS.
Refining the Solution
Cloud Code proposes an npm build
, which the user cancels due to familiarity with the error. Restarting the Next.js service temporarily fixes the issue, but inconsistencies persist. The task of sustainable memory management is addressed by having Cloud Code write the task to a file, achieving sustainability in a simple way.
Final Result
The final result is a complete video with the intended local rendering.
Conclusion
Cloud Code can be a very powerful tool. Hai Dalu describes Cloud Code as working with a smart and tireless programmer. It enables rapid prototyping and idea realization by handling intricate details related to front-end logic, back-end APIs, rendering SDKs, and front-end bundling. Cloud Code accelerates development and avoids common pitfalls through appropriate prompting and guidance.
The next episode will explore advanced techniques and practical applications of Cloud Code, focusing on effective collaboration and avoiding common issues.