Why you should use different languages

Biscuit's Cookie Algorithms
4 min readSep 12, 2024

--

From pngset.com

A few months ago, I talked about the downsides of using many different languages to write software. But there is one upside.

This upside is that you learn a lot from using different languages and different frameworks. You learn things you like and things you don’t. For example, I now wish that every language had a version of Java Swing’s getSubimage function. What this function does is that it returns a reference of a portion of an image. I like this function because I don’t have to create a variable to store a single sub image, and then use it. I can use for loops, for example, to iterate over a sprite sheet and return each sub image that I want to use in an animation. I could do this in JS, but I’d have to use a traditional list, and lists have that strange [] syntax. Meanwhile, ArrayLists have a .get function. Also, in JS I’m returning an object that represents a portion of an image, but in Java I’m returning an actual portion of the image that I can use right away.

Speaking of JS, there are so many good things about it. For example, the DOM. Its object orientation makes it easy to understand and reason about. I don’t even need HTML to create HTML elements. This means that I can see when HTML elements are created in my JavaScript code, and I can also manipulate the DOM elements that I just created directly, without using getElementById. Also, don’t take what I just said about JS objects to mean that I don’t like JS objects. The fact that I can create entire dynamic datatypes on the fly, without thinking about it, is something that I wish every language had. Also, I like the forEach function. Instead of using a designated loop, I can just use a function to do something for every element in a list. I like this approach over traditional for each loops like the ones in C++. There are also things that I don’t like about JS, though. I really like being able to code using objects, and in other languages I could use an object to detect key presses. But in JS, I’m supposed to use event listeners. This means that all my key pressing code is tied to a function that’s separate from the rest of my program. Also, JavaScript’s dynamic nature really doesn’t align with my preferences as a programmer. I prefer static, strongly typed, compiled languages like C++, Java, and Rust. This approach to programming prevents a lot of runtime errors. But, it’s something that I can get over. If I really wanted to, I could use TS.

I also learned that I like temporary values. For example, I like being able to type, “new Entity().move(5)”. Doing things like these saves me a line of code at not much cost to readability. I also like Java’s bottom-up approach to programing. It’s perfect for smaller to mid size games, because your entire program is a hierarchy that’s easy to reason about. When I code Java, I find myself “climbing the hierarchy” a lot when debugging. I simply start from the objects that are lowest on the hierarchy, then climb up until I find the error. Brian Will said that most of the time, objects don’t represent actual things in the real world. Well, I disagree. In a video game, you aren’t making factories. You make classes that represent actual things, like buttons, players, swords, etc. But, I understand why people use ECSs now. If I were making a really big game with a huge hierarchy, I might have to look at way too many files just to find out where the error is. But, I’m currently learning that bottom-up approaches aren’t always the best. Right now, I’m learning how to make a game with a top-down approach, because in a large program, top-down approaches are almost always better, or so I’ve heard. I’ve even heard of methods that are pure functions, taken from functional programming. Or, if I always programmed in C, I wouldn’t appreciate first class functions or lambda functions(yes, I know of function pointers. I also know that they aren’t used often(presumably because they aren’t readable)). But using JavaScript has helped me see the beauty of first class functions.

Anyway, that’s all I can think of. All in all, programming in multiple languages gave me a lot of insight that I couldn’t have gained otherwise. This isn’t to say that you should be like me and write all your programs with different languages each time, but if you’ve only programmed in C for 10 years, I’m telling you to try Java. You’ll love the generics.

--

--

Biscuit's Cookie Algorithms
Biscuit's Cookie Algorithms

Written by Biscuit's Cookie Algorithms

I am a game developer who wants to document the development of his games, and also gather support for them.

No responses yet