<FromGitter>
<Blacksmoke16> why not just do `puts some_string`?
<FromGitter>
<Afront> I was also wondering about that as well ⏎ Since I'm not sure on what the differences are between `print` and `write` aside from converting the object to a string
<FromGitter>
<Afront> I was also porting C code, which does something similar to the first code snippet
<FromGitter>
<Blacksmoke16> mainly what they accept
<FromGitter>
<Blacksmoke16> print just does `obj.to_s self` writing the obj's string representation to the IO
Vexatos has joined #crystal-lang
<FromGitter>
<Blacksmoke16> while write requires an array of bytes
<FromGitter>
<Afront> oh okay, I guess I'll just use print then ⏎ Thanks!
ur5us has quit [Ping timeout: 256 seconds]
gangstacat has quit [Ping timeout: 272 seconds]
gangstacat has joined #crystal-lang
postmodern has quit [Read error: Connection reset by peer]
postmodern has joined #crystal-lang
<FromGitter>
<elorest> Should folders and filenames in crystal code bases use hypens or underscores? It seems much more mixed than ruby or python.
<FromGitter>
<Blacksmoke16> just having a way to import a single type from a namespace would be 💯
<FromGitter>
<Blacksmoke16> versus having to include all that namespace's types, or use an alias
<FromGitter>
<stronny> alias?
<FromGitter>
<Blacksmoke16> less than ideal
<FromGitter>
<Blacksmoke16> just to make the type names shortert
<FromGitter>
<stronny> that's a complex conversation, many conflicting goals here
<FromGitter>
<Blacksmoke16> im sure its not trivial either
<FromGitter>
<confact> A thing I have on `as` on require/import in ES6 is that sometimes they are named totally different on every place it is imported and I have to go check what is actually required/imported. The code gets messy fast, especially if many people have different ideas on naming.
<FromGitter>
<Blacksmoke16> well `as` would be an alias you define
<FromGitter>
<Blacksmoke16> which is easily solved by having some standards on naming
<FromGitter>
<Blacksmoke16> at least this way you would be able to tell by looking at the top of the page
<FromGitter>
<j8r> There are already GitHub notifications, plus Gitter activity
<FromGitter>
<sam0x17> is there an automatically sorted container in the standard library (like a binary tree)?
<FromGitter>
<stronny> what's the usecase?
<FromGitter>
<sam0x17> bunch of fibers are building up an array of items that gets sorted by an attribute at the end -- right now just doing `results.sort_by { |item| item["id"] }`
<FromGitter>
<stronny> how is the array getting used?
<FromGitter>
<stronny> sort once is cheaper than rebalancing tree on every insert I think
<FromGitter>
<sam0x17> yeah you're probably right
<FromGitter>
<sam0x17> I was just thinking that
<FromGitter>
<stronny> answering your question I can't think of any
<FromGitter>
<stronny> shards probably
<FromGitter>
<sam0x17> yeah I know of some shards that have it I just wanted to make sure I'm not missing out on some standard library container I don't know about
<FromGitter>
<stronny> also array is O(1) on access, trees are typically O(log N)
<FromGitter>
<sam0x17> yeah java has a hybrid with O(1) iteration and O(log N) insert
<FromGitter>
<sam0x17> I forget what it's called but that's what I was thinking of
<FromGitter>
<sam0x17> probably just a red black tree
<FromGitter>
<sam0x17> or AVL
<FromGitter>
<stronny> you can do that with additional memory sure
<FromGitter>
<sam0x17> yeah, array is better for this :)
<xyhuvud>
That particular usecase might be better served by a heap. Not that we have that either in stdlib. personally I'd really love to see a good heap and a good (b-)tree implementation in stdlib.
<xyhuvud>
time has run away from red black and avl trees - they are not very good from a cache perspective.
<xyhuvud>
or well, heaps don't allow iteration, but it depends on what you'd actually use the contents for.
DTZUZU2 has quit [Ping timeout: 250 seconds]
DTZUZU2 has joined #crystal-lang
HumanGeek has quit [Read error: Connection reset by peer]
<oprypin>
but with `@llvm_mod` being a different object at that point, causing a failure `Undefined llvm function: __CxxFrameHandler3`. this happens only if i run this code *on* Windows, but works correctly (@llvm_mod always matches) if I cross-compile on Linux to Windows. see also `@mod.to_unsafe` on the screenshot. do you know what it could be?
<Stephanie>
oh god
<oprypin>
:D
<Stephanie>
oh, right
<Stephanie>
right tight
<Stephanie>
--single-module
<Stephanie>
on windows
<Stephanie>
will fix it, as a workaround
<oprypin>
oh well thats easy :o
<Stephanie>
the answer is, that i fucked up
<Stephanie>
i only add the personality function definition in the main module
<oprypin>
yea apparently.
<Stephanie>
which always worked fine since i was cross-compiling
<Stephanie>
and that implies single-module
<Stephanie>
i need to add a fix which just checks if it's defined for each module
<Stephanie>
and defines it if it's not
<Stephanie>
like all the other functions
<Stephanie>
i just forgot about that
<oprypin>
Stephanie, thank you, that workaround helps
<Stephanie>
nice
<Stephanie>
it's what i thought then
<Stephanie>
i guess i'll PR a fix?
<oprypin>
Stephanie, sure, would be nice.
<oprypin>
Stephanie, how far did u get with running Crystal itself? i assume since you added info about installing LLVM on the wiki page, you at least tried it?
<Stephanie>
yeah
<Stephanie>
it worked, with a patch
<Stephanie>
which still lives in the windows branch of my fork
<Stephanie>
but it like
<Stephanie>
compiled hello world
<Stephanie>
on windows
<oprypin>
nice. so im just duplicating that work :D
sagax has quit [Read error: Connection reset by peer]
<FromGitter>
<kinxer> @manveru If you haven't found it yet, it turns out that there's a more complete GeoJSON shard than mine: https://github.com/geocrystal/geo_json ⏎ It makes me sad to be outdone, but it looks like a really excellent shard.
<FromGitter>
<sam0x17> yeah I was thinking the method would be missing so compile time error
<FromGitter>
<sam0x17> it's all good tho I'm going with a different structure was just curious
<FromGitter>
<Blacksmoke16> that should work the same
<FromGitter>
<sam0x17> is there a built-in way of getting the domain from a `URI`? or am I justified in writing a bit of string parsing
<FromGitter>
<sam0x17> got it -- there's a `.host`
<FromGitter>
<j8r> `URI#hostname`?
<FromGitter>
<j8r> there is also `URI#host` yes
<FromGitter>
<sam0x17> difference?
<FromGitter>
<Blacksmoke16> looks like `hostname` is essentially the same as `host`, just handles unwrapping ipv6 hosts
<FromGitter>
<kinxer> That's what I was thinking of.
<FromGitter>
<asterite> You can't have recursive structs. But JSON::Any works because it's a union of all primitive types or reference types, so there's the pointer of the reference indirection which makes it be "recursivee"
<FromGitter>
<asterite> It's like having a class with a member referring to itself
<FromGitter>
<Blacksmoke16> ahh, you could use a class for that
<FromGitter>
<asterite> "it's a union of all" -> well, it has an instance vars that's a union of all...
Xeago has quit [Read error: Connection reset by peer]
ur5us has joined #crystal-lang
<watzon>
Ok STDOUT being buffered is fucking with me
<FromGitter>
<Blacksmoke16> `STDOUT.sync = true`?
<watzon>
I just got a project set up in a pet container and tried to run it and wasn't getting any output. As soon as set `STDOUT.buffer_size = 0` I get output
<watzon>
I was scratching my head trying to figure out what was wrong
<watzon>
sync works as well
<FromGitter>
<manveru> @kinxer that's also super new...
<FromGitter>
<kinxer> It could be a bit more well-documented, but it's structured simply, more complete to the GeoJSON spec than my library, and seemingly equivalent speed-wise to my library (both can deserialize a quarter-GB GeoJSON file in about 4 seconds).
<FromGitter>
<kinxer> That sounds really useful.
<FromGitter>
<manveru> i'm using an ad-hoc class for it atm, it doesn't really need a ton of the geojson features, and i don't have much time to spend on it
<FromGitter>
<kinxer> Alas, I don't have the bandwidth for that right now (and it wouldn't be useful to *me* right now), but I hope you have the opportunity to spend more time on it at some point.
<FromGitter>
<kinxer> I think geo applications would work really well in Crystal; for instance, it seems like the primary open-source map servers right now are in Javascript, C++, and Python. Crystal could provide near-C++ speed with better developer friendliness (arguably more than all three other languages).
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter>
<elorest> > @elorest I always use underscores ⏎ ⏎ Thanks @asterite. Me too but lately I've gotten some push back. My thought is that since hyphen actually has meaning in english, math, dates etc, it shouldn't be used as a replacement for spaces in filenames. This allows for meaningful uses of hyphens such as `your_app_production_03-19-2020.log`.
<FromGitter>
<Blacksmoke16> i also use hyphen to denote namespaces
<FromGitter>
<Blacksmoke16> like `require "athena-dependency_injection"`
<FromGitter>
<Blacksmoke16> that represents `Athena::DependencyInjection`
<FromGitter>
<Blacksmoke16> ofc only really do that for the main file that you would require for a shard
_ht has quit [Remote host closed the connection]
<FromGitter>
<Blacksmoke16> is there a way to tell if two objects are comparable?