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/

medium中的坚持

medium中的坚持

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

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

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

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

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

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

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

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

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

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

img