Seventh development version

I’ve finally managed to implement subroutines! I expected this task to be the greatest obstacle to development progress, and it didn’t turn out to be so bad after all—indeed, structures (and modules) are looking more daunting now. A bit of polishing still remains: local variables are implemented, but static variables aren’t yet; subroutines can’t take either array or scalar references as parameters, nor can they return references to arrays or scalars; and I’m sure there are plenty of bugs that I haven’t managed to iron out yet.

If you can, please download (tar.gz, zip) and test the seventh development version, and report any bugs that you find! Thanks in advance. :-)

What’s new?

  • Subroutines:
    hello ("Tom")
    
    sub hello (name$)
       print "Hello, " + name$ + "!"
    end sub
  • Local variables:
    a = 1
    print a
    test ()
    print a
    
    sub test ()
       print a
       local a = 2
       print a
    end sub
  • A FREE command:
    dim array[100]
    array[50] = 1
    free array
  • Multiple assignments per line:
    a = 1, b = 2, c = 3
  • And a few other little things.

Here are a couple of really rough benchmarks.

// subroutine calling
for call = 1 to 1000000
   test (1, 2, 3)
   test (call, call + 1, call + 2)
next

sub test (a, b, c)
   return a + b + c
end sub

(On my machine: 3.965 seconds in Yabasic 2.763, 0.530 seconds in Yabasic 3.)

// recursive subroutine

test (100000)

sub test (a)
   if a test (a - 1)
end sub

(On my machine: 0.206 seconds in Yabasic 2.763, 0.022 seconds in Yabasic 3.)

  1. I ran the first benchmark using lua. On my machine (intel i7 2.66 ghz on win7) runtime was 0.29 seconds.

    Tried it with luajit as well: 0.08 seconds.

    Of course I had to adapt your benchmark program a bit to make it work with lua (but only a bit).

    I tried running the benchmark program using yabasic as well (compiled yabasic using mingw (3.4.5) on windows 7).

    Runtime: 0.85 seconds.

    All timing was done using powershell (example: measure-command {.\yabasic.exe test2.yab}).

    Lua is known for it’s speed of execution. On this particular benchmark lua is only twice as fast as yabasic.

    Hopefully yabasic does just as well with other benchmarks. Perhaps speed will start to drop as you add more features to the language?

    I ran into some small compilation issues using mingw. The signals SIGHUP and SIGQUIT are not defined in mingw. After removing the statements having to do with SIGHUP and SIGQUIT compilation succeeded.

  2. AGS, thanks very much for testing this version! :-) I’m pleased that Yabasic 3 is running pretty speedily on your machine as well. I expect a very minor slowdown as extra features are added, but the fundamentals are well in place, and there are several things I could probably do to improve performance.

    Thanks for reporting the SIGHUP/SIGQUIT issue. I’ll fix it right away!

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>