batteries icon indicating copy to clipboard operation
batteries copied to clipboard

vec2 and vec3 interface is not friendly

Open 1bardesign opened this issue 5 years ago • 2 comments

At the moment, the vector modules have a naming pattern which is fairly user unfriendly. This is affecting uptake.

There are two issues, both basically lead to "hungarian style" names which are hard to understand at a glance.

Type Prefix:

Problem: Currently, the operation type (scalar or vector) is specified with a "hungarian notation" style single letter prefix. This avoids type dependent dynamic dispatch and keeps code fast but also is pretty unfriendly to a beginner.

Fix: fully specified names could be provided for each operation, with hungarian style aliases preserved for writing terse code if preferred. vector_add and vadd both available, but the former canonicalised as the initial definition.

Immediate/Modifying Suffix:

Problem: Currently, if an operation modifies its operand or not is specified with an "immediate" suffix on the method, eg vaddi for "vector add immediate". This looks a lot more like an assembly instruction than a lua method :smile:

Fix: A different naming convention could be adopted. Current candidate is verb for modifying and verbed for copying - eg normalise and normalised for modifying and copying normalisation respectively.

Note that this would break existing code. It definitely needs to be communicated well to existing users!

I do think both are worth doing though to make the incredibly useful vector modules more likely to get use in the wider community.

1bardesign avatar May 12 '20 02:05 1bardesign

Done vec2 as of 918c9438 - feedback welcome, will need to find some time to do vec3.

1bardesign avatar Aug 09 '21 09:08 1bardesign

vec3 still needs doing

I've been underwhelmed when using vec2 honestly and find myself using the shorthand quite often. Other users have said they found it nicer though so probably a win?

1bardesign avatar Nov 23 '21 00:11 1bardesign