LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

What features do you wish were in smilebasic?

Root / General / [.]

12Me21Created:
I don't think any 3DS games are allowed to run while it's in sleep mode.
Animal Crossing, Smash, Ambassador programs; I know a lot of games that continue to run with the system closed. I mean fully run: Animal Crossing continues running if your gate is open. It even warns you about it. Ambassador programs (like the GBA games) simply never allow the system to go into sleep mode. It's doable, I just don't know if it's a thing only Nintendo games can do. Edit: Base 1 has a computational overhead. In memory, variables are stored with an address. For arrays, this address points to the first element. Offsets (like 1, 2, 3) add to the address, so "no offset" from the first address is the first element (0 based index). If it starts at 1, the generated code would have to perform a subtract EVERY time you access an array. Imagine array accesses taking 50% longer... each and every one.
It could just add 1 in DIM, and never use index 0.

That's not a bad idea, but what if you have a multi-dimensional array? The first entire subarray wouldn't be used and each subarray's first slot also wouldn't be used. It starts to eat up memory... for instance, if you have an array that's 1000 across but only 3 deep (like an array of enemy values), you're using 4000 memory slots to hold a 3000 slot structure. 0 based index is also kind of an "old school" thing. The big original languages that were popular back when BASIC was popular (like C) all used 0 based indices because you couldn't waste memory or CPU time back then.

That's not a bad idea, but what if you have a multi-dimensional array? The first entire subarray wouldn't be used and each subarray's first slot also wouldn't be used. It starts to eat up memory... for instance, if you have an array that's 1000 across but only 3 deep (like an array of enemy values), you're using 4000 memory slots to hold a 3000 slot structure.
That is true, but I'm sure there is a better solution than my idea. Maybe the unused 1000 slots could be used to hold other variables and stuff. TI BASIC managed to get away with 1-indexed arrays, and only a few kilobytes of RAM, so I'm sure it possible.
0 based index is also kind of an "old school" thing. The big original languages that were popular back when BASIC was popular (like C) all used 0 based indices because you couldn't waste memory or CPU time back then.
Yes. But BASIC isn't meant to be old school, it's supposed to be relatively easy and enjoyable to program in. Anyway, another thing I (and everyone else) wish was in smilebasic is the ability to transfer stuff from your computer to the 3DS. Maybe access to the server from computers? That way they could still control everything.

The ambassador GBA games can't sleep because they run in AGB_FIRM, the hardware GBA mode left over from the DS hardware used in the system. It's simply not supported by GBA hardware. To elaborate on sleep mode, applications are set to trigger and run an interrupt routine when the system sleeps. They do things in sleep mode, but since the system disables a lot of features and components (such as the screen) they use very little power. For most games it's just waiting for the system to wake and perhaps preserving game state, but other apps do more complex things (of which I can't give any examples.) In the case of SB, they put the interpreter into standby and basically wait until you wake up, whilst updating MAINCNT. It's entirely possible for them to implement a routine that triggers when sleep happens (similar to SPCALL and CALL SPRITE), but they would probably have to check the routine's code manually to make sure it doesn't execute anything illegal while asleep. This won't work at all the way the precompiler is currently set up.

To elaborate on sleep mode, applications are set to trigger and run an interrupt routine when the system sleeps. They do things in sleep mode, but since the system disables a lot of features and components (such as the screen) they use very little power. For most games it's just waiting for the system to wake and perhaps preserving game state, but other apps do more complex things (of which I can't give any examples.)
That's not how I understood it at all... Here's how I think it works: If a game wants to keep running when the system is closed, then it disables sleep mode. This leaves the CPU running fully, but the screen is (obviously) inaccessible among other things. The L and R buttons are still accessible. There is an easy way to tell if a game is doing this: when the 3DS is in sleep mode, the power light starts "breathing" instead of being on constantly. If the game prevents sleep mode, the light will continue to be on steady. The only example I can think of (besides GBA games which don't count) is when a game or app keeps playing music with headphones plugged in. Smash Bros does this if you turn it on, and the built-in music app does this by default.

Function overloading! As a result, parameter type-checking!

Optional arguments in functions.

Function overloading! As a result, parameter type-checking!
Agreed. That and some sort of internet support which is never going to happen... oh well.

Optional arguments in functions.
Optional arguments would be AMAZING. Also a local file transfer would be nice but won't happen probably :(

Optional arguments in functions.
Optional arguments would be AMAZING.
My new programming language compiler, H#, will have optional arguments. My previous language N# did not have optional arguments unfortunately. Please note that H# will be a functional declarative language before immediately trying it.

local file transfer? That can already be done...

I hope that I'm not posting on a dead thread, but the first comment was edited a couple minutes ago, so here I go. I don't think that anyone has said Array Constructors (DIM HI[2]=[5,9]) If someone has, I'll delete this post.

I hope that I'm not posting on a dead thread, but the first comment was edited a couple minutes ago, so here I go. I don't think that anyone has said Array Constructors (DIM HI[2]=[5,9]) If someone has, I'll delete this post.
If you have something to say, it's better to post on a old(ish) thread than to make a new one Anyway, yeah that would be nice. However, maybe DIM H[2]=={5,9} would be better, because [5,9] looks too much like you are making a 5x9 2D array. and then, in place of a 1D array, you would be able to put {,} lists.

Here's why 0-indexed languages make sense.
Memory tape:
|n+0|n+1|n+2|n+3|etc|
| 0 | 1 | 2 | 3 |etc|
So as random said, something like STRING$[0] means "start of the string with an offset of 0." From a low-level perspective, it makes sense, and it has since become the standard. The reason so many people are confused is because in a non-programming world, we don't usually count from 0. Programming counts at 0. Because we count from 0 inclusive, this results in stuff like arrays having a length of n but a highest slot of n-1. However, this can make sense by thinking of the lowest slot as n-n.

Ok, which is better: FOR I=0 TO LEN(ARRAY)-1 FOR I=1 TO LEN(ARRAY) yeah. Also, commands like INSTR() have to return -1 when nothing is found in 0-indexed languages, which means they must also be modified for use in IF statements. IF INSTR(...)+1 THEN IF INSTR(...)!=-1 THEN or IF INSTR(...) THEN Programming languages should be designed for people to understand them. If you want to program in a language that is designed for computers to understand, then just use assembly.

For your first point, ideally we should have a foreach statement (which I've added in N#). It works like this:
foreach (index in array)
As for the INSTR issue, that's an easy workaround.
IF INSTR(...)!=-1 THEN
I don't mind this. As for programming languages being easy to understand, that depends on the language. C was made to be fast and powerful. Its purpose was not to be easy. SB was made to be a BASIC revival language. Its main goal was not to be a full-fledged application development environment.

foreach is a small and limited fix for a problem that doesn't need to exist. (and, like with many C statements, It always looks foREACH to me. But that is irrelevant.)
As for the INSTR issue, that's an easy workaround.
And this is why I prefer 1 indexing. You don't need all those workarounds. I think every language should have an option that lets you use 0 or 1 indexing, but I'm sure you can argue with that too. Using 1 indexing doesn't make a compiled language any slower or less powerful. As for the "full-fledged application development environment" thing, you're right, but BASIC isn't really limited because it's BASIC, it's limited because most people don't take it seriously enough to make a dialect that has all the features of "popular" languages. In addition, because 1 indexing is what non-programmers use, it makes it easier to work with things like inputs/outputs.

It actually can make it slower. It requires (because of my memory tape example) distinction between array/whatever referencing and another constant and has to adjust. Like randomous said, "Base 1 has a computational overhead. In memory, variables are stored with an address. For arrays, this address points to the first element. Offsets (like 1, 2, 3) add to the address, so "no offset" from the first address is the first element (0 based index). If it starts at 1, the generated code would have to perform a subtract EVERY time you access an array. Imagine array accesses taking 50% longer... each and every one."

As I said... if the language is COMPILED, 1 or 0 indexing makes no difference in speed, because the compiler converts them both into 0 indexed. And if you're using an interpreted language... well, you obviously don't care about speed, so that argument doesn't matter. However, remember all those workarounds that are required for 0 indexing? INSTR()+1, LEN()+1? Those are just converting small areas of code into 1 indexed code, and doing it this way might actually have a speed difference.

What if we're using an interpreted language like SB and we want speed but are limited because of the environment?