Rust writes the new generation web framework Teo, which supports both Node and Python, with amazing speed!

Rust writes the new generation web framework Teo, which supports both Node and Python, with amazing speed!

Today I will share the topic. With the rapid development of web technology, development has become increasingly complex and requires more time and effort. Today, I will introduce this new generation web framework written in Rust.

Web project development is becoming increasingly complex, which also brings many challenges to developers. It is necessary to flexibly use the latest web development frameworks to improve development efficiency and respond to constantly changing needs.

Recently, while browsing Github, I came across a new generation of web framework with structure as its core - TEO, a web framework suitable for Rust, Node.js, and Python , which can greatly improve the work efficiency of application developers when using web servers and databases. It is worth mentioning that this project has now become GVP project of Gitee.

img

What is TEO?

Teo is a new generation web framework. It consists of the following parts:

  • Teo schema: an intuitive and innovative schema language that is descriptive and readable
  • Teo Server: High-performance core written in Rust and API bindings for Node.js, Python, and Rust
  • Teo CLI: A CLI tool for reading schemas and performing tasks, including database migration, running servers, and seeding data
  • Teo Query Client: Automatically generated type-safe query builder for multiple platforms and languages

Why use TEO?

Traditional web frameworks

  • Many boilerplate codes : developers need to write duplicate code for each route, which is not only time-consuming but also error-prone.
  • Lack of built-in features : Traditional frameworks often do not provide common functions such as filtering, sorting, and pagination, and developers need to implement these functions themselves.
  • Debugging Difficulty : Debugging SQL queries and MongoDB aggregation is complex, error-prone, and time-consuming.
  • Type and interface duplication : In front-end development, developers need to re-declare the data types and interfaces of the back-end model, resulting in duplication of work.

Teo Modern Web Framework:

  • Reduce boilerplate code : The new generation of frameworks reduces the amount of boilerplate code developers need to write by providing more abstraction and automation tools.
  • Built-in common features : Modern frameworks often have common features such as filtering, sorting, and pagination built in, making it easy for developers to implement these features without having to write them from scratch.
  • The new generation framework provides better tools and interfaces to simplify the debugging process of database queries and aggregation, reducing the possibility of errors.
  • Unified data types and interfaces : Modern frameworks allow developers to define data models and interfaces on the server side, and then automatically generate Client code, reducing duplication of effort and improving consistency between front-end and back-end code.

More information about Teo can be found on the official website.

Functions and features

Let’s take a look at what features Teo provides.

  • Innovative structural definition inspired by GraphQL and Prisma
  • Automatic database migration
  • Supports Rust, Node.js, and Python
  • Supports MySQL, PostgreSQL, SQLite, and MongoDB.
  • Generated ORM types and interfaces
  • Query Client generated for frontend
  • Very efficient and high performance
  • Data cleaning, transformation, and validation
  • Built-in user sessions
  • Built-in permission check
  • First in, last out Middleware
  • Custom routes and handlers

img

Quick Start

A typical Teo workflow consists of the following parts:

1. Select your language stack

Teo supports three server-side programming languages: Node.js, Python, and Rust. You can choose a language you are familiar with to work with.

  • Node.js works well with web technologies.
  • Python is great for interacting with artificial intelligence infrastructures.
  • Aimed for the Highest Performance, Rust is hard to write.

Teo cares about code repetition and productivity. Therefore, the front-end Client is generated by Teo. Teo supports 5 front-end languages: TypeScript, Swift, Kotlin, C #, and Dart. This almost covers mainstream front-end technologies. Easily use these generated Clients or share them with front-end developers.

Note: Currently, Swift, Kotlin, C #, and Dart are not yet supported, but the Teo team has set a goal for 2024, and I believe it should be supported soon.

2. Structure your data

Teo has an innovative and easy-to-read schema language inspired by GraphQL and Prisma. Database configuration, server configuration, models and enumerations, and routing handlers are all declared in it. What you write is what you think, what you see is what you get, which is really great.

Teo adopts the pattern you described in detail and performs database migration, input validation, and transformation for you.

3. ORM entity and server code

Automatically generated routing handlers can meet 80% of business needs. There are always some custom requirements that require developers to write code to handle. Teo is a mature web framework, not a no-code or low-code tool. Let Teo do the heavy lifting and generate ORM entities. Use Teo’s programming API to write code in any server language supported by Teo.

4. Generate Client for Front-end

Issues with traditional front-end development:

  • Developers repeatedly write interface request and parameter processing code in multiple front-end projects, which is inefficient and error-prone.

Teo framework solution:

  • Teo automatically generates type-safe front-end code, reducing repetitive work and improving development efficiency.
  • Supports multiple programming languages to adapt to different development needs.
  • Integrate into existing projects or create new packages to provide flexibility.

Interested partners can go and experience it now!

Reference materials:

Rust and Go in 2024

Rust and Go in 2024

Which is better, Rust or Go? Which language should you choose for your next project and why? How do they compare in terms of performance, simplicity, security, features, scalability, and concurrency? What do they have in common and what are their fundamental differences? Let’s find the answer through a friendly and fair comparison of Rust and Go.

# 1. Rust and Go are both great

Firstly, it is very important to note that Go and Rust are both absolutely excellent programming languages. They are modern, powerful, widely adopted, and provide excellent performance.

Rust is a low-level statically typed multi-paradigm programming language that focuses on safety and performance - Gints Dreimanis [2]

However:

Go is an open-source programming language that makes it easy to build simple, reliable, and efficient software golang.org [3]

In this article, I will try to briefly outline which scenarios I think Go is the ideal choice and which scenarios Rust may be a better choice.

# 2. Similarities

What is the common goal of the two languages?

# 2.1 Memory safety

Historically, one of the biggest causes of software errors and security bugs is unsafe or incorrect access to memory.

Rust and Go handle this problem in different ways, but both aim to be smarter and safer in managing memory than other languages.

# 2.2 Fast and compact executable files

They are all compile languages, which means your program will be directly compiled into executable machine code so that you can deploy the program as a single binary file. Compared with interpreted languages such as Python or Ruby, this also makes Rust and Go programs have extremely fast execution speed.

# 2.3 Common language

Rust and Go are both powerful and extensible general-purpose programming languages that you can use to develop various modern software. Both have excellent standard libraries and thriving third-party ecosystems, as well as strong commercial support and a large user base.

# 2.4 Pragmatic programming style

Although Go and Rust both have functional features related to functional and Object Oriented Programming (OOP), they are both pragmatic languages designed to solve problems in the most appropriate way.

# 2.5 Suitable for large-scale development

Rust and Go both have some useful features that make them suitable for large-scale programming, whether it is for large teams, large codebases, or both.

For example, both Rust and Go use standard code formatting tools (Go’s gofmt, Rust’s rustfmt), which puts an end to useless arguments about the placement of parentheses.

Both also have excellent built-in high-performance standard build and dependency management tools; no more struggling with complex third-party build systems or learning a new one every few years.

# 3. Differences

Although Rust and Go share many similarities, in some areas, rational people may prefer one language over the other to meet specific project needs.

# 3.1 Performance

Go and Rust are both very fast. However, Go’s design is more conducive to fast compilation, while Rust is optimized for fast execution.

Rust’s runtime performance is also more consistent because it does not use garbage collection mechanism. On the other hand, Go’s garbage collector reduces some of the burden on programmers, making it easier to focus on solving the main problems rather than memory management details.

For areas where execution speed outweighs all other considerations (such as game programming, operating system kernels, web browser components, and real-time control systems), Rust is a better choice.

# 3.2 Simple

From a design perspective, Go is a small language with very few syntax, keywords, and language structures. You can quickly learn the basics of Go and use the language to improve work efficiency.

This gives Go an advantage in projects with short time spans or teams that need to quickly introduce a large number of new programmers, especially when they are relatively inexperienced.

# 3.3 Functional features

On the other hand, Rust has almost all the features of programming languages you can imagine, as well as some features that you may not be able to imagine. This makes it a powerful and expressive language that can accomplish the same thing in multiple different ways.

If you’re transitioning to Rust from another language, you can probably find Rust equivalents for most of the features you’re used to. This gives Rust an advantage when large projects need to migrate from legacy languages like C++ or Java.

# 3.4 Concurrency

Unlike most languages, Go is designed with built-in support for concurrent programming, such as goroutines (a lightweight version of threads) and channels (a safe and efficient way to communicate data between concurrent tasks).

These make Go the perfect choice for large-scale concurrent applications such as network servers and microservices.

# 3.5 Security

Rust is carefully designed to ensure that programmers cannot do unsafe things they do not want to do, such as overwriting shared variables. The compiler requires you to specify the way data is shared between different parts of the program and can detect many common errors and bugs.

Therefore, the so-called “battle with borrow checkers” is a common complaint among new Rust programmers. Implementing programs with safe Rust code often means fundamentally rethinking their design, which can be frustrating, but when reliability is your top priority, the benefits of doing so are worth it.

# 3.6 Scale

Go aims to make it easy for you to expand projects and development teams. Its minimalist design brings a certain consistency, and the existence of a clearly defined standard style means that any Go programmer can read and understand new code libraries relatively quickly.

When it comes to large-scale software development, clarity is better than intelligence. For large organizations, especially many distributed teams, Go is a good choice. Its fast build time is also conducive to rapid testing and deployment.

# Step 4 Trade-offs

The design teams of Rust and Go made some very different choices, so let’s take a look at some areas where these trade-offs make these two languages very different from each other.

# 4.1 Garbage collection

Generally speaking, languages with garbage collection and automatic memory management functions (such as Go) can quickly and easily develop reliable and efficient programs, which is the most important for some people.

However, garbage collection, due to its performance overhead and stop-the-world pauses, can make program behavior unpredictable at runtime, and some people find this inconsistency unacceptable.

Programmers must clarify that the language responsible for allocating and releasing each byte of memory (such as Rust) is more suitable for real-time or ultra-high-performance applications.

# 4.2 Abstract

The history of computer programming is an increasingly complex and abstract story that allows programmers to solve problems without worrying too much about how the underlying machines actually work.

This makes the program easier to write and possibly more portable. However, for many programs, accessing hardware and precisely controlling the execution of the program is more important.

Rust’s goal is to make programmers “closer to metal” and have more control, while Go abstracts architectural details and brings programmers closer to problems.

# 4.3 Speed

Rust has made many design trade-offs to achieve the best execution speed. In contrast, Go cares more about simplicity and is willing to sacrifice some (runtime) performance for it.

At this point, whether you prefer Rust or Go depends on whether you are willing to spend more time waiting for the program to build or wait for the program to run.

# 4.4 Correctness

Go and Rust both aim to help you write correct programs, but in different ways: for example, Go provides an excellent built-in unit test framework and a rich standard library, while Rust focuses on eliminating runtime errors using its borrow checker mechanism.

To be fair, it is easier to write a given program in Go, but the result may contain errors more easily than the Rust version. Rust imposes disciplinary constraints on programmers, but Go lets programmers choose the level of discipline they want to apply to specific projects.

# 5. Conclusion

I hope this article can make you believe that both Rust and Go are worth considering seriously. You should reject the dilemma of this mistake: you can only learn one of them. In fact, the more languages you know, the higher your value as a software developer.

Every new language you learn will give you a new way of thinking, which can only be a good thing. The most important factor for the quality and success of any software project is not the choice of language, but the skills of the programmer.

When using the language that suits you best, you become most proficient and can enjoy the most programming pleasure. Therefore, if the question is “Should I learn Rust or Go?”, the only correct answer is “Yes”.

References

[1] 《Rust vs Go in 2024》: https://bitfieldconsulting.com/golang/rust-vs-go

[2] Gints Dreimanis: https://serokell.io/blog/rust-guide

[3] golang.org: https://go.dev/

GPT开发是福是祸

GPT开发是福是祸

最近我在使用 GPT 做一些软件开发,主要开发方向是做 Chrome 插件开发。这个插件的功能是右键获取文本内容然后将其进行屏蔽(知乎问题回答界面,屏蔽某个用户回答)。先说总结,GPT 和 Gemini 给我带来的效率提升是毋庸置疑的,但是还是需要花费较多的时间进行验证,但是这个验证时间和我原本开发的时间来说,是一个很小的时间。

结论:GPT 开发是好事,但是需要有足够的辨识能力,有时候 GPT 也不知道自己再说什么,我也不知道应该如何引导他。

# Gemini 工具

我最开始放入的提示词:

image-20240319143819711

我写了一部分程序,然后放给 gemini,需要让他帮我处理一些内容,提示词内容如下。

image-20240319152607775

我告诉他拿不到这个元素,让他帮我重新处理

image-20240319152632977

他出现问题我又一次进行询问,然后效果还是不理想

image-20240319144100167

image-20240319144110231

在 GEMINI 这个工具使用过程中我发现他对于插件的认知不够好,也许是我不会使用。但是在让他帮我写 Readme 的时候写的方式很棒

image-20240319152850270

# GPT 对 JS 理解不错

在使用 Gemini 的过程中有一点不舒服,然后换到了 GPT3.5 进行一些 DOM 元素的处理,整体看下来效果不错。

image-20240319152911755

内容合伙人

内容合伙人

# 一个人做内容还行吗?

一个人做内容还行吗?我认为不行,现在你想要做内容,依靠自己一个人的力量与哪些已经做了 1 年以上,哪怕三个月的都有时间成本的差异。那如果一群人一起做内容呢?我也不知道会是怎么样的一个现象,我想试试看。

以下是一些一个人做内容的难点:

  • 时间成本高: 内容创作需要大量的时间和精力投入,从选题、策划、创作、到发布、推广,都需要亲力亲为,一个人很难兼顾所有。
  • 资源有限: 个人资源和能力有限,难以获得足够的素材、信息和支持,内容的质量和丰富度可能受到限制。
  • 影响力弱: 单打独斗的影响力有限,难以触达更广泛的受众,内容传播效果可能不佳。
  • 缺乏反馈: 缺少来自他人的反馈和建议,难以了解内容的优缺点,难以持续改进。

相比之下,内容合伙可以有效克服这些难点:

  • 优势互补: 团队成员可以发挥各自的优势和专长,共同创作高质量的内容。
  • 资源共享: 团队成员可以共享彼此的资源和信息,丰富内容的素材和形式。
  • 协作分工: 团队成员可以分工合作,提高内容创作的效率。
  • 互相引流: 团队成员可以利用各自的粉丝群体,互相引流,扩大内容的影响力。
  • 集思广益: 团队成员可以相互交流学习,获得更多灵感和建议,不断提升内容质量。

# 新时代的内容创作模式

内容为王的时代,优质内容是吸引用户、提升品牌影响力的关键。然而,内容创作需要大量的时间、精力和资源投入,对于个人创作者来说,往往存在时间成本高、资源有限、影响力弱等挑战。

内容合伙的出现,为内容创作提供了一种新的模式。内容合伙是指多个内容创作者或团队共同合作,进行内容创作、发布和推广的一种模式。通过优势互补、资源共享、协作分工、互相引流,内容合伙可以有效克服个人创作的难点,提升内容创作的效率和质量。

内容合伙的优势:

  • 优势互补: 团队成员可以发挥各自的优势和专长,共同创作高质量的内容。
  • 资源共享: 团队成员可以共享彼此的资源和信息,丰富内容的素材和形式。
  • 协作分工: 团队成员可以分工合作,提高内容创作的效率。
  • 互相引流: 团队成员可以利用各自的粉丝群体,互相引流,扩大内容的影响力。
  • 集思广益: 团队成员可以相互交流学习,获得更多灵感和建议,不断提升内容质量。

内容合伙的应用场景:

  • 知识分享: 专家学者、知识博主等可以共同创作知识类内容,例如文章、视频、课程等。
  • 内容创作: 创作者可以组建团队,共同创作剧情类、故事类、情感类等内容。
  • 品牌营销: 品牌可以与内容创作者合作,定制化内容,进行品牌宣传和推广

# 我们需要内容合伙的原因

# 知识和技能的互补

每个人都有自己的知识和技能专长,但一个人不可能精通所有领域。内容合伙可以将不同领域的人聚集在一起,形成互补的知识和技能矩阵,从而提供更全面、更有价值的内容。

1. 知识和技能的互补性:

内容创作需要多种知识和技能的支撑,包括:

  • 专业知识: 对特定领域的深入了解和专业知识。
  • 写作能力: 能够将复杂的概念和想法清晰、准确地表达出来。
  • 编辑能力: 能够对内容进行校对和编辑,确保其准确性、流畅性和可读性。
  • 设计能力: 能够设计美观、吸引人的内容。
  • 营销能力: 能够推广和传播内容,吸引更多受众。

一个人不可能拥有所有这些知识和技能,因此,** 内容合伙可以发挥知识和技能的互补性,** 使不同领域的人能够共同创作出高质量的内容。

2. 知识和技能互补的案例:

  • 一个医疗领域的专家可以与一个科普领域的作者合作,将复杂的医学知识转化为易于理解的科普文章。
  • 一个设计师可以与一个作家合作,将作家的文字转化为生动、形象的图文内容。
  • 一个视频编辑可以与一个内容创作者合作,将内容创作者的创意转化为高质量的视频。

3. 知识和技能互补的价值:

知识和技能的互补可以带来以下价值:

  • 提升内容质量: 不同领域的专家共同创作,可以确保内容的专业性和准确性。
  • 丰富内容形式: 不同技能的人员合作,可以丰富内容的形式和表现力。
  • 扩大受众范围: 不同领域的合伙人可以将内容传播到不同的群体,扩大内容的影响力。

4. 如何实现知识和技能的互补:

  • 明确合作目标: 明确合作的内容主题和目标受众,以便选择合适的合伙人。
  • 发挥优势互补: 每个合伙人发挥自己的优势,共同创作内容。
  • 有效沟通协作: 合伙人之间保持有效沟通,确保合作顺利进行。

# 信息共享和协作

内容合伙可以促进不同领域的信息共享和协作,打破信息孤岛,提升内容创作的效率和质量。例如,一个医疗领域的专家可以与一个科普领域的作者合作,将复杂的医学知识转化为易于理解的科普文章。

1. 信息共享:

内容合伙人可以共享彼此的知识和信息,包括:

  • 专业知识: 对特定领域的深入了解和专业知识。
  • 市场洞察: 对市场趋势和用户需求的了解。
  • 创作经验: 内容创作的经验和技巧。
  • 资源和工具: 内容创作所需的资源和工具。

信息共享可以帮助内容合伙人:

  • 提升内容质量: 确保内容的准确性、完整性和专业性。
  • 避免重复劳动: 减少重复搜集和整理信息的工作量。
  • 拓展视野: 了解不同领域的知识和观点,激发新的创作灵感。

2. 协作:

内容合伙人可以协作进行内容创作,包括:

  • 共同策划: 共同确定内容主题、目标受众和创作方向。
  • 分工合作: 每个合伙人根据自己的优势分工负责不同的内容创作任务。
  • 相互反馈: 对彼此的内容进行评论和建议,不断改进内容质量。

# 触达更广泛的受众

内容合伙可以帮助内容创作者触达更广泛的受众。每个合伙人都有自己的粉丝群体,通过合作,可以将内容传播到不同的群体,扩大影响力。

# 提升品牌知名度

内容合伙可以帮助合伙人提升品牌知名度。当多个合伙人共同创作内容时,可以相互背书,提升彼此的品牌形象和影响力。

# 降低成本和风险

内容合伙可以帮助合伙人降低成本和风险。例如,多个合伙人可以共同承担内容创作的成本,并分担内容创作的风险。

medium中的坚持

medium中的坚持

最近,我在 Medium 中文社区中看到两位好友退出了 Medium 合作伙伴计划。这不禁让我感慨颇多,也引发了一些思考。

如果想要加入 Medium 社区可以通过关注微信公众号:程序员张三,回复【medium】。

Medium 是一个可以通过撰写文章经由他人阅读从而产生收益的一个平台。

Medium 合作伙伴计划旨在鼓励创作者创作优质内容,并通过内容获利。该计划的核心是 “粉丝支持”,粉丝可以通过订来支持他们喜爱的创作者。

Medium 中文社区自创建以来已过去一个多月,目前成员总数已超过 300 人。虽然尚未统计加入 Medium 合作伙伴计划的人数,但已有零星社员分享了自己的收益截图,其中最高月收益达 30 美元,最低也有 1 美元。从社员分享的收益截图来看,Medium 合作伙伴计划确实能够为创作者带来一定的收入。虽然目前大多数创作者的收益还不算高,但随着社区的不断发展和壮大,未来创作者的收益有望进一步提高。

回想起当初刚开始在 Medium 上写作的时候,光是通过审核就花了好几个月的时间。而现在,新加入的作者们仅仅一个月就能开始赚钱了。我由衷感谢大家给予的信任和支持,让我觉得这一切都是值得的。

现在来说一说两个退出合作伙伴计划的原因,虽然有些小众,但却很重要。首先,因为内容太小众,所以吸引不了足够多的人观看,导致流量不够。其次,由于内容过于特定,没有吸引到足够的关注。这些问题其实是在任何社交账号开展活动时都可能会遇到的挑战。

初期的挑战是我们成长道路上不可或缺的一环。尽管前行的路途可能崎岖曲折,但正是通过这些挑战,我们才能稳步前进,实现收入的稳定。坚持不懈是取得成功的关键,只有持之以恒,慢慢地走过这段时间,才能够获得可靠的收益。

如果你也考虑在 Medium 上尝试副业,我会建议你选择一些更大众化的内容进行编写。例如,你可以写一些关于软件开发、情感或者新闻类的文章,这些主题更容易吸引到更多的读者。

当你在 Medium 上运营时,有时候可能会感到困惑,不知道如何开始或者如何提升自己的内容。但是,幸运的是,Medium 社区为你提供了许多帮助。社区中的其他作者和读者可以为你提供宝贵的建议和反馈。如果你不确定要写什么内容,社区可以帮助你选择选题,给你灵感。他们还可以帮助你修改文章,让你的文字更加流畅和吸引人。在这个平台上,你不必独自一人努力,社区会像一个大家庭一样支持着你,帮助你成长和进步。所以,不要害怕向社区求助,因为在这里,你永远不会孤单。

img