ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Fund Crystal's development: | GH: | Docs: | Gitter:
<FromGitter> <> swagger makes me sad. i think our species needs to stop accepting "least bad" for an excuse.
<FromGitter> <> imagine your sole purpose in life is to be a framework for documentation. and then your own TOC doesn't scroll.
ur5us_ has joined #crystal-lang
ur5us_ has quit [Ping timeout: 240 seconds]
<FromGitter> <descholar-ceo> Hello here, just a quick question; can we use `crystal` to prgram `embedded systems` ? (I am still too new to crystal)
<holst> moe: ;-)
<holst> a lot of crap came out of enterprise architecture
taupiqueur has joined #crystal-lang
notzmv has quit [Ping timeout: 252 seconds]
taupiqueur has quit [Quit: taupiqueur]
<FromGitter> <Blacksmoke16> @descholar-ceo technically yes, but by default it comes with a fairly large stdlib and GC, which might be a problem depending on your exact use case
notzmv has joined #crystal-lang
<FromGitter> <descholar-ceo> Great, thank you! So, if I understood well, then means that there is no any particular library which helps to achieve that, it's just about dealing directly with the language itself. Am I right?
<FromGitter> <Blacksmoke16> yes, it is possible to disable the GC and/or the stdlib. But the stdlib is not setup for manual memory management, nor is the stdlib designed to allow picking and choosing which features you want as its very interdependent
<FromGitter> <descholar-ceo> Thank you for the answer, I will look for a way to manage my use cases
<FromGitter> <descholar-ceo> Anyways another question that I wanted to know, what about the fault tolerance with crystal? Does it have a way to handle that like elixir?
<FromGitter> <descholar-ceo> *No..*. I mean: like when one worker crashes, everything it used is cleabed up and more importantly all other workers are unaffected. <= Or when one process fails and crashes, there should be another supervisor process which would restart it with all its operations and memory that it had before crashing!
<FromGitter> <Blacksmoke16> im going to go with probably not
<FromGitter> <Blacksmoke16> a crystal program would be its own process, if you kill that process it would restart and lose its context
<FromGitter> <Blacksmoke16> if by worker you mean like in a multithreaded environment, pretty sure an exception on one thread wouldnt affect the others, however MT mode is still considered experimental and needs to be opted into
<FromGitter> <Blacksmoke16> maybe there's a way to implement that by storin state and stuff outside of the process, but afaik thats not something that is built in
<FromGitter> <> Elixir uses Erlang/OTP under the hood, that's where it gets those resiliency/supervisor features from. Erlang is quite unique in that regard, I don't think any other languages have these baked in.
<FromGitter> <> @descholar-ceo: basically, you'll have to do like other languages: store the state in a remote, reliable DB like Redis or Postgres
<FromGitter> <> And for auto restart of the process, depends of the environment: systemd, docker have it natively
notzmv has quit [Ping timeout: 252 seconds]
notzmv has joined #crystal-lang
notzmv has quit [Ping timeout: 268 seconds]
sorcus has quit [Ping timeout: 268 seconds]
sorcus has joined #crystal-lang
notzmv has joined #crystal-lang
ur5us_ has joined #crystal-lang
ur5us_ has quit [Ping timeout: 260 seconds]
zantrax has joined #crystal-lang
<zantrax> Hello! is method missing discouraged or its ok to use?
<zantrax> Maybe there is a neater way to achieve what I am looking for.
<zantrax> My class basically looks like this:
<zantrax> ```
<zantrax>     def initialize(@data : Hash = {} of Symbol => String)
<zantrax>     end
<zantrax>     def title
<zantrax>       data[:title] || ""
<zantrax>     end
<zantrax>     def year
<zantrax>       data[:year] || ""
<zantrax>     end
<zantrax>   ... like 10 more tags
<zantrax> ```
<zantrax> So was thinking about instead doing
<zantrax> ```
<zantrax>     macro method_missing(call)
<zantrax>       data.fetch({{ }}, "")
<zantrax>     end
<FromGitter> <Blacksmoke16> just make them all ivars and dont use a data hash
<FromGitter> <Blacksmoke16> ` "title", 2022`
<FromGitter> <Blacksmoke16> 12 constructor args would be a lot tho, maybe you could leverage a few diff classes instead of having everything in one as well
<zantrax> That was my original approach, but ended up with a huge initializer
<FromGitter> <Blacksmoke16> could you consolidate them into a few types?
<zantrax> Might be an option
<zantrax> Thanks for the suggestion
<zantrax> so method_missing is kind of a no bueno?
<FromGitter> <Blacksmoke16> its main con is it would result in the type of the value being a union of all the values of the hash. however given you have everything as a string, probably would be okay?
<FromGitter> <Blacksmoke16> related:
<FromGitter> <Blacksmoke16> so id avoid it if you can, be simpler in the long run
<zantrax> Sounds good