<hightower2>
I don't need to #join Fibers or anything, right?
<FromGitter>
<Blacksmoke16> i dont think so? :shrug:
<FromGitter>
<straight-shoota> hightower, you can spawn fibers as fire and forget. But it's still good practice to keep taps on spawned fibers.
<FromGitter>
<straight-shoota> variable access is not thread safe. If you want to share a variable between fibers, you need to guard it. You can also take a look at Atomic(T). Or better: Use only channels to communicate between fibers.
<hightower2>
great, thanks
<FromGitter>
<stronny> mutex is also fine
ur5us has joined #crystal-lang
<hightower2>
yes, sure
<hightower2>
Hey what's the most convenient way to display Time::Span#total_seconds to 3 decimals?
<hightower2>
I'm looking for something that's not as crude as using printf
<FromGitter>
<stronny> sprintf?
<FromGitter>
<Blacksmoke16> .round?
<FromGitter>
<stronny> actually what do you mean 3 decimals?
<hightower2>
5.123 instead of 5.2973641546
<FromGitter>
<Blacksmoke16> prob like `1.234`
<FromGitter>
<Blacksmoke16> `val.round 3`
<FromGitter>
<stronny> there's `Number#humanize`
<hightower2>
Hm round 3 looks good, except that it doesn't force 3 decimals, so 5.250 gets displayed as 5.25
<FromGitter>
<Blacksmoke16> does it matter?
<hightower2>
yes I'd have to have it formatted in columnar output
<hightower2>
well, will resort to sprintf
<FromGitter>
<stronny> why do you avoid sprintf?
<hightower2>
I think "%f.3" % span.total_seconds will work... or whatever the exact syntax is
<FromGitter>
<stronny> isn't it already there in the trace?
<FromGitter>
<Blacksmoke16> probably, not easily exposed as it could be
<FromGitter>
<stronny> also, won't *FILE* expand to the definition file, not usage file?
<FromGitter>
<Blacksmoke16> mm it seems that way yea
<FromGitter>
<Blacksmoke16> darn
<FromGitter>
<stronny> what's wrong with current state of things?
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<FromGitter>
<Blacksmoke16> nothing really, just a thought i had
<FromGitter>
<Blacksmoke16> adding some logging and thought it would be handy to point out an exception happened at file:line without printing whole trace
<FromGitter>
<stronny> > The backtrace is an array of strings, each containing “0xAddress: Function at File Line Column”. ⏎ ⏎ `x.backtrace.first`?
<FromGitter>
<Blacksmoke16> oh, that literally contains the file and line number doesnt it
<FromGitter>
<stronny> it does indeed
<FromGitter>
<Blacksmoke16> hm its not actually correct
<FromGitter>
<Blacksmoke16> `at src/athena.cr:201:5 in 'user'`
<FromGitter>
<Blacksmoke16> actual exception is raised on 198
<FromGitter>
<Blacksmoke16> thats a bit more helpful but no, still 201
<FromGitter>
<Blacksmoke16> `at src/athena.cr:201:5 in '*RoutingController#user<Int32>:User'`
<FromGitter>
<stronny> looks like the backtrace starts one frame back heh
<FromGitter>
<Blacksmoke16> rip
<FromGitter>
<Blacksmoke16> minimal example works fine
<FromGitter>
<stronny> okay, so easy <irony>fix</irony> would be to wrap raise
<FromGitter>
<stronny> that way your backtrace would start at the call of the raise wrapper
<FromGitter>
<Blacksmoke16> wrap raise in what?
<FromGitter>
<Blacksmoke16> oh the method
<FromGitter>
<Blacksmoke16> `throw` :trollface:
<FromGitter>
<stronny> yeah that would be interesting lol
<FromGitter>
<Blacksmoke16> how bad of an idea would it be to use `Log::Context` a bit outside of the logging context?
<FromGitter>
<stronny> hm?
<FromGitter>
<Blacksmoke16> its quite useful as a general container for data related to something
<FromGitter>
<Blacksmoke16> i.e. `raise SomeError.new "Something went wrong", context: Log:Context.new user_id: user.id`
<FromGitter>
<Blacksmoke16> which in turn would be logged via `Log.error(exception: ex) ...`
<FromGitter>
<stronny> in the world of static analysis "a general container for data related to something" usually is counterproductive
<FromGitter>
<Blacksmoke16> let me rephrase
<FromGitter>
<Blacksmoke16> contextual data related to an exception
<FromGitter>
<stronny> why don't you make a new exception type that takes its context directly?
<FromGitter>
<Blacksmoke16> hm
chachasmooth has quit [Ping timeout: 265 seconds]
<FromGitter>
<Blacksmoke16> i would deff do that to represent data explicitly related to the exception
<FromGitter>
<stronny> instead of `SomeError` make it `UserError.new "description", user.id`
<FromGitter>
<Blacksmoke16> to be clear, i would just use this for logging, i.e. use the context from the exception, and merge it into the other logger context
chachasmooth has joined #crystal-lang
<FromGitter>
<stronny> example?
<FromGitter>
<Blacksmoke16> way things are setup atm is i have a default error listener the gets invoked for each exception that bubbles up to the "top level"
<FromGitter>
<Blacksmoke16> i.e. if you do `1 / 0` in a controller action it would log
<FromGitter>
<stronny> okay
<FromGitter>
<Blacksmoke16> `[2020-04-15T02:08:48.006400000Z] athena.routing.FATAL: Uncaught exception DivisionByZeroError: 'Division by 0' at /var/lib/snapd/snap/crystal/340/share/crystal/src/int.cr:138:7 in 'check_div_argument' {}`
<FromGitter>
<Blacksmoke16> and in turn be returned to client as 500
<FromGitter>
<Blacksmoke16> so within this listener, it would be possible to check if the exception is a like `ContextualException` and if so, add its context to the logger for that entry
<FromGitter>
<Blacksmoke16> which seems useful
<FromGitter>
<stronny> no, that's what you do in ruby
<FromGitter>
<stronny> in crystal you define a type for every actual context and use inheritance to code it up
<FromGitter>
<Blacksmoke16> right, to be clear thats what im doing as well, i have a concrete exception class for some common HTTP errors
<FromGitter>
<stronny> so what's wrong?
<FromGitter>
<Blacksmoke16> the question is how to best expose context related to that exception to the logger
<FromGitter>
<Blacksmoke16> some `.context` method on the exception could prob do it as well, which each class would implement?
<FromGitter>
<stronny> if all you need is a string then yeah, that would work
<FromGitter>
<Blacksmoke16> yea i like that better, then its not dependent on some random `Log` type
<FromGitter>
<stronny> it's nice that Crystal has arbitrary hashes, but in the long run you're better off using them sparingly
<FromGitter>
<Blacksmoke16> for sure
<FromGitter>
<Blacksmoke16> was thinking of the use case where you do have a custom exception type, but then want to include some arbitrary data related to it
<FromGitter>
<Blacksmoke16> to be logged
<FromGitter>
<stronny> don't do that =)
<FromGitter>
<Blacksmoke16> but yea, i cant really think of a use case where that would be actually useful
<FromGitter>
<Blacksmoke16> if anything use modules to mix into existing types
<FromGitter>
<Blacksmoke16> like idk, to include a request URI related to it or whatever
<FromGitter>
<stronny> usually there's not much to do with exception other than report it
<FromGitter>
<Blacksmoke16> exactly, and any data you would want to log would be on the obj itself
<FromGitter>
<stronny> so having this information available as a separate variable seems rather overengeneered to me
<FromGitter>
<Blacksmoke16> or logged at some other point, like user/customer ids
<FromGitter>
<Blacksmoke16> agreed
<FromGitter>
<stronny> just dump it into the message and be done
<FromGitter>
<Blacksmoke16> now how to best render this error message :P
<FromGitter>
<Blacksmoke16> er include exception context in the entry to display*
<FromGitter>
<stronny> in large red letters!
<FromGitter>
<stronny> (by the way a bedtime story: we had td-agent crashing; turned out that some crypto soft like geth or somesuch not only dumped ANSI sequenses to syslog, it wrote invalid utf8 which caused ruby to choke and die lol)
<FromGitter>
<Blacksmoke16> reminds me when i learned the hard way that mysql utf-8 isnt actually utf-8
<FromGitter>
<stronny> oh, my ass queue elle
<FromGitter>
<stronny> don't get me started on this dumpster fire
<FromGitter>
<Blacksmoke16> someone put an emoji into the the title of their contract and it broke the app, since it got saved but then wasnt able to be retrieved or something iirc
<FromGitter>
<Blacksmoke16> was for a side project for a game so nothing impt but still ha
<FromGitter>
<stronny> you reach for a backup to discover you have many gigabytes of `?` because of course
<FromGitter>
<stronny> E N C O D I N G S
<FromGitter>
<Blacksmoke16> i ended up just deleting all the titles lol
<FromGitter>
<stronny> no data no problem
<FromGitter>
<Blacksmoke16> `UPDATE couriers SET title = ''` 😆
<FromGitter>
<Blacksmoke16> 🙈
<FromGitter>
<Blacksmoke16> about around the same time i learned about db normalization and stopped storing *EVERYTHING* with each courier
<FromGitter>
<tenebrousedge> o________o
<FromGitter>
<Blacksmoke16> wonder if i can find the screenshot of what it was before
<FromGitter>
<stronny> well you better unlearn it now, because you see, rdbms doesn't scale!
<FromGitter>
<stronny> today everyone is a big data scientist
<FromGitter>
<Blacksmoke16> was the refactored schema
DTZUZU has joined #crystal-lang
DTZUZU2 has quit [Ping timeout: 250 seconds]
* FromGitter
* tenebrousedge claws at eyes
ur5us has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
_whitelogger has joined #crystal-lang
_ht has joined #crystal-lang
ur5us has quit [Ping timeout: 256 seconds]
<FromGitter>
<Afront> @Blacksmoke16 Hey, how did you make that picture? 👀
<FromGitter>
<Afront> Is it from an ORM in Crystal?
ur5us has joined #crystal-lang
<jhass>
@straight-shoota mmh, why did you go for javascript_config_file over versions_index=foo.json?
postmodern has quit [Quit: Leaving]
<FromGitter>
<neutrinog> does anyone know how to create a hex number out of 3 other numbers? e.g. I have R, G, B int values that need to be converted to `0x<RRGGBB>`
<jhass>
color = r << 16 + (g << 8) + b
<FromGitter>
<neutrinog> in the end I want the base 10 form of that hex value... kinda weird.
<jhass>
sorry need parens around the r << 16, + binds stronger than <<
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
return0e_ has joined #crystal-lang
<FromGitter>
<neutrinog> thanks
return0e has quit [Ping timeout: 264 seconds]
Stephie has quit [Ping timeout: 258 seconds]
Stephanie has joined #crystal-lang
Stephanie has quit [Client Quit]
Stephie has joined #crystal-lang
<jhass>
not too weird, android for example encodes color values exactly like that :) (well with an additional alpha value in front)
ur5us has quit [Ping timeout: 252 seconds]
ur5us has joined #crystal-lang
HumanGeek has joined #crystal-lang
Human_G33k has quit [Ping timeout: 240 seconds]
Deuns has joined #crystal-lang
<Deuns>
hello
<jhass>
hi :)
<Deuns>
hi jhass
<Deuns>
I am trying to start invidious on openbsd-current. It builds fine with crystal 0.34.0 but I launch it : "Invalid memory access (signal 11) at address 0x4" (full trace at https://pastebin.com/ZkLREqw9)
<Deuns>
searching the internet it seems to be related to a compiler bug.
<Deuns>
Can anyone help on debugging this one ?
<jhass>
mmh, that's not a very helpful trace :/
<jhass>
(not your fault :D)
<Deuns>
unfortunately. I am all hear to have a better trace :)
<jhass>
running it under lldb might give a better one
<jhass>
I see it ships precompiled static libraries in one of its dependencies (lsquic)
<jhass>
might be just that
<Deuns>
I rebuilded lsquic so I can compile :)
<Deuns>
Program received signal SIGSEGV, Segmentation fault.
<Deuns>
) at /usr/src/lib/libcrypto/ex_data.c:425
<Deuns>
int_new_ex_data (class_index=Variable "class_index" is not available.
<Deuns>
I will dig in that direction
<Deuns>
thanks jhass
<jhass>
good it tells you something, for me it doesn't really :D
<FromGitter>
<hanneskaeufler> > *<jhass>* @hanneskaeufler yeah, just do it :) https://carc.in/#/r/8w87 ⏎ ⏎ D'oh, I was preoccupied with the thought of it now working so I didn't even try zomg, thanks
<FromGitter>
<j8r> jhass: but it does not to have a key name different to the cookie name
<Stephie>
i'm glad we still have the old purple crystal styling on the docs generator
<Stephie>
instead of making it black and white and boring
<jhass>
hehe
<jhass>
I wouldn't mind a dark theme though
<Stephie>
idk
<Stephie>
i tend to not like dark themes
<Stephie>
it should use the new "dark theme" browser thing
<FromGitter>
<j8r> We still need to write CSS styles
<Stephie>
...yup
<Stephie>
that is indeed how the web works
<FromGitter>
<j8r> Indeed, autodetection would be nice instead of a manual toggle
<FromGitter>
<Blacksmoke16> custom properties would help, as CSS could be generalized and by just loading a custom `theme.css` file, would propagate to rest of stuff
<FromGitter>
<Blacksmoke16> i.e. have some for links, background, sidebar, etc
<FromGitter>
<stronny> I think your suggestions mean that Crystal is not good enough
<FromGitter>
<stronny> you seem to want to log more information, while a good implementation would require you to log less
<FromGitter>
<stronny> here are my thoughts: ⏎ ⏎ 1) basically there are two main modes of logging: audit and debug ⏎ 2) both should ideally be automatic, based on some source annotations instead of explicit calls to log functions ⏎ 3) debug logs should be smart enough to provide as much context to a problem as possible ... [https://gitter.im/crystal-lang/crystal?at=5e9711dee920022432a637e5]
<FromGitter>
<Blacksmoke16> none of those features would inherently result in more logged data on their own.
<FromGitter>
<Blacksmoke16> they give the ability to better setup common data, or control how stuff is logged
<FromGitter>
<stronny> why do you have several backends?
<FromGitter>
<Blacksmoke16> does it not make sense to log something to a file in dev env, elasticserach, and new relic for example?
<FromGitter>
<Blacksmoke16> ofc with each of those backends not handling *every* entry, i.e. only send unhandled exceptions and/or >error to newrelic
<FromGitter>
<stronny> as a first approach I'd say the program should log to stdout and that's it
<FromGitter>
<Blacksmoke16> sure
<FromGitter>
<Blacksmoke16> then is it so bad to want to log to stdout, but then also send to es, or sentry etc if its a warning or higher?
<FromGitter>
<Blacksmoke16> or in case of prod, change stdout to a file
<FromGitter>
<stronny> it's okay if you control the whole operation
<FromGitter>
<stronny> it's bad if you only distribute your program
<FromGitter>
<Blacksmoke16> i was thinking of having this by default, it would be up to the end user to configure how they wish
<FromGitter>
<Blacksmoke16> wasnt*
<FromGitter>
<Blacksmoke16> plus the multi backend thing is already possible so :shrug:, could be improved a bit with the bubble concept but im not expecting all of that to be approved
<FromGitter>
<stronny> as a rule integration should not be done by configuring a monolithic blob, it should be done by composition of small entities
<hightower2>
Hey folks, using Crystal 0.34 (but possibly unrelated to version), I run a most basic app powered by Kemal (like 20 lines total), and immediately as it starts the resident memory size goes to 360MB, while an empty "crystal eval" process takes 140MB. What's the story behind this?
<hightower2>
(I mean behind these numbers which I find surprisingly high)
<FromGitter>
<stronny> how about a release build?
<hightower2>
yes the kemal number is with --release, and it made no difference compared to running without
<FromGitter>
<Blacksmoke16> prob would also help to ask what this app is doing
<FromGitter>
<Blacksmoke16> like returning large JSON payloads or something?
<hightower2>
no nothing, this is immediately after startup, with no requests
<hightower2>
but I think I see... this must be memory usage from the compilation stage
<hightower2>
if I compile to a binary I bet it'd be much smaller when the binary runs.. lemme check
<hightower2>
yeah indeed... the binary itself takes around 20MB
<hightower2>
ok, thanks for the discussion
<FromGitter>
<Blacksmoke16> id suggest setting up a target
<FromGitter>
<Blacksmoke16> then you can do `shards build --production` to build prod binaries of your application
<FromGitter>
<Blacksmoke16> that you could then run directly, or do whatever with
<hightower2>
yes, yes, no worries, I just stumbled upon this randomly and didn't recall the reason immediately
<FromGitter>
<Blacksmoke16> 👍
HumanGeek has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter>
<neutrinog> does anyone know how to create a multi-dimensional array of a fixed size? I'm not looking for a StaticArray because the array size is determined from a variable.
<FromGitter>
<neutrinog> seems like there some be some handy syntax for that.
<FromGitter>
<ondreian> Is there a good way to run `postinstall` hooks in isolation for testing?
<FromGitter>
<ondreian> `shards run postinstall` for instance
<FromGitter>
<Blacksmoke16> prob could setup another project and install your shard
<FromGitter>
<Blacksmoke16> then like delete lib/bin/lock file etc
<FromGitter>
<Blacksmoke16> to test it again
<FromGitter>
<ondreian> hmm, ok. thanks, guess that works for now.
<FromGitter>
<Blacksmoke16> can also setup the shard dep to point to a local file
<FromGitter>
<Blacksmoke16> not sure how that would play with postinstall but worth a shot?
<FromGitter>
<lodenos> Hello everyone, I search a way for writing of multi included module an example for be more explicite, It normal way is `module A module B end end` and in used is `A::B` but I would like some `module A ... end module B ... end` and find for writing like thar `A::B`
<FromGitter>
<kinxer> Sure. If you use the `initial_capacity` constructor, you can give it any capacity you want.
<FromGitter>
<randiaz95> I think crystal can be used to make some sweet future internet tech
<FromGitter>
<randiaz95> its good syntax/readability with great speed
<FromGitter>
<randiaz95> What are you into making ben?
<FromGitter>
<kinxer> I don't actually get a lot of time/energy to work on Crystal software... I mostly use C++ and bash at work. I'd like to write some geographic software in Crystal at some point, and maybe some natural language/linguistics software.
<FromGitter>
<randiaz95> Very cool :D
<FromGitter>
<randiaz95> There are hundreds of applications when it comes to those two
<FromGitter>
<randiaz95> I wish I had more energy.
<FromGitter>
<kinxer> Yeah. I also have a few ideas for things that I've never heard of being done before, but those are (of course) huge projects, and I've barely started on any of them.
<FromGitter>
<randiaz95> Having a big family of non-coders is draining..
<FromGitter>
<kinxer> Lol. I feel like it'd be more draining to have a family of coders, honestly.
<FromGitter>
<randiaz95> Lol!
<FromGitter>
<randiaz95> Habits make things less draining
<FromGitter>
<randiaz95> Changing your routine for me is draining
<FromGitter>
<kinxer> Yeah... The state of the world right now doesn't help with that.
<FromGitter>
<randiaz95> Imagine your dad had already written the libraries for authentication in node and all you need to do is hit an api endpoint.. ⏎ ⏎ Essentially a firebase crud api. ⏎ ⏎ Your pervy sister trained boosting algo to find inappropriate things in images. [https://gitter.im/crystal-lang/crystal?at=5e9758508e987f3a5e19c417]
<FromGitter>
<randiaz95> you can make an instagram within a day lol.
<FromGitter>
<randiaz95> Im trying to see the positive of this.
<FromGitter>
<kinxer> I mean, the self-hosted smart-home situation could be fantastic.
Deuns has left #crystal-lang [#crystal-lang]
<FromGitter>
<randiaz95> True.. are you saying the return of desktop apps is coming?!
<FromGitter>
<randiaz95> If the internet dies.
<FromGitter>
<kinxer> Family Matrix chat, self-hosted location sharing, etc...
<FromGitter>
<kinxer> I mean, I only work on native works professionally (putting me in the minority in the Crystal community, I think :P ).
<FromGitter>
<kinxer> *native apps
<FromGitter>
<randiaz95> The privacy thing is kinda not a feature, due to the fact that no one reads terms of agreement and 2ndly how would u upgrade the software without them thinking that you are possibly taking data.
<FromGitter>
<kinxer> I'm sorry, I'm not following. Is this re Matrix?
<FromGitter>
<randiaz95> What is re-matrix?
<FromGitter>
<randiaz95> Im talking about the self-hosting part; that would be stored on a desktop/laptop computer
<FromGitter>
<kinxer> Oh, I was thinking about self-hosting just for one's one family.
<FromGitter>
<randiaz95> on a hosting service?
<FromGitter>
<kinxer> And I said "re Matrix", meaning "regarding/relating to Matrix".
<FromGitter>
<kinxer> No, on an in-home server.
<FromGitter>
<kinxer> If you're not doing anything really enterprise-scale, I'd expect that using your own machine wouldn't cause problems.
<FromGitter>
<randiaz95> my desktop has 32 gigs of ram and 2 terabytes
<FromGitter>
<randiaz95> of hardisk
<FromGitter>
<randiaz95> so im sure im good.
<FromGitter>
<kinxer> Yeah, that's hefty. I don't have anything nearly that big.
<FromGitter>
<randiaz95> i wonder if i can change my wifi's ip to have a domain
<FromGitter>
<randiaz95> RandyNet
<FromGitter>
<randiaz95> I can chat with my drone and it would fly to the kitchen and bring a bag of chips.
<FromGitter>
<kinxer> Yeah... I will have to refactor some manually-written text-parsing C++ code soon, though, to use C++ streams, 'cause if I don't then someone else in 3-10 years will have to decipher it.
<FromGitter>
<tenebrousedge> I've been doing those Google Foobar challenges lately, and the only options for languages are Python and Java, so I learned Python
<FromGitter>
<kinxer> That part wouldn't be necessary in Python.
<FromGitter>
<randiaz95> I wonder if he is reckless with that if he would be reckless with your rvalue pointers
<FromGitter>
<tenebrousedge> whitespace issues are so so obnoxious
MasterdonX has joined #crystal-lang
<FromGitter>
<kinxer> Yeah... Mixed tabs and spaces are annoying in most languages; in Python they're syntax. :|
<FromGitter>
<kinxer> I say this as a young developer who learned Python first in school.
<FromGitter>
<randiaz95> 2 space tabs are optimal for me
<FromGitter>
<randiaz95> unless you have bad astygmatism like me and u need more space
<FromGitter>
<randiaz95> 4
<FromGitter>
<tenebrousedge> I really have no idea why Python is as popular as it is
<FromGitter>
<kinxer> Python is a whole lot more fun to mess with than C-like languages, but recently I've had trouble going back to Python because of the weak typing.
<FromGitter>
<randiaz95> Also, if you want to be accepting of bad eyesight please use underscore and notThis
<FromGitter>
<randiaz95> Python is the easiest language to learn
<FromGitter>
<randiaz95> easier than ruby
<FromGitter>
<tenebrousedge> @kinxer that seems like a low bar
<FromGitter>
<kinxer> Lol. Fair.
<FromGitter>
<randiaz95> c# is fun too
<FromGitter>
<randiaz95> specially with high autocomplete
<FromGitter>
<kinxer> In school, the languages I learned some of were Python, C, C++, Java, Haskell, and Perl. And my first programming language was technically TI-BASIC.
<FromGitter>
<randiaz95> When crystal has good autocomplete it will explode.
<FromGitter>
<kinxer> So Python was my favorite of those.
<FromGitter>
<randiaz95> I know python off the top of my head
<FromGitter>
<randiaz95> i can make an antivirus off the top of my head.
<FromGitter>
<kinxer> I just wasn't exposed to anything more pleasant to work in than Python.
<FromGitter>
<randiaz95> I wish python had a File.new or File.read obj
<FromGitter>
<randiaz95> Much better syntax
<FromGitter>
<randiaz95> with open("file.txt") as file:
<FromGitter>
<randiaz95> too many words
<FromGitter>
<randiaz95> I use pd.read_X anyways
<FromGitter>
<j8r> Python is good for coding, not running :/
<FromGitter>
<randiaz95> Not true.. Its fine for running 90% of projects and systems
<FromGitter>
<j8r> I prefer more safe languages to run in production
<FromGitter>
<randiaz95> When you get more than 100 requests per second ( Which you should be making tons of money already) do a rewrite of major endpoints in crystal.
<FromGitter>
<randiaz95> you can use static typing on all functions now in Python.
<FromGitter>
<j8r> I don't only talk about performance
<FromGitter>
<kinxer> Yeah. My concern with Python is much more the type safety than performance.
<FromGitter>
<j8r> No, @randiaz95 - this are just docs
<FromGitter>
<j8r> we can put everything and it will happily compile
<FromGitter>
<j8r> I put a space by mistake, but it changes nothing to the result
<FromGitter>
<randiaz95> OH i forgot I thought u meant compile
<FromGitter>
<randiaz95> I thought the compilers for python would do type checking.
<FromGitter>
<randiaz95> Sure that is a flaw. but I mean, if you throw garbage in any language ( Except GO ) it will return garbage lol
<FromGitter>
<randiaz95> Go is perfect for that then
<FromGitter>
<j8r> It is possible there are linters, like pylint, and others that check types
<FromGitter>
<j8r> but won't be as perfect as built-in
<FromGitter>
<randiaz95> Just handle everything as a string lol
<FromGitter>
<randiaz95> if you need operators of other data types do quick transformations.
<FromGitter>
<j8r> Rust is probably one of the best language to run in production... except I won't be surprised to have rarely very weird incomprehensible errors
<FromGitter>
<j8r> predictive performance is a good to have
<FromGitter>
<randiaz95> Can't we just test our code?
<FromGitter>
<randiaz95> lol
<FromGitter>
<j8r> Sure, but testing all possible cases is impossible
<FromGitter>
<j8r> and even though there are some errors unrelated to the code itself
<FromGitter>
<j8r> like some piece of code that put pressure on the GC, degrading the service
<FromGitter>
<j8r> *I meant, unrelated if the code works by passing the test
lanodan has quit [Ping timeout: 260 seconds]
yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
yxhuvud has joined #crystal-lang
lanodan has joined #crystal-lang
ur5us has joined #crystal-lang
_ht has quit [Quit: _ht]
<hightower2>
Hey what function is called on object destruction?
<oprypin>
hightower2, finalize
<hightower2>
thank you kindly
<oprypin>
hightower2, it is frowned upon because u never know when it will be called
<FromGitter>
<Blacksmoke16> only for classes ^
<hightower2>
yes, yes, I have a class. But good note, thanks
<FromGitter>
<ondreian> What's best practices for expressing non-Integer type enums, specifically `String` enums in my current case.
<FromGitter>
<tenebrousedge> since when do we have string enums?
<FromGitter>
<tenebrousedge> I would probably use a hash
<FromGitter>
<ondreian> Well, the documentation says there aren't any, but if I want to provide the niceness of compile-type checks/autocomplete for an example coming from Typescript for instance...
<FromGitter>
<tenebrousedge> @Blacksmoke16 what's the benefit of that over a hash?
<FromGitter>
<Blacksmoke16> you get the type safety of the enum
<FromGitter>
<Blacksmoke16> another option would be to overload `to_s(io)` as those values are just the string representations of the enum
<FromGitter>
<tenebrousedge> can't enums be used as hash keys though?
<FromGitter>
<Blacksmoke16> sure, case wouldnt allocate memory tho
<FromGitter>
<kinxer> Also, isn't everything in the method example stack-allocated?
<FromGitter>
<Blacksmoke16> so thats one benefit
<FromGitter>
<tenebrousedge> `case` is less flexible. I prefer to use enumerable data structures, by default. I'm definitely not going to worry about the memory use of a three-element hash
<FromGitter>
<Blacksmoke16> flexibility doesnt matter in this since its an enum tho?
<FromGitter>
<Blacksmoke16> enum members wont change dynamically
<FromGitter>
<tenebrousedge> today it's an enum. Tomorrow you might want more than one value?
<FromGitter>
<tenebrousedge> I dunno, I just have a knee-jerk anti-`case` habit
<FromGitter>
<Blacksmoke16> if this is a flag enum then yea dont use case
<FromGitter>
<Blacksmoke16> well you could, just use a custom to_s method
<FromGitter>
<ondreian> I just want autocomplete to work properly. If I use a hash that won't work
<FromGitter>
<ondreian> I think the `case` encode/decode method is probably best
<FromGitter>
<Blacksmoke16> enum with custom `to_s(io)`, or some other method
<FromGitter>
<Blacksmoke16> depends on how it will be used
<FromGitter>
<tenebrousedge> I mean, that example is just using constants
<FromGitter>
<straight-shoota> > we need the ability to make pull requests to wiki 😬 ⏎ ⏎ The wiki is just a git repo, so should actually be doable... =)
<FromGitter>
<straight-shoota> But I'd prefer to use the wiki as little as possible