Categories
CS 462

Blog Post #3 – Wrapping Up

My senior project journey has been a very interesting experience. I would say that our most difficult journey would be losing two out of our five team members. My team handled these losses pretty well, but we had to make some sacrifices on the parts of the project we wanted to work on to fill in the missing pieces. Personally, I took the initiative to develop these missing components, ensuring they were completed to a high standard and remained accessible for the rest of the team.

The hardest chunk to fill in was the project’s machine learning / AI aspect. One of the main goals of our project was to use computer vision to somehow create a self-driving car. We were not given any constraints or tips for this, just more of an end goal. Initially, we planned to have many advanced features that sounded cool on paper, but we ended up constraining our scope due to the difficulty of implementing some of those features. We had been planning on using reinforcement learning to control our vehicle for a while, but we recently found out that it would not be that feasible to implement in this project.

I chose this project because I thought working with a gaming engine built with the Rust programming language would be cool. We were also given a list of areas we could focus on for the project. One of these areas was graphics shaders, which I was looking forward to. Unfortunately, once the project was underway, I was told that our focus was now autonomous driving, which is interesting but not something I would have picked myself. On top of that, I have not seen a single company that uses Rust or Bevy for game development, as most of them use Unity or Unreal. While I can still put this on my resume, it may not be as impactful as a shader project would have been or creating a game in one of the more popular engines.

Categories
CS 462

Blog Post #2 – Technologies

Virtually everything that is being used in our senior project is new to everyone in our group. The main thing, Bevy, is a game engine that is written in Rust. The cool thing about Bevy is that it is entirely open-source, which means anyone can contribute to it. While the engine is by far the most developed Rust game engine, it still lacks some features that all other big game engines have, like an editor or official tutorials. Nonetheless, we are making some good progress even with these limitations.

One of my favorite parts about working with Bevy is the fact that it is written in and uses Rust. In the grand scheme of things, I am still new to coding. This means it can be easy for someone like me to make small mistakes that can be a big problem for the stability of a program. Rust is a language that helps prevent many of these minor issues by checking everything at compile time. While it sometimes makes developing an application a little slower, once something I write in Rust works, it continues to work.

Due to Bevy still being pretty new, if I could start over, I think that I would do a project in either Unreal Engine or Unity. One of the main points of working on this project is to help build my resume, and I still have yet to find one job listing that lists Bevy as a nice to have. However, Bevy uses an ECS or Entity Component System, which is something Unreal Engine is slowly adapting to. Who knows? Once it gets more complete, I have a feeling Bevy will be a strong contender in the game engine space, especially since there are no licensing fees.

Categories
CS 462

The Hidden Implications of Clean Code

Since the start of my programming career, I have always found it satisfying to rewrite my code in a way that does the same thing but is easier to understand. So, one might assume I am an avid supporter of “clean code,” which is actually not the case. There are quite a few benefits to writing clean code, but there are also some downsides that people forget to talk about.

Good Practices of Clean Code

Starting with the benefits of clean code, there are a few tactics one can use to make their code easier to read without much effort:

Avoid Deep Nesting

Every time you nest something that is one extra step the person reading your code has to keep in their mind. If possible, try to collapse nested structures into one level. If the code has already been executed beyond a certain point, then the previous code no longer needs to be taken into consideration.

Bad Example:

javafunction calculateTaxes(user, cart) {
    if (!isMaintenancePeriod) {
        if (user.isAuthenticated) {
            if (user.isAuthorized) {
                if (cart.total > 0) {
                    // Deep nested logic
                }
            }
        }
    }
}

Better Approach:

javafunction calculateTaxes(user, cart) {
    if (isMaintenancePeriod) return null;
    if (!isValidUser(user)) return null;
    if (!isValidCart(cart)) return null;
    
    return calculateRegionalTax(user, cart);
}

Eliminate Code Duplication

While I do not think you have to extract everything, especially if you are only using it once, you should try to extract logic into reusable functions. By centralizing repeated logic, you can make code more maintainable.

Use Meaningful Names

Some programmers find coming up with good names challenging, but this does not mean we should give up entirely. When naming variables, you should at least use descriptive names that clearly convey purpose and intent. This makes code more self-documenting and can eliminate the need for some comments.

Bad Example:

pythondef calc(a, b):
    res = 0
    tmp = a
    for i in range(b):
        res += tmp
    return res

Better Example:

pythondef multiply(multiplicand, multiplier):
    product = 0
    currentValue = multiplicand
    for count in range(multiplier):
        product += currentValue
    return product

Where the Problems Start

I do not think clean code is a bad idea, but I have a few issues with it.

First, not everyone agrees on what “clean code” means. Does it mean having very short functions? Does it require continuously extracting functions to make them more abstract? Do functions really have to only do one thing? The answer to these questions, and many more, will change depending on who you ask.

Now, there are a few things I do not like that are sometimes considered “clean code.” First, the idea to keep functions extremely short (2-4 lines) is impractical and can lead to fragmented, hard-to-follow code. Excessive function granularity makes code harder to follow by forcing readers to jump between tiny functions.

Another issue is that premature optimization of code flexibility can lead to it becoming unnecessarily complex. I have noticed that writing clean code sometimes leads to over-engineering and feature overload. If you follow something like the DRY principle 100% of the time, it can lead to over-abstraction and hard-to-maintain code. People spend so much time turning a simple program into a framework-like program when they could have used the time better somewhere else.

I recently read an article that discussed some of the issues with “clean code,” specifically Robert C. Martin’s Clean Code book, more in-depth. The book itself is already pretty outdated, but it is an interesting article.

When Clean Code Is Worse

Here is a video that talks about how clean code principles can significantly hurt performance: “Clean” Code, Horrible Performance

In short, this video talks about and gives examples of how common “clean code” principles can impact software performance. One of the examples the YouTuber gave was using polymorphism over switch statements and hiding internal implementations, which can make code 15-24 times slower since it requires more cycles. Now, there are languages like Rust that let you do zero-cost abstractions, but that is not the case with many languages. The video goes into more advanced options, which significantly improved performance but broke even more “clean code” rules.

Now, clean code is not necessarily a bad thing, but one should not blindly follow these rules without considering their significant performance implications.

Categories
Uncategorized

Blog Post #3 – Off to a great start

My main focus for this senior project is the User Interface. Personally, I feel it can be hard to show off a project when interacting with said project is clunky and confusing. Since our project does not have a specific style, I decided I wanted to make a dark, simple interface that anyone could understand. I might end up stylizing it somehow, but the built-in UI tools with the game engine we are using are somewhat limited. Who knows? Our game engine, Bevy, gets significant releases every few months, and I know they plan on overhauling their UI system at some point.

I have implemented a few UI areas. There is a main menu one can use to join the world or exit the game. A simple pause menu gives the user a few options while the game is running. Since our game has a vehicle, I added a speedometer overlay that will eventually update the car’s speed in real-time. I also added a secondary camera view that will ultimately be used by the car’s AI for self-driving. There have been no significant breakthroughs in the project, but that is understandable since the project is just starting out.

On the work side, applying for internships is still the season. Last year, I did not hear back from many places, so I decided to redo my portfolio website. I am a fan of Blizzard games, so I decided to make an interactive version of their battle.net launcher on my website.

Link to portfolio: https://johnklucinec.vercel.app/

I look forward to seeing what my team will create in the upcoming semesters.

Categories
CS 461

Blog Post #2 – First Major Milestone

After weeks of research and planning, my team finally had the chance to start coding. Our project is a little different from other teams since we are doing an industry project. This means our project is being guided by someone in the industry instead of being solely about the team.

For our project, we are using the Bevy game engine. This is a game engine which uses and is built with Rust. For me, I wanted my senior project to be written in either Rust or C++, so I am happy with the tech stake we chose. However, one thing to keep in mind is that Bevy is still a relatively new game engine. This means that there are fewer guides and resources to learn than what engines like Unity or Unreal have. Nonetheless, I think my team will be able to pull through, even though some are new to both Rust and Bevy.

One challenge I am currently facing with Bevy is that there are no up-to-date tutorials on UI. I keep finding many informative resources on different UI components, but they are all behind by multiple Bevy versions. For the most part, the code is the same, but there will be one or two small things that have been renamed or simplified that end up adding an extra thirty minutes because of all the time it takes for me to figure out how to do it in the lastest Bevy update. At least there have not been any major roadblocks so far, as once you figure out the Rust errors, the just code works.

Now, I am still a little disappointed we are not using C++/Unreal for this project. While I prefer Rust as a coding language, there are just so many opportunities out there for C++ developers. At least in this current time, working on a year long project that was in C++ would look better on my resume than one in Rust. At least Rust is starting to break into the cooperate world, so maybe more opportunities will arise by the time that I graduate.

Categories
CS 461

Introduction

To everyone reading this, my name is Johnny, and I am currently a senior CS student at Oregon State University. I started my journey at the University of New Hampshire in their computer science program but did not overly enjoy it. The year was 2020, and we all know how that went. While I did not have the opportunity to do much during my first year, I was able to start a competitive Overwatch team, which is still going strong today.

Since then, I have tried doing a year of cinematography at UNH, but that was not my cup of tea. Then, one summer night, while playing pubg with my friends, one of them told me I should just try and return to computer science. I decided to make the switch, but instead of returning to UNH, I decided to try OSU’s campus (since driving across America is somewhat of a commute), and I have been enjoying it for the past few years.

Eventually, I want to work in the gaming industry or develop GPU drivers. Thankfully, I found some teammates for my capstone who are interested in doing Engineering Simulations with Game Development Tools. The project looks very interesting, and I am excited to work with my new team.

Categories
Uncategorized

Hello world!

Welcome to blogs.oregonstate.edu. This is your first post. Edit or delete it, then start blogging!