AnyLang Programming Language Comparison/Anylang Common Concepts

From Wikibooks, open books for an open world
Jump to navigation Jump to search

AnyLang Common Concepts[edit]

The following is the central list of AnyLang Common Concepts. These are programming concepts that are common enough to be compared and applied across multiple mainstream programming languages.

code blocks

block.case_ifconditional case statement
block.catchcatch block
block.diehow to terminate a process with error message
block.elseelse statement
block.else_ifelseif statement
block.finallyfinally block
block.ifif statement
block.pausehow to pause the process
block.qmark_ifternary qmark question mark conditional if statement
block.quithow to terminate a process
block.switchswitch statement
block.trytry block
block.try_catcha simple try-catch block

code comments

codecmmt.beginenda generic begin-end multiline comment region
codecmmt.docgendocgen tag
codecmmt.multimulti-line cmmt
codecmmt.singlesingle-line cmmt
codecmmt.xregionmy_generic_region tag

debugging operatinos

codedebug.loglogging errors and program info to a log file
codedebug.testif statement used for debugging or example

basic structural elements of code

codeelem.blockbare code block
codeelem.end_codeend code
codeelem.init_codeinit code
codeelem.init_libinit library
codeelem.init_varsinit vars
codeelem.line_continline continuation for putting a newline in the middle of a statement (language dependent)
codeelem.line_terminline termination character (e.g. semicolon) for languages that require it
codeelem.named_blocknamed code block
codeelem.new_doca new document
codeelem.new_footera new footer within a document page
codeelem.new_headera new header within a document page
codeelem.new_liba new document as a library module (arbitrary defn of what constitutes a module)
codeelem.new_pagea new page within a document (arbitrary defn of what constitutes a page)
codeelem.new_reca new record entry

looping structures

codeloop.arrloop over an array
codeloop.dicenumerate or iterate over a the keys and values in a dictt
codeloop.dirloop over items in a directory
codeloop.foreachfor bar in foo
codeloop.whilevarwhile loop with a variable
codeloop.forvarold c-style loop( for icc=0; icc ~ foo.length; icc++ )
codeloop.lastloop control final iteration
codeloop.modify_in_placeloop over an array (or iterable) and modify the elements in place
codeloop.nextloop control, skip to the next iteration
codeloop.rowsloop over rows in a SimpleTable
codeloop.whilewhile statement


codemeta.argscommand line arguments passed into current script
codemeta.current_osget the current operating system that we are running under
codemeta.docs_classself-documenting class
codemeta.docs_funcself-documenting functions
codemeta.docs_funcparamself-documenting function parameters
codemeta.docs_methself-documenting methods
codemeta.docs_methnamereturn the name of the currently running method
codemeta.docs_methparamself-documenting method parameters
codemeta.nameismaindetermine if source file is the current 'main' namespace [websearch://"python main trick"]
codemeta.newdoca starting template for a new file in this language
codemeta.quick_docshelp facility for language constructs
codemeta.source_linethe current line in the current source file
codemeta.source_paththe full path of the current source file

currently running script path

codemeta.source_pdirthe parent directory of the current source file. use path of the source file itself, and NOT the path of the file that calls it via *include* or *require*
codemeta.versionthe language version of the current script or language interpreter

source code regions

coderegion.detailsworksheet of an xregion metadata island
coderegion.file_infofile info metadata island
coderegion.generatorworksheet of an xregion metadata island
coderegion.mainworksheet of an xregion metadata island
coderegion.see_alsoworksheet of an xregion metadata island

console operations

console.printprint to console
console.printfformatted print to console
console.printlnprint to console with newline

data definitions and schemas

datadef.aohjust like perldsc AoH
datadef.1yamlrecsmall yaml syntax
datadef.2yamlrecmed yaml syntax
datadef.3yamlrecbig yaml syntax
datadef.newtablea new ReallySimpleData table
datadef.newwkbka new ReallySimpleData wkbk
datadef.newwksheeta new ReallySimpleData wksheet
datadef.simpletablecreate a SimpleTable structure similar to perl AoH
datadef.simpletable_ivcreate a SimpleTable structure similar to perl AoA (IV = IndexedValues)
datadef.yamlrecSimpleRecord yaml syntax

data processing operations

datamunge.json_mungedump a variable out to json and load it back in from json
datamunge.dec_base_64decode base64 format
datamunge.dec_htmlentdecode HTMLEnt format
datamunge.dec_jscriptdecode jscript_url_style escaping
datamunge.dec_rot_13decode rot13 format
datamunge.enc_base_64encode base64 format
datamunge.enc_htmlentencode HTMLEnt format
datamunge.enc_jscriptencode jscript_url_style escaping
datamunge.enc_rot_13encode rot13 format

date and time operations

datetime.2date_fmtspecify a string like "Fri Sep 9 13.46.58 2005" (perl localtime() in scalar context)
datetime.datecurrent system Date of the Month
datetime.datemspecify a string like Fri 2005-08-26 13.23.03 (preferred)
datetime.day_of_weekcurrent system Day of the week
datetime.monthcurrent system Month
datetime.nowcurrent system time and date
datetime.time_millisecreturn the current time with millisecond accuracy (for timestamps)
datetime.yearcurrent system Year

error trapping and exceptions

error.arr_boundsarray index out of range
error.dict_keyexdictionary key does not exist
error.warningsenable or disable warnings

filesystem operations

filesys.basenameget file basename from path
filesys.copyCopy a file or directory
filesys.deleteDelete a file or directory
filesys.deltreedelete a directory tree
filesys.dir_existstrue if a directory exists
filesys.extenget file extension from full path
filesys.file_existstrue if a file exists
filesys.file_sizereturn file size as an integer (usu in bytes)
filesys.loop_dirloop over files within a directory
filesys.loop_treerecursively iterate files within a directory tree
filesys.mkpathcreate directory even if there is more than one missing pathstep
filesys.moveMove a file or directory
filesys.parent_dirget file parent dir from a full path
filesys.renameRename a file or directory

function arguments

funcarg.arg_arrayspecify an array that holds multiple args
funcarg.arrarray declare a function argument
funcarg.booboolean declare a function argument
funcarg.defvalspecify function parameters argument default value
funcarg.intinteger declare a function argument
funcarg.objobject declare a function argument
funcarg.opt_argspecify an optional parameter
funcarg.passfuncpass a function as an argument
funcarg.passobjpass an object or dictionary that holds multiple args
funcarg.req_argspecify a required parameter
funcarg.strstring declare a function argument

function definitions

funcdef.1funcsml syntax declare a function
funcdef.1methsml syntax declare a oop_method
funcdef.2funcmed syntax declare a function
funcdef.2methmed syntax declare a oop_method
funcdef.3funcbig syntax declare a function
funcdef.3methbig syntax declare a oop_method
funcdef.closurefunction as full-fledged closure
funcdef.funcdefpsu funcdef template
funcdef.funcdspfunction DspTemplate
funcdef.funcmetaattach arbitrary metadata to a function
funcdef.lambdafunction as python-lambda-style expression

basic GUI display

guidsp.alertGuiAlert(sPrompt) alert box with ok button
guidsp.buttongeneric pushbutton control
guidsp.checkboxgeneric checkbox control same as html//inputCheckbox
guidsp.combo_boxsame as html//Select execept user can also supply a value
guidsp.date_timeA box that looks like a single-line edit control but instead accepts a date and/or time. A drop-down calendar is also provided
guidsp.editsame as html//textarea
guidsp.gridgrid and list control
guidsp.group_boxA rectangular border/frame
guidsp.hotkeyA box that looks like a single-line edit control but instead accepts a keyboard combination pressed by the user
guidsp.input_boxstrVal = GuiInput(sPrompt
guidsp.month_calA relatively tall control that displays all the days of the month in calendar format
guidsp.passsimple input box for password same as html//inputPassword
guidsp.picturean area containing a picture
guidsp.progressprogress bar
guidsp.radiogeneric radio button same as html//inputRadio
guidsp.rangeup-down arrows to toggle through a range of integers
guidsp.rich_editrich edit textbox with formatting
guidsp.selectsame as html//Select
guidsp.select_multisame as html//Select with multiple='true'
guidsp.sliderA sliding bar that the user can move along a vertical or horizontal track
guidsp.tabcontrol containing multiple pages
guidsp.textsimple input box for text same as html//inputText

GUI windows

guiwin.centercenter a window relative to the desktop (or parent window)
guiwin.coordsspecify the position of a window relative to the desktop (or parent window)


interop.alt_interopdifferent alternatives for interop
interop.com_objecthow to instantiante a msft OLE COM object
interop.shell_runrun an external program e.g. ShellRun('notepad.exe') as a separate process
interop.shell_runwaitrun external program and wait for it to finish

code libraries and addons

lib.include_libinclude a library file
lib.include_onceinclude a library file once

OOP classes

oopclass.class_constructorconstructor method of a class
oopclass.new_classa new OOP class
oopclass.reflect_classnameget the name of a class from within the class itself

OOP methods

oopmeth.aliascreate an alias name for an oop method
oopmeth.filteriterate through the names of all selected methods of a class based on any criteria
oopmeth.instancedeclare an instance method in a class
oopmeth.invokeoperatorthe symbol used as the method invocation operator
oopmeth.multileveldeclare and use a nested method (e.g., mymap.delaware.dover.getpopulation() )
oopmeth.reflectiterate through the names of all methods of a class
oopmeth.staticdeclare a static method in a class
oopmeth.symboliccall an oop method using a scalar for the methodname

OOP objects

oopobj.new_instanceA new OOP plain object. Create an object (aka instance of a class).

OOP references

oopref.symbolicinstantiate an object from an oop class using a scalar for the classname (without using string eval)

regular expressions and related concepts

regex.22_notationspecify notation for individual characters char
regex.backrefRegEx memorizing capture register inside match-region or substitute-region
regex.basic_syntaxRegEx basic syntax basic_ops
regex.capturespecify a capturing match register
regex.matchRegEx match operation
regex.noncapturespecify a non-capturing grouping match register
regex.replaceRegEx replace operation

SQL and related concepts

sqldata.bulk_insertpopulate a sql table using a text file as the raw data

formatting and using strings in source code

strdsp.esc_bs1note regex22 is better
strdsp.esc_bs2note regex22 is better
strdsp.esc_qq1note regex22 is better
strdsp.esc_qq2note regex22 is better
strdsp.here_docspecify multi-line string inside code like a perl heredoc
strdsp.here_funcheredoc function
strdsp.here_strstring in variable
strdsp.here_varinterpolated variable inside string
strdsp.heredoc_indentheredoc indented along with the rest of the code
strdsp.interpospecify a string variable with possible interpolation
strdsp.number_formatpretty-format a number for locale or data display
strdsp.printfspecify a string variable with special formatting options
strdsp.skeleton_fillfill in the content of a SimpleTemplate
strdsp.verbatimspecify a string variable with NO interpolation

reserved for later use

system.timeoutthrow an exception or terminate process if it is taking too long


template.delimspecify the syntax for template delimiter
template.valueofvalue output for template style programming

data validation

valid.file_existtrue if a file exists in the filesystem
valid.file_not_existtrue if a file does not exist in the filesystem
valid.is_numericexpression evaluates to a number
valid.is_stringexpression evaluates to a string
valid.is_trueexpression evaluates to truth value

variable declaration

vardec.myarrquickly declare array
vardec.mybooquickly declare boolean
vardec.mydicquickly declare dictionary
vardec.myintquickly declare integer
vardec.myobjquickly declare object
vardec.mystrquickly declare string
vardec.nullrepresent a null value in source

working with variables

varops.array_assignassign a value to Array
varops.array_decldeclare Array
varops.array_initinitialize Array
varops.composite_defndefine a composite variable (e.g., like with perl data structure cookbook)
varops.composite_manipmanipulate a composite variable (e.g. sort, search filter view add edit delete)
varops.dumperdump variable contents like with perl DataDumper
varops.object_assignassign a value to Object
varops.object_decldeclare Object
varops.object_dupe_byrefshallow copy and duplicate an object or nested variable by reference
varops.object_dupe_byvalcopy and duplicate an object or nested variable by value
varops.object_initinitialize Object
varops.scalar_assignassign a value to a scalar
varops.scalar_decldeclare a scalar
varops.scalar_initinitialize a scalar
varops.typecastconvert the native type of a variable into another type
varops.vartypeget the native type of a variable

web and http

webhttp.htincludetransclusion include one page or page fragment into another
webhttp.cflocationredirect to a new page like coldfusion cflocation
webhttp.cgi_referrerclient referrer url
webhttp.cgi_remoteaddrclient IP address
webhttp.server_getgrab a web page from another site using serverside code