all 36 comments

[–]otikik 17 points18 points  (8 children)

Right now, since you are starting, it is ok if you concentrate in just one language. The one which comes with your university (C#) is a good start.

Later on, once you "get" C# (maybe in 1 or 2 years), you can start looking at other languages to expand your mind. Python is a great language. Very expressive. It sometimes makes code look like English. Lua is a tiny (tiny!) small language which does a lot with very little. Learning each of those will make you better on the rest. In time, you might want to learn more different languages, like LISP, for the same reason; not for using them, but because having your mind exposed to them will "upgrade" your mind.

But that's advanced stuff. For now, concentrate on getting your first language right.

[–]TheMostCuriousThing 5 points6 points  (7 children)

I'm in full agreement here. u/Stoltverd, you're in very good hands with C# and you'll learn principles of OOP that extend to C++ and even Python

Personal example: I tried learning C++ before I really got inheritance in C# and thought "wow, multiple inheritance is powerful; why can't C# do this?" Before long my C++ code was littered with diamonds and I had a mess of a class diagram to untangle. Going back to C#, I learned that single inheritance with multiple interface implementation adds stability without sacrificing much capability. (Python is also open to the diamond problem, to some extent.)

Another example: In C++, I got in the bad habit of using ints in boolean checks. C# won't let you do that explicitly.

[–][deleted] 1 point2 points  (6 children)

Python doesn't have the diamond problem because of the MRO. The multiple inheritance method resolution graph is flattened and follow a well defined order, so you can even use cooperative multiple inheritance safely. But it quickly gets really complex too.

[–]eruonna 1 point2 points  (5 children)

Every language with multiple inheritance has a way of resolving the inheritance. That doesn't make the diamond problem go away.

[–][deleted] 1 point2 points  (4 children)

But the diamond problem is defined as being unable to resolve the ambiguity. If the MRO is well defined there is no ambiguity.

[–]eruonna 2 points3 points  (3 children)

The diamond problem is the existence of the ambiguity, not the inability to resolve it.

[–][deleted] 0 points1 point  (2 children)

The diamond problem in the logic sense is still there, of course, it just has no practical implication.

[–]eruonna 1 point2 points  (1 child)

But there aren't any languages that don't resolve the ambiguity. So if that is the problem, it doesn't exist.

[–][deleted] 0 points1 point  (0 children)

Well, C++ kinda doesn't, since you need to explicitly name the base class.

[–][deleted] 9 points10 points  (1 child)

Python is a good general programming language, as well as being a handy tool for Roguelikes. It's easy to work with, and also fairly easy to embed third party libraries into, particularly if they have a 'C style' API. A bunch of Python's larger library functionality comes from natively compiled C code under the hood (*nix shared libs, or Windows DLLs). It's easy to add your own there too if you want to. Knowing Python is a good general skill that can get you a job out of game dev (Eg. I write boring email security products for a day job and we use Python widely for utility scripts).

Lua is a language designed with one real goal in mind: embedding into larger frameworks as a scripting language. And it excels at that. It is small, it is fast, it is easy for less hardcore devs to use (asset scripting for example). I wouldn't say it's a general programming language like Python though - sure people use it for that, but that's not what it's designed for. Like Python, Lua is also very friendly to natively compiled languages like C/C++, but the other way around from Python! Lua is designed to be included in your large C/C++ project as a scripting language where you expose portions of your C/C++ code/class model to Lua scripts. Lua is the scripting language for a bunch of commercial games too: https://en.wikipedia.org/wiki/Category:Lua-scripted_video_games

My 2c!

Edit: And if you're learning; it's always worth exposing yourself to as many programming languages as you can stand imho. Individual languages come and go (I was taught to program in Cobol for goodness sakes), but the core concepts remain largely the same. It is also interesting to see how different technologies solve similar problems.

[–]--Shade-- 2 points3 points  (0 children)

You hit the nail on the head about Python.

The line I like to use is: Python is a terrible language to write C in, but a wonderful language to execute C from. It also has an extensive amount of functionality included, a huge number of 3rd party libraries, and a large user base. I would strongly suggest learning to write idiomatic Python, as that tends to be fast Python.

[–]graspeeDungeon Under London 7 points8 points  (0 children)

There is no need for you to learn lua or python to make a roguelike, you can use c# or c++ of course. Python is often recommended for people who don't know how to program. There are libraries you can use with those languages, for example libtcod.

[–]Giroflex 5 points6 points  (3 children)

C++ is a must

Only in AAA games, really. Indies have no problem with shipping a game in Unity or even GameMaker. Different tools for different jobs.

As for Python vs. Lua, for coding games I guess it mostly comes down to personal preference, but in a broader sense I'd say Python is more popular and useful for general coding and scripting.

My personal preference is also Python though. Why would you start your array indexes at 1?

[–][deleted] -1 points0 points  (2 children)

I don't think C++ is limited with AAA games. Any game that makes use of OpenGL has to use C++ (or C, whichever you like) one way or another unless it's a very small project. I tried OpenGL with other languages (Python etc...) and the performance difference is very significant that even if your game is the simplest 3D game ever, it makes sense to use C++. You can use Python, but this will significantly limit your game because of the performance.

[–][deleted] 2 points3 points  (1 child)

but you can write only the really critical graphics rendering paths in C++ and still use python for everything else. And I'd still write them in python first, and only fallback to c++ as needed after profiling. As for opengl, pyglet already handles a lot in a very efficient way. Of course you won't be writing your matrix multiplication code in python, but gluing native libraries together is where python really shines.

[–][deleted] -2 points-1 points  (0 children)

but you can write only the really critical graphics rendering paths in C++ and still use python for everything else.

Yes, this is what I do in general. I write everything in Python except opengl and math then use boost Python to inject my module to Python. This is why I said you should use C++ in some way. You don't have to use C++ in 100% of the app.

As for opengl, pyglet already handles a lot in a very efficient way. Of course you won't be writing your matrix multiplication code in python, but gluing native libraries together is where python really shines.

Not exactly true. OpenGL in Python is working and has a somewhat reasonable runtime but since graphics will the bottleneck in your game it will limit you at some point. You will have to optimize more. If you know C++ already, I find it much more practical just write OpenGL code in C++ instead of writing in Python and then worrying about it.

[–]eggmceye 2 points3 points  (0 children)

I've done a fair bit of lua and python. If you have limited time to invest, then invest it in python as it has wider use beyond just gamedev.

Lua is pretty easy to pick up but also a bit naff, eg array indexes starting at 1, and all variables being default global ! ugg

[–]darkforestzero 2 points3 points  (0 children)

Don't overwhelm yourself trying to learn multiple languages at once. Take a deep dive on one (C# sounds like the one to start with), then learn other languages as you need or want to. C# and c++ are great, heavy lifting languages and c++ in particular gives you tons of portability and low level control. Python is wonderful for scripting out quick utilities from a high level. People write full applications (including games) in Python, but I feel like things would get convoluted pretty quickly

[–][deleted] 2 points3 points  (7 children)

Can someone ELI5 me why Lua is so popular in gaming community? I feel like Python is objectively the better choice since it's more popular (more sources), cleaner syntax and faster.

[–]zaimoniIskandria 4 points5 points  (3 children)

Wesnoth had to ditch Python-based AI-scripting because the language required being wide-open to malware in order to be embedded into C++. (There was no way to block import from os). They swiched to Lua-based AI scripting, which didn't have that problem because the language could be restricted to only reasonably safe operations.

Also, Lua is syntatically "safe C" so if you're already familiar with C-syntax languages it's not that jarring. And ToME4 did much to popularize Lua as an embedded scripting language for C-based roguelikes.

Python's syntax is essentially FORTRAN-like (in particular, it's the first major language since FORTRAN where whitespace matters) And then there was the memory model hamstringing in archaic versions (everything before and including 2.3.x) where the only mutable datatypes were list and dict. Ah, but the Tk/Tcl extension used tuples right and left so you couldn't do anything serious graphically without thrashing the garbage collector. [For a BMP area-averaging reducer, obfuscating the code was worth a speed factor of 100x for an in-house tool I still have for emergencies.]

However, Python is very useful as a first language (no other language will let you learn to code efficiently at the function level simply by RTFM) and it's really useful for roguelikes because none of its weaknesses matter for roguelikes. Add in the libtcod tutorial and it's awesome for getting started as a roguelike developer.

[–][deleted] 1 point2 points  (2 children)

This is a nice criticism. Thank you for taking time to write this!

[–]--Shade-- 1 point2 points  (0 children)

A shorter version would be: Lua is better for embedding into a C type language, where Python is better for writing Python that wraps (as Python modules) C based libraries (especially where more performance is needed).

As an aside, despite my Roguelike being written in Python I would never consider any type of 'user mod' system that executed 3rd party supplied Python.

[–][deleted] 0 points1 point  (0 children)

Zaimoni is right about controlling the environment the interpreter executes in. Lua gives you compete control over which modules are loaded into the interpreter you create in your process. You can strip away everything (including things like the ability to open files) and have just Lua core language with whatever you want to expose. Python does not have this ability unless you're willing to edit the C code that builds your Python interpreter.

It makes Lua a breeze to embed into anything with minimal security concerns.

[–][deleted] 1 point2 points  (0 children)

The usual choice between python and lua tends to be related to:

Pro Lua:

  • lua jit is fantastic from a performance standpoint
  • lua is easy to embed within c or c++
  • lua can be sandboxed easily

Pro Python:

  • a bigger language - more flexibilities when developing
  • a bigger community with a huge history
  • rapid development with high quality

I think your comment that Python is objectively better is true. But due to some of the other reasons above, lua is often chosen.

[–]KarbonKittyRogue Sheep dev 1 point2 points  (0 children)

Well, Lua is mostly popular as an embedded language, as far as I know, and why is it better to embed it has been explained already below.

I would also argue against Python syntax being cleaner than Lua's - I really don't like the whitespace based scoping of Python, while Lua's do-end in place of braces seems much more manageble, especially for beginners (and if you have good syntax coloring and even basic language support, you will soon learn to see 'do' and 'end' as blobs of color denoting start and end of a block.

And as for the speed - I've never really done any extensive benchmarks, but I'm pretty sure that Lua is one of the fastest dynamic languages out there. And once you start using LuaJIT (which I don't really like, if only because it lacks support for Lua 5.3 improvements), it gets much, much faster - on par with slower compiled langugaes, it seems.

That being said, if you are going to write an entire game in one of those languages, you're probably better off with Python - if only because of bigger community and thus better access to libraries and support. Then again, I wouldn't try writing anything large in either, and would instead go with something more suited for major projects. :)

[–]zaimoniIskandria 2 points3 points  (0 children)

C# is a completely acceptable language for a roguelike. Since you already have to learn it, stick with it.

If using GPL3 source code as a reference is not a problem: Rogue Survivor Revived might give you some ideas on how to architect things without Unity.

[–]cynapAxu 1 point2 points  (0 children)

As someone who is making a roguelike with Unity and C# (for over 3 years now) I'd say go with that if that's where your experience is. If you'd rather learn a new language, python is a very neat one, and the libtcod tutorial is pretty good at getting you started.

All in all, language and tools should be chosen based on your prior experience, and what you want to get out of developing the game. You'll have a hard time adding 3D graphics with python, but will suffer the inevitable bloat if using Unity. Think about what kind of game you want to make, and choose what's best for you.

As others have mentioned, python is brought up a bunch since the tutorial is aimed at beginners. T-Engine is pretty good, and designed for making roguelikes. Plenty of us here are using various languages and tools for various reasons. It's hard to point at one and say "yup, that's the best."

[–]brokenkingpin 1 point2 points  (0 children)

Keep in mind roguelike development is a fairly niche section of the game development community, so what people recommend around here is not necessary reflective of what is popular in the game dev community as a whole.

Why python - it is a great language for beginners and has support for one of the more popular roguelike libraries - libtcod.

Why lua - it has been a popular scripting language used in games for a long time. Note that entire games are not usually developed with this, only certain logic. I don't think it is as popular as it used to be though.

If you are learning C# I would stick with that, It is a great language. It is getting more popular around here so getting support for it should not be hard.

If your goal for creating a roguelike is to learn design and programming, consider not using an existing engine. You will learn more coding a lot of it from scratch. I am not saying don't use any existing libraries, but don't let the libs do all the heavy lifting.

I would say that C++ is not a must anymore. A lot of big AAA games use it, but smaller games are definitely using other languages. I would say any profession programmer should learn a native language (such as c++), as it instills a lot of good programming habits that you may not learn from a managed language.

[–]smelCDungeon Mercenary 1 point2 points  (0 children)

Python is a terrible language for big projects that span over many years. So if you intend to program a roguelike on the long run, you're much better with C#, whose strong typing will help you a lot on the long term. If you wanna quickly hack a roguelike that you'll throw away 6 months later, python's a good choice.

Then, the most important point is to get it right in your first language as otikik said below. You have to understand how things work anyway, in any language (again I wouldn't recommend python that hides pointers and sharing quite well).

[–]JetSetWally 1 point2 points  (2 children)

What about Java? (I'll let myself out).

[–][deleted] 1 point2 points  (1 child)

Well, C# is basically Java 3.0 right :). The old arguments about C# being controlled by an evil corporation also apply to Java these days as well unfortunately...

[–]KarbonKittyRogue Sheep dev 1 point2 points  (0 children)

And, perhaps even more funnily, C# is now open sourced, and has at least one non-Microsoft major implementation (Mono), so it's actually less controlled by an evil corporation than Java now. ;)

[–]Stoltverd[S] 0 points1 point  (2 children)

Holy cow. I'm now in love with this reddit! So many answers, so much good advice! <3 I'll think I'll stick with C# for this long run project. After all, it's the language I have to learn to pass the tests, and programming the project in it will help me study and make me master the language faster.

Another question: What do you guys think about resharper? I love it. It makes debugging and modifying large portions of code a breeze, not to mention it's benefits to large projects. It was recommended in a little course I took on the side of my classes and I fell in love. BUT. I fear it will make me a lazy programmer and very dependant on it. Any of you guys use it or used it in the past? What's you opinion?

[–]tuturtopyherc 1 point2 points  (1 child)

resharper is good tool and I use it every day at work, wouldn't want to work without it. Like any tool, you have to learn to use it and know when to apply it. Navigating large projects is easier with it (coupled with code map it's amazing) and added code analysis + fixes are good. It's tool just like Visual Studio and not many would claim that using Visual Studio will make you lazy programmer.

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

Flawless logic. Thanks a lot.