Writing code: Difference between revisions
Line 42: | Line 42: | ||
[[ File:UnderwoodKeyboard.jpg ]] | [[ 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] | Mac OS: Enable the [https://support.apple.com/guide/mac-help/use-the-keyboard-viewer-on-mac-mchlp1015/mac Keyboard viewer] |
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
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