Replies: 0 comments 7 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Code is always the best solutionA common approach to programming, especially for the web, is to reduce the amount of actual programming that takes place and instead use simplified markup, configuration, and selection formats like CSS, HTML, YAML, and Regex. The promise of this is that you will be able to accomplish everything you need to do in a very easy, simple way. However, there are several problems with this strategy. Firstly, it requires learning many different languages, typically with very magic syntaxes packed with random symbols that do various things, with no clear connection between the symbols and the actions. Second of all, the simplified formats never end up covering all use cases, resulting in hacky workarounds to achieve the desired functionality, or, in some cases, entirely new languages that promise to cover all of the use cases, for real this time. The eventual result of this trend is that people end up stuffing entire programming languages into these supposedly simple formats to cover their requirements (for example, SCSS, JSX, and templates). The resulting languages are neither simple, clear, nor extensible, creating massive amounts of unreadable and inefficient code. This means that everyone has to learn these languages and their magic syntaxes, struggle to read their complicated code, reach constant limits in functionality, and suffer runtime errors and bad performance due to the typically duck-typed, interpreted nature of these languages. Unless there are very limited uses for something, avoiding real code will always cause many problems and no benefits. The solution to this is simple—whenever possible, everything should be written in real code, preferably in one language. Therefore, GoKi takes this approach: everything, from trees to widgets to styling to enums, is written in real, pure Go code. The only non-Go functional files in a GoKi package or app should be TOML files, which are only used for very simple configuration options to commands, and not for any actual code. |
Beta Was this translation helpful? Give feedback.
-
Nested Embedding + Interfaces (i.e., virtual functions) -- i.e., traditional OOPThere is a class of domains where the classic OOP paradigm of type inheritance and virtual functions is the most efficient paradigm. This is the case in the GoGi GUI, and, arguably, in any kind of GUI framework. Specifically, the OOP paradigm makes sense when:
The Go Accessing embedded types
em, ok := n.Embed(TypeEmbedType).(*EmbedType)
if !ok {
continue
} |
Beta Was this translation helpful? Give feedback.
-
Do NOT get too carried away with generator stuff!Once we have a generator tool (
|
Beta Was this translation helpful? Give feedback.
-
Struct fields are better than maps for Config, Styling, etcConfiguration settings, typically settable with a config file and / or command-line arguments, are stored as key-value maps in the widely used cobra, viper and other such tools. Likewise, in v1 of GoGi, styling was set using Props maps. However, using a
This is why the grease configuration and app command management system is based structs, and v2 of GoGi uses "direct styling" functions that directly set values on the |
Beta Was this translation helpful? Give feedback.
-
This is an attempt to systematize and document the principles and decisions driving V2 rewrite:
Prefer
generate
toreflect
Generated code is faster and cleaner and can be targeted to just what is needed.
reflect
should be reserved for things likegiv.StructView
and other such views which need to be truly generic and operate on any kind of type from any package, etc.generate
is easiest for code we own.This
goki
package represents the logical conclusion of this principle: a tool that combines multiple generate steps into one big generator pass -- once we have this infrastructure in place, it is easy to add new generator types.Use interfaces instead of
reflect
Interfaces go hand-in-hand with generated code: the boilerplate code that satisfies the interfaces is auto-generated as needed.
The prototype here is enums
Repositories and packages should be small, focused, minimal
Find the coherent chunks of functionality and encapsulate them in separate repositories, instead of creating sprawling mega-repos like
ki
was before. Now that we know all the functionality we need, we can think more carefully about how to package it.Try to make these repos as independent as possible -- don't have them depend on other goki infrastructure unless absolutely necessary, so that they can be used by anyone in an unencumbered way.
This is what we look for, in considering whether to import a given package, so it is what we should provide.
Examples:
This is why we don't want to apply goki "desc" comment generator and type registry to all of our packages -- only required when using gi, so it should be in gi!
Use function libraries instead of putting lots of methods on a type
Go uses the
strings
package instead of adding a lot of builtin methods on thestring
type. The advantages are:Consistent with this approach, colors implements functions operating on the standard
color.RGBA
data type, instead of the many methods we defined ongist.Color
in V1.Type registry is required for generic
New
See ki issue #11 for logic.
Once we buy into the type registry, it provides a place to hang other things that we otherwise might need to use reflect for.
Ki
types?Beta Was this translation helpful? Give feedback.
All reactions