Author Topic: Notes on Script BASIC  (Read 29953 times)

Aurel

  • Guest
Re: Notes on Script BASIC
« Reply #15 on: September 21, 2018, 02:20:37 PM »
Oh boy
No is not .Sequence is something different and that is proof that you don't know the things.
In fact i am not surprised it is not the first time you like to talk about things you don't understand
..man you must know the background of stuff then you can patronize what is what and what we must do
 ;D
hmmmm tomek ..tomek...
Ok i agree with you that from ordinary perspective is not important to know
but is not bad to know because someone like you may talk from very high points ...
he he ...jibba

Aurel

  • Guest
Re: Notes on Script BASIC
« Reply #16 on: September 21, 2018, 02:22:17 PM »
..and what a heck script basic have with all this  ::)

Ed Davis

  • Guest
Re: Notes on Script BASIC
« Reply #17 on: September 21, 2018, 02:38:58 PM »
Here is a list sequence of numbers - [120, 135, 345, 345, 1890, 12, 120, 12, 135, 712, 78, 120]. The task is to print three biggest unique elements sorted from biggest to smalllest.

Below is a C version.  I used 12 just to show that only unique entries are printed. 

This definitely shows the utility of using something like Python, Ruby, etc. 

I'm taking a C# course.  I wonder if it has any shortcuts?  e.g., I can do this in C#, the C way (e.g., old programmers joke:  I can write FORTRAN in any language), but don't yet know enough about C# to know if it has any Python-like shortcuts.

Code: [Select]
#include <stdio.h>
#include <stdlib.h>

#define ARRAY_SIZE(a) sizeof(a)/sizeof(a[0])

/* Comparison function. Receives two generic (void) pointers to the items under comparison. */
/* https://en.wikipedia.org/wiki/Qsort */
int compare_ints(const void *p, const void *q) {
    int x = *(const int *)p;
    int y = *(const int *)q;

    if (x < y)
        return 1;   // Return -1 if you want ascending, 1 if you want descending order.
    else if (x > y)
        return -1;  // Return 1 if you want ascending, -1 if you want descending order.

    return 0;
}

// print first k unique entries from array ar, don't go past n
void print_unique(int ar[], int k, int n) {
    int i, last;

    for (i = 0; i < n && k > 0; ++i, --k) {
        if (i == 0 || ar[i] != last)
            printf("%d\n", ar[i]);
        last = ar[i];
    }
}

int main() {
    int ar[] = {120, 135, 345, 345, 1890, 12, 120, 12, 135, 712, 78, 120};

    qsort(ar, ARRAY_SIZE(ar), sizeof(ar[0]), compare_ints);
    print_unique(ar, 12, ARRAY_SIZE(ar));
    return 0;
}

I used gcc, but this should compile with any standard C compiler.
« Last Edit: September 21, 2018, 02:53:08 PM by Ed Davis »

Tomaaz

  • Guest
Re: Notes on Script BASIC
« Reply #18 on: September 21, 2018, 02:44:37 PM »
Aurel, I don't care about this internal stuff. The whole idea of easy to use scripting languages is that you don't have to. I used Python in my example and in Python this kind of data is called "a list". In Lua it's called "a table", in Euphoria it's called "a sequence" and in Ruby it's called "an array". If you want to discuss this internal stuff, please register on any of Python forums and tell them to call lists "arrays" . Guido just resigned, so who knows? You even may be succesful.  ;D Just let me know where you've registered. Don't want to miss an opportunity for good laughs.  ;D

I've posted a piece of code that works and do exactly what is meant to do. And you come with some absurd arguments about it. I think it is just a desperate way to start a fight with me.  ;) And what it has to do with ScripBasic? John several times claimed that ScriptBasic arrays were more flexible and powerfull than similar data types in modern languages. I want to show you how wrong he was.

ZXDunny

  • Guest
Re: Notes on Script BASIC
« Reply #19 on: September 21, 2018, 03:12:43 PM »
WOW ...WOW ...
John is really quick he delete account here
geee

I suspect it's because we're not being professional with our BASICs. In his eyes, BASIC isn't meant to be fun, it's certainly not meant to be easy to create one (even though it's pretty trivial to make a simple language interpreter) and the fact that we're having fun with ours and not pursuing a career out of it offends his delicate sensibilities :D

And goshdammit, no BASIC creators have contributed to his wiki! Heathens, the lot us.

And so he's flounced out of our little community. It's not the first time though, so I'm not overly concerned.
« Last Edit: September 21, 2018, 03:14:36 PM by ZXDunny »

B+

  • Guest
Re: Notes on Script BASIC
« Reply #20 on: September 21, 2018, 03:43:55 PM »
Well I hope he quit to go put all his focus on project to make a Beginners package to prove how extensible and pluggable ScriptBasic really is. So he can get his B back from B+, I hate calling anything ASIC.

Should be a trivial thing for a professional coder, heck it might even be fun.

Aurel

  • Guest
Re: Notes on Script BASIC
« Reply #21 on: September 21, 2018, 04:33:24 PM »
Quote
and in Python this kind of data is called "a list". In Lua it's called "a table", in Euphoria it's called "a sequence" and in Ruby it's called "an array"

well that explain a lot about you   ;D
just like hole is a hole  ;D ;D ;D
oh boy oh boy....
good thing is that i am not John and also i don't care about your babeling "stupid" things .
maybe is a time for vodka  ::)

Tomaaz

  • Guest
Re: Notes on Script BASIC
« Reply #22 on: September 21, 2018, 04:57:25 PM »
Quote
and in Python this kind of data is called "a list". In Lua it's called "a table", in Euphoria it's called "a sequence" and in Ruby it's called "an array"

well that explain a lot about you   ;D

Can anyone explain what that explains about me?

Aurel, are you aware that "lists" doesn't neceserilly mean "linked lists"? Python, for example has lists that are not linked lists, but if you need linked lists you can implement them easily without using anything written in C/C++:

https://www.tutorialspoint.com/python/python_linked_lists.htm
https://medium.com/@kojinoshiba/data-structures-in-python-series-1-linked-lists-d9f848537b4d
http://interactivepython.org/courselib/static/pythonds/BasicDS/ImplementinganUnorderedListLinkedLists.html

Here is a code in NewLisp:

Code: [Select]
(set 'x '(120 135 345 345 1890 12 120 12 135 712 78 120))
(println (slice (sort(unique x) >) 0 3))

I hope that lists in NewLisp are, under the hood, implemented as linked lists*. Otherwise, you have to inform its author that he has to change the name to NewArrp.  ;D

EDIT After you've registered on some Python forum, just remember to put "https is a just another crap". It will instantly gain you some "respect". ;D ;D ;D

* I believe they are, but you have to check the manual to be 100% sure.
« Last Edit: September 21, 2018, 05:06:54 PM by Tomaaz »

Aurel

  • Guest
Re: Notes on Script BASIC
« Reply #23 on: September 21, 2018, 05:25:16 PM »
No ..Noo ...noooooooooooo
pssssst ...so i must create LIST which is what LIST listing  >:(
in fact it is good to fool naive jer**
 ;D

Aurel

  • Guest
Re: Notes on Script BASIC
« Reply #24 on: September 21, 2018, 05:28:56 PM »
YO man script basic don't have LIST[]  ::)
oh poor JRS

oh sorry mister T i forget that you know everything  :P
« Last Edit: September 22, 2018, 11:06:31 AM by Aurel »

AlyssonR

  • Guest
Re: Notes on Script BASIC
« Reply #25 on: September 21, 2018, 06:05:27 PM »
No matter what you say ... Script Basic is a decent program - and like any, it has pluses and it has minuses.

It is *not* the easiest version of BASIC to use, but it is quick and clean and is well suited to providing back-end services (especially if you want to be able to connect to a diagnostic socket using a terminal program).

For business-style front ends, I still think that VB6 is as good as it gets - which is a shame, because there are so many cool looking user interfaces that can be build elsewhere - but at the cost of a rat's nest of programming because you need to re-create the wheel for every widget, whatsit and whistle.

Now, if someone could come up with a (cross-platform) graphical terminal program (they used to be called graphics terminals) that allowed a form to be generated from a configuration file, using skinnable widgets and complete with all of the event messages and data interchange over a serial connection, then I'd probably pay money for it.

Peter

  • Guest
Re: Notes on Script BASIC
« Reply #26 on: September 21, 2018, 08:42:54 PM »
Hi Tomaaz,

Well, that is a naughty thing to do, challenging BASIC with a construct which is the very essence of some other programming language ;). As you know, Lisp, or LISt Processing, was designed to process lists. No wonder that a list can be processed in such an elegant way in newLisp. List processing is of course not the strongest skill of a BASIC language.

And I understand your reaction, it actually made me laugh :) Still, I keep using my converter, but this is with a reason. After I had used ScriptBasic for a while, I discovered newLisp and I started to program it fanatically (see some programs here). I used to be very good at it, if you don't mind me saying. If you look into the archives of the newLisp forums, you'll see a lot of my posts. I also posted a lot of issues and bugs in the language (for example here). I liked the language so much that I actually met the newLisp creator Lutz Mueller in person.

However, I did leave newLisp, for a couple of reasons, even though newLisp can process a list very good as well as it can do some other things very good. Your code snippet looks nice and small, but there are other aspects to newLisp which, at a certain point in time, can be a disadvantage. To name a few:
  • newLisp is an interpreter and therefore inevitably slow, even though it relies on precompiled libc functions heavily
  • newLisp is an interpreter and therefore always allows a 3rd party to peek into a program's source code, one way or another
  • newLisp is an interpreter and therefore always requires an interpreter binary to create a 'standalone' executable
  • at the time, newLisp releases kept changing the API, which is very tiring for end users who have to keep changing their programs to stay up to date
  • at the time, newLisp releases kept popping up bugs in lots of unexpected ways, and because the internal design structure of the implementation was kind of hard to grasp these bugs could be very confusing
  • GPL license not liberal enough for certain purposes
  • newLisp is the project of someone else and a newLisp programmer inevitably depends on the willingness of that person when it comes to bug fixes and proposed new functionality (note that mr. Mueller is a very nice and open developer, but it is about the dependency).
You mentioned some requirements, but here are mine: I left newLisp because I needed to create genuine binaries optimized for speed, independent from interpreters or other persons, without the option of 3rd parties peeking inside my code, and sought for a compatible (meaning multi-platform Unix oriented) way to do this. I ended up implementing a kind of a C preprocessor, using a syntax loosely based on VIC-20 BASIC and ScriptBasic, because I am a nostalgic person. This is the Basic Converter project.

Surely, it is not The Best Thing For All Purposes, but it fills my needs. And even though I may have to use a FOR/NEXT and a SORT to accomplish your task, at least I can create a program which performs such task very fast, independent from interpreters and libraries and other persons, in a readable manner, producing a binary which cannot be peeked into, executable on all POSIX platforms, even on my Android phone. Which you cannot say about newLisp (nor ScriptBasic) :P

This would be a solution in BaCon:

Code: [Select]
SPLIT UNIQ$("120 135 345 345 1890 12 120 12 135 712 78 120") TO list$ SIZE t
MAP list$ BY VAL TO nr SIZE t
SORT nr SIZE t DOWN
PRINT nr[0], " ", nr[1], " ", nr[2]

Not even a FOR/NEXT required  :)

Best regards,
Peter

Aurel

  • Guest
Re: Notes on Script BASIC
« Reply #27 on: September 21, 2018, 09:10:26 PM »
Peter
Tomaaz patronize to me about Python and not about newLips
and i doubt that he know how to make programs in newLisp or any other Lisp-Scheme etc PL-s  ::)
(copy/paste examples is his way just to show off....
Script Basic primary thing is as far as i know server-side scripting is it?
so as such this language is not for most hobby -enthusiast etc programmers
and also primary target is Linux.

Tomaaz

  • Guest
Re: Notes on Script BASIC
« Reply #28 on: September 21, 2018, 11:06:43 PM »
Peter, thanx for an interesting post and your solution in BaCon!

What I like about NewLisp is its simplicity, nice set of built-in functions and good documentation. However, I'm not 100% happy with it. The most important reason is its performance. Sometimes, NewLisp is surprisingly slow. I'm also not the biggest fan of Java-based GUI. To be honest I think that even Tk would be a better option and I don't understand why it's been swapped for Java. Recently, a new version of NewLisp has been released. I need to have a look at it again and force myself to think in a functional style, because my NewLisp coding was to procedural, I'm afraid. To be honest, the only reason I've mentioned NewLisp here was to have a laugh at Aurel's nonsensical "linked lists" argument (glad it made you laugh. ;)) My main example is in Python and it's been posted to show ScriptBasic's weakness rather than to promote Python itself. Unfortunately, if Python is mentioned anywhere on this forum then you can be 100% sure that Aurel will arrive ASAP with his WinApi, anti-OOP and vodka arguments.  ;)

I wonder what's your opinion on ScriptBasic. You've mentioned that you used it for some time. You're a top BASIC developer and user, so it would be very interesting to hear what you think about that interpreter.

Tomaaz patronize to me about Python and not about newLips

 ;D ;D ;D Lips, python... Sigmund Freud would have had something to say about your case. Then, of course, there is "the pipe" and Tux the Linux mascot...  No, I don't even want to think about it!!!  :o :o :o
« Last Edit: September 21, 2018, 11:14:58 PM by Tomaaz »

Peter

  • Guest
Re: Notes on Script BASIC
« Reply #29 on: September 22, 2018, 08:53:01 AM »
Ha ha, you do have quite a sense of humor I must say :) Regarding ScriptBasic, it is a good BASIC with some interesting features, but from my point of view, it has similar issues as encountered in newLisp:
  • ScriptBasic is based on an interpreter and therefore inevitably slow
  • ScriptBasic is based on an interpreter and therefore always allows a 3rd party to peek into a program's source code
  • ScriptBasic is based on an interpreter and therefore always requires an interpreter binary to create a 'standalone' executable, even though it creates intermediate bytecode first
  • its LGPL license is not liberal enough for certain purposes
  • ScriptBasic's current state: it is not actively being maintained anymore by the original developer, Peter Verhas, whose presence in the project would guarantee a high quality implementation
  • ScriptBasic is not supported on other Unix based platforms, meaning other than Linux
As for the newLisp GUI, I also was disappointed that it started to use a Java-based GUI, a decision made some time ago. I am not saying that it should have been GTK, but come on... Java?!?! Really?!?!  ???  Even if this would be the last graphical toolkit in the world, I would not remotely consider using it because of its huge and clumsy install base - as a matter of fact, I would rather optimize my text based editor and render my code in ASCII using ANSI escape codes and UTF8 based character sets to draw lines thereby simulating a window layout (like the DOS based Visual Basic 3.0, or Turbo Pascal).

Regards
Peter