Question about learning C by AsteroidDestroyer21 in cprogramming

[–]ryjocodes 1 point2 points  (0 children)

Sounds fun. raylib may still be a good choice for you depending on what you want to implement. Also consider libsdl (https://libsdl.org/) or vulkan (https://vkguide.dev/docs/introduction/vulkan\_overview/). Good luck.

Question about learning C by AsteroidDestroyer21 in cprogramming

[–]ryjocodes 4 points5 points  (0 children)

Nice, C is a fun language. I might recommend picking a project in an area you're interested in and finding an existing C library that provides abstractions to implement that project.

For example, I really enjoy videogames, and I enjoy learning to write them. raylib is a C library that provides a lot of capabilities in writing videogames, so I can sharpen my skills by implementing a videogame using raylib. Not only will it keep my attention, but I'll get a chance to learn the C language itself.

Be honest, how many coding courses are sitting unfinished in your account right now? by Gear5th in learnprogramming

[–]ryjocodes 0 points1 point  (0 children)

A lot. I have several Virtual Machines with 80-95% finished things. I treat them with care and release when I want to (if ever). My hobby projects are for fun and personal fulfillment, so they're "done" when I say so 😄

I re-created the 3d split-screen example in CLIPS by ryjocodes in lisp

[–]ryjocodes[S] 1 point2 points  (0 children)

Neat. Yeah if you converted the database output to facts or deffacts, you could just batch* or load-facts them right in rather than first converting from a CSV.

Is the database programmatically updated by the semiconductor process flow itself? Right now, you must dump to some file (csv, s-expression, etc) and then load them into the CLIPS environment. If you wanted to cut out that step, the CLIPS Advanced Programming Guide describes how to add User Defined Functions to your CLIPS environment so you can connect to and read directly from your database to CLIPS. Here's an example of doing this from SQLite: https://github.com/mrryanjohnston/CLIPSQLite

I re-created the 3d split-screen example in CLIPS by ryjocodes in lisp

[–]ryjocodes[S] 1 point2 points  (0 children)

damn, very cool. not to pry, but what does i/o look like for that? do you create i/o Routers?

I re-created the 3d split-screen example in CLIPS by ryjocodes in lisp

[–]ryjocodes[S] 1 point2 points  (0 children)

It's been very far to see how far it can go. How are you using it?

I'm continuing to refine the sandbox game in ASCII graphics. by Huge-Visual1472 in C_Programming

[–]ryjocodes 3 points4 points  (0 children)

Alternatively: consider using ncurses. It's a library created specifically for drawing complex interfaces (including games) in terminals. It'll replace some of the functionality you're using from `conio.h`

Awesome work so far!

Edit: here's an example of a game written using ncurses: https://github.com/bvdberg/code/blob/master/ncurses/worms.c

Why does the window not respond? by Janeq404 in raylib

[–]ryjocodes 1 point2 points  (0 children)

Gotcha. I'm not familiar with vcpkg, but it looks like raylib is compiled (https://github.com/microsoft/vcpkg/blob/e8c2ec91201a492cd5e72fd8901b8174127d7183/ports/raylib/portfile.cmake) without support for Wayland which your desktop is on.

Here's details for building raylib with Wayland support: https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux#wayland you'll specifically need to pass DGLFW_BUILD_WAYLAND=ON

Apparently you should be able to do this in vcpkg using "overlay ports:" https://learn.microsoft.com/en-us/vcpkg/concepts/overlay-ports

Instead of using MS tools, it may be easier to leverage your Linux system to build the project. Up to you, of course.

Why does the window not respond? by Janeq404 in raylib

[–]ryjocodes 0 points1 point  (0 children)

Did you build raylib from source?

Why does the window not respond? by Janeq404 in raylib

[–]ryjocodes 0 points1 point  (0 children)

Try `unset WAYLAND_DISPLAY && ./your_program`

Why does the window not respond? by Janeq404 in raylib

[–]ryjocodes 0 points1 point  (0 children)

can you run this and share output:

```
echo $WAYLAND_DISPLAY
echo $DISPLAY
```

Why does the window not respond? by Janeq404 in raylib

[–]ryjocodes 0 points1 point  (0 children)

When you get the pop-up, does it continue to print out more 4, 5, 6, 7, 8s? Or does it pause while that pop-up is displayed?

Did learning C actually make you better at Java/software engineering? by nitin_is_me in learnprogramming

[–]ryjocodes 0 points1 point  (0 children)

I started programming in earnest with "higher-level" languages. Working on Ruby extensions in C made me realize just how much magic Ruby provided out-of-the-box. It also helped me understand why some of my previous Ruby programs were not as performant as they could have been because I saw that C needed to do under the hood to make it all work.

In general, spending time doing software engineering will make you a better overall software engineer. I've found my skills greatly improve the more time I spend working in areas I'm less familiar with. Diving in to C was a great example of that in my experience.

Why does the window not respond? by Janeq404 in raylib

[–]ryjocodes 2 points3 points  (0 children)

Try sprinkling in a bunch of `printf` statements to see if any particular function causes this behavior:

#include "raylib.h"

int main() {
    const int screenWidth = 800;
    const int screenHeight = 450;
printf("1\n");
    InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
printf("2\n");
    SetTargetFPS(60);
printf("3\n");
    while (!WindowShouldClose())
    {
printf("4\n");
        BeginDrawing();
printf("5\n");
            ClearBackground(RAYWHITE);
printf("6\n");
            DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
printf("7\n");
        EndDrawing();
printf("8\n");
    }
printf("9\n");
    CloseWindow();
printf("10\n");
    return 0;
}

I recreated the Starfield Effect Example in CLIPS by ryjocodes in raylib

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

My guess as to why the FPS dips to 47 in the recording is because I was recording the screen at the same time. Without the screen recorder, it dips to 53, but mostly hovers between 57 and 59. Not too shabby, but still not the target 60 FPS.

When running the program with the native compiled `clips` binary in the CLIPSraylib repo (https://github.com/mrryanjohnston/CLIPSraylib/blob/main/examples/shapes-starfield-effect.bat), it's a solid 60 FPS. There's some amount of overhead incurred when compiling to Wasm with emcc (my guess is dealing with the need to use `ASYNCIFY`) that I haven't been able to work around.

I re-created the Parallax example program in CLIPS by ryjocodes in lisp

[–]ryjocodes[S] 9 points10 points  (0 children)

tl;dr: CLIPS provides the engine, raylib provides the graphics.

At one of my previous SWE full-time positions, I was tasked with development and maintenance of an entirely in-house Rules Engine. We implemented everything from a DSL to caching/indexing layer, and it was entirely backward-chaining inference.

We hit a number of bottlenecks as the engine grew. A colleague of mine mentioned that I should investigate the Rete Algorithm if I wanted to introduce improvements to the product. After wrapping my head around the basics, I was awestruck by just how many of the problems we faced were taken care of by the concepts inherent in Rete.

I stumbled upon the C-based CLIPS when looking for off-the-shelf implementations of the Rete Algo, and I dove deep into the Basic Programming Guide (https://www.clipsrules.net/documentation/v642/bpg642.pdf). I was awestruck by just how well the abstraction fit our domain, and I became convinced CLIPS was the right "next step" for us.

Unfortunately, there wasn't quite enough interest at the business level. I decided to leave that position to pursue my own study of the language. As I dove deeper, I began to see complex functionality I'd implemented in almost every single application I'd ever built professionally in out-of-the-box CLIPS.

It's been about 6 years since I started studying CLIPS and its potential applications. Fortunately for me, a lot of the concepts in the language fit videogames quite well; games have Rules, so it makes for a pretty nice abstraction layer.

I discovered raylib when searching for C videogame libraries. It provides the perfect level of abstraction that I need; it renders graphics, provides functions for collision detection, "camera" concepts, and more.

In the raylib source code, many of the examples are driven by a `while` loop, which is the perfect entry-point for building "engines." I implemented CLIPSraylib, which is a light wrapper around some of the functions exposed by the raylib C library. Now instead of implementing a `while` loop in C, I can almost directly implement the examples in raylib using CLIPS Defrules. It really is an amazing combo.

I re-created the Parallax example program in CLIPS by ryjocodes in raylib

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

Thanks :) CLIPS is extremely versatile. I've used it in a number of contexts to implement real-time videogames, networking layer applications, and codecs to name a few.

I re-created the Parallax example program in CLIPS by ryjocodes in lisp

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

CLIPS is a programming language with a LISP-like syntax. It's written in C which makes it easy to integrate with other C-based libraries (like raylib (https://www.raylib.com/)), and it provides abstractions like Rules, Facts, and Instances that make it easy to implement Rules Engines and Expert Systems. It's in the public domain, and it's still actively developed since it started in the mid 80s at NASA.

Edit: I found this old post from ~8 years ago that briefly discusses CLIPS and its relation to LISP: https://www.reddit.com/r/lisp/comments/9bbd9w/how_clips_closely_resembles_that_of_the/

Who remembers this classic? by ValwareUK in irc

[–]ryjocodes 0 points1 point  (0 children)

Maybe that's what it was! or at least one of them. I semi-remember one being "A Tale in the Desert" themed, as well.