BASIC Developer & Support Resources > Scripting Languages

Serious Versus Scripting Languages

(1/1)

JRS:

--- Quote ---There's no good reason to build systems in the "serious" languages any more. Build your system in a soft language, profile it, then replace the bottlenecks with "serious" snippets. The result is something that is vastly more flexible and maintainable, but which performs exactly the same.
--- End quote ---

Serious Versus Scripting Languages

Has scripting languages changed how maintainable applications are written?

JRS:
In an effort to expand on this concept a bit, here is an example ScriptBasic extension module using BCX Universal (Ubuntu 32) to create the Linux shared object. (libtrial.so) This allows you to use ScriptBasic to get the meat of your project defined and use BCX to create dynamic called C functions to increase performance in sections of your code. In the end, your are able to compile your project to a small footprint executable (wrapped PCODE in C) and link dynamically to SB's runtime and extensions.

trial.bas

--- Code: Text ---$DLL$EXECON "-I/usr/src/scriptbasic" #include <basext.h> 'besVERSION_NEGOTIATEFUNCTION versmodu(Version as integer, pszVariation as string, ppModuleInternal as void ptr ptr) as integer export  FUNCTION = INTERFACE_VERSIONEND FUNCTION 'besSUB_STARTFUNCTION bootmodu(pSt as pSupportTable, ppModuleInternal as void ptr ptr, pParameters as pFixSizeMemoryObject, pReturnValue as pFixSizeMemoryObject ptr) as integer export  DIM pEo AS pExecuteObject  DIM pL AS long ptr  besMODULEPOINTER = besALLOC(sizeof(long))  IF besMODULEPOINTER = NULL THEN FUNCTION = 0  pL = (long *)besMODULEPOINTER  *pL = 0  FUNCTION = 0END FUNCTION 'besSUB_FINISHFUNCTION finimodu(pSt as pSupportTable, ppModuleInternal as void ptr ptr, pParameters as pFixSizeMemoryObject, pReturnValue as pFixSizeMemoryObject ptr) as integer export  DIM pEo AS pExecuteObject  FUNCTION = 0END FUNCTION 'besFUNCTIONFUNCTION trial(pSt as pSupportTable, ppModuleInternal as void ptr ptr, pParameters as pFixSizeMemoryObject, pReturnValue as pFixSizeMemoryObject ptr) as integer export   DIM pEo AS pExecuteObject  DIM pL AS long ptr   PRINT "Function trial was started..."  pL = (long *)besMODULEPOINTER  (*pL)++  besRETURNVALUE = besNEWMORTALLONG  LONGVALUE(besRETURNVALUE) = *pL   PRINT "Module directory is ";(char*)besCONFIG("module")  PRINT "dll extension is ";(char*)besCONFIG("dll")  PRINT "include directory is ";(char*)besCONFIG("include")    FUNCTION = 0END FUNCTION 
ttbcx.sb

--- Code: Text ---DECLARE SUB trial ALIAS "trial" LIB "libtrial" modptr = trial() PRINT "Module Pointer = ",modptr,"\n" 
Results

root@Laptop:/home/jrs/bcx# scriba ttbcx.sb
Function trial was started...
Module directory is /usr/local/lib/scriba/
dll extension is .so
include directory is /usr/share/scriba/include/
Module Pointer = 1
root@Laptop:/home/jrs/bcx#

A good example of how a C function can speed things up dramatically is the use of the SPLITA() function. You will see what I mean if you try to take a delimited string and build an array from it with a loop structure compared to using SPLITA() to do it.

Navigation

[0] Message Index

Go to full version