Shop OBEX P1 Docs P2 Docs Learn Events
So, what about xbasic? - Page 7 — Parallax Forums

So, what about xbasic?

1234579

Comments

  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 03:46
    ...as the C purists say you can't have inline assembly, but what is allowed is arrays of hex, so that is how assembly is written.
    I think this is a reference to an argument that was given a long time ago in response to a request to add inline assembly to Catalina C. GCC, of course, has always had a way to do that. I think the argument was that a program that contains embedded assembly language is not compliant with the ANSI standard for C since that standard has no concept of inline assembly. It may be that Catalina even supports inline assembly now. I think this is a very old argument.
  • Heater.Heater. Posts: 21,230
    edited 2014-01-17 03:47
    mindrobots,
    ...due to the expressive verbosity of C...
    I love it.

    It just shows how peoples views of the same thing can vary so wildly.

    Compared to Ada, Pascal, COBOL and a few others C is positively terse.
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 03:52
    Heater. wrote: »
    mindrobots,

    I love it.

    It just shows how peoples views of the same thing can vary so wildly.

    Compared to Ada, Pascal, COBOL and a few others C is positively terse.
    I never thought I'd hear the term "verbosity" applied to C. :-)
  • Heater.Heater. Posts: 21,230
    edited 2014-01-17 04:01
    Perhaps mindrobots would prefer to program in APL :)

    I'd like to copy and paste an APL example to a code block here but it seems to be impossible, all APL examples on the net are shown as png images and such.
  • Heater.Heater. Posts: 21,230
    edited 2014-01-17 04:13
    mindrobots,
    I've decided in my old age I'm getting too lazy for some languages.
    Same here.

    Having had to use Algol, PL/M, C, Ada, Coral, Pascal, Spin etc over the years I'm fed up with it. They are all the same in a different syntax and a different set of annoying quirks. To hell with that tread mill. C is what makes the world go round so C it is. The best of a bad bunch.

    Then there are the BASICs. All rude and crude. All different. Often non-portable. Nope, no more BASICs for me. I'm not even going to keep any one of them on my list.

    Nope, a new language for me has to be different in some meaningful way. One might think that would lead to Lisp or Scheme or APL or Prolog or some other weirdness. That's too much for me now.

    Luckily there is JavaScript. That innocent and long scoffed at little language that turns out to have ideas embedded in it that language like Java and C++ are only just now trying to imitate. Features that open up whole new programming styles if you are adventurous.

    It also helps that JS looks like C :)

  • RsadeikaRsadeika Posts: 3,837
    edited 2014-01-17 04:46
    Nope, no more BASICs for me.
    Well, I guess we can take one name off the list for potential users of xBasic. Moving on, as I stated in my OP, my interest for xBasic is in a quick and dirty prototyping language, possibly another tool in the toolchest. Of course xBasic has to experience some more growth in terms of drivers before it becomes something that I could really use. But, with interest growing in the PASM bytecode array stuff, we just might see some drivers showing up, and even be able to use them within a COG or two. Not really sure which way xBasic is heading from here.

    Ray
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 05:13
    Rsadeika wrote: »
    Moving on, as I stated in my OP, my interest for xBasic is in a quick and dirty prototyping language, possibly another tool in the toolchest. Of course xBasic has to experience some more growth in terms of drivers before it becomes something that I could really use. But, with interest growing in the PASM bytecode array stuff, we just might see some drivers showing up, and even be able to use them within a COG or two. Not really sure which way xBasic is heading from here.
    I think you've nailed the problem. xbasic won't be a "quick and dirty" language if we pile all kinds of features on it such that it approaches Spin in complexity. I'm not sure what a good balance is at this point but fancy inline assembly features and support for modules or even objects probably move it out of the realm of simple languages. Unfortunately, those features are needed to build non-trivial programs. It's a quandary.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2014-01-17 05:13
    Of course xBasic has to experience some more growth in terms of drivers before it becomes something that I could really use.

    I agree. There is a huge amount of code in the Obex that only works for Spin. A typical Obex object will have some Spin and some Pasm. For anyone tasked with translating the code to xBasic, it would be much simpler if the Pasm just stayed as it is. I think it is entirely possible to do that with a preprocessor using a command line spin compiler.
    ...and support for modules or even objects probably move it out of the realm of simple languages.

    Objects shouldn't be too hard. Take a typical Spin program with multiple objects. Rename each variable in an object with a prefix "object1_" etc, which makes them global, but at the same time only locally accessible. Rename all calls such as object1.myroutine as myroutine, and check for naming conflicts. Merge all the objects together as one single large text file. Now all calls within objects become functions/subroutines in a global program but only still work within that object.

    This can be done with a preprocessor - text files in, text files out. It is possible to do the same thing with Spin objects - merge multiple objects together into one huge single text file, so long as there are no variable or function names the same between objects. It is a matter of making every variable/function unique. I've done this manually - it is tedious but quite possible. So xBasic can have objects.
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 06:28
    I'm trying to figure out why some people are drawn to Basic dialects. I wonder if just giving the language a name including "basic" makes people think it will be easy to use so they approach it differently than they would C or Spin or Javascript, etc? As Heater pointed out, some Basics these days aren't really less complex than C and they often have very inconsistent syntax. For example, I think VB uses "END IF" to end an IF statement but "WEND" to end a WHILE statement. Why not "END WHILE"? Anyway, it could be that adding the word "basic" relaxes people and makes them less afraid to dive in and try things?
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 06:31
    David Betz wrote: »
    I'm trying to figure out why some people are drawn to Basic dialects. I wonder if just giving the language a name including "basic" makes people think it will be easy to use so they approach it differently than they would C or Spin or Javascript, etc? As Heater pointed out, some Basics these days aren't really less complex than C and they often have very inconsistent syntax. For example, I think VB uses "END IF" to end an IF statement but "WEND" to end a WHILE statement. Why not "END WHILE"? Anyway, it could be that adding the word "basic" relaxes people and makes them less afraid to dive in and try things?
    Also, what set Basic apart for me were the easy to use string functions. By that measure, xbasic isn't really Basic since it doesn't have MID$, LEFT$, RIGHT$, etc. Python and Javascript are closer to what I expect from Basic runtime support. :-)
  • Heater.Heater. Posts: 21,230
    edited 2014-01-17 06:33
    I think you are right David,

    "END IF", "WEND", it's crazy stuff.

    If it does not use line numbers and GOTO, GOSUB then it's no longer BASIC as far as I'm concerned. It's actually trying to be Pascal or C or whatever and failing miserably.

    I don't even understand why we, well MS, started turning BASIC into a high level block structured language when we already had plenty of them standardized already.
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 06:38
    Heater. wrote: »
    II don't even understand why we, well MS, started turning BASIC into a high level block structured language when we already had plenty of them standardized already.
    Good question. Of course, it makes sense to evolve any language but the step from line-numbered, Dartmouth Basic to VB.NET is pretty huge and it's hard to see that the result is even the same language. If you look at C++ you can still see C underneath and as a subset. The base language is still evident. This is true even in Lisp and probably Smalltalk. The more modern versions are a clear evolution of the original language. Basic is a whole other story.
  • TinkersALotTinkersALot Posts: 535
    edited 2014-01-17 06:59
    <sheepish grin>

    B etting
    A nother
    S yntax
    I s
    C ooler

    ??
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 07:02
    What if I converted xbasic to use C-like syntax? Would it still be Basic? :-)
  • Heater.Heater. Posts: 21,230
    edited 2014-01-17 07:13
    My guess is that it was just marketing gibberish from Microsoft. MS had made it's name with 4K and 8K and whatever BASICs for the old 8 bit machines. Later they had GWBASIC which added WHILE/WEND and such nonsense for the PC. Later they had Visual BASIC for Windows. Just keep the name so that you can pull your customers along with it. Even if the resulting language has nothing of the original left except "DIM".

    In a similar vein. Netscape had a scripting language called LiveScript which they were going to put into browsers. At the time they were working with Sun to get Java applets into the browser. Somewhere along the line Sun insisted that LiveScript be called JavaScript. The poor down trodden language has had to suffer under that hideous name ever since even though it has nothing to do with Java and is actually a superior language.

    Luckily JS survived the best efforts of marketing.
  • Heater.Heater. Posts: 21,230
    edited 2014-01-17 07:14
    David,
    What if I converted xbasic to use C-like syntax? Would it still be Basic? :-)
    Careful. If you do that. And throw in the string handling you want you will soon end up with JavaScript.
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 07:15
    Heater. wrote: »
    Even if the resulting language has nothing of the original left except "DIM".
    Hmmm... I wonder if there is some significance to that? :-)
  • Heater.Heater. Posts: 21,230
    edited 2014-01-17 07:17
    Chuckle:)

    Do they still have "LET"?
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 07:26
    Heater. wrote: »
    Chuckle:)

    Do they still have "LET"?
    I don't know about VisualBasic but xbasic allows you to use LET but doesn't require it. It would probably make sense to remove it.
  • RsadeikaRsadeika Posts: 3,837
    edited 2014-01-17 07:26
    BASIC = Beginners All-purpose Instruction Code. BASIC is a programming language devised to simplify programming for beginners.
    I like the above line. Maybe this:"... a programming language devised to simplify programming for beginners." , should not be forgotten. The actual BASIC could have all the complexity of C available for use, if and when somebody would want to use it, but it would be somewhere in the background. I am not really sure that something like that could be accomplished, but I am sure that every language started out with good intentions. So how do you blend simple usage and complex utility into a useful language?

    Ray
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 07:31
    Rsadeika wrote: »
    I like the above line. Maybe this:"... a programming language devised to simplify programming for beginners." , should not be forgotten. The actual BASIC could have all the complexity of C available for use, if and when somebody would want to use it, but it would be somewhere in the background. I am not really sure that something like that could be accomplished, but I am sure that every language started out with good intentions. So how do you blend simple usage and complex utility into a useful language?

    Ray
    That's a very good question. It is quite easy to pile on complexity. I could add objects, modules, inline PASM, and lots of other stuff to xbasic but it would probably make it harder to use as well as more powerful. Also, it would blur the distinction between xbasic and, say, Spin. In fact, Spin may already achieve the "simple to use" goal if you ignore some of its more esoteric operators. The basic language is quite simple and easy to understand. Maybe we could just rename "Spin" to "PropBasic". Oh no, that name is already taken! :-)
  • Heater.Heater. Posts: 21,230
    edited 2014-01-17 07:35
    Ray,
    So how do you blend simple usage and complex utility into a useful language?
    See JavaScript.

    At the beginner end you have simple variables: numbers and strings. Simple expressions. Simple control flow structures "if", "for", "while".

    Moving up we get into arrays and lists and functions.

    Moving up we get into objects perhaps classes, object enhancement, interfaces, prototypical inheritance.

    Moving up we get into first class functions, closures, promises...

    And so on. All with the same simple language.

    I think JS is the only language that sees such a lot of serious use across the board from rank beginners to serious turbo coders.

    And now it's coming to the micro-controller world.
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 07:39
    Heater. wrote: »
    Ray,

    See JavaScript.

    At the beginner end you have simple variables: numbers and strings. Simple expressions. Simple control flow structures "if", "for", "while".

    Moving up we get into arrays and lists and functions.

    Moving up we get into objects perhaps classes, object enhancement, interfaces, prototypical inheritance.

    Moving up we get into first class functions, closures, promises...

    And so on. All with the same simple language.

    I think JS is the only language that sees such a lot of serious use across the board from rank beginners to serious turbo coders.

    And now it's coming to the micro-controller world.
    Yes, Javascript is a nice language. The last I looked though it's "object" features were a bit crufty. Has that been fixed?
  • Heater.Heater. Posts: 21,230
    edited 2014-01-17 07:46
    Define "crufty" in this context.
  • RsadeikaRsadeika Posts: 3,837
    edited 2014-01-17 07:52
    Most of the things that I talk about here are geared to the Propeller. So, Heater., xJavascript for the Propeller 1, when can we expect something? Or it could maybe renamed too something like xBasicscript for the Propeller.

    Ray
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 07:58
    Heater. wrote: »
    Define "crufty" in this context.
    Okay, strike that comment. I just thought I remembered some awkward syntax for defining methods but I looked at a couple of books I have on Javascript and everything I found in there looked perfectly sensible. Maybe I looked at some badly written sample code back early on. In fact, browsing through a book I have called "Elequent JavaScript" made me want to try it out again!
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 08:34
    mindrobots wrote: »
    "BASIC" may have been true in 1960 when you look at the alternatives of the time and how truly simple BASIC was. Now as mentioned, it has morphed into some unrecognizable monster that has lost everything a 1960 user would recognize except the "DIM". Agreed this was more marketing and continuing sales than anything else. Introduce Fear, Uncertainty and Doubt about any other language except what MS calls BASIC.

    As for modern "simple" languages, I'd counter JS with Python (2 million RasPi users can't be wrong, right? :smile:) While suffering somewhat in the efficiency department when compared to others, it's pretty sweet sitting down at an interactive prompt and being able to go from a one line "Hello World" to importing modules and interacting with objects as you develop your code. (Plus, it doesn't need all those silly braces :smile:)
    Python does seem nice as does the interactive version of Javascript Heater has been talking about. One problem though is that both of these languages are probably unsuited for high performance MCU applications unless you augment them with native code built-in functions to handle the heavy lifting.
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 08:53
    mindrobots wrote: »
    I think the biggest issue for MCU adoption is the size of their runtime footprint as garbage collection...that's why Forth was invented: interactive, small footprint
    Yes, I am very well aware of this. It is why I still have a desire to learn more about Forth.
    ... and most people would argue that if you collected the garbage in Forth, it would cease to exist! :lol:
    Yeah, well. You can always find people who will trash any language! There may even be people in the world who don't believe that xbasic is the ultimate in programming languages! :-)
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-17 10:35
    This is a reply to a PM I received from JonnyMac. His mailbox is full so I can't send it directly to him.
    JonnyMac wrote:
    David,

    A question I posted in the xBasic thread has been skipped over by all the noise generated by Ray.

    Could you give me the 30-second overview to adding native assembly snippets to an xBasic program or library?

    Thanks,

    Jon

    Hi Jon,

    Did you get a reply to this? I tried sending one but it isn't appearing in my "sent" folder so I'm not sure if it made it through.

    Anyway, I'm planning on working on xbasic some over the weekend and I'm going to try to add symbolic PASM support using my simple PASM assembler. I'm also planning to try adding multi-line NATIVE code so you don't have to do things one instruction at a time and maybe it will let me support some branching like DJNZ. Once that's done and I remind myself of how this all works I'll try to write a cheat sheet for NATIVE coders. Are there any specific questions I can answer for you in the meantime?

    Thanks,
    David
  • JonnyMacJonnyMac Posts: 9,107
    edited 2014-01-17 10:51
    No, I'm cool. It's not likely, given the way the VM executes, that I would pursue this any further. That's not a criticism, it's just that I am happy with Spin and, thusfar, have found that Spin executes a little faster (granted with my very limited experiments). Still, I have customers of EFX-TEK products that like BASIC and I have pointed them to the xBasic web site. I'll keep lurking and as things develop, will experiment with them.

    Sadly, this thread devolved from its topic to the merits of other languages.
Sign In or Register to comment.