What language should I use for an IF coding tutorial?

Sorry to say that I have this itch that’s bothering me. If you want to write IF, then Inform et al is best. But if you are learning how to code, then writing it from scratch is the only way to go, IMHO.

So, I have Raspberry Pi Zero 2 W that I’m willing to use for the cause. What programming language should I use?

  • C
  • Perl
  • Processing
  • BASIC (specify)
  • Others (specify)

0 voters

I think I have Atari 800 emulator that does BASIC, but I’d rather have one that people can use in repository. I have a soft spot for SmileBoom BASIC for Nintendo 3DS, but that’s not available for RPi.

Python and Javascript aren’t viable choices at this time, due to too high level of abstraction. Any machine language, if used, will be VM and designed by me.

Also, I’m not going to worry about memory paging, so language that can use more than 64K memory is desirable. Graphic and sound would be optional but nice to have.

Any thoughts?

1 Like

I’m unclear on which problem you’re solving.

If the goal is to develop IF for your Raspberry Pi Zero 2 W, well, that’s actually a pretty powerful machine. It has 512MB of RAM. I’m almost certain that you could install Frotz on it and it would run pretty much every game out there. (I bet it could even compile Frotz locally, without even breaking a sweat, eliminating any need to cross-compile.) The Zero 2 W can certainly run both Python and JavaScript.

It seems like you’re imagining using this to “learn to code” in some way. But… you already know how to code, yes? So I guess your goal is to develop a coding tutorial? For the Raspberry Pi?? But then, why not teach someone to code in a popular language, like Python or JavaScript…? There are a number of coding tutorials out there that do lead you through developing a simple work of IF in Python and JavaScript.

Or… is your goal to learn/teach how to code in C? (But then, why poll us about what language…?)

Or maybe your goal is to learn to code a VM…? But even then, there are tutorials out there to learn to code a VM in Python and JavaScript. Even if you want to write native code on the “bare metal,” you could code it in Rust, which can cleanly cross-compile to ARM, and is a much more beloved language than C in 2022.

4 Likes

You are correct. I’m trying to get some coding tutorial going. The existing coding tutorials are somewhat unsatisfactory to me, and I think I can do better by simplifying the process. Think of old BASIC IF type in, but written in plain English, rather than specific language features/libraries. Hence, no Inform, Python nor Javascript.

If you think about it, old codes are really a few pages long, yet people keep saying that it will take years to do! Somehow I don’t think that’s right, and I’m trying to prove otherwise. But I want to involve other people, hence the survey.

Python and JavaScript are both excellent learning languages with significant opportunities to use them on other projects. I don’t understand why you think they’d be inappropriate to this situation. They’re both much easier to learn and more popular than C, and they both work great on your RPi.

I have a hunch that the real answer is, “I just want to use a low-level language for this to scratch a personal itch. Python or JavaScript may be great languages in general, but they wouldn’t satisfy me in this case.” But, if you insist on a low-level language, then BASIC, Perl, and Processing should all be excluded.

If you just want to use a low-level language that you’re already pretty familiar with, then only C fits the bill, and polling us about it is really beside the point!

2 Likes

TADS would be a great coding language to have additional tutorial material available. Although quite a bit is already available from MJR and Eric Eve.

I’ll put you down for C, then. Actually, not including graphic, C has better string handling, data structure and flow control than BASIC. I’m thinking of using programmable calculator, but be honest, I don’t think there’d be anybody besides me who will be interested.

The point here is to prove coding IF is easy enough without having the language do it for you. Sure, using TADS will be much, much easier. However, any success will be attributed to the language instead of the technique. Hence, missing the point.

I think that’s already been proven in the 1980s. You won’t be covering any new ground, but I’m sure it will be personally interesting to you.

2 Likes

Yeah. It may be selfish of me, but I want to see more Paul Panks. Thanks for commenting.

I’m more interested in homegrown games and systems than Inform et al. ones, so don’t take that comment the wrong way. It was just a response to say, yes, coding a basic IF system is relatively easy as was shown many times in the 1980s. Coding something at an Inform sort of level, is a lot more challenging, but there are still plenty of examples of 1980s/1990s single-person coded “own” systems with complex sentence processing power.

2 Likes

So, uh, can I put that down as “Other (programmable calculator)”? :grin::wink:

1 Like

In my experience, when you learn a new language that’s similar to C (be it TADS, Java, C# and whatnot), you don’t have any real difficulty learning the actual language. The majority of the time is spent learning the APIs (like adv3 or .NET.)

A C-based authoring system would still have an API you’d need to learn. The fact that you’re using a language you already know doesn’t really seem to make it that easier.

3 Likes

These days no one should start by learning C IMO. There are just too many footguns. If you don’t want an interpreted (or JITed) language like Python or Javascript, then why not Rust?

2 Likes

Why not Go? C++? C#? Because of all “C like language”, C has the most platform penetration. Even as recent as 1.5 years ago, I’d have asked, “What’s Rust?”

If we’re talking about total beginners here, my preference would be BASIC. Hey, it’s in the name! Tiny Basic used to be included, but not anymore, apparently.

C should be safe enough if I stay away from the more complex construct. In fact, I plan to use TinyC instead of GCC, keeping it simple.

C-like isn’t necessarily a good thing. Manually managing memory where all the burden of safety is put on you? Gross. No one should have to learn that. And then there’s all the other issues - like uninitialised variables and undefined order of parameter execution, those two tripped me up recently and I’m a very experienced software developer. So many things that the compiler should be catching for you. And some C compilers will warn about some of them, but you’ll have to learn to turn on a bunch of fiddly and inconsistent compiler switches.

If you’re talking about C-like syntax, well that’s the easiest thing to learn. If you’re thinking about what to teach beginnings, I wouldn’t focus on which syntax will be worth using the longest, because it’s easy to learn, and because the similarities are limited once you move beyond function definitions. Would be worth consider Scheme or another Lisp too.

2 Likes

If you feel that strongly about it, please vote for Perl. It has the best error recovery system. Do you understand now why I put choices up there that aren’t necessarily low level?

BTW, Processing is there because that’s my answer for generic programming language since BASIC fell out of favor.

Let’s not talk about LISP. :face_with_raised_eyebrow:

Perl is a bewildering parallel-universe version of programming. You can write clear and readable Perl, but I don’t see much of it. :wink: I wouldn’t recommend it purely because of having to manually get function arguments via shift, or destructuring, etc. Also, error handling without algebraic types is often pretty messy. I see that there is an algebraic types library for Perl, which lifts my evaluation of the language. Is it used for error handling though?

Actually algebraic types make reasoning about optional parameters so much safer that I’d probably prioritise teaching a language with native support for them over any that use null parameters. That doesn’t include TypeScript either, sadly, as you have to manually handle the tagged unions.

2 Likes

TI, Casio and Numworks calculators all support Python development.

Another thought, have you considered REXX from IBM? I first saw it in OS/2 back in the day. It is still viable and has excellent string handling capability.

Personally, I’m not a fan of Python. The whole “tab” issue is a pain in the neck.

1 Like

I think the most confusing thing about this conversation is that you just wanna do this one of the languages you know well, which is fine, but the “reasons” you provide to do it in C just don’t add up.

If you mean “code written in C will run on the most platforms,” I think that’s not true today. You can’t deploy C code to iPhone or iPad unless you buy a Mac and pay Apple $100/year. You can write JavaScript for free, targeting everything with a browser, and everything else that supports Node.js (which includes pretty much every Unix you’d care to run on).

You can deploy Rust code everywhere you can deploy C code, without having to debug memory corruption. You may not be too familiar with Rust, but today, it’s just better than C for all of the things that C does, and if you’re educating a coding newbie by introducing them to C as their first language, you’re not giving them the best possible coding tutorial.

Today, in 2022, none of the languages on your list are very good starter languages. C, Basic, and Perl are all past their prime; learning them as a coding newbie limits that newbie’s potential, rather than expanding it. Processing should be understood as a domain-specific language for drawings; it’s as unsuitable to developing IF as Inform would be to dynamically generating images.

Instead of saying “C has the most platform penetration,” I think you should say, “Look, I’m familiar with C, Perl, Basic, and Processing, and of those languages C has the most platform penetration. Objectively, Python, JavaScript, or Rust would be “better,” but that would require me to develop expertise in Python, JavaScript, or Rust for this, enough expertise to teach one of these languages, and I just don’t feel like learning a new language for this project.”

And that’s totally fine! It’s your volunteer project; you could even do it in Lisp if you wanted to, just for fun!

Just don’t attempt to persuade us that C is best for what you’re working on, any more than Lisp would be.

2 Likes

Uh, hello? If you don’t want me to use C, then don’t vote for it?

Look, the whole project is to prove that coding IF is so easy, it doesn’t matter what coding language you’re using! If I put out a code that people find confusing, then that is a valuable data point, in and of itself. That is the point of the whole exercise!

You do realize that the survey lets you pick multiple languages, right? The use of one doesn’t prevent another. If you want to convert my C/BASIC/whatever language to (insert your favorite language here), I will thank you for it.

Now, if you want to argue that C isn’t usable by beginners, then I disagree because I learned real quick to change my coding style to handle C language “inadequacies”. But that is a separate thread, okay? Don’t discuss it here, please.

This whole discussion has gone in a not-very-useful direction.

You said at the beginning:

Python and Javascript aren’t viable choices at this time, due to too high level of abstraction. Any machine language, if used, will be VM and designed by me.

If that’s true, then Perl, Processing, and BASIC are also too high-level. You’re asking about C. Use C. If you don’t want to use C, figure out what you do want – we can’t help with that.

Writing a simple two-word IF parser takes a few days. That’s why there were so many simple two-word IF platforms in the 1980s.

Writing a solid, fully-featured IF parser system that other people will want to use takes months or years. If you want an idea what that development process looks like, look at the threads about Dialog on this forum. That’s about three years of development by now.

5 Likes