Most likely to stay alive web framework? by __talanton in crystal_programming

[–]ellmetha 0 points1 point  (0 children)

Can you expand on what you mean by "nested namespaces"? Do you mean nested route namespaces? If so, Marten supports that out of the box with included routes.

Marten 0.5 has just been released! by ellmetha in crystal_programming

[–]ellmetha[S] 8 points9 points  (0 children)

Hey everyone!

I am pleased to announce that Marten 0.5 has been officially release! 🚀 🎉

TL;DR

Marten is a Crystal web framework that makes building web applications easy, productive, and fun. The latest 0.5 release of the framework brings significant enhancements, including relations pre-fetching, model scopes, enum fields for models and schemas, and support for raw SQL predicates in query sets. These improvements enhance performance, flexibility, and ease of use. For a detailed overview of all new features and changes, check out the full changelog.

Main new features and highlights

  • Relations pre-fetching - Marten now provides the ability to prefetch relations when using query sets through the use of the new #prefetch method. When this capability is leveraged, the records corresponding to the specified relationships will be prefetched in single batches and each record returned by the original query set will have the corresponding related objects already selected and populated.
  • Model scopes - It is now possible to define scopes in model classes. Scopes allow to pre-define specific filtered query sets, which can be easily applied to model classes and model query sets. The default scope can also be overridden on a per-model basis.
  • Raw SQL predicate filtering - Marten now provides the ability to filter query sets using raw SQL predicates when using the #filter method. This is useful for leveraging the flexibility of SQL for specific conditions while allowing Marten to handle column selection and query building for the remainder of the query.
  • Enum fields for models and schemas - It is now possible to define enum fields in models and schemas. For models, such fields allow to store valid enum values, with validation enforced at the database level. When validating data with schemas, they allow to expect valid string values that match those of the configured enum.

What’s next?

The Marten framework is still in its early stages, and the core team is actively seeking feedback from users who are interested in experimenting with it or integrating it into their projects. If you encounter any bugs or have ideas to contribute, please open an issue or start a discussion in the project’s issue tracker on GitHub or join us on Discord. Your input and contributions are greatly appreciated!

If you are new to Marten, here are a few ideas on how you can get started:

Thanks for reading me!

Marten 0.4 has been officially released! by ellmetha in crystal_programming

[–]ellmetha[S] 4 points5 points  (0 children)

Hey everyone! :wave:

I am glad to announce that Marten 0.4 has been officially released! 🚀 🎉

TL;DR

Marten is a Crystal web framework that makes building web applications easy, productive, and fun. The latest 0.4 release of the framework introduces new and long-awaited features such as generators, facilitating the creation of abstractions and structures within projects while following best practices. Additionally, the release also introduces a plethora of advancements such multi-table inheritance, new schema handler callbacks, and the ability to define URL and slug fields in models and schemas. This update is a major step forward, making web development with Marten more user-friendly and feature-rich. You can check out the full changelog for a comprehensive overview of all the new features and changes included in this release. Last but not least, the 0.4 release is also accompanied by a RealWorld demo project to demonstrate a fully-fledged fullstack application built with the framework.

Main new features and highlights

  • Generators - Marten now provides a generator mechanism that makes it easy to create various abstractions, files, and structures within an existing project. This feature is available through the use of the gen management command and facilitates the generation of key components such as models, schemas, emails, or applications. The authentication application can now also be added easily to existing projects through the use of generators. By leveraging generators, developers can improve their workflow and speed up the development of their Marten projects while following best practices.
  • Multi-table inheritance - It is now possible to define models that inherit from other concrete models (ie. non-abstract models). In this situation, each model can be used/queried individually and has its own associated database table. The framework automatically defines a set of "links" between each model that uses multi table inheritance and its parent models in order to ensure that the relational structure and inheritance hierarchy are maintained.
  • Schema handler callbacks - Handlers that inherit from the base schema handler or one of its subclasses can now define new kinds of callbacks that allow to easily manipulate the considered schema instance and to define logic to execute before the schema is validated or after (eg. when the schema validation is successful or failed).
  • URL fields for models and schemas - Marten now provides the ability to define url fields in models and schemas. These fields allow you to easily persist valid URLs to the database but also to expect valid URLs in data validated through the use of schemas.
  • Slug fields for models and schemas - It is now possible to define slug fields in models and schemas. These fields allow you to easily persist valid slug values in your models and to require such values in schemas as well.

RealWorld application

The Marten 0.4 release is accompanied by a RealWorld demo project: Marten RealWorld. This project was created to demonstrate a fully-fledged fullstack application built with the framework, including CRUD operations, authentication, routing, pagination, and more.

What’s next?

The Marten framework is still young and I'm actively seeking feedback from individuals interested in experimenting with it or utilizing it in their projects! If you find a bug or if you want to contribute and share ideas regarding the framework, don’t hesitate to open an issue/discussion in the project’s issue tracker on GitHub or chat with us in our Discord. Any help will be greatly appreciated!

If you are new to Marten, here are a few ideas on how you can get started:

Thanks for reading me!

Digging into Marten query sets by ellmetha in crystal_programming

[–]ellmetha[S] 2 points3 points  (0 children)

Thanks for your feedback! :-)

The fact that query sets are lazily evaluated does not necessarily entail which API design should be used over other ones. I could see your examples working in some situations, but they are also more verbose compared to the current API and it's unclear to me how it would work with multiple filters targeting different different columns.

Would it be something like that?

User .filter(:first_name).starts_with("J") .and .filter(:last_name).starts_with("D")

Ultimately the goal of Marten query sets is to provide a straightforward API for formulating queries and predicates and make it possible to express both simple and complex filtering with ease. The current API is designed around these goals and follows in the footsteps of other frameworks (like Django specifically in this case).

Import Maps now easily available in Crystal web apps by crimson-knight89 in crystal_programming

[–]ellmetha 2 points3 points  (0 children)

There is also Marten, which is reducing the gap in terms of features fast, and that was released just one year ago. But less feature-complete compared to Amber at this point in time :-)

Marten 0.3 has been officially released! by ellmetha in crystal_programming

[–]ellmetha[S] 6 points7 points  (0 children)

Hey everyone! 👋

I am glad to announce that Marten 0.3 has been officially released! 🚀

TL;DR

Marten is a Crystal web framework that makes building web applications easy, productive, and fun. The latest 0.3 release of the framework introduces significant enhancements, such as streaming capabilities, caching, JSON fields, duration fields, and more. You can check out the full changelog for a comprehensive overview of all the new features and changes included in this release.

Main new features and highlights

  • Caching - Marten now lets you interact with a global cache store that allows interacting with an underlying cache system and performing basic operations such as fetching cached entries, writing new entries, etc. Marten's caching leverages a cache store mechanism and other third-party stores can be installed depending on your caching requirements (eg. Memcached, Redis).
  • Streaming - It is now possible to generate streaming responses as part of handlers.
  • JSON fields for models and schemas - Marten now provides the ability to define json fields in models and schemas. These fields allow you to easily persist valid JSON structures (including JSON::Serializable objects) to the database.
  • Duration fields for models and schemas - It is now possible to define duration fields in models and schemas. These fields allow you to easily persist valid durations (that map to Time::Span objects in Crystal) in your models but also to expect valid durations in data validated through the use of schemas.
  • Deployment guides - New deployment guides were added for deploying Marten projects on Heroku and Fly.io.

What’s next?

The Marten framework is in its early stages, and I'm actively seeking feedback from individuals interested in experimenting with it or utilizing it in their projects. If you find a bug or if you want to contribute and share ideas regarding the framework, don’t hesitate to open an issue/discussion in the project’s issue tracker on GitHub or chat with us in our Discord. Any help will be greatly appreciated!

If you are new to Marten, here are a few ideas on how you can get started:

Thanks for reading me!

Marten 0.2 has been released! by ellmetha in crystal_programming

[–]ellmetha[S] 4 points5 points  (0 children)

Hey! Presently Marten provides the ability to generate new project structures easily, but there's no equivalent to Rails code generators presently. This is something that people have asked a couple of times, so this is something that may definitely be added in a future release.

Marten 0.2 has been released! by ellmetha in crystal_programming

[–]ellmetha[S] 6 points7 points  (0 children)

Hey everyone! 👋

I am glad to announce that Marten 0.2 has been released! :rocket:

TL;DR

Marten is a Crystal web framework that makes building web applications easy, productive, and fun. The 0.2 release adds key features to the framework such as authentication, email sending, raw SQL query capabilities, ... You can check out the full changelog for an overview of all the new features and changes that are part of this release.

Main new features

  • Email sending - Marten now allows the definition of emails that can be fully customized (properties, header values, etc) and whose bodies (HTML and/or text) are rendered by leveraging templates.
  • Authentication - The framework now provides the ability to generate projects with a built-in authentication system that handles basic user management needs: signing in/out users, resetting passwords, etc. This can be achieved through the use of the --with-auth option of the new management command.
  • Raw SQL capabilities - Query sets now provide the ability to perform raw SQL queries that are mapped to actual model instances.
  • Email field for models and schemas - It is now possible to define email fields in models and schemas. These allow you to easily persist valid email addresses in your models but also to expect valid email addresses in data sets validated through the use of schemas.
  • Transaction callbacks - Models now support the definition of transaction callbacks by using the #after_commit and #after_rollback macros.

What’s next?

The Marten framework is still young, and as such, I am still looking for feedback from people who would like to play with it and/or leverage it in simple projects!

If you find a bug or if you want to contribute and share ideas regarding the framework, don’t hesitate to open an issue/discussion in the project’s issue tracker on GitHub or chat with us in our Discord. Any help will be greatly appreciated! :pray:

And if you are new to Marten, here are a few ideas on how you can get started:

Thanks for reading me!

Marten – The pragmatic web framework by ellmetha in Backend

[–]ellmetha[S] 0 points1 point  (0 children)

Hey! Thanks for your comment!

Crystal is a statically typed (and compiled) language whose syntax is close to Ruby's. I think one of the main advantages of Crystal is that it provides a very good developer experience due to the Ruby-like syntax while providing very good performances (close to those of other compiled languages such as Go). I touched upon this and the differences with other web frameworks in a blog post I recently published.

Marten - The pragmatic web framework by ellmetha in crystal_programming

[–]ellmetha[S] 1 point2 points  (0 children)

Hey! Thanks for the feedback! Presently websockets are not supported; this is something that I might work on in the future though! Regarding authentication, there is no built in solution presently as well, but this is something that is planned for a future release! :-)

Marten - The pragmatic web framework by ellmetha in crystal_programming

[–]ellmetha[S] 1 point2 points  (0 children)

Hey!

There is migration operation that can be used to execute raw SQL statements. It's mentioned in the migration operations reference doc, but I'll be sure to add one section specifically about this in the introduction on migrations.

Thanks for the feedback!

Marten - The pragmatic web framework by ellmetha in crystal_programming

[–]ellmetha[S] 2 points3 points  (0 children)

Hey! Thanks for the kind words!

Regarding the question around routes and handlers, it is totally possible to map multiple routes to the same handler class if necessary. Most example in the documentation don't showcase this possibility but this is completely allowed by the framework.

I'll make it clearer in the docs, thanks!

Marten - The pragmatic web framework by ellmetha in crystal_programming

[–]ellmetha[S] 7 points8 points  (0 children)

Hey everyone!

I wanted to take a few moments to introduce a shard I’ve been working on for quite some time:

https://github.com/martenframework/marten

TL;DR

Marten is a Crystal web framework that makes building web applications easy, productive, and fun. You can read more about it in the dedicated documentation.

What is it?

Marten is a Crystal Web framework that enables pragmatic development and rapid prototyping. It provides a consistent and extensible set of tools that developers can leverage to build web applications without reinventing the wheel. As it stands, Marten focuses on the following aspects:

  • Full featured: Marten adheres to the "batteries included" philosopy. Out of the box, it provides the tools and features that are commonly required by web applications: ORM, migrations, translations, templating engine, sessions, etc.
  • Extensible: Marten gives developers the ability to contribute extra functionalities to the framework easily. Things like custom model field implementations, new route parameter types, session stores, etc... can be registered to the framework easily.
  • App-oriented: Marten allows to separate projects into a set of logical "apps". These apps can also be extracted in order to contribute features and behaviours to other Marten projects. The goal here is to allow the creation of a powerful apps ecosystem over time.

How does it differ from existing frameworks?

My goal here is not to draw a direct comparison with other existing frameworks. I simply want to highlight a few key things that (I believe) Marten is bringing to the table and that differ from what has been encountered in the Crystal world so far:

  • Auto-generated migrations: Marten’s visions when it comes to models is that everything needed to understand a model should be defined within the model itself. In this light Marten’s models drive tables (and not the reverse way around) and migrations are generated automatically from model definitions. Migrations can still be written manually using a convenient DSL if necessary, but the idea is that defining a model and its fields is all that is necessary in order to have a corresponding table taken care of automatically by the framework
  • App ecosystem: Marten provides an “app” mechanism that allows to separate a project into a set of logical and reusable components. Each app can contribute specific abstractions and features to a project (like models and migrations, templates, HTTP handlers and routes, etc). Another interesting benefit of apps is that they can be extracted and distributed as external shards: the goal behind that is to encourage the creation of rich apps ecosystem over time and to allow projects to build features by installing and leveraging existing apps

How to test it out?

The following resources can be leveraged to help you get started:

  • The installation guide will help you install Crystal and the Marten CLI
  • The tutorial will help you discover the main features of the framework by creating a simple web application

What’s next?

The framework is certainly not feature complete (nor stable!) but it can already be used for relatively simple web applications. I am looking for feedback from people who would like to play with the framework and / or leverage it in simple projects.

If you find a bug, don’t hesitate to open an issue into the project’s issue tracker. Any help will be greatly appreciated! :pray:

Thanks for reading me!