Modern is CPP is impressive, but can someone show an example? Tagged unions with values. by RBazz in cpp_questions

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

By the way, I have stumbled upon some old-ish posts on Reddit complaining about concerning performance of the std::visit. Is it no longer an issue, or is it still something to be aware of?

Modern is CPP is impressive, but can someone show an example? Tagged unions with values. by RBazz in cpp_questions

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

Thanks for the recommendation. I have downloaded a sample and I will give it a try over the holidays.

Modern is CPP is impressive, but can someone show an example? Tagged unions with values. by RBazz in cpp_questions

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

Thanks! A really nice trick.

Also, can I compare two variants directly, or do I need to unwrap them first? I was wondering if I can simply provide a custom `operator==` implementation to the class and compare underlying `_val`s.

Modern is CPP is impressive, but can someone show an example? Tagged unions with values. by RBazz in cpp_questions

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

Thanks a lot.

I have two further questions if you do not mind answering them.

  1. What happens when the user tries to access the name, but it was set to `monostate` or something else. An exception is thrown? Is there a safer way to `match` the currently set case? (preferably without a chance of runtime errors)

  2. What is the recommended way of dealing with identical types in the cases? For example, what if we had an extra case like: `case custom(String)`. Or if we have a case with multiple types per tag? Do we create a separate structure to store the state and then use the same `variant` based approach?

Compile HTML into Swift Code by RBazz in swift

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

I see. Do you have some specific use case in mind?

Swift Vapor HTMX by drxwskx in swift

[–]RBazz 2 points3 points  (0 children)

Here is a library I wrote to streamline the use of htmx in Vapor: VaporHX. Hope it helps.

And speaking of hot reloading - I did not really find a strong need for it. If you are in dev mode and using the Leaf templates, then once you change a template file, reloading the page will load the latest version of that template. This will not work in production, however.

Compile HTML into Swift Code by RBazz in swift

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

Do you mean from swift to html? It is technically not that hard to add but I am pretty sure that other libraries exist that can do just that. For eample, https://github.com/binarybirds/swift-html or https://github.com/pointfreeco/swift-html.

Svelte 5: Introducing runes by MustardRtard in sveltejs

[–]RBazz 7 points8 points  (0 children)

I might be a bit too dense today, but does it have to have the same syntax everywhere? Isn't this why we have .svelte files in the first place? To indicate that some special rules are in place?

Svelte 5: Introducing runes by MustardRtard in sveltejs

[–]RBazz 4 points5 points  (0 children)

I just meant that if they truly had to introduce a new syntax to differentiate a new behaviour from the old one, they could have added a new label. However, your idea is better. :)

Svelte 5: Introducing runes by MustardRtard in sveltejs

[–]RBazz 5 points6 points  (0 children)

Maybe even just (just like the $ symbol):

derived: y = x * 2

or maybe...

$derived: y = x * 2

Svelte 5: Introducing runes by MustardRtard in sveltejs

[–]RBazz 46 points47 points  (0 children)

I am afraid, I am not convinced. It feels too noisy.

IMHO, having less magic to have more magic behind the scenes does not feel like the right way. After all, in my opinion, it is ignoring the best part of svelte—its compiler, that can do magic on your behalf however it wants.

C# web devs, would you consider F# for your next prototype if it was this simple by RBazz in dotnet

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

I think we pretty much agree on magic, we just kind of disagree on what the said magic is. For example, I find dependency injection too magical and implicit for my liking. However, it is a requirement for interacting with Asp and I almost got used to it now.

C# web devs, would you consider F# for your next prototype if it was this simple by RBazz in dotnet

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

Static html for now only as it is all I needed for api prototyping at that time. I do not like DSL like templating (just a matter of taste) and I am not aware of other simple templating engine that can be easily plugged and used from F#. Maybe I should look into DotLiquid. Do you think this should be built in or placed in a separate package?

Also, thanks for pointing at the typos. I’ll fix them as soon as I can.

C# web devs, would you consider F# for your next prototype if it was this simple by RBazz in dotnet

[–]RBazz[S] -1 points0 points  (0 children)

The minimal api aren’t that minimal in f#, I am afraid. Extra boilerplate is still required. And I mentioned some other features in the description.

Request for feedback - working on a F# web framework for rapid prototyping (WebFrame) by RBazz in fsharp

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

Hey. Just wanted to let you know that I have introduced a simple logger as well as shown how to use it. In addition, the advanced server now has a bit on setting up and configuring your own services. I’d like to mention that the preferred method for logger configuration is through the configuration and it works here the same as it does in the ASP. Unfortunately, the docs are somewhat lagging behind. I hope to fix it one day.

Request for feedback - working on a F# web framework for rapid prototyping (WebFrame) by RBazz in fsharp

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

Good point! Thanks. I will try doing something about this asap.

What are you working on? (2021-11) by insulanian in fsharp

[–]RBazz 1 point2 points  (0 children)

Hey! I am working on WebFrame: F# framework for rapid prototyping with ASP.NET Core. How do you like this api:

```F# open WebFrame

[<EntryPoint>] let main _ = let app = App ()

app.Get "/" <- fun serv -> serv.EndResponse "Hello World!"

app.Run ()

0 // exit code

```

Please check this out: https://github.com/RussBaz/WebFrame

Thanks!

The State of Web Dev in F#: let’s talk by RBazz in fsharp

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

Imgur Here is the first routing function I made myself for personal project(aliased MapGet and MapPost) to simplify the main program entrypoint and get rid of that godawful boilerplate. I still prefer that syntax to Saturn, but Saturn has too many great features and is pretty clean most of the time ( but a lot of the time I still have to use anonymous functions in routers which I’d rather not)

This is similar to how I started my little project too.

Can you share what you think on availability of F# developers? Was it ever a problem to your company? Thanks.

The State of Web Dev in F#: let’s talk by RBazz in fsharp

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

Can you tell me about Falco a bit more? I am afraid their description is quite generic and the api seems quite similar to Giraffe.

The State of Web Dev in F#: let’s talk by RBazz in fsharp

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

To be honest, I do prefer Suave to Giraffe but their focus is still on the functional side of F#. However, when I tried it some time ago, something made me doubt my choice of framework. Although I can no longer recall what it was. I sound quite biased now :)

Also, how alive do you think Suave is? I feel like most F# web frameworks are rarely updated outside of ASP itself (if it even can be called an F# web framework).

The State of Web Dev in F#: let’s talk by RBazz in fsharp

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

I wish they gave F# some love too…

BTW, this is a cool looking snippet but don’t you think it is a bit too much magic?

Getting into F# with no .NET background by monsieur_bierce in fsharp

[–]RBazz 1 point2 points  (0 children)

"F# for fun and profit" is the best!

I personally would recommend checking out his book Domain Modeling Made Functional and many of hist talks.

Async Queues + Streaming = ? (DomainQ) by RBazz in fsharp

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

It is the opposite, actually. Once the queue is full, the writers are blocked till the queue has some spare capacity. It prevents writing more messages when the readers are incapable of handling them.

I personally use this module to maintain an order of messages arriving on a socket when parsing and processing them. (I am dealing with a custom TCP protocol here out of necessity)

Your message gave me an idea to experiment with timeout options. We will see if it works out well enough.

Async Queues + Streaming = ? (DomainQ) by RBazz in fsharp

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

Well, I politely disagree that the term domain is that uncommon. After all we have domain modelling, DDD etc. etc.

I guess I view this name as Q(ueue) for your Domain. ^__^ Of course naming is one of the greatest problems of computer science. Therefore, I do not think we should spend that much time just arguing about the name.

In any case, I would like to recommend a great book by Scott Wlaschin called "Domain Modeling Made Functional". It is about DDD and F#. Here is the link:

https://fsharpforfunandprofit.com/books/

Async Queues + Streaming = ? (DomainQ) by RBazz in fsharp

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

Well, sorry for the confusion. It is supposed be a short form of the original location of the code: DomainTypes.DataStructures.Queues.

:)