The Crystal Programming Language Forum

George Dietrich: Athena Reborn

I just released another great episode on a different way to design a web framework in Crystal. I soke with George in this podcast about the athena framework. Please enjoy my conversation with George and subscribe and rate us.

Github: https://github.com/Blacksmoke16
Discord: Blacksmoke16#0016
Athena: https://github.com/athena-framework
Athena Docs: https://athena-framework.github.io/athena/Athena/Routing.html
Athena Gitter: https://gitter.im/athena-frameworkcr/community
Parameters: https://athena-framework.github.io/athena/Athena/Routing/ParamConverterInterface.html#additional-configuration

5 Likes

We have now tooled up to do YouTube.

I’m glad you discussed Athena in this one. I glanced at Athena in the past, but was turned off by the multitude of annotations. It seemed so foreign to what I’ve seen in other frameworks. Hearing some of the pros to this approach was enlightening.

2 Likes

I use annotations a lot (in the languages that support them: Java, C#, Crystal) as it simplifies configuration and creates less code.

I was in a similar boat. I am not as use to annotations but have used them in Java. I really enjoyed the interview because I think it brings a good perspective to Crystal even I don’t use it. But I have been thinking of hot to use it more.

Glad to hear :slight_smile:, I hope it inspired you to give it another look :wink:.

It definitely takes a different, non Ruby inspired approach, especially if you never worked any languages that make use of them.

I think there is a lot of merit in them tho. The most impactful benefit of them that I touched on in the interview was that they are shard agnostic. In the end you’re just working with types, methods, and instance variables. You can think of it as just applying metadata to standard Crystal concepts as opposed to each shard/framework implementing their own custom macro DSL specific to each project. That’s not to say you can’t do both.

As I also mentioned, another benefit is that the features I can provide from the framework’s point of view can only improve as macros and annotations mature within the language. There is some exciting stuff on the horizon when https://github.com/crystal-lang/crystal/issues/8148, https://github.com/crystal-lang/crystal/issues/9246 and especially https://github.com/crystal-lang/crystal/issues/8835 are resolved/implemented.

There are definitely places where they can work well, but as with any language feature it’s knowing what your options are, and using the right tool for the job. Annotations excel for just wanting to store data tied to a specific thing that you can later read and use in a macro.

I wrote https://dev.to/blacksmoke16/utilizing-macros-annotations-in-a-web-framework-3abk a while ago, probably could use an update but I imagine the information there is still valid (even the syntax isn’t). I think I’ll write a new article related to some of the patterns I learned in the past year while working on Athena that have been working quite well for me.

1 Like

I use annotations a lot (in the languages that support them: Java, C#,
Crystal) as it simplifies configuration and creates less code.

also, rust attributes are annotations to me: https://doc.rust-lang.org/reference/attributes.html

marc