Skip to content

Instantly share code, notes, and snippets.

@gingerBill
Created March 10, 2017 12:47
Show Gist options
  • Save gingerBill/3c72d6290db6d145bd44e30c352fc118 to your computer and use it in GitHub Desktop.
Save gingerBill/3c72d6290db6d145bd44e30c352fc118 to your computer and use it in GitHub Desktop.
Brief comments on https://eev.ee/blog/2016/12/01/lets-stop-copying-c/ for Odin
A - Agree with eev.ee
D - Disagree with eev.ee
S - Have it for sanity reasons
O - Other reason
[A] Textual Inclusion
[A] Optional block delimiters
[A] Bitwise operator precedence
[O] Negative modulo
[A] Leading zero for octal
[D] No power operator
[O] C-style for loops
[A] switch with default fallthrough
[A] Type first
[A] Weak typing
[O] Integer division
[O] bytestrings
[S] increment decrement
[D] !
[A] Single return and out parameters
[O] Silent errors
[D] Nulls
[A] Assignment as expressions
[D] No hyphens in identifiers
[D] Braces and semicolons
[D] Blaming the programmer
Agree
-----
Textual Inclusion - Textual inclusion (C Macros) is just plain bad.
Optional block delimiters - Brace everything.
Bitwise operator precedence - Handled very well in Odin.
Leading zero for octal - Odin uses 0b 0o 0d 0x prefixes if the want a specific base.
switch with default fallthrough - Odin's `match` statements have an explicit `fallthrough`.
Type first - name: type = assignment (better for parsing, reading, and type inference).
Weak typing - Strong typing virtually everywhere.
Single return and out parameters - Native multiple return values. (Not through tuples)
Assignment as expressions - Statements and expressions are different things. `if x = foo(); x {}` is much clearer in Odin.
Disagree
--------
No power operator - Not that useful in a "lower-level" language such as Odin. A procedure call is much clearer.
! - `== false` maybe a clearer if the person is worried.
Nulls - Nullable types are good for "higher-level" languages, but not a language like Odin. Maybe types used to be in Odin but they were removed for numerous other reasons (e.g. multiple return values usually solve the same issue).
No hyphens in identifiers - Will cause clarity issues (e.g. `a-b` is that an identifier or `a - b`).
Braces and semicolons - Not a fan of significant whitespace. It causes more problems than it solves (IMHO).
Blaming the programmer - NULL derefs are usually very easy to find and (for me at least) a logical issue; This is an argument for safety which is too big to write in a small remark.
Sanity
------
increment decrement - `++` is useful to have just for sanity reason even if it is the same as `+= 1`.
Other
------
Negative modulo - Maybe having a separate operator (%%) to do positive module would be better.
C-style for loops - I think a `for in` loop should be good in 95% of cases but sometimes, a C-style for loop is perfectly fine and clear.
Integer division - If the language is "lower-level", then a/b should be integer division if a and b are integers, if "higher-level" then no.
Bytestrings - I like how I handle strings in Odin - just bytes but with specific utf8 operations if needed.
Silent errors - I don't like software exceptions to begin with. Multiple return values are much better solution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment