ticalc.org
Basics Archives Community Services Programming
Hardware Help About Search Your Account
   Home :: Community :: Articles :: Is it Time to Replace TI-BASIC?
Is it Time to Replace TI-BASIC?

Posted on 21 February 2005

The following text was written by George Limpert:

Anyone who remembers coding in TI-BASIC on the TI-81 or TI-85 and has then has coded for a more modern calculator knows the language has made great strides. Many of these changes have been influenced by the collection of nerds and gamers we affectionately refer to as the TI community. When TI created their original graphing calculator models, they never envisioned they would be used for the purposes we have found for them. A large portion of the changes to the language reflect the ideas of students over a decade ago who envisioned their calculators entertaining them during boring lectures. Despite the many changes to TI-BASIC, the language is still looked upon by the best game programmers as inadequate at best.

The complaint of many programmers about TI-BASIC is its speed, or the lack thereof. Unfortunately this issue is unlikely to be addressed anytime soon. When TI designed the language, they envisioned a way of adding new math functionality to the calculator, but with safeguards in place to prevent harmful behavior by programs. Speed of program execution is nice but doesn't appear to have been one of TI's primary objectives when creating the language.

Some people will suggest any serious programming ought to be done in assembly language. Compared with programming in TI-BASIC, it's like going hunting with a rifle instead of a pocket knife; it's faster, more powerful, and there's nothing to stop you from aiming that rifle squarely at your foot. If you make an error programming in TI-BASIC, you get an error message awaiting you to press a key. A mistake programming in assembly might give you a sudden boost of free RAM in exchange for your valued programs, equations, and notes. It's probably best to do serious game programming in assembly, but what about other types of programs?

Not too long ago, a fellow with a fine idea for calculator programming visited the flagship IRC channel for discussing TI calculators. Instead of compiling TI-BASIC programs so they run faster, he proposed replacing the language altogether. While he was met with ridicule, the idea is worthy of further discussion.

Last semester, I took a course on data compression techniques. One project assigned was to implement a Huffman encoder and decoder in C or Java. The discussion in class about Huffman coding went in one ear and out the other. Instead of struggling with C, I decided to implement the project first on my TI-89 because I expected TI-BASIC to be simpler. After about five minutes into coding, however, I hit a roadblock; there's no easy way to implement any sort of trees. Sure, it's possible, but to many programmers it's not obvious how to create or manipulate trees. The solution is to represent each node as a list; the first element is the value and the second and third elements are the names of child nodes within the binary tree. The child nodes are then accessed using a wonderful feature of the language known as indirection. On the TI-83 line of calculators, however, indirection isn't possible, and one would have to use a matrix, instead. Manipulating a matrix is slow and makes the programming involved even more complicated.

A tree is one of the fundamental techniques used in programming. It's applicable to many algorithms including searches and sorts. Unfortunately it can't easily be done within TI-BASIC.

This discussion also addresses another major limitation of TI-BASIC. What if, instead of storing the name of a child node, I want to store another data structure, such as a list, in one of those spots? The answer, of course, is it's not possible. One might ask why anyone would want to do this. Consider, for example, if a programming task involved pushing an integer and a list to a stack. While no such task readily comes to mind, it's a reasonable proposition. Stacks are another fundamental technique of programming. And, of course, complex data structures alone are useful at times.

There are many other such examples of why TI-BASIC is inadequate. Even if it will never be a fast language, simple programming techniques in the language ought to be exactly that -- simple. These limitations make TI-BASIC useless to many applications that are not at all related to gaming.

Programming in assembly can be difficult and dangerous to your data. It also usually requires a computer, a link cable, and a lot of patience. If that's not the best option and TI-BASIC is inadequate, maybe another programming language isn't so absurd of an idea after all.

The obvious question then becomes what features should such a language have. If a language is to truly replace TI-BASIC, it ought to have all the features that TI-BASIC currently has with some additions to fix the limitations with TI-BASIC. It's likely a replacement for TI-BASIC would need to be interpreted instead of compiled. One might assume that if we're creating a new interpreted language that has more features than TI-BASIC that it would be even slower. This is not necessarily the case.

The architecture of compilers and interpreters are very similar. The first step in either is referred to as a lexical scanner. This scans through the program text for keywords and symbols. The output generated is a series of tokens which represent the text of the original program. TI-BASIC does this as well; on some calculators, programs are always represented as tokens, but on others you will notice a delay when running a program for the first time due to this conversion. The next step of a compiler or interpreter is a parser. This deals with the syntax of the language, converting the string of tokens to a tree structure. A tree in an accurate representation of how a language is actually evaluated. Following this step is semantic analysis. A statement in a language may be syntactically correct but still make no sense to the compiler or interpreter. At this step, actions such as checking type and scope of variables are performed. At this point, compilers and interpreters diverge. An interpreter will evaluate the parse tree and execute the statements while a compiler will output another language such as assembly language or machine code.

This discussion on the architecture of interpreters is relevant because the implementation of TI-BASIC is not necessarily the most efficient scheme. Most likely, TI-BASIC stores programs merely as a stream of tokens because of the space required to store a representation of a parse tree. A parse tree, however, can be converted back to plain text just as the stream of tokens can. If parsing is only done once instead of being done constantly during execution, greater speed can be realized. One need not stop after parsing, however. Much of the semantic analysis step can also be performed at this time without modifying the parse tree. One may view this as a trade-off between program size and execution speed, but it need not be the case. A parse tree, when outputted to a file, can be compressed and then uncompressed at runtime, which may gain back some or all of the space lost to representing the program as a parse tree.

Another major change to such a new language is in the area of variables. There is no method within TI-BASIC to store a reference to another variable. Therefore any reference variables will necessarily be local to the interpreted program. Such a language, however, would still need to provide easy access to variables from TI-BASIC. This means that any variables that are to use the additional features of this language will need to be declared within the program. If this is the case, it allows for a few other enhancements to the language. One potential enhancement is the concept of aggregate data types.

Dealing with variables is a major slow point of TI-BASIC. The language on some calculators provides two very useful features for programmers -- dynamic types and dynamic resizing of variables. Dynamic types mean that if I have an variable currently storing an integer and I choose to store a string it it, the variable becomes a string variable. Dynamic resizing of variables means that the space used to store a variable is automatically expanded or contracted depending on how much space is needed to store the data. While these are very useful enhancements, they are also slow. A new language could make these features optional to programmers, providing an additional speed boost.

In spite of these and other possible enhancements, some tasks are better suited for assembly language. Furthermore, programmers shouldn't have to reinvent the wheel every time they write a program. PHP had a good idea when it allowed modules to be added to the interpreter that extend the functionality of the language. While a new calculator language may be at the core a replacement for TI-BASIC, the ability to extend the language through modules instead of writing a new interpreter makes the language far more powerful than it would be otherwise.

TI-BASIC is a fine language suitable for many tasks. Assembly has many advantages over TI-BASIC and has many uses as well. There are, however, many programming tasks that for one reason are another are not suited well to either language. A replacement for TI-BASIC, if sufficiently enhanced, can make TI calculators a far more powerful tool. The question of a new programming language shouldn't be a question of if but of how and what.

  Reply to this item

Re: Is it Time to Replace TI-BASIC?
Lewk Of Serthic  Account Info
(Web Page)

Whenever I click on the "2" at the bottom, I get

Not Found

The requested URL /archives/news/articles /12/124/124619.html was not found on this server.

Reply to this comment    22 February 2005, 05:32 GMT


Re: Re: Is it Time to Replace TI-BASIC?
Coolv  Account Info
(Web Page)

Change your preferences to have ticalc display all of the posts in one page.

Reply to this comment    22 February 2005, 22:02 GMT

Re: Re: Re: Is it Time to Replace TI-BASIC?
Kevin Ouellet  Account Info
(Web Page)

I don't think it's a good idea. I did that and when I opened an old newsarticle page with 500 comments it screwed up my computer.

Reply to this comment    23 February 2005, 02:26 GMT


Re: Re: Re: Is it Time to Replace TI-BASIC?
no_one_2000_  Account Info
(Web Page)

I do that... it makes things a heck of a lot easier. It's only a bad idea to do this if you have a slow connection or if your computer just plain sucks. :-P

Reply to this comment    23 February 2005, 21:04 GMT


Re: Re: Re: Re: Is it Time to Replace TI-BASIC?
Coolv  Account Info
(Web Page)

I have a fast connection and a good computer...

Reply to this comment    23 February 2005, 23:27 GMT

I have something
shkaboinka  Account Info
(Web Page)

It just so happens that I have a new language very near completion. I have been working on it for over a year now.

My language (and compiler, I choose to keep them separate) will compile code that is similar to C++/Java, but all completely structured in z80 assembly, and with some TI-BASIC syntax in mind.

One thing that makes it so great is that it is meant to be modified externally; that is, only the fundamentals of the lang like basic data manipulation and types and functions and control-structures etc are biult in; anything else can be added to the language however anyone pleases.

Most of what is added to the language externally are defined in assembly; any assembly feature or w/e can be incorporated so that the language can be customized to work with anything.

This is all for the z80 platforms (from TI82 to TI86). I am currently making some final changes to the language before I finish up the last part (the part that handles expressions), and then I will release it and see what happens.

When I release it, I intend to use my yahoo group to setup a sort of community of people to help define and modify the language externally (in the language); also there are a couple other things I plan on adding in after it works fine with what it has now (user-defined types / "objects" aka structs aka classes), and some pointers and stuff.

What do you think? Hopefully I will be able to finish it VERY soon (some problems with viruses on my computer have slowed me down a little, but I have other means). Here is my group page for the project (which is meant for developing the lang, but until it is done, I have a couple people helping me with some asm stuff and stuff):

http://groups.yahoo.com/ group/Antidisassemblage/

(you have to ignore the space in the link; ticalc wont allow strings of chars that are too long)

Reply to this comment    22 February 2005, 21:05 GMT

Re: Is it Time to Replace TI-BASIC?
Colin Hart  Account Info

I'tll tell you what we need. PASCAL. PASCAL. PASCAL. Yay for PASCAL. I think pascal would be the perfect langauge for the TI calc. It's easier to work with then other high level langauges, but is also the most powerful. Pascal is as powerful as you want it to be.

Pascal!

Reply to this comment    23 February 2005, 01:58 GMT


[ ! ]
anykey  Account Info
(Web Page)

You haven't tried Python, have you?
EOL

Reply to this comment    24 February 2005, 03:55 GMT


Re: [ ! ]
Colin Hart  Account Info
(Web Page)

I still like pascal better then python or debian.

Reply to this comment    25 February 2005, 22:17 GMT


debian?
OnyxG7 Account Info

I don't believe debian will run on Ti calcs anytime soon. Still, you always have PedROM :)

Reply to this comment    5 March 2005, 15:43 GMT

Re: Is it Time to Replace TI-BASIC?
Joey M  Account Info

Yes, TI-Basic has its limitations, but at one point I wrote an entire GUI/Operating System entirely in Basic. It had decent graphics and ran pretty quickly for something with so much code. Ti-Basic, and Basic in general, is still a good, useful, and veritable programming language and is a good medium for any platform- PC, Mac, TI-83+, TI-89, Commodore 64, anything in the last twenty years. It cannot and will not be replaced anytime soon, and I am confident in such a prediction.

Reply to this comment    23 February 2005, 03:53 GMT


Re: Re: Is it Time to Replace TI-BASIC?
Colin Hart  Account Info
(Web Page)

But the point is, you probally ( most likely) did more work then you needed to, if there was a much more functional langauge in place.

Reply to this comment    23 February 2005, 05:01 GMT


Re: Re: Re: Is it Time to Replace TI-BASIC?
Travis Evans  Account Info

I think it's still beneficial, because writing something complex in a language not designed to handle that helps strengthen problem-solving skills and lets you practice looking for the most efficient ways to do things.

But, yeah, most of the time it's probably more fun and practical to use the right tool (programming language) for the job. :-)

Reply to this comment    1 March 2005, 21:35 GMT

Re: Is it Time to Replace TI-BASIC?
david zhang  Account Info
(Web Page)

I believe the basic structure of BASIC is good, but it could be made better. In particular, I would like the BASIC to change three of the following:

1. Don't make the variables global. For a simple program, this is not an issue, but if you're writing a complicated program which involves several dozen variables, then you'll have to be careful of the variables you used and try not to overwrite them by mistake.

2. This is a consequence of the first change. Both reference and value parameters should be allowed in BASIC for programs. Having this done would give the programmer the control in whether a variable be changed or not in a program. Which of course, requires that all variables are not global.

3. This has something to do with the program I'm working on. I work with a lot of matrix manipulation, thus I need more than 10 of the default matrix variables ([A] to [J]) to work with. I understand that you can define your own your own list with special names in 83/84, but why can we define names for the matrixis as well?

Reply to this comment    23 February 2005, 19:22 GMT


Re: Re: Is it Time to Replace TI-BASIC?
Kevin Kofler Account Info
(Web Page)

ad 1: The TI-92, TI-92+, TI-89, Voyage 200 and TI-89 Titanium all support local variables in TI-BASIC.

Reply to this comment    24 February 2005, 01:11 GMT


Re: Re: Re: Is it Time to Replace TI-BASIC?
david zhang  Account Info
(Web Page)

what about the ti-83/84 users? are they gonig to be left in the dark?

Reply to this comment    27 February 2005, 09:29 GMT


Re: Re: Re: Re: Is it Time to Replace TI-BASIC?
CajunLuke  Account Info
(Web Page)

In all probability.

Reply to this comment    27 February 2005, 16:35 GMT

Doing trees
OnyxG7 Account Info

Here is a hack to do trees with Ti-basic:
use variables like this (ø must never be defined):
ø(ø(3,5),8)
To navigate your tree, you just use part on it:
part(t) = 2
part(t,1) = ø(3,5)
(And also: part(t,0) = "ø")

Anyway, Ti-basic had been driving me mad, with its limitations in local variables, functions vs programs. That was plain arbitrary and could easily have been removed from the language.
Happily, there is the TiGCC option. With its very good docs, it makes programming quite easy, and so much consistent and powerful. Not to mention that the Ti-BASIC stack is available if you ever need it.

Reply to this comment    5 March 2005, 15:14 GMT

Re: Is it Time to Replace TI-BASIC?
Dustin Durell  Account Info

Now, the author of this has a good point, programming BASIC does not allow for advanced commands to run certain programs that require it. But there is something the author does not realize.

The purpose of BASIC is to program commonly used sequences so that it performs them simoltanously(sp?). These include FORMULAS and GRAPHING, and other such things. The people at TI had no intention of making a language for complex programming, hence BASIC. So, in mind of the average customer, they excluded such advanced features because they will

1. Confuse the average customer
2. Take up unnessessary RAM because only a small fraction of the customers will use these commands.

The point is, I know it might be nice for the select few, but on the whole, the whole programming feature would be useless to 99% of the customers. If you have a huge hankering to do some advanced programming, go to asm.

Reply to this comment    19 March 2005, 00:48 GMT


Re: Re: Is it Time to Replace TI-BASIC?
Ankur Dave Account Info

I think a good-sized portion of TI calculator users can program but are frustrated by the limitations and cluttered code of TI-BASIC. And most (around 99%) of those people don't want/have the time to learn ASM, which is a very tedious language as it involves fiddling with registers and so on rather than just saying 1 -> X. There should be a sort of intermediate language for the sort of people who want more than TI-BASIC but also don't want to invest the time it takes to learn ASM. And no, this does not cause a problem with backward compatibility because TI can just have two code editors: one for BASIC and one for the other language. I think C++ would be good for this because it is powerful and, compared to ASM, simple to get started.

Reply to this comment    29 October 2005, 04:13 GMT

Re: Is it Time to Replace TI-BASIC?
jman52990  Account Info

i agree with many of your points. ti-basic is very slow and basic. i program for basic simply because it is on-calc and doesnt require a computer. if i had the time and energy, i would learn assembly programming.

that being said, i think basic is still a good jumping off point. it is simple and easy to learn. perhaps they could add a faster language and still keep basic for beginners.

Reply to this comment    24 March 2005, 21:24 GMT

1  2  3  4  5  6  7  

You can change the number of comments per page in Account Preferences.

  Copyright © 1996-2012, the ticalc.org project. All rights reserved. | Contact Us | Disclaimer