Writing code: Difference between revisions

From XPUB & Lens-Based wiki
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
<slidy theme="aa" />
== Writing Code ==
== Writing Code ==


Line 20: Line 18:
Examples:
Examples:


* [http://www.sublimetext.com/ Sublime Text] Unfortunately not free software, it ''is'' however ''free'' to use (it nags about registering from time to time), and it's cross platform
* [http://www.sublimetext.com/ Sublime Text] Unfortunately not free software, it ''is'' however ''gratis'' (aka ''freeware'') (it complains about registering from time to time), and it's cross platform
* [[gedit]]
* [[gedit]]
* Atom
* Brackets


== White space ==
== White space ==
Line 32: Line 32:


* Imperative
* Imperative
Commands, traditional "programming" languages like [[JavaScript]], [[Python]]
* Declarative
* Declarative


== Special Characters ==
Descriptive, "Markup" languages like [[HTML]], [[CSS]]
 
== Know your keyboard ==
 
[[ File:UnderwoodKeyboard.jpg ]]
 
http://lowerquality.com/desertjournalism/15-IMG_3780%20(9).jpeg
 
Mac OS: Enable the [https://support.apple.com/guide/mac-help/use-the-keyboard-viewer-on-mac-mchlp1015/mac Keyboard viewer]
 
== What the $#!@ ==
 
; ( . ): period (aka dot, full stop)
; ( - ): hyphen (aka dash)
; ( _ ): underscore
; ( = ): equals sign
; ( $ ): dollar sign
; ( / ): slash (forward)
; ( \ ): backslash
; ( # ): hash
; ( ! ): exclamation mark (aka bang)
; ( @ ): at sign
; ( * ): star (asterisk)


== Matching symbols ==
== Matching symbols ==
Line 56: Line 81:
|&quot; &quot;
|&quot; &quot;
|Double Quotes
|Double Quotes
|}
== What the $#!@ ==
{|
|-
|dash
|-
|.
|dot
|-
|_
|underscore
|-
|=
|equals sign
|-
|$
|dollar sign
|-
|/
|slash (forward)
|-
|\
|backslash
|-
|#
|hash
|-
|!
|exclamation mark (aka bang)
|-
|@
|at sign
|-
|*
|star (asterisk)
|}
|}



Latest revision as of 14:06, 16 September 2020

Writing Code

Writing code has special demands from other kinds of writing.

Specialised tools exist for writing code that help make some of the complexities of code writing manageable.

Code Editor

A code editor has features like:

  • Ability to work with many files & languages at the same time
  • Syntax coloring for different languages
  • Symbol matching
  • Commenting Shortcut
  • Tab/Space "sensitivity"
  • "Show invisibles" feature

Examples:

  • Sublime Text Unfortunately not free software, it is however gratis (aka freeware) (it complains about registering from time to time), and it's cross platform
  • gedit
  • Atom
  • Brackets

White space

Characters like space, tab, carriage return and new line or basically anything that doesn't print a visible symbol.

While many languages are said to "ignore" whitespace (like HTML) ... (one space is the same as 20 spaces), others are very sensitive to subtle differences (like Python considering tabs vs. spaces).

Code Types

  • Imperative

Commands, traditional "programming" languages like JavaScript, Python

  • Declarative

Descriptive, "Markup" languages like HTML, CSS

Know your keyboard

UnderwoodKeyboard.jpg

15-IMG_3780%20(9).jpeg

Mac OS: Enable the Keyboard viewer

What the $#!@

( . )
period (aka dot, full stop)
( - )
hyphen (aka dash)
( _ )
underscore
( = )
equals sign
( $ )
dollar sign
( / )
slash (forward)
( \ )
backslash
( # )
hash
( ! )
exclamation mark (aka bang)
( @ )
at sign
( * )
star (asterisk)

Matching symbols

< > Angle Brackets
[ ] Square Brackets
{ } Curly Brackets
( ) Parentheses
' ' Single Quotes
" " Double Quotes

Syntax

Each language has rules determining proper structure. Files that have structural errors are said to have syntax errors (in the case of imperative languages) or else described as not being well-formed, invalid, or just plain broken.

Some programs when interpreting code are more permissive than others. Web browsers will generally speaking display something, even when HTML code is syntactically incorrect. When displaying an SVG graphic however, any errors typically means that nothing but a short complaint will be shown that the file is invalid.

Markup

Many coding languages use a notion of markup tags inspired by the SGML family of languages