User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 10:26 am

Here's the base bsearch transliterated into Python:

Code: Select all

def bsearch (value, sorted_collectio,n eq_predicate, lt_predicate, min_index, index_inc, max_oper, extract_oper):
  start = min_index
  end = max_oper(sorted_collection)

  while start < end:
        mid =((start + end) / 2
        elem = extract-oper(sorted_collection, mid)
        if eq_predicate(elem, value):
           return mid
        elif lt_predicate(elem, value):
           end = mid + index_inc
        else:
           start = mid - index_inc
  return False
The rest of the code is simply defining functions that call bsearch with defined operators.

The above code is very generic. It could be simplified down to:

Code: Select all

def bsearch (value, sorted_collection):
  start = 0
  end = len(sorted_collection) - 1

  while start < end:
        mid =((start + end) / 2
        elem = sorted_collection[mid]

        if elem == value:
           return mid
        elif elem < value:
           end = mid + 1
        else:
           start = mid - 1
  return False
That would work for any random-access sequence of numerically comparable elements.

[Edit: Man, that Loop construct in Scheme is WEIRD]

User avatar
joan
Posts: 14348
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 10:36 am

rurwin wrote: ...
The above code is very generic. It could be simplified down to:

Code: Select all

def bsearch (value, sorted_collection):
  start = 0
  end = len(sorted_collection) - 1

  while start < end:
        mid =((start + end) / 2
        elem = sorted_collection[mid]

        if elem == value:
           return mid
        elif elem < value:
           start = mid - 1
        else:
           end = mid + 1
  return False
That would work for any random-access sequence of numerically comparable elements.
To be pedantic the simplified code will not work for any elements. :D

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 10:43 am

I blame Scheme, and the decades since I last wrote Lisp code.
I think I've corrected it now.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 11:14 am

Emanuele wrote:Sorry @tufty, maybe I was a bit too confrontational.
Not at all. I certainly didn't take it that way, anyway, and even if I had, I wouldn't have taken it personally. Flame away, I can take it :)

I'm absolutely with you on teaching concrete problems as well, but they are, at least if we're talking about fundamentals, secondary to teaching the structural patterns, the algorithms needed. As such, looking at different possible implementations of something like binary search is incredibly important, and a very valuable teaching tool. There's pretty much 2 ways to go about it - iteratively and recursively (although I'll show a third option and blow Burngate's mind a little further later in this post), and they pretty much come down to the same thing:

Split your dataset down the middle, extract the middle value, if it's the value we're looking for return it, otherwise repeat using either the "left" or "right" part of the dataset depending on the value in the middle. The only difference is how we go about doing the "repeat" bit, but the difference is largely syntactic (assuming a language that handles tail recursion) and the two approaches are fundamentally identical.

Here's a BBC BASIC version of the same thing, pulled shamelessly from (google's cache of) rosettacode.org. What you'll notice is that the pattern, described above, is hopelessly mixed with the implementation details (in this case, the use of signed 32 bit variables in a single-dimensioned array); reimplementing to use (for example) fixed length strings or arbitrary structures contained in some other container type (if BASIC even permits such an approach) means rewriting the whole thing. It's also longer, both line for line and expression for expression, than the more generic scheme version (my friend Burngate's comprehension notwithstanding).

Code: Select all

REM Search ordered array A%() for the value S% from index B% to T%
DEF FNwhere(A%(), S%, B%, T%)
LOCAL H%
H% = 2
WHILE H%<(T%-B%) H% *= 2:ENDWHILE
H% /= 2
REPEAT
  IF (B%+H%)<=T% IF S%>=A%(B%+H%) B% += H%
  H% /= 2
UNTIL H%=0
IF S%=A%(B%) THEN = B% ELSE = -1
It's all swings and roundabouts, though, really.

For those as what don't read scheme much, here's a non-generic scheme version looking for numbers in a vector, with comments

Code: Select all

;; Define a function named bsearch taking two arguments, val and vec
(define (bsearch val vec)
  ;; Define a recursion point named loop (which can be used as a function later) taking two arguments, start and stop, with initial values
  (let loop ([start 0] [end (- (vector-length vec) 1)])
    ;; Check for "not found" condition, where 'end' is less than 'start', return false if so
    (if (< end start) #f
        ;; Introduce 2 new variables, the midpoint (from an integer division of (start + end) by 2) and the value at that location in the vector. 
        (let* ([mid (quotient (+ start end) 2)] [mid-val (vector-ref vec mid)])
          (cond [(= val mid-val) mid]                  ;; If we've found it, return the index
                [(< val mid-val) (loop (+ mid 1) end)] ;; If we're "to the left", recurse with the right hand side of start->mid->end
                [else (loop start (- mid 1))]))))      ;; otherwise recurse with the left hand side of start->mid->end
And, for Burngate's amusement, the same thing (mechanically, and perhaps incorrectly, as my cps-converter is not fully war-tested) converted into continuation passing style. Warning - it might be marginally less readable than the other versions presented.

Code: Select all

(define bsearch
  (lambda (val vec k-2)
    (letrec ([mid (lambda (s e k-20)
                    (+/k
                      s
                      e
                      (lambda ($rv-21) (quotient/k $rv-21 2 k-20))))]
             [loop (lambda (start end k-5)
                     (</k end
                          start
                          (lambda
                            ($rv-6)
                            (mid start
                                 end
                                 (lambda
                                   ($rv-19)
                                   (vector-ref/k
                                     vec
                                     $rv-19
                                     (lambda
                                       ($rv-18)
                                       (=/k val
                                            $rv-18
                                            (lambda
                                              ($rv-17)
                                              (if $rv-17
                                                  (lambda
                                                    ($rv-7)
                                                    (mid start
                                                         end
                                                         (lambda
                                                           ($rv-8)
                                                           (mid start
                                                                end
                                                                (lambda
                                                                  ($rv-16)
                                                                  (vector-ref/k
                                                                    vec
                                                                    $rv-16
                                                                    (lambda
                                                                      ($rv-15)
                                                                      (</k val
                                                                           $rv-15
                                                                           (lambda
                                                                             ($rv-10)
                                                                             (if $rv-10
                                                                                 (mid start
                                                                                      end
                                                                                      (lambda
                                                                                        ($rv-14)
                                                                                        (+/k
                                                                                          $rv-14
                                                                                          1
                                                                                          (lambda
                                                                                            ($rv-13)
                                                                                            (loop
                                                                                              $rv-13
                                                                                              end
                                                                                              (lambda
                                                                                                ($rv-9)
                                                                                                (if $rv-6
                                                                                                    #f
                                                                                                    $rv-7
                                                                                                    $rv-8
                                                                                                    $rv-9
                                                                                                    k-5)))))))
                                                                                 (mid start
                                                                                      end
                                                                                      (lambda
                                                                                        ($rv-12)
                                                                                        (-/k
                                                                                          $rv-12
                                                                                          1
                                                                                          (lambda
                                                                                            ($rv-11)
                                                                                            (loop
                                                                                              start
                                                                                              $rv-11
                                                                                              (lambda
                                                                                                ($rv-9)
                                                                                                (if $rv-6
                                                                                                    #f
                                                                                                    $rv-7
                                                                                                    $rv-8
                                                                                                    $rv-9
                                                                                                    k-5)))))))))))))))))))))))))))])
      (vector-length/k
        vec
        (lambda
          ($rv-4)
          (-/k $rv-4 1 (lambda ($rv-3) (loop 0 $rv-3 k-2)))))))
  (lambda ($rv-1) ($rv-1 (lambda ($rv-0) (letrec $rv-0 halt)))))

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 11:18 am

Here is a simple recursive Binary tree search for a datum valu with in the tree. This is only the search function for the purpose of example. I wrote this while half asleep this morning at 6:00 and as such must appologize for any errors, though it should work alright.

Code: Select all

      10 : REM A simple tree search Function.
      20 : REM Bigin with by tracing down the left branch, and on the way
      30 : REM back up treate each right branch as a new head recursively.
      40 : REM
      50 : REM The structure that we will use is given as:
      60 : REM BYTE OFFSET :  Discription.
      70 : REM 0           : Word pointer to parent.
      80 : REM 4           : Word Datum.
      90 : REM 8           : Left Child Pointer.
     100 : REM 12          : Right Child Pointer.
     110 : REM
     120 : REM keeping with a 16 byte structure simplifies things do to the
     130 : REM use of a power of two.
     140 : REM
     150 : REM For simplicity we are not building a tree, though rather just
     160 : REM writing a function to return a pointer to the maching node, or
     170 : REM a NULL pointer (0) if there is no match.
     180 : 
     190 : DEF FNTreeFind(TreeBase%, Search%)
     200 :   LOCAL Top%, Current, RVal%
     210 :   Top%=TreeBase%
     220 :   Current%=TreeBase%
     230 : 
     231 :   REM
     232 :   RVal%=0
     240 : 
     270 :   IF Current%!4 = Search% THEN RVal%=Current%
     271 :   IF Current%!8 <> 0 THEN RVal%=FNTreeFind(Current%!8,Search%)
     320 :   RVal%=FNTreeFind(Current%!12,Search%)
     321 : 
     322 : =Rval%           
I know that this is a little slow, not going for optimum, going for understandable.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 11:19 am

rurwin wrote:[Edit: Man, that Loop construct in Scheme is WEIRD]
Named let? Yeah, it is a bit, but once you're used to it, it's pretty readable.

Code: Select all

(let some-name ([var1 init1] [var2 init2] ...)
  ...body-code...)
is equivalent to (and usually implemented as)

Code: Select all

(let ([some-name (lambda (var1 var2 ...) ...body-code...)])
  (some-name init1 init2 ...))
Which may or may not make more sense to you :)

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 11:27 am

Here is a more readable ver.
Attachments
content0.gif
content0.gif (13.53 KiB) Viewed 6595 times
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

OtherCrashOverride
Posts: 582
Joined: Sat Feb 02, 2013 3:25 am

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 12:04 pm

tufty wrote:Here's a BBC BASIC version of the same thing, pulled shamelessly from (google's cache of) rosettacode.org
Here is a VisualBasic.Net version of the BBC BASIC version:

Code: Select all

    REM Search ordered array A%() for the value S% from index B% to T%
    Function FNWhere(Of Z As IComparable)(ByVal A As Z(),
                ByVal S As Z,
                ByVal B As Integer,
                ByVal T As Integer) As Integer

        Dim H As Integer

        H = 2
        While H < (T - B)
            H *= 2
        End While

        H /= 2
        Do
            If (B + H) <= T Then
                If S.CompareTo(A(B + H)) > 0 Then
                    B += H
                End If
            End If
            H /= 2
        Loop Until (H = 0)

        If S.CompareTo(A(B)) = 0 Then
            Return B
        Else
            Return -1
        End If

    End Function
This is a generic version of the function that will work on an array of any type that is comparable such as strings, integers, floating point, ... horses.

Looks like BASIC to me contrary to claims otherwise made earlier in this thread.

[Edit]
I should note that the type specifiers such as "%" do work in VisualBasic. I replaced them with "Integer" as the use of the symbol is considered a deprecated practice.

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 12:20 pm

OtherCrashOverride wrote:
tufty wrote:Here's a BBC BASIC version of the same thing, pulled shamelessly from (google's cache of) rosettacode.org
Here is a VisualBasic.Net version of the BBC BASIC version:

Code: Select all

    REM Search ordered array A%() for the value S% from index B% to T%
    Function FNWhere(Of Z As IComparable)(ByVal A As Z(),
                ByVal S As Z,
                ByVal B As Integer,
                ByVal T As Integer) As Integer

        Dim H As Integer

        H = 2
        While H < (T - B)
            H *= 2
        End While

        H /= 2
        Do
            If (B + H) <= T Then
                If S.CompareTo(A(B + H)) > 0 Then
                    B += H
                End If
            End If
            H /= 2
        Loop Until (H = 0)

        If S.CompareTo(A(B)) = 0 Then
            Return B
        Else
            Return -1
        End If

    End Function
This is a generic version of the function that will work on an array of any type that is comparable such as strings, integers, floating point, ... horses.

Looks like BASIC to me contrary to claims otherwise made earlier in this thread.

[Edit]
I should note that the type specifiers such as "%" do work in VisualBasic. I replaced them with "Integer" as the use of the symbol is considered a deprecated practice.
And where is the definition of the class that apears to be type Z????

I am speaking of the class with the member method "CompareTo"?

With out that the example is incomplete (even if it is provide with a standard lib, we are talking about BASIC so include the complete definition for that).

Also in VB the postfix for a 32bit integer is &, and % is for a 16bit integer. As BBC BASIC V is designed around the ARM there are only 8bit and 32bit integers, thus % specifies a 32bit integer.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 12:29 pm

For symmetry, here is the BASIC V Tree search code transliterated into Python:

Code: Select all

# A simple tree search Function.
# Bigin with by tracing down the left branch, and on the way
# back up treate each right branch as a new head recursively.
#
# The structure that we will use is given as:
# Attribute   :  Discription.
# Parent      : pointer to parent.
# Value       : Datum.
# Left        : Child Pointer.
# Right       : Right Child Pointer.
#
# For simplicity we are not declaring or building a tree, though rather just
# writing a function to return a pointer to the matching node, or
# a NULL pointer  if there is no match.

def TreeFind(TreeBase, Search):
  Top=TreeBase
  Current=TreeBase

  #
  RVal= Null
  
  if Current.Value == Search: RVal=Current
  if Current.Left <> Null: RVal= TreeFind(Current.Left, Search)
  RVal = TreeFind(Current.Right, Search)

  return Rval
But then, why store stuff in a tree if it isn't sorted? The code above is only as efficient as a linear search through an array. If it is sorted then this will be far more efficient.

Code: Select all

# A simple tree search Function.
#
# The structure that we will use is given as:
# Attribute   :  Discription.
# Parent      : pointer to parent.
# Value       : Datum.
# Before      : pointer to Children with lower values
# After       : pointer to Children with higher values
#
# For simplicity we are not declaring or building a tree, though rather just
# writing a function to return a pointer to the matching node, or
# a NULL pointer  if there is no match.

def TreeFind(TreeBase, Search):

  if TreeBase == Null: return Null
  Top=TreeBase
  Current=TreeBase

  #
  RVal= Null
  
  if Current.Value == Search:
    RVal=Current
  else if Current.Value > Search:
    RVal= TreeFind(Current.Before, Search)
  else:
    RVal = TreeFind(Current.After, Search)

  return Rval
That BASIC bsearch code is simply horrible. It wastes vast complexity on ensuring H is a power of two, and because that would lead to an index violation it has to put a special check in. If it finds the value, it still keeps on looping.

OtherCrashOverride
Posts: 582
Joined: Sat Feb 02, 2013 3:25 am

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 12:38 pm

DavidS wrote:And where is the definition of the class that apears to be type Z????
There is no type Z. Its a generic. Common practice is to call it T but that was already used as a parameter and I chose to keep the code as similar as possible to the original while offering modern functionality.
DavidS wrote:I am speaking of the class with the member method "CompareTo"?
There is no class with "CompareTo", its an interface defined by the .NET common type system akin to ABS, INKEY, etc built into BBC BASIC. But for "completeness" here is the code for it taken from Mono (note that the code is C#, not VB.Net):

Code: Select all

using System.Runtime.InteropServices;

namespace System {

        [ComVisible(true)]
        public interface IComparable {
                int CompareTo (object obj);
        }
        
#if NET_4_0
        public interface IComparable <in T> {
                int CompareTo (T other);
        }
#else
        public interface IComparable <T> {
                int CompareTo (T other);
        }
#endif
}
[Edit]
DavidS wrote:Also in VB the postfix for a 32bit integer is &, and % is for a 16bit integer. As BBC BASIC V is designed around the ARM there are only 8bit and 32bit integers, thus % specifies a 32bit integer.
http://msdn.microsoft.com/en-us/library ... z43ek.aspx
In VisualBasic.Net, % = 32bits, & = 64bits
Last edited by OtherCrashOverride on Thu Oct 17, 2013 12:46 pm, edited 1 time in total.

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 12:39 pm

@rurwin:
Yes I wrote this assuming a non sorted tree. I would make it much beter for a sorted tree.

And yes because of the recursion it still runs for a while after it finds the answer.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
jojopi
Posts: 3085
Joined: Tue Oct 11, 2011 8:38 pm

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 12:40 pm

DavidS wrote:As BBC BASIC V is designed around the ARM there are only 8bit and 32bit integers, thus % specifies a 32bit integer.
That is for compatibility with BBC BASIC I, nothing to do with ARM.

Ultimately it is probably from the fact that floating point required an extension ROM in ATOM BASIC, and having only 16 bit integers as standard would have been too limiting.

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 12:41 pm

A better BASIC V bsearch would be:

Code: Select all

    REM Search ordered array A%() for the value S% from index B% to T%
    DEF FNwhere(A%(), S%, B%, T%)
    LOCAL H%
    REPEAT
      H% = (B%+T%) / 2
      IF S%>A%(H%) THEN B% = H% ELSE IF S%<A%(H%) THEN T% = H%
    UNTIL S%=A%(H%) OR B%=T%
    IF S%=A%(H%) THEN = H% ELSE = -1

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 12:45 pm

@OtherCrashOverride:

Ah Ok. As you know I have not used VB in a long while. Though if that is the direction that VB has evolved in recent years I definitely would not recomend it to any one. That is almost as bad as using templates in C++.

I have no problem with C++, as long as Templates are not included.

In BASIC I have no problem with intrisics, if they are implemented in a reasonable maner.

Though you are giving me more reasons to dislike VB. And I thought that VB 4.0 gave enough reasons, VB.NET seems to be worse. Though if it is what you like then more power to you :-/ .
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 12:47 pm

@rurwin:
Cool thank you.

That also does a better job of showing the power of BBC BASIC V.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 12:53 pm

That depends how you define power. It's exactly equivalent to the Python code I posted above, and it only works for integers in an array.

Bakul Shah
Posts: 321
Joined: Sun Sep 25, 2011 1:25 am

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 1:02 pm

rurwin wrote:[Edit: Man, that Loop construct in Scheme is WEIRD]
Basically

Code: Select all

(let foo ((arg1 val1) ...) body)
is equivalent to

Code: Select all

(begin
  (define (foo arg1 ...) body)
  (foo val1 ...))
When you call foo as the last thing from body, you've got a loop since in Scheme tail recursion is guaranteed to not increase stack space use.

User avatar
Emanuele
Posts: 180
Joined: Wed Aug 03, 2011 5:28 pm
Contact: Website

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 1:06 pm

Wow! I've never seen that many versions of bsearch! And to be honest my post that started it all was talking about bsearch-LIKE code, but the "LIKE" bit somehow got lost.
rurwin wrote:That BASIC bsearch code is simply horrible. It wastes vast complexity on ensuring H is a power of two, and because that would lead to an index violation it has to put a special check in. If it finds the value, it still keeps on looping.
Thank You very much. That was exactly my point. We are all here arguing which syntactic sugar tastes the sweetest, not noticing the elephant in the room: after one semester discussing higher order abstractions, and another one in how to fit 7 patterns in a hello word program, the average graduate goes out in the real world unable to put together a decent nested loop and a couple of flags even if his life depended on it.

OtherCrashOverride
Posts: 582
Joined: Sat Feb 02, 2013 3:25 am

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 1:16 pm

DavidS wrote:Though if that is the direction that VB has evolved in recent years I definitely would not recomend it to any one. That is almost as bad as using templates in C++.
I have demonstrated that VisualBasic.Net is the most modern, flexible, capable version of BASIC! I win the internets and this thread! :lol:

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 1:29 pm

When the guys here are interviewing job candidates, they give them a similar exercise to the algorithms we have been discussing, to be written out on a white-board, in any language or pseudo-code. It separates the wheat from the chaff quite successfully.

I'd have to agree with DavidS on one point. C++ templates might be necessary, but they are definitely the third hump of the camel.

OtherCrashOverride
Posts: 582
Joined: Sat Feb 02, 2013 3:25 am

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 1:45 pm

rurwin wrote:C++ templates might be necessary, but they are definitely the third hump of the camel.
I probably should state that C#/VB.Net *generics* are very different from C++ *templates*. They are also true generics in that they are implemented in the bytecode unlike Java's. Explaining the difference is beyond the scope of this thread. I also should point out that using them is not a requirement, but it is a modern programming practice to do so.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 2:58 pm

Emanuele wrote:the average graduate goes out in the real world unable to put together a decent nested loop and a couple of flags even if his life depended on it.
Ah, but they get all that "book learning" beaten out of them within a week of starting their first real job, when they suddenly realise that the world actually runs on excel spreadsheets and bits of hacked-together perl.

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Thu Oct 17, 2013 4:01 pm

OtherCrashOverride wrote:
rurwin wrote:C++ templates might be necessary, but they are definitely the third hump of the camel.
I probably should state that C#/VB.Net *generics* are very different from C++ *templates*. They are also true generics in that they are implemented in the bytecode unlike Java's. Explaining the difference is beyond the scope of this thread. I also should point out that using them is not a requirement, but it is a modern programming practice to do so.
Well as I have always said:
There is the "Modern" / "Industry Standard" way to code, then there is good procedural coding. I still think that these ideas from the 1960s should have been left in the 1960s.

I am aware that generics in VB.NET are different from templates. This does not mean that I agree with using them.

Further I was glad when Pascal finaly stoped using byte code and we got real compilers. I have the same objection to .NET, even though it is JITed to native, it is still byte code.

So now that you like 1960s dropped ideas OtherCrashOverride, I call your deffinition of modern weird. Though to each his own

Though I will say that there are many modern BASIC implementations, including BBC BASIC V, FreeBASIC, and QB64.

As to your earlier statement about the APIs that can be used from VB.NET, I must point out that any API available on the host is available to BBC BASIC V, and there are a few Open GL API implementations for RISC OS. And if things keep going the way they are we will have accelerated GL on the VideoCore IV soon. AND BBC BASIC V will be able to use using the native API with out the need for language specific wrapper libraries.

Thus I would argue that BBC BASIC V is a more complete language for Modern applications. We do not need some set of libraries, ActivX, or other to use any API, as we call the core API directly.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
scidata
Posts: 90
Joined: Tue Jan 06, 2015 4:21 pm
Location: Toronto
Contact: Website

Re: BASIC - more harmful than useful?

Thu May 14, 2015 8:09 pm

Pick/BASIC mentioned; I'm happy for the rest of the day.

BASIC is a waste of one's intellect. Nobody who ever spends time thinking about it, coding in it, or more specifically, writing BASIC interpreters will ever amount to anything. Just ask Gates and Allen.
"Self-education is, I firmly believe, the only kind of education there is" - Isaac Asimov

Return to “Staffroom, classroom and projects”