coding-horror / basic-computer-games

An updated version of the classic "Basic Computer Games" book, with well-written examples in a variety of common MEMORY SAFE, SCRIPTING programming languages. See https://coding-horror.github.io/basic-computer-games/
The Unlicense
10.84k stars 1.33k forks source link

common common functions ;-) #699

Open mojoaxel opened 2 years ago

mojoaxel commented 2 years ago

In https://github.com/coding-horror/basic-computer-games/issues/548#issuecomment-1079839924 it was decided to have a (minimal) set of common IO-functions so those don't need to be re-implemented in every game.

I propose we use the same function (same names) in every programming language (as far as possible!)

That way the code get's easier to read and compare.

What do you think?

mojoaxel commented 2 years ago

To stay close to the original BASIC implementation I would propose the following functions (pseudo language)

In addition it could be useful to have the following functions:

coding-horror commented 2 years ago

yes! I think this is perfect. Just the minimum viable set of common functions, justified by at least 10 (ish) of the programs needing them..?

ugurkupeli commented 2 years ago

I have published a utility crate for rust users. Currently there are only functions for printing intro/instructions and different types of user prompts - but I think that is good for our purpose.

drewjcooper commented 2 years ago

See the common library for .Net at 00_Common/dotnet for my rationale and implementation of this idea.

I like the idea of having a set of functions with names/signatures that are typical of the language's standard library, but provide the behaviour of the BASIC interpreter.

I don't like the idea of creating a DSL that looks like BASIC. Hence, I have not implemented a Tab(int) function in the .Net common library, or any of my game ports, preferring to stick to C#/.Net idioms.