Best Programming Language

For other topics related to the FreeBASIC project or its community.
jevans4949
Posts: 1156
Joined: May 08, 2006 21:58
Location: Crewe, England

Best Programming Language

Postby jevans4949 » Jan 30, 2017 17:08

This topic (from Kot, AFAIR) got lost in the move.

I have added Freebasic to the list, in case anybody wants to upvote it.

https://www.slant.co/topics/25/~best-programming-language-to-learn-first
BasicCoder2
Posts: 3589
Joined: Jan 01, 2009 7:03
Location: Australia

Re: Best Programming Language

Postby BasicCoder2 » Jan 30, 2017 20:53

Are those who recommend a language remembering the topic was best programming language to learn first or are they just recommending the language?

The prelude in the list writes:
"A good programming language to start with should be one that teaches best practices and common paradigms and designs that can be found on all other languages. "

This doesn't even need to be a real language, it can be an easy to read pseudo language. I remember decades ago a book on assembler programming that wrote the program examples in a higher level "language" and then showed how to translate them down into any low level language. I also saw the same being done in a program design course for beginners where a pseudo language was being used to explain how to structure a program and then it had to be translated into a C version.

Once you have learned the basics of computer programming you then can choose a language or languages to learn that will fulfill whatever programming goals you might have.

For me BASIC and/or Assembler were the only choices on the hobby computers I could buy at the time.
.
greenink
Posts: 200
Joined: Jan 28, 2016 15:45

Re: Best Programming Language

Postby greenink » Jan 30, 2017 23:26

Try finding a simple, well defined low level programming language. There are none. C2 looks like it will never be finished and I didn't see in the documentation that it is fully defined (2's complement arithmetic.) There are a few others in the same kind of state.
With FB I can do low level programming and I get a few very useful pragmatic things like graphics as well.

I am waiting for FreshIDE 3 to become available for Linux to see how that works out in actual practice.
https://fresh.flatassembler.net/
figosdev
Posts: 18
Joined: Jan 06, 2017 7:24

Re: Best Programming Language

Postby figosdev » Jan 31, 2017 2:58

This doesn't even need to be a real language, it can be an easy to read pseudo language.


I have a theory that if more languages like this were made, it would boost the creation of friendlier educational (and all-purpose) languages.

Whats more, Id like to see more languages that work on top of existing libraries. This is getting more possible and common.

For example, Javascript via node.js calling Python libraries (hypothetically,) or a language like Haxe implemented in OCAML, which can compile (to whatever degree) to several languages.

My favorite would be a language that makes it easy (not just possible) to write languages-- like a Basic for writing Basic dialects (people have used FB this way, I think) on top of a huge catalog of functions which pull in various libraries from something like Python or C++:

1. User-Friendly Metalanguage (the really tricky part) for creating a compiler or interpreter that uses
2. Giant command matrix API, which provides a standard/simple universal interface to:
3. BFL collection of libraries (Meta library)

This means all the libraries are already included (no matter where theyre from-- theyre pulled in by the project; hopefully most are actively maintained-- not necessarily by the project.)

The interface to the libraries is standard (oversized, building-full-of-file-cabinets style, but reducible through the API.)

And then you just write your language on top of that, using the language creation tools (youre basically writing a language specification/implementation, but it feels more like writing a program.)

Youll want to tell me this isnt possible, but I think its just very tricky. In many ways, Python satisfies layers 2 and 3. Basic would be a better model for the top layer. Im aware that metalanguages exist. The trick is taking something esoteric and making it accessible. People try, but they get painted into corners. Simple isnt as easy as it looks.
Boris the Old
Posts: 139
Joined: Feb 04, 2011 20:34
Location: Ontario, Canada

Re: Best Programming Language

Postby Boris the Old » Jan 31, 2017 4:08

Back in the late 1970's and early 1980's, when personal computers were appearing, I created a COBOL-like language to allow me to write ASM programs in psuedo code. Here's a small example of some code that's still in use today, exactly as shown. It's part of a series of MSDOS COBOL80 business applications that are still in use and still supported. Over the years I've added extensive ASM modules to support the COBOL80 code, including ISAM file support.

Macros and code generators are a great way to write well structured and bug free code.

Code: Select all

PAGE 60,132

INCLUDE MACLIB

OPTIONS  flow  SUBR  <Flow text into window work area>

PROGRAM  DATE 1983-08-20  OWNER <Deer Valley Software>

;=======================================================================
;                  PROGRAM DATA
;-----------------------------------------------------------------------

DATA

    INCLUDE      COMMON.INC

;=======================================================================
;                  LINKAGE SECTION
;-----------------------------------------------------------------------

  LINKAGE

;-----------------------------------------------------------------------

    INCLUDE      FLOW.INC

;-----------------------------------------------------------------------

    PARAMETER    sourcebuffer  <source buffer>
      STRING       ,  LENGTH 256  VALUE ?
    ENDPARAMETER sourcebuffer

;-----------------------------------------------------------------------

    PARAMETER    sourcelen  <length of source buffer>
      BIN1         sourcelength  VALUE ?
    ENDPARAMETER sourcelen

;-----------------------------------------------------------------------

    PARAMETER    objectbuffer  <object buffer>
      STRING       ,  LENGTH 256  VALUE ?
    ENDPARAMETER objectbuffer

;-----------------------------------------------------------------------

    PARAMETER    objectlen  <length of object buffer>
      BIN1         objectlength  VALUE ?
    ENDPARAMETER objectlen

;-----------------------------------------------------------------------

    PARAMETER    linelen  <length of text line>
      BIN1         linelength  VALUE ?
    ENDPARAMETER linelen

;-----------------------------------------------------------------------

    PARAMETER    objectcount  <object line count>
      BIN1         linecount  VALUE ?
    ENDPARAMETER objectcount

;-----------------------------------------------------------------------

  ENDLINKAGE

;=======================================================================
;                  STORAGE SECTION
;-----------------------------------------------------------------------

  STORAGE

;-----------------------------------------------------------------------

    STRUCTURE    sourcelinechar  <source character control block>  POINTER charptr
      CHAR         sourcechar  VALUE ?  <source work character>
    ENDSTRUCTURE sourcelinechar

;-----------------------------------------------------------------------

    STRUCTURE    sourceline  <source buffer control block>  POINTER sourceptr
      STRING       ,  LENGTH 80  VALUE ?
    ENDSTRUCTURE sourceline

;-----------------------------------------------------------------------

    STRUCTURE    objectline  <object buffer control block>  POINTER objectptr
      STRING       ,  LENGTH 80  VALUE ?
    ENDSTRUCTURE objectline

;-----------------------------------------------------------------------

    RECORD    bin1work  <BIN1 work area>
      BIN1      flowlength   VALUE ?   <source length for whole words>
      BIN1      templength   VALUE ?   <unscanned scource length>
      BIN1      linemax      VALUE ?   <maximum number of text lines>
    ENDRECORD bin1work

;-----------------------------------------------------------------------

    RECORD    pointerwork  <POINTER work area>
      POINTER   objectptr  VALUE ?  <pointer to object text>       STRING
      POINTER   sourceptr  VALUE ?  <pointer to source text>       STRING
      POINTER   charptr    VALUE ?  <pointer to source character>  CHAR
    ENDRECORD pointerwork

;-----------------------------------------------------------------------

  ENDSTORAGE

;-----------------------------------------------------------------------

ENDDATA

;=======================================================================
;                  PROGRAM CODE
;-----------------------------------------------------------------------

CODE REFERENCE <AUTO,AUTO,AUTO,AUTO,AUTO,AUTO>
  PARM  sourcebuffer
  PARM  sourcelength
  PARM  objectbuffer
  PARM  objectlength
  PARM  linelength
  PARM  linecount

;-----------------------------------------------------------------------

  ENTER Mainline  <Expand source buffer into object buffer>  START

    MOVE sourcelength TO templength
    MOVE objectlength TO linemax
    DIV linemax BY linelength
    POINT sourceptr AT sourcebuffer
    POINT objectptr AT objectbuffer

    LOOP ON linecount FROM 1 TO linemax
      WHEN templength NG linelength
        TRUE
          MOVE <sourceline,templength> TO <objectline,linelength>
          LEAVE
        FALSE
          PERFORM SplitLine
      ENDWHEN
    ENDLOOP

  EXIT Mainline

;-----------------------------------------------------------------------

  ENTER SplitLine  <Split line from source at word break>

    POINT charptr AT sourceline OFFSET linelength

    LOOP ON flowlength FROM linelength TO 1 BY - 1
      POINT charptr AT sourcechar NEGOFFSET 1
      WHEN sourcechar EQ BLANK
        TRUE
          LEAVE
      ENDWHEN
    ENDLOOP

    MOVE <sourceline,flowlength> TO <objectline,linelength>

    POINT charptr   AT sourcechar OFFSET 1
    POINT sourceptr AT sourcechar
    POINT objectptr AT objectline OFFSET linelength
    SUB flowlength FROM templength

  EXIT SplitLine

;-----------------------------------------------------------------------

ENDCODE

ENDPROGRAM

END


All uppercase keywords are macros that are expanded into assembler code via a six-pass job stream. Each pass of the assembler converts macros into additional macros, slowly building up the structure of the program.

Here are some typical macro definitions. They create more macro calls that are reduced further during the following passes.

Code: Select all

$$LOOP MACRO ??A,?N,??B,?F,??E,?T,??F,?D,?C
 LOCAL L1,L2
 $_PH1 <$LOOP ?N,?F,?T,?D,?C>
_LL = _LL+1
 $_SYMSET _LN,%_LL
 $_PH3 <$MOVE ?N,,?F,,>
 $_JUMP ?&L1,SHORT
 $_LBL ??L,%_LL,_LN
 IFB <?D>
 IFB <?C>
 $_PH3 <$INC ?N>
 ELSE
 $_PH3 <$ADD ?N,?C>
 ENDIF
 ELSE
 IFIDN <?D>,<+>
 IFB <?C>
 $_PH3 <$INC ?N>
 ELSE
 $_PH3 <$ADD ?N,?C>
 ENDIF
 ELSE
 IFIDN <?D>,<->
 IFB <?C>
 $_PH3 <$DEC ?N>
 ELSE
 $_PH3 <$SUB ?N,?C>
 ENDIF
 ELSE
 ERROR $LOOP: D
 ENDIF
 ENDIF
 ENDIF
 $_LABEL ?&L1
 IFIDN <?D>,<->
 $_PH3 <$COMPARE ?N,,NL,?T,,?&L2>
 ELSE
 $_PH3 <$COMPARE ?N,,NG,?T,,?&L2>
 ENDIF
 $_SYMINC _LN,%_LL
 $_JMP ??L,%_LL,_LN
 $_LABEL ?&L2
 ENDM

$$LEAVE MACRO
 $_PH1 <$LEAVE>
 $_JMP ??L,%_LL,_LN
 ENDM

$$ENDLOOP MACRO
 $_PH1 <$ENDLOOP>
 $_SYMDEC _LN,%_LL
 $_JMP ??L,%_LL,_LN
 $_SYMINC _LN,%_LL
 $_LBL ??L,%_LL,_LN
_LL = _LL-1
 ENDM


And here is a very simple example of a GUI class, clsPanel. Like all classes and namespaces in my applications, it is divided into two files, Declarations and Procedures. Both files are created by code generators.

Code: Select all

'===============================================
'
'  file name       :  clsPanelDecl.bi
'  description     :  Gui Panel Class (declarations)
'  reference       :  6019
'  date generated  :  2017-01-21 00:02
'  configuration   :  FreeBASIC v1.05, FLTK v1.3.3
'  copyright       :  1977-2017, Rod Gobby
'  version         :  8.1
'
'===============================================
'
'  Notes and Change Log
'
'-----------------------------------------------
' This comment is for history only. It shows the main milestones of the
' code generators created by Rod Gobby (Deer Valley Software)
'
' 1977   v1.0   Assembler macros (IBM 360/370)
' 1979   v2.0   Data General Business BASIC
' 1982   v3.0   Microsoft COBOL-80, MS MASM (DOS)
' 1994   v4.0   Microsoft COBOL-80, MS MASM (DOS to Windows transition)
' 1998   v5.0   Microsoft Visual Basic (Windows)
' 2005   v6.0   PowerBasic/EZGUI (Linux/Windows)
' 2010   v7.0   PureBasic, FreeBasic (OOP testing environment)
' 2014   v8.0   FreeBasic/FLTK (OOP/Linux/Windows)
'
'-----------------------------------------------
'    Date                Description
'-----------------------------------------------
' 2015.12.18   released
'
'===============================================
'
BeginClass (clsPanel)
'
BeginClassDeclarations                      BaseClass (clsGadget)                                  ' extends the Gui Base Gadget class
'
'===============================================
'
PrivateDeclarations
'
'-----------------------------------------------
'
'Private file handle control blocks
'
'Private file records
'
'Private variables
'
'Private property variables:  read/write
'
'Private property variables:  read only
'
'Private property variables:  write only
  PrivateField (prjCBDesign,                typProcPtr)                                            ' 16080 : callback proc:  design an object
'
'===============================================
'
PublicDeclarations
'
'-----------------------------------------------
'
'Public properties:  read/write
'
'Public properties:  read only
'
'Public properties:  write only
  DeclarePublicSetField (exjCBDesign,       typProcPtr, prjCBDesign)
'
'-----------------------------------------------
'  Procedure 2 : class constructor
DeclarePublicConstructor
'
'-----------------------------------------------
'  Procedure 3 : class destructor
DeclarePublicDestructor
'
'-----------------------------------------------
'  Procedure 4 : process the gadget events
DeclarePublicVirtualFunction (funEvents) _
    BVal (bvvFltkEvent,                     typUInt32) _                                           ' 16899 : fltk event number:  0 to 25
  ParmReturn (typInt32)
'
'-----------------------------------------------
'  Procedure 5 : build this object
DeclarePublicSubroutine (subBuild) _
  ParmEnd
'
'===============================================
'
EndClassDeclarations
'
EndClass
'
'===============================================
'  end of  :  clsPanelDecl.bi
'===============================================


Code: Select all

'===============================================
'
'  file name       :  clsPanelProc.bi
'  description     :  Gui Panel Class (procedures)
'  reference       :  6019
'  date generated  :  2017-01-21 00:02
'  configuration   :  FreeBASIC v1.05, FLTK v1.3.3
'  copyright       :  1977-2017, Rod Gobby
'  version         :  8.1
'
'===============================================
'
'  Notes and Change Log
'
'-----------------------------------------------
' This comment is for history only. It shows the main milestones of the
' code generators created by Rod Gobby (Deer Valley Software)
'
' 1977   v1.0   Assembler macros (IBM 360/370)
' 1979   v2.0   Data General Business BASIC
' 1982   v3.0   Microsoft COBOL-80, MS MASM (DOS)
' 1994   v4.0   Microsoft COBOL-80, MS MASM (DOS to Windows transition)
' 1998   v5.0   Microsoft Visual Basic (Windows)
' 2005   v6.0   PowerBasic/EZGUI (Linux/Windows)
' 2010   v7.0   PureBasic, FreeBasic (OOP testing environment)
' 2014   v8.0   FreeBasic/FLTK (OOP/Linux/Windows)
'
'-----------------------------------------------
'    Date                Description
'-----------------------------------------------
' 2015.12.18   released
'
'===============================================
'
BeginClass (clsPanel)
'
BeginClassProcedures
'
'===============================================
'
PublicProcedures
'
'-----------------------------------------------
'
'Public properties:  read/write
'
'Public properties:  read only
'
'Public properties:  write only
  PublicSetField (exjCBDesign,              typProcPtr, prjCBDesign)
'
'-----------------------------------------------
'  Procedure 2 : class constructor
BeginPublicConstructor
'
'
'objGadget properties (base class)
  priClassType                              = iCLASS_TYPE_PANEL                                    ' 16447 : the entity number of the derived class:  0 = default
'
'objPanel properties
  prjCBDesign                               = Nothing                                              ' 16080 : callback proc:  design an object
'
EndPublicConstructor
'
'-----------------------------------------------
'  Procedure 3 : class destructor
BeginPublicDestructor
'
'
'
EndPublicDestructor
'
'-----------------------------------------------
'  Procedure 4 : process the gadget events
BeginPublicVirtualFunction (funEvents) _
    BVal (bvvFltkEvent,                     typUInt32) _                                           ' 16899 : fltk event number:  0 to 25
  ParmReturn (typInt32)
'
'
'  not used -- placeholder only
'
EndPublicFunction
'
'-----------------------------------------------
'  Procedure 5 : build this object
BeginPublicSubroutine (subBuild) _
  ParmEnd
'
'
  proParent->subAttachChild                 (Me)                                                   ' attach me to the parent object
  subApplyExternalResizeRules               ()
  prpWidgetRef                              = modGui.funPanelCreate(priActualLeft, priActualTop, priActualWidth, priActualHeight)
  modGui.subWidgetSelfSet                   (prpWidgetRef, Me)                                     ' link the widget to this gadget
  modGui.subWidgetBorder                    (prpWidgetRef, prvBorderStyle)
  modGui.subWidgetCaption                   (prpWidgetRef, prsCaption)
  modGui.subWidgetAlign                     (prpWidgetRef, prvCaptionAlignment)
  subSetexlActive                           ()                                                     ' 16770 : true = object is activated, false = object is deactivated
  subSetexlVisible                          ()                                                     ' 16771 : true = object is visible, false = object is invisible
  subSetexvForegroundColour                 ()                                                     ' 14750 : foreground colour
  If prvBorderStyle <> vGUI_BORDER_TRANSPARENT Then
    subSetexvBackgroundColour               ()                                                     ' 14751 : background colour
  End If
  If IsTrue (prlResizeAllowed) Then
    modGui.subPanelResizable                (proParent, Me)                                        ' 16405 : true = gui object can be resized
  End If
  modGui.subPanelDesignBegin                (prpWidgetRef)
  PerformCallback                           (prjCBDesign)                                          ' 16080 : callback proc:  design an object
  modGui.subPanelDesignEnd                  (prpWidgetRef)
'
EndPublicSubroutine
'
'===============================================
'
PrivateProcedures
'
'===============================================
'
EndClassProcedures
'
EndClass
'
'===============================================
'  end of  :  clsPanelProc.bi
'===============================================
caseih
Posts: 1555
Joined: Feb 26, 2007 5:32

Re: Best Programming Language

Postby caseih » Jan 31, 2017 16:51

greenink wrote:I am waiting for FreshIDE 3 to become available for Linux to see how that works out in actual practice.
https://fresh.flatassembler.net/

Apparently you can run FreshIDE under Wine, and have it generate native Linux executables.
Imortis
Moderator
Posts: 1734
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Best Programming Language

Postby Imortis » Jan 31, 2017 18:51

Boris the Old wrote:...I created a COBOL-like language...

This is totally off topic and 100% meant as a joke: Why would you ever do this?!? When I was in college, we had a COBOL course (this was only about 10 years ago) and even then we made the following joke:

"There are millions of lines of COBOL code still in use today and that ONE program should be retired."

In all seriousness, though that is an impressive bit of code. Good job.
Boris the Old
Posts: 139
Joined: Feb 04, 2011 20:34
Location: Ontario, Canada

Re: Best Programming Language

Postby Boris the Old » Jan 31, 2017 19:47

Imortis wrote:"There are millions of lines of COBOL code still in use today and that ONE program should be retired."

In all seriousness, though that is an impressive bit of code. Good job.


Thanks for the compliment. And don't worry about the COBOL joke, we old-time COBOL programmers have heard them all. :-) With an estimated 200 billion lines of COBOL code in use around the world, we've all become very rich writing that code.

I started programming just after COBOL was invented, but just before BASIC was invented. However, the first 15 years of my programming life revolved around IBM Autocoder (a 2nd generation assembler) and IBM 360/370 Assembler. It didn't take me long to realize that psuedo code, in the form of macros, made my life a lot easier.

Over the years, though, I found myself writing more and more BASIC applications, but still using the programming techniques I'd used with Assembler. Macros are a programmers best friend, right up there with strict naming conventions and highly structured code.

It's sad that BASIC gets the same treatment as COBOL, because it's a very powerful and flexible language. But then I think back to when I was a young hotshot programmer - we all believed that any programmer over 30 had reached his "best before" date and had nothing more to offer the world -- I've since changed my mind about that. :-)

Rod
greenink
Posts: 200
Joined: Jan 28, 2016 15:45

Re: Best Programming Language

Postby greenink » Jan 31, 2017 22:34

Apparently you can run FreshIDE under Wine, and have it generate native Linux executables.

That process is so convoluted, I'll wait. Anyway there would be no performance gains over FB. I'm just interested in reducing the amount of written code while maintaining readability. I'd like to be able to do this in FB:

type T
a as long
b as long
function add() as long
return a+b
end function
end type

Or

type T
a as long
b as long
end type

function T.add() as long
return a+b
end function

In other words I don't want to declare.
caseih
Posts: 1555
Joined: Feb 26, 2007 5:32

Re: Best Programming Language

Postby caseih » Feb 01, 2017 1:44

greenink wrote:That process is so convoluted, I'll wait. Anyway there would be no performance gains over FB.

Getting fresh ide to run in Wine isn't really convoluted thought. In ubuntu it would just be a matter of installing wine from the repos (or grab the latest staging wine from a PPA). Then it's "wine installer.exe" and it should be good to go. Not much to it. But I agree with you that there really is little reason to use assembler over FB, or even C. Especially since there are lots of other processor architectures like ARM that are gaining in popularity and use these days.

As for the not wanting to pre-declare type methods, I don't find it particularly burdensome. But then I come from a C background, and this kind of separation is very useful, especially if you have some utility types that need to be used in several different .bas files in your project.
Boris the Old
Posts: 139
Joined: Feb 04, 2011 20:34
Location: Ontario, Canada

Re: Best Programming Language

Postby Boris the Old » Feb 01, 2017 3:40

greenink wrote:In other words I don't want to declare.


An easy way to avoid writing declares is to use a simple utility program to do it for you.

It takes a few lines of code to scan your program for all the sub and function statements, and output them to a text file in the form of declare statements. The resulting file can then be included in your main program code.

First law of programming: Never write code if a program can do it for you.

Second law of programming: Only write code once.

Rod
greenink
Posts: 200
Joined: Jan 28, 2016 15:45

Re: Best Programming Language

Postby greenink » Feb 01, 2017 13:40

I suppose so. I think FB has a single pass compiler or something and that's why you need declares. I agree that it's not as big a problem as in C.
BasicCoder2
Posts: 3589
Joined: Jan 01, 2009 7:03
Location: Australia

Re: Best Programming Language

Postby BasicCoder2 » Feb 01, 2017 17:33

Boris the Old wrote:First law of programming: Never write code if a program can do it for you.

That reminds me of an old code generating program with an optimistic name,
https://en.wikipedia.org/wiki/The_Last_One_(software)
http://www.tebbo.com/archive/pw8102.htm

I guess a GUI editor is a code generator.

Another rule is use other people's code, that is, don't reinvent the wheel.
Still reinventing the wheel might make a better wheel and it does act as a tutorial.
For most of us however a routine written by an expert is probably going to be better than one you write yourself.
On the first microprocessors like the Z80 you had to write your own trig functions and floating point arithmetic.
.
figosdev
Posts: 18
Joined: Jan 06, 2017 7:24

Re: Best Programming Language

Postby figosdev » Feb 02, 2017 0:24

Boris the Old wrote:Macros and code generators are a great way to write well structured and bug free code.


Talk about "automate the boring stuff." Where can I find a book on using code generators for that? (Semi-rhetorical question. Though if you know one, feel free...)
Boris the Old
Posts: 139
Joined: Feb 04, 2011 20:34
Location: Ontario, Canada

Re: Best Programming Language

Postby Boris the Old » Feb 02, 2017 20:26

figosdev wrote:Talk about "automate the boring stuff." Where can I find a book on using code generators for that? (Semi-rhetorical question. Though if you know one, feel free...)


I've never read any books on the subject, but I think macros and code generators tend to be the result of laziness and a lifetime of programming. Over the years, most professional programmers tend to put together a "toolkit" of useful code and coding strategies, targeted at the type of applications they develop. Off-the-shelf products, that try to be all things to all people, usually don't work out well in the long run.

I feel lucky that I learned my trade when programming was looked on as an art, not as a science. So that for my first 15 years, working for companies like GM and IBM, I had a lot of freedom to try out new ideas. In those days, programmers were told what an application had to do, but how they did it was up to them. It was 40 years ago, this week, that I started my own programming business and was able to put all that experience into practice.

Programming, as an art, can't be well defined. For me, it's always been an attempt to make my code easy to write and easy for others to understand. Macros are good for making code self documenting and for reducing the coding effort. For example, if I wanted to create a read/write property in a class, I could write something like:

Code: Select all

  PrivateField (prlEventsBlocked, typBoolean)
.
.
  PublicGetField    (exlEventsBlocked, typBoolean, prlEventsBlocked)
  PublicSetFieldOpt (exlEventsBlocked, typBoolean, prlEventsBlocked)


Assuming the class name is clsGadget, and the "Set" invokes an optional private subroutine, this expands to:

Code: Select all

  prlEventsBlocked As Long
.
.
  Property clsGadget.exlEventsBlocked () As Long
    Property = prlEventsBlocked
  End Property
  Property clsGadget.exlEventsBlocked (ByVal bvprlEventsBlocked As Long)
    prlEventsBlocked = bvprlEventsBlocked
    subSetexlEventsBlocked()
  End Property


The interesting thing about this example, is that none of the above code is actually hand coded - not even the unexpanded "hand-written" code. The unexpanded code is auto-generated from a single entry in the application specifications. When I entered the specs of the "clsGadget" class, I indicated that I needed data element #16474 and that it should have a Read/Write attribute. The optional subroutine got picked up automatically because I'd defined it elsewhere in the class specs.

The foundation of these sort of techniques has to be a rigorous adherence to program structure and naming conventions, otherwise it won't work. For instance, all my Classes and Namespaces have the same structure, so I don't have to worry about petty syntax details. Also, because most data types have different uses, I use 26 custom data types and let the macros and code generators sort out the syntax for me.

Sorry, I've rambled a bit, but what I'm trying to say is that it's probably best for programmers to build up their own "toolkit" of useful stuff.

Rod

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests