From 49ef85a3957eab130bd806c3ec5bf2d02764e5a0 Mon Sep 17 00:00:00 2001 From: Kai O'Reilly Date: Mon, 22 Jul 2024 12:21:57 -0700 Subject: [PATCH] more blog cleanup --- content/blog/-2024-07-22-initial-release.md | 53 ++++++++++----------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/content/blog/-2024-07-22-initial-release.md b/content/blog/-2024-07-22-initial-release.md index ebd00aa..e7d2826 100644 --- a/content/blog/-2024-07-22-initial-release.md +++ b/content/blog/-2024-07-22-initial-release.md @@ -4,9 +4,9 @@ author = ["Kai O'Reilly", "Randy O'Reilly"] *For a video introduction to Cogent Core, see {TODO}* -Today we are announcing the initial public release of the Cogent Core GUI framework. Cogent Core allows you to build powerful, fast, elegant apps that run on all platforms with a single Go codebase, allowing you to Code Once, Run Everywhere. This blog is an interactive Cogent Core app running on the web using [wasm](https://en.wikipedia.org/wiki/WebAssembly). The same code can run on macOS, Windows, Linux, iOS, Android, and the web through a command line tool that manages all the details for running and building apps for each platform. +Today we are announcing the initial public release of the Cogent Core GUI framework. Cogent Core allows you to build powerful, fast, elegant apps that run on all platforms with a single Go codebase, allowing you to Code Once, Run Everywhere (Core). This blog is an interactive Cogent Core app running on the web using [wasm](https://en.wikipedia.org/wiki/WebAssembly). The same code can run on macOS, Windows, Linux, iOS, Android, and the web through a command line tool that manages all the details for running and building apps for each platform. -Cogent Core is written in [Go](https://go.dev), and inherits many of its features from this language and its associated ecosystem. Go code is simple, easy to read and write, and emphasizes a minimalist approach without the extra syntax and boilerplate that clutters other languages. +Cogent Core is written in [Go](https://go.dev) and inherits many features from this language and its associated ecosystem. Go code is simple and easy to read and write, and it emphasizes a minimalist approach without the extra syntax and boilerplate that clutters other languages. Here's a simple hello world app in Cogent Core: @@ -22,15 +22,15 @@ func main() { } ``` -See that "Hello, World!" button? That is a live rendering of the code shown in the text editor above. You can change the message, press `Ctrl+Enter` or just click off, and you'll see it update! +See that "Hello, World!" button? That is a live rendering of the code shown in the text editor above. You can change the message in the code, press `Ctrl+Enter` or just click off, and you'll see it update! Cogent Core supports all the usual types of GUI widgets, along with some fairly advanced ones not found in other frameworks. Interactive, editable examples of all major widgets are available on the main [docs](https://www.cogentcore.org/core) page (which is also a Cogent Core app running via wasm). Here's a small sample of widgets, and a few things you can do with them: ```Go -core.NewButton(b).SetText("Hello, World!").SetIcon(icons.Send).OnClick(func(e events.Event) { - core.MessageSnackbar(b, "Hello!") +core.NewButton(b).SetText("Send").SetIcon(icons.Send).OnClick(func(e events.Event) { + core.MessageSnackbar(b, "Message sent") }) core.NewText(b).SetText("Name:").SetTooltip("Enter your name in the text field") core.NewTextField(b).SetPlaceholder("Jane Doe") @@ -44,7 +44,6 @@ slider.OnChange(func(e events.Event) { spinner.Update() }) core.NewColorButton(b).SetColor(colors.Orange) - type language struct { Name string Rating int @@ -61,9 +60,9 @@ You can even make interactive plots of data: ```Go type Data struct { - Time float32 - Population float32 - Distance float32 + Time float32 + Users float32 + Profit float32 } plotcore.NewPlotEditor(b).SetSlice([]Data{ {0, 500, 1520}, @@ -75,13 +74,13 @@ plotcore.NewPlotEditor(b).SetSlice([]Data{ ## Key features -Overall, the key feature of Cogent Core is that it allows you to efficiently write full-scale GUI apps in the Go language, with no limits relative to what can be accomplished in other frameworks. More specifically, it has: +The key feature of Cogent Core is that it allows you to efficiently write full-scale GUI apps in Go, with no limits relative to what can be accomplished in other frameworks. More specifically: -* A full set of GUI widgets, with built-in support for most elements of the [Material 3](https://m3.material.io/) standard, with tooltips, drag-and-drop, sprites, popup completion, a full text editor with code highlighting, and other advanced features, allowing powerful apps to be assembled by customizing these existing elements. +* A full set of GUI widgets, with built-in support for most elements of the [Material 3](https://m3.material.io) standard, with tooltips, drag-and-drop, sprites, popup completion, a full text editor with code highlighting, and other advanced features, allow powerful apps to be assembled by customizing these existing elements. * Extensive styling properties allow everything to be customized, including a powerful automatic layout system that solves all the hard layout problems for you, and complete event-driven control over app behavior. Styling is easy to control and well documented, and anyone can quickly customize widgets to fit their needs. -* Responsive widget elements that automatically adapt to different screen sizes and orientations, enabling one coherent codebase to run across different platforms. +* Responsive widget elements automatically adapt to different screen sizes and orientations, enabling one coherent codebase to run across different platforms. * The code to implement standard widgets is transparent and elegant, making it easy to write your own custom widget elements if needed. @@ -111,7 +110,7 @@ Meanwhile, Randy's son Kai was busy experimenting with different frameworks and So the father and son team (more son than father, to be clear) spent the next year rewriting this codebase many times over, peeling away layers of complexity and finding the most robust and elegant solutions to the many problems such a framework must solve. The [principles](https://cogentcore.org/core/architecture/principles) capture some of our hard-won lessons. We hope that the experience of using this framework demonstrates the resulting simplicity and power of the approach. -Throughout this process, Randy maintained what is now [Cogent Code](https://cogentcore.org/cogent/code) as his primary everyday code editor, and the neural network models based on this framework were used by students and colleagues. Therefore, the core of the framework is well-tested and ready to use, even as we continue to build out more features and welcome input from the broader community for how to make it even better. +Throughout this process, Randy maintained what is now [Cogent Code](https://cogentcore.org/cogent/code) as his primary everyday code editor, and students and colleagues explored and extended the neural network models based on this framework. Therefore, the core of the framework is well-tested and ready to use, even as we continue to build out more features and welcome input from the broader community for how to make it even better. We each have a long-term commitment to the future of the Cogent Core framework. Randy and other scientists and instructors rely on it for research and teaching. Kai plans to build his career around the framework. He is programming apps in it and is available for consulting projects to develop Cogent Core solutions. @@ -119,13 +118,13 @@ We think Go is such a special language that it deserves to be used for everythin ## Future directions -One important future direction, evident in the interactive editing ability shown above, is to use the [yaegi](https://github.com/traefik/yaegi) Go interpreter as a replacement for the traditional role that Python has played relative to backend languages such as C++, so that you can transparently have a dynamic, interpreted experience as well as the lightning-fast compilation of Go. We think this can provide an ideal combination of rapid prototyping and hot-reloading (as in the Flutter framework), within a strongly typed and robust language that scales to large-scale applications (unlike Python and JavaScript). +One important future direction, highlighted by the interactive editing ability shown above, is to use the [yaegi](https://github.com/traefik/yaegi) Go interpreter as a replacement for languages like Python so that you can transparently have a dynamic, interpreted experience as well as the lightning-fast compilation of Go. We think this can provide an ideal combination of rapid prototyping and hot-reloading (as in the Flutter framework), within a strongly typed and robust language that scales to large-scale applications (unlike Python and JavaScript). **TODO** screenshots! -Furthermore, we have written a shell language variant of Go, called `cosh` or [Cogent Shell](https://github.com/cogentcore/core/shell), which allows direct intermixing of shell-like execution of command-line tools, with standard Go control constructs, using the yaegi interpreter. Everything can be transpiled into standard Go and built the usual way as a fully compiled executable as well. Next, we plan to extend this general approach to the numerical computing and data science domain, in the [Cogent Numbers](https://github.com/cogentcore/cogent/tree/main/numbers) framework, to provide a viable competitor in this Python-dominated domain. +In addition, we will continue working on a shell language variant of Go, called `cosh` or [Cogent Shell](https://github.com/cogentcore/core/shell), which allows direct intermixing of shell-like execution of command-line tools with standard Go code using yaegi. Everything can be transpiled into standard Go and built the usual way as a fully compiled executable as well. Next, we plan to extend this general approach to the numerical computing and data science domain, in the [Cogent Numbers](https://github.com/cogentcore/cogent/tree/main/numbers) framework, to provide a viable competitor in this Python-dominated space. -In addition, we will be completing the [Cogent Canvas](https://cogentcore.org/cogent/canvas) app for editing SVG vector graphics, the [Cogent Mail](https://github.com/cogentcore/cogent/tree/main/mail) client, a [terminal emulator](https://github.com/cogentcore/cogent/tree/main/terminal), and a [3D modeling app](https://github.com/cogentcore/cogent/tree/main/craft). We also plan to make a video editor and continue working on a [web browser](https://github.com/cogentcore/cogent/tree/main/web). +We will also be completing the [Cogent Canvas](https://cogentcore.org/cogent/canvas) app for editing SVG vector graphics, the [Cogent Mail](https://github.com/cogentcore/cogent/tree/main/mail) client, a [terminal emulator](https://github.com/cogentcore/cogent/tree/main/terminal), and a [3D modeling app](https://github.com/cogentcore/cogent/tree/main/craft). We also plan to make a video editor and continue working on a [web browser](https://github.com/cogentcore/cogent/tree/main/web). ## Comparisons with other frameworks @@ -133,21 +132,21 @@ In the remainder of this blog, we provide some commentary about how we think Cog ### Web frameworks -Most of the world's GUI software is written using one of the many web frameworks, which provide various benefits but come with difficult disadvantages: +Most of the world's GUI software is written using one of the many web frameworks, which provide various benefits but come with challenges: -* The awkward separation of JS, HTML, and CSS makes it hard to create dynamic interfaces without some combination of them, resulting in inconsistent languages like [JSX](https://en.wikipedia.org/wiki/JSX_(JavaScript)) and [SCSS](https://en.wikipedia.org/wiki/Sass_(style_sheet_language)). In comparison, Cogent Core allows you to write everything in one coherent language. +* The awkward separation of JS, HTML, and CSS makes it hard to create dynamic interfaces without some combination of them, resulting in inconsistent languages like [JSX](https://en.wikipedia.org/wiki/JSX_(JavaScript)) and [SCSS](https://en.wikipedia.org/wiki/Sass_(style_sheet_language)). Cogent Core allows you to write everything in one coherent language. -* HTML and CSS don’t provide modern-looking widgets out of the box, forcing you to either [painfully wrestle with CSS](https://blog.logrocket.com/creating-custom-css-range-slider-javascript-upgrades/) or depend on one of many inconsistent CSS frameworks. In contrast, Cogent Core comes with modern and easily customizable widgets without a single line of CSS. +* HTML and CSS don’t provide modern-looking widgets out of the box, forcing you to either [wrestle with CSS](https://blog.logrocket.com/creating-custom-css-range-slider-javascript-upgrades/) or depend on one of many inconsistent CSS frameworks. Cogent Core comes with modern and easily customizable widgets without a single line of CSS. -* Web frameworks are plagued by browser inconsistencies, making things as simple as favicons the subject of [blog posts](https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7) featuring language like “nightmare” and “how to maintain sanity.” Cogent Core apps, by contrast, automatically work consistently across all devices. +* Web frameworks are plagued by browser inconsistencies, making things as simple as favicons the subject of [blog posts](https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7) featuring language like “nightmare” and “how to maintain sanity.” Cogent Core apps automatically work consistently across all devices. -* The benefits of Cogent Core relative to the web are highlighted by our [tic-tac-toe tutorial](https://www.cogentcore.org/core/tutorials/tic-tac-toe), which has fewer than half the lines of code of the similar [React one](https://react.dev/learn/tutorial-tic-tac-toe), while also containing no ternaries and no JSX. +The benefits of Cogent Core relative to the web are highlighted by our [tic-tac-toe tutorial](https://www.cogentcore.org/core/tutorials/tic-tac-toe), which has fewer than half the lines of code of the [React one](https://react.dev/learn/tutorial-tic-tac-toe), while also containing no ternaries and no JSX. ### Flutter Although [Flutter](https://flutter.dev) can be good for creating simple mobile apps, it has several limitations: -* It is not suitable for building advanced desktop apps, such as those that [need multiple windows](https://github.com/flutter/flutter/issues/30701). In comparison, Cogent Core has complete desktop support, as evidenced by the powerful multi-window [code editor](https://cogentcore.org/cogent/code) and [neural network models](https://emersim.org) built with it. +* It is not suitable for building advanced desktop apps, such as those that [need multiple windows](https://github.com/flutter/flutter/issues/30701). Cogent Core has complete desktop support, as evidenced by the powerful multi-window [code editor](https://cogentcore.org/cogent/code) and [neural network models](https://emersim.org) built with it. * Flutter’s declarative paradigm creates excessive indentation and makes it hard to integrate logic into GUIs without falling back on ternaries and other such constructs. For example, here is an indentation closing block from the [Flutter sample app](https://github.com/flutter/samples/blob/main/material_3_demo/lib/home.dart): @@ -167,19 +166,19 @@ Although [Flutter](https://flutter.dev) can be good for creating simple mobile a } ``` -By contrast, Cogent Core uses [plans](https://cogentcore.org/core/basics/plans) to allow for elegant integration of imperative and declarative logic. +Cogent Core uses [plans](https://cogentcore.org/core/basics/plans) to allow for elegant integration of imperative and declarative logic. -* Flutter contains a lot of repetitive boilerplate, such as `Widget build(BuildContext context)`, and is peppered with distracting keywords like `final`, `required`, and `@override`. In contrast, Cogent Core works to avoid boilerplate and contains few keywords due to Go’s emphasis on simplicity. +* Flutter contains a lot of repetitive boilerplate, such as `Widget build(BuildContext context)`, and is peppered with distracting keywords like `final`, `required`, and `@override`. Cogent Core works to avoid boilerplate and contains few keywords due to Go’s emphasis on simplicity. ### Platform-specific frameworks -Many apps are written using languages specific to certain platforms, such as Swift and Java. However, doing this requires significant duplication of effort as you have to write and maintain your app multiple times if you want it to be cross-platform. By contrast, Cogent Core allows you to write an app in one language and have it work well on all platforms. +Many apps are written using languages specific to certain platforms, such as Swift and Java. However, doing this requires significant duplication of effort as you have to write and maintain your app multiple times if you want it to be cross-platform. Cogent Core allows you to write an app in one language and have it work well on all platforms. ### Other Go frameworks -* [Fyne](https://fyne.io) is "fine" overall, but it does not provide the customization and advanced widgets necessary for building powerful apps. In contrast, Cogent Core enables complete customization and provides a vast array of useful widgets. +* [Fyne](https://fyne.io) is "fine" overall, but it does not provide the customization and advanced widgets necessary for building powerful apps. Cogent Core enables complete customization and provides a vast array of useful widgets. -* [Gio](https://gioui.org) has a lot of powerful features, but the low-level nature of the immediate mode design makes it very difficult to develop apps since even simple things like making a button with text and an icon can take [30 lines of code](https://git.sr.ht/~eliasnaur/gio-example/tree/main/kitchen/kitchen.go#L225). In Cogent Core, it only takes one line of code to make a button with text and an icon. +* [Gio](https://gioui.org) has a lot of powerful features, but the low-level nature of the immediate mode design makes it difficult to develop apps since even simple things like making a button with text and an icon can take [30 lines of code](https://git.sr.ht/~eliasnaur/gio-example/tree/main/kitchen/kitchen.go#L225). In Cogent Core, it only takes one line of code to make a button with text and an icon. * [Wails](https://wails.io), [go-app](https://go-app.dev), and other such packages suffer many of the same issues as standard web frameworks, as you are still effectively writing JS, HTML, and CSS. Cogent Core allows you to completely bypass web languages and write everything in Go.