ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.22.0 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
onionhammer1 has quit [Ping timeout: 276 seconds]
onionhammer1 has joined #crystal-lang
hightower2 has quit [Ping timeout: 240 seconds]
onionhammer has joined #crystal-lang
onionhammer1 has quit [Ping timeout: 240 seconds]
greengriminal has joined #crystal-lang
<FromGitter> <fridgerator> ^ that one is huge
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
<FromGitter> <drosehn> compiled binaries also avoid some security issues (mainly with setuid executables).
<FromGitter> <drosehn> note that you could setup ssh keys so they have a very limited set of actions they can perform.
<FromGitter> <drosehn> ... where you choose the exact set of actions which are allowed by the key when you set it up.
greengriminal has quit [Quit: Leaving]
<FromGitter> <bigtunacan> Anyone running into the hanging issue on crystal-pg I have submitted a PR for that. In the meantime my fork is available at https://github.com/bigtunacan/crystal-pg
<FromGitter> <bigtunacan> It's probably not the most elegant solution, but at least it works ;)
<FromGitter> <bigtunacan> Now I can get back to my real project until someone comes up with a better fix than mine.
<FromGitter> <fridgerator> wow, awesome @bigtunacan !
<FromGitter> <bigtunacan> Thanks; it was literally a 3 line change
<FromGitter> <bigtunacan> All of the time was just finding the bug XD
<FromGitter> <fridgerator> I saw that
<FromGitter> <fridgerator> I hate those
<FromGitter> <bigtunacan> On the plus side I don't need to switch to MySQL for now; and I can get back to work on my website :smile:
<FromGitter> <fridgerator> :thumbsup:
<FromGitter> <fridgerator> much appreciated!! Now I can implement unique constraint
<FromGitter> <bigtunacan> No problem; we all have to do what we can; otherwise why be here
<FromGitter> <elorest> exactly!
<FromGitter> <elorest> Crystal isn't a spectator sport.
Philpax has joined #crystal-lang
hightower2 has joined #crystal-lang
flaviodesousa has joined #crystal-lang
<FromGitter> <krypton97> K
rohitpaulk has joined #crystal-lang
<oprypin> that's Kalium. you want Kr
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <sdogruyol> hey everyone
rohitpaulk has quit [Ping timeout: 255 seconds]
hightower2 has quit [Read error: Connection reset by peer]
hightower2 has joined #crystal-lang
<FromGitter> <bew> hey Serdar ;)
<FromGitter> <akzhan> hey )
<FromGitter> <sdogruyol> how're you doing people
<FromGitter> <umutuluer> @sdogruyol i have a question that is related to kemal fw
<FromGitter> <sdogruyol> sure
<FromGitter> <sdogruyol> @umutuluer
<FromGitter> <sdogruyol> @RX14 thanks for checking out the PR
<FromGitter> <umutuluer> we want to use an api project but my teammates have a little apprehensions because of that we choose golang for now. what do you think about? should we use kemal?
<FromGitter> <umutuluer> especially about security
<FromGitter> <straight-shoota> If security is a concern, it might not yet be the right time to think about Crystal, because it's not that matured and still under development. Prior to a stable release there can be no valid assessment about vulnerability issues.
<FromGitter> <akzhan> Crystal is not production ready at all. it has hashdos vulnerability at this moment.
<FromGitter> <sdogruyol> @umutuluer security is a really broad term. I'd use it for a microservice
<FromGitter> <sdogruyol> it's true that Go is past 1.0 and more battle-test in many ways. If security is really your concern i'd use something more mature atm
<FromGitter> <umutuluer> thanks for replying :)
<FromGitter> <sdogruyol> you're welcome :+1:
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/vQmIy
<crystal-gh> crystal/master a431a57 Daniel Smith: Add `zero?` to Number, Time::Span, and Complex (#4026)
olbat has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang
olbat has joined #crystal-lang
olbat has quit [Changing host]
<travis-ci> crystal-lang/crystal#a431a57 (master - Add `zero?` to Number, Time::Span, and Complex (#4026)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/246178615
<DeBot> https://github.com/crystal-lang/crystal/pull/4026 (Add `zero?` to Number, Time::Span, and Complex)
olbat has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang
<crystal-gh> [crystal] MakeNowJust opened pull request #4610: Parser: fixed #4608, correct to parse regex after close bracket (master...fix/crystal/4608-regex-after-close-bracket) https://git.io/vQmsu
olbat has quit [Ping timeout: 268 seconds]
olbat has joined #crystal-lang
hightower2 has quit [Ping timeout: 276 seconds]
<crystal-gh> [crystal] mverzilli reopened pull request #4592: Parser: fix #4590, correct to parse empty parenthesis "()" (master...fix/crystal/4590-wrap-paren-nop) https://git.io/vHjy5
olbat has quit [Ping timeout: 268 seconds]
olbat has joined #crystal-lang
<FromGitter> <cearls> Nice shoutout to Crystal as a supported language on new Apex product Up by TJ Holowaychuk https://github.com/apex/up
<FromGitter> <molovo> @cearls did he manage it? That’s awesome news
<FromGitter> <cearls> @molovo I’m not sure. It’s just a placeholder repo, but it is listed in the readme.
<oprypin> dank repo >_>
<FromGitter> <molovo> @cearls Yeah, I was chatting to him on twitter about it the other day, he was just discovering Crystal for the first time. It must have made an impression
<FromGitter> <cearls> @molovo Yep, I saw his tweets, was good exposure
olbat has quit [Ping timeout: 246 seconds]
bazaar_ has quit [Quit: leaving]
olbat has joined #crystal-lang
bazaar has joined #crystal-lang
<FromGitter> <fridgerator> in what cases can I not rescue an exception?
<FromGitter> <fridgerator> thanks to this PR by @bigtunacan https://github.com/will/crystal-pg/pull/100 crystal-pg now no longer hangs on certain exceptions. But I was hoping to catch the unique constraint exception
<oprypin> fridgerator, i dont think there are such cases, other than OS-specific bugs
<FromGitter> <fridgerator> If I wrap my `connection.query()` in a `begin; rescue` block, it doesn't catch
<FromGitter> <fridgerator> hrmm ok, i'll look around further
<oprypin> fridgerator, perhaps it starts a fiber and raises the exception there
olbat has quit [Ping timeout: 240 seconds]
<FromGitter> <fridgerator> ah
<FromGitter> <fridgerator> crap
olbat has joined #crystal-lang
<FromGitter> <fridgerator> that sucks, lol
olbat has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang
<FromGitter> <jwoertink> is it me or is something going on? I just noticed mverzilli and asterite aren't on the people list for the crystal org. I'm also not seeing commits from asterite from before 20 days ago. (unless github just doesn't allow more than X commits to be shown?)
<Papierkorb> jwoertink, asterite posted about a ruby project of his in here yesterday
<FromGitter> <jwoertink> oh? I'll have to scroll up and check that out
<crystal-gh> [crystal] akzhan opened pull request #4611: Fix memset, memcpy, memmove calls on Pointer type. (master...fix-pointer-contract) https://git.io/vQm2i
<oprypin> maybe they arent people on the list but it's possible to hide membership
olbat has quit [Ping timeout: 268 seconds]
olbat has joined #crystal-lang
<oprypin> wow reading #4589 makes me think we're not in good hands
<DeBot> https://github.com/crystal-lang/crystal/issues/4589 (Pointer's copy_from|copy_to|move_from|move_to are inherently broken.)
olbat has quit [Ping timeout: 260 seconds]
olbat has joined #crystal-lang
<FromGitter> <bew> yeah that "Crystal is not C so we don't fix low level stuff" statement makes me a little sad about the possible language future
Ven has joined #crystal-lang
<FromGitter> <paulcsmith> I'm curious why that is? I don't understand the problem well so what problems would it cause for developers down the road? Slower performance? Bugs?
<FromGitter> <jwoertink> @oprypin I was saying more than 20 days ago https://github.com/crystal-lang/crystal/commits/master?after=a431a57b37d149a3536b7cb184356279b490aeda+34&author=asterite It stops on June 3rd. I'm not sure if that's a github thing or not, but I would think it would show his commits back to 2014 or whatever
Ven is now known as Guest2886
<oprypin> paulcsmith, no support for memory regions over 2GB
<oprypin> random breakages all over the codebase when you reach that threshold
<FromGitter> <paulcsmith> What is a memory region? It seems like a pretty high limit. Would that mostly apply to stuff like games where you need a huge asset?
<FromGitter> <akzhan> Yes, we must use platform specific size_t, ptr_diff_t of C++
<oprypin> akzhan, srsly though, no idea why you won't listen to me in that PR
<oprypin> >> typeof(LibC::SizeT.new(5))
<DeBot> oprypin: # => UInt64 - https://carc.in/#/r/28sz
<FromGitter> <paulcsmith> Ah ok. I guess that's something I'll never have to worry about for what I do, but I can see how that could be annoying to have to do if you were doing a game engine or something
<oprypin> dont forget mmap. reading files by accessing a particular memory region
<oprypin> allocated and faked by the OS
<FromGitter> <akzhan> @oprypin it is a fix only. I want to change Intrinsics contracts to use LibC::SizeT, but it is a goal of another Pull Request. I want to rewrite Pointers/Sizes/Offsets at all. But it is risky task. And I have no time.
<FromGitter> <mverzilli> hey
<oprypin> you have time to add a method that duplicates functionality but don't have time to just drop it?
<FromGitter> <mverzilli> sorry I just found out my membership to the org was private
<FromGitter> <mverzilli> wasn't even aware that setting existed
<FromGitter> <mverzilli> now it's public
<FromGitter> <mverzilli> Ary's private
<FromGitter> <akzhan> Not by changing Intrinsic contracts to use SizeT. But thanks, I’ll do
<FromGitter> <bew> aaah the mystery's gone
<oprypin> jwoertink, i dont know, seems like broken search
<FromGitter> <mverzilli> he doesn't want so much exposure at this time
<oprypin> wait what
<FromGitter> <mverzilli> about the copy_from|...|etc issue
<FromGitter> <mverzilli> the conversation is still open
<FromGitter> <mverzilli> I agree the statement "we're not C, we don't have to do this" is unfortunate
<FromGitter> <straight-shoota> @jwoertink your link limits commits to after a431a57
<FromGitter> <straight-shoota> remove that param from the url and you get prior commits
<FromGitter> <jwoertink> I just went to the first page and clicked "older". It stops the pagination on that link I pasted
<oprypin> straight-shoota, yeah remove that param and go to page 2 and you're back at the same parameter
<oprypin> it's broken
<oprypin> remove ?author as well and you cansee older commits
<FromGitter> <mverzilli> please don't get super tripped up about that issue
<FromGitter> <jwoertink> yeah, I see that now.
<FromGitter> <straight-shoota> oh, okay
<FromGitter> <straight-shoota> so it's bug in github
<FromGitter> <jwoertink> I guess on to a different more happy note. I got a crystal app up in production yesterday
<FromGitter> <paulcsmith> :thumbsup:
<FromGitter> <mverzilli> congrats!
<FromGitter> <mverzilli> links? what is it about?
<FromGitter> <jwoertink> Our original plan was to generate this giant JSON data and then write it to a zip for a partner to pull down. Turns out that the endpoint is fast enough to serve the data without needing to zip it :D
<FromGitter> <mverzilli> \o/
<FromGitter> <jwoertink> sorry, can't link to it. It wouldn't be appropriate with the data I work with :p
<FromGitter> <jwoertink> but still awesome! It serves up about 4mb of JSON in about 900ms
<FromGitter> <mverzilli> understand! anyway, if could write it down here it'd be awesome: https://github.com/crystal-lang/crystal/wiki/Used-in-production
<FromGitter> <jwoertink> and most of that time is spent in the DB because the query requires like 9 left joins lol
<FromGitter> <bew> nice! where is the json from? is it from a file? a db?
<FromGitter> <jwoertink> from a DB
<FromGitter> <bew> ah you just said it
<FromGitter> <mverzilli> also, if at any time you want to write a blogpost about it we'd be happy to publish it in the official blog
<FromGitter> <jwoertink> sweet!
<FromGitter> <jwoertink> I wouldn't mind putting together something about the process. We use circleci to build the docker image and deploy it on our rancher setup
<FromGitter> <mverzilli> cool! would love to see that
<FromGitter> <jwoertink> :thumbsup:
<FromGitter> <akzhan> @paulcsmith @mverzilli just created https://github.com/crystal-lang/crystal/issues/4612 to initiate discussion about SizeT etc.
<oprypin> are you kidding me
<oprypin> i show you that it's in the language and you go and create an issue to add them
<oprypin> >> LibC::SizeT
<DeBot> oprypin: # => UInt64 - https://carc.in/#/r/28t1
<FromGitter> <akzhan> No, it’s issue about language design. no LibC.
<RX14> using LibC constants is fine for now
<oprypin> the language cant deal with actual varying types
<RX14> eventually we might do something like go and remove libc but before then why not just use the LibC aliases
<oprypin> they will not want to go for such a solution
<RX14> what do you mean oprypin
<RX14> by "varying types"
<FromGitter> <akzhan> Anyway we cannot use LibC::SizeT on intrinsics, because we need to change Intrinsics contracts along LibC ones.
<FromGitter> <akzhan> or just add a comment about. hm.
<RX14> I see no reason why using the libc types with Intrinsics wouldn't work @akzhan
<RX14> i havent *tried* it but...
olbat has quit [Ping timeout: 246 seconds]
<oprypin> RX14, well i mean like in c++ size_t is an actual type that can change behavior per platform
<oprypin> crystal doesnt have those, for good reasons
<FromGitter> <akzhan> It will work. but Intristics will highty depend on LibC.
<RX14> yes
<RX14> but
<RX14> size_t will be implemented in a header file
<RX14> and use a typedef right
<oprypin> akzhan, note that there's no actual dependency on LibC
<RX14> which is like crystal's alias
<oprypin> RX14, ok fine, then take `long` as an example - i dont think that's a typedef
<RX14> so i don't see how size_t is any more a language fixture in C than crystal
<RX14> oprypin, yeah but size_t isn't like long
<oprypin> it's just in an unfortunately named namespace
<RX14> and there's no need for it to be ever
<FromGitter> <akzhan> OK, will change. Thanks @oprypin @RX14
<oprypin> RX14, what do you mean it isn't like long - the behavior is exactly the same on linux
<RX14> long is a language keyword
<RX14> size_t is not
<oprypin> RX14, the real reason why size_t did so well in C was implicit type conversions
olbat has joined #crystal-lang
<RX14> the reason why it did so well because it was actually useful
<oprypin> well it is useful, i wouldnt mind if all standard lirary of crystal used size_t appropriately
<oprypin> but with the current situation it would just be painful
<RX14> yes it's useful in the stdlib
<RX14> i don't see why anything's painful oprypin
<oprypin> people would just be like ffs i dont care .to_i32 everywhere
<RX14> we shouldn't expose any type to be LibC::SizeT
<RX14> it would be used in the implementations only
<oprypin> then what's the point if you can't use it?
<RX14> what
<oprypin> pointer, at the very least, would need it exposed
<oprypin> or slice
<RX14> it's exposed *right now*
<RX14> oprypin, pointer already changes size i would think
<oprypin> actually is UInt64, which is decent https://crystal-lang.org/api/master/Pointer.html#address%3AUInt64-instance-method
<FromGitter> <akzhan> I can’t do this in right way: ⏎ ⏎ In short: ⏎ ⏎ lib Intrinsics ... [https://gitter.im/crystal-lang/crystal?at=594d389957a6e9f72eefd184]
<RX14> you sure it's not just a U64 because the doc tool was run on 64bit oprypin?
<oprypin> RX14, yeah view source
<oprypin> doc doesnt resolve aliases like that
<FromGitter> <brawnski> Hi. Just ran across a JSON.mapping bug. It seems it doesn't check the keys in the json before generating variable names. i.e. an active?: Bool key is mapped to an @active? instance variable. Crystal doesn't seem to like instance variables with question marks.
<RX14> well i was more thinking it might be defined in the compiler
<oprypin> if it is already exposed as UInt64 then what's there to discuss
<oprypin> just fix the silly to_i32 in internal implementation and be done with the pointless discussion
<FromGitter> <akzhan> LOL why I didn’t :)
<oprypin> brawnski, well... you're probably not supposed to name a key like that, it's meant to be exactly the same as in json
<oprypin> if there was a special case to drop `?` then what if you use both `asdf?` and `asdf`
<FromGitter> <bew> @brawnski I opened an issue about that, let me find it
<FromGitter> <paulcsmith> @brawnski Instead you can use `active` and then do `property? active`. The `property?` will generate a `?` method for it
olbat has quit [Ping timeout: 260 seconds]
<oprypin> RX14, so basically the big deal here is the language design makes a big point about never exposing types that differ per platform. and for a proper solution one would have to fight this idea, i think
<RX14> hmm
<RX14> i'd say never expose it in a high level interface
<RX14> where even slice is high level
<RX14> pointer should be platform sized
<oprypin> uh sure, now go convince them about this
<RX14> pointer might be platform sized already
<RX14> just that the codegen converts #address to a u64
<FromGitter> <brawnski> @bew, etc. all... thanks. I changed my mapping -> active: { type: Bool, key: "active?" }
<RX14> hmm oprypin
<RX14> i think it is
olbat has joined #crystal-lang
<RX14> #address just converts the platform specific pointer to a U64
<oprypin> well of course internally they couldnt get away with just having u64
<oprypin> but that's not my point
<FromGitter> <bew> @brawnski oh ok, it was not the same use case
olbat has quit [Ping timeout: 240 seconds]
<oprypin> yeah i guess json mapping could do something to support the question mark case
Philpax has quit [Ping timeout: 260 seconds]
<oprypin> brawnski, but you can add to your class, for convenience: `def active?; active; end`
<FromGitter> <brawnski> @bew not quite, but i do agree with the issue.
hightower2 has joined #crystal-lang
Guest2886 has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang
Ven_ has joined #crystal-lang
Ven_ has quit [Ping timeout: 255 seconds]
flaviodesousa has quit [Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/]
olbat has quit [Ping timeout: 246 seconds]
olbat has joined #crystal-lang
<FromGitter> <peterschols> Hi! I'm relatively new to Crystal and a bit puzzled by Crystal's type system. In the following code, the compiler correctly notices that new_array does not contain any nils after calling #compact: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ array.compact! ... [https://gitter.im/crystal-lang/crystal?at=594d412976a757f8089a8f8a]
<FromGitter> <straight-shoota> In the first example, your keeping the same variable and it's type does not change, it stays `Array(String | Nil)`. In the second example, you're assigning the return value of `compact` to a variable. The parser can recognize this and therefore assigns the restricted type. ⏎ This works with the same variable name as well: ⏎ ⏎ ```array = ["a", "b", "c", nil] ⏎ array = array.compact ⏎
<FromGitter> ... array.each{|str| puts str.upcase}``` [https://gitter.im/crystal-lang/crystal?at=594d42286ae41d5d3378f664]
<FromGitter> <fridgerator> I would imagine you check the classes, `new_array.class` would be `Array(String)` and `array` in the second example would be `Array(String | Nil)`
<oprypin> peterschols, basically the real reason is that a mutating method like `compact!` can't change the type of the variable. it was `Array(String | Nil)` and it remains so.
<oprypin> straight-shoota might have swapped around "first" and "second" examples in the explanation?
<FromGitter> <straight-shoota> yes, I think I was reading it upside down :D
<FromGitter> <straight-shoota> It is of course the other way round
<FromGitter> <peterschols> @straight-shoota @oprypin thanks a lot, makes sense. ⏎ I thought that the compile type could be updated when adding or removing objects of different types, but apparently only when assigning a new variable (or reassigning an existing variable).
<oprypin> peterschols, "reassigning an existing variable" is not a correct deduction, and assigning a variable is not what changes the type
<oprypin> new object - new type
<FromGitter> <bew> `array.compact` will create a *new* array
<oprypin> but yeah, for compile-time matters, it is tightly related to the variable
<FromGitter> <straight-shoota> And the reason is not even the type system: the object itself - and therefore it's class - stay the same. You can't change the class of an object ;)
<oprypin> you're creating a new array, whose `compact` method is smart to exclude Nil from the return type, and assigning it to a variable which now has a definite type deduced from the object
<FromGitter> <peterschols> @oprypin sorry, I was confused. So the type is determined on object creation and remains fixed.
<FromGitter> <bew> object type yes
<oprypin> peterschols, that's the runtime type of the object. and when you create an object and cleanly assign it to a variable, the compiletime type of the variable becomes the same and also remains fixed
<oprypin> sigh it's not easy to explain, high risk of even more confusion
<Yxhuvud> not really at object creation, at variable creation.
<Yxhuvud> or assignment oslt.
olbat has quit [Ping timeout: 260 seconds]
olbat has joined #crystal-lang
<FromGitter> <bew> jk `confusion **= 9999`
<FromGitter> <peterschols> @yxhuvud @oprypin @bew @straight-shoota thanks a lot for the help, I'll need to look into this some more. Any pointers to useful docs, besides the official Crystal gitbook?
<crystal-gh> [crystal] bcardiff pushed 4 new commits to master: https://git.io/vQmS4
<crystal-gh> crystal/master ab1847d Brian J. Cardiff: LLVM: Render call and invoke with OperandBundle (ie: funclet)
<crystal-gh> crystal/master 544c893 Brian J. Cardiff: LLVM: Add BasicBlock.null
<crystal-gh> crystal/master 16057bb Brian J. Cardiff: LLVM: Add OperandBundleDef (ie: funclet) and CatchPad/Ret/Switch
<oprypin> nope
<FromGitter> <bew> currently no, but you can experiment and ask here ;)
<FromGitter> <peterschols> Ok, thanks :)
<FromGitter> <bew> there is no specs for the macro method `run`?
olbat has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang
<oprypin> bew, there aren't
<oprypin> are there specs for any macro methods, for that matter?
<FromGitter> <bew> (in addition for all specs for methods on ArrayLiteral and other nodes)
Ven has joined #crystal-lang
Ven is now known as Guest80443
<travis-ci> crystal-lang/crystal#72fe026 (master - Merge pull request #4501 from bcardiff/llvm-operand-bundle-def): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/246278412
<DeBot> https://github.com/crystal-lang/crystal/pull/4501 (Add llvm operand bundle def and catch pad/ret/switch)
Guest80443 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sz0 has quit [Quit: Connection closed for inactivity]
olbat has quit [Ping timeout: 276 seconds]
<crystal-gh> [crystal] bew opened pull request #4614: On macro run error: show status, stdout and stderr (master...show-errors-for-macro-run) https://git.io/vQmAJ
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 255 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 260 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 255 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 258 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 260 seconds]
olbat has joined #crystal-lang
<FromGitter> <krypton97> hello boys
<FromGitter> <krypton97> how fast is crystal comparing to java and when should I use it?
<FromGitter> <elorest> Crystal is compiled java is bytecode. Java has one of the fastest VM’s but still doesn’t compare to a compiled language like crystal, nim rust, go.
olbat has quit [Ping timeout: 240 seconds]
<FromGitter> <bew> For some benchmarks you can see https://github.com/kostya/benchmarks/blob/master/README.md
olbat has joined #crystal-lang
hightower2 has quit [Ping timeout: 260 seconds]
olbat has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 255 seconds]
olbat has joined #crystal-lang
<FromGitter> <akzhan> kostya’s benchmark isn’t relevant anyway (they doesn’t comply to spec.)
<FromGitter> <akzhan> Oops, said about another project - https://github.com/kostya/crystal-benchmarks-game
<FromGitter> <krypton97> yeah but java is using jit and compiles the bytecode as it goes, not all at once
<FromGitter> <krypton97> I'm not saying java could be better, I don't actually use java, but sometimes JIT is not that bad
<FromGitter> <luislavena> @krypton97 JIT is great and JVM has *years* of experience and knowledge, but also lot of parameters and tweaks to all the different scenarios. I would say that *it depends* when to use a compiled language vs when to use a language backed by JVM (like Java)
<FromGitter> <luislavena> a compiled language like Crystal or the others listed before have benefits noticeable on environments like command line applications, where faster startup are a must.
<FromGitter> <luislavena> It might also have wins in memory efficiency, but YMMV on that
olbat has quit [Ping timeout: 255 seconds]
olbat has joined #crystal-lang
olbat has joined #crystal-lang
olbat has quit [Changing host]
<FromGitter> <bararchy> Is there an easy way to cast\convert "[1,2,3]" to Array(Int32) ?
<FromGitter> <bew> Or faster: https://play.crystal-lang.org/#/r/28vo
<FromGitter> <akzhan> yeah
olbat has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 276 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 260 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 246 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 246 seconds]
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 260 seconds]
olbat has joined #crystal-lang
<FromGitter> <sdogruyol> i'd like to have something like this for Crystal https://nim-lang.org/blog/2017/06/23/community-survey-2017.html
<FromGitter> <sdogruyol> WDYT people?
<FromGitter> <johnjansen> anyone got an elegant solution for this https://carc.in/#/r/28vv
<FromGitter> <johnjansen> silly question, but even so
<FromGitter> <fridgerator> great idea
olbat has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang
<FromGitter> <krypton97> how does crystal comapre to nim?
<FromGitter> <krypton97> in terms of speed
<FromGitter> <sdogruyol> check https://github.com/kostya/benchmarks @krypton97
olbat has quit [Ping timeout: 260 seconds]
<RX14> @johnjansen https://carc.in/#/r/28vy
<FromGitter> <johnjansen> damn @RX14 im thinking that was a bad example now ;-)
<RX14> yeah you forgot to return the accumulator lol
olbat has joined #crystal-lang
<FromGitter> <johnjansen> nah, i know that much, but i was trying to conjure up an example that fitted the problem i was having, and i did a bad job of that clearly
<FromGitter> <krypton97> any good gui lib for crystal?
olbat has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang
<FromGitter> <krypton97> also the following code seems to run without any issues
<FromGitter> <krypton97> def fib(n) ⏎ if(n == 0) ⏎ 0 ⏎ elsif(n == 1) ⏎ 1 ... [https://gitter.im/crystal-lang/crystal?at=594d94fd4bcd78af563bcd0f]
<Papierkorb> ?
<FromGitter> <johnjansen> thats what i was thinking (tips head sideways whilst reading code)
<RX14> @krypton97 there's https://github.com/Fusion/libui.cr
<dom96> sdogruyol: do it :)
<FromGitter> <johnjansen> @RX14 https://carc.in/#/r/28wb
<FromGitter> <johnjansen> line 17
<RX14> @johnjansen simply don't use UInt32? :3
<FromGitter> <johnjansen> its the Nil’s that are complicating it …
<RX14> can't you set the default as 0
<RX14> i emant use UInt32 instead of UInt32?
<RX14> i should have used | Nil
<FromGitter> <johnjansen> i could its probably the same net net, although its going to be a very very large hash
<RX14> well setting = nil doesn't make it smaller
<FromGitter> <johnjansen> ok, thats probably the morsel i needed to confirm
<RX14> i'm not entirely sure i understand the code
<FromGitter> <johnjansen> neither am i at this time on friday ;-)
<RX14> haha
<RX14> why do you set as nil and then set as zero
<RX14> instead of using 0 as the default value?
<FromGitter> <johnjansen> i was going to take a look at memory usage actually, part of it was an attempt to keep the data clean, part out of interest
<FromGitter> <johnjansen> @RX14 https://carc.in/#/r/28wg
<FromGitter> <johnjansen> works as 0’s
<FromGitter> <johnjansen> still not sure how id solve the initial problem if i had no choice though
<FromGitter> <johnjansen> :-/
<RX14> you wouldn't write to the hash
<FromGitter> <johnjansen> this is the correct / final version https://carc.in/#/r/28wh
<FromGitter> <johnjansen> so does `0` cost no more memory than `nil` ?
<RX14> @johnjansen https://carc.in/#/r/28wi
<RX14> thats how i'd solve the problem from the initial example if I couldn't refactor
<FromGitter> <johnjansen> yes …. that was the brain melt i needed … awesome ;-)
<RX14> @johnjansen https://carc.in/#/r/28wr
<RX14> using unions has a size overhead
<FromGitter> <johnjansen> thats interesting ...
<RX14> it must be tagged with a u64
<RX14> i thought it was just a u32 tag
<FromGitter> <johnjansen> what must?
<RX14> which would mean U32? would be 8 bytes in my mind
<RX14> @johnjansen unions
<FromGitter> <johnjansen> thats what i thought
<RX14> (nearly) every union type has a 32bit type id
<RX14> which tells you which type in the union it is
<FromGitter> <johnjansen> ok, that makes total sense
<FromGitter> <johnjansen> so the union values are significantly more expensive in this case
hightower4 has joined #crystal-lang
<RX14> yup
<RX14> at the very least unions are the same size as their largest member
<RX14> and often larger than their largest member
olbat has quit [Ping timeout: 255 seconds]
olbat has joined #crystal-lang
olbat has joined #crystal-lang
olbat has quit [Changing host]
hightower3 has quit [Ping timeout: 260 seconds]
<FromGitter> <johnjansen> got it … thanks
<RX14> there's actually an optinization to any Reference type (classes) which is nillable which represents nil as a null pointer
<FromGitter> <johnjansen> turns of i only need a UInt8 so i think im winning on that
<RX14> cool
<FromGitter> <johnjansen> course i have to create vectors for millions of rows and compare them, but ill give it a shot and see what happens
bmcginty_ has quit [Ping timeout: 240 seconds]
olbat has quit [Ping timeout: 255 seconds]
bmcginty has joined #crystal-lang
olbat has joined #crystal-lang
bmcginty has quit [Ping timeout: 276 seconds]
olbat has quit [Ping timeout: 240 seconds]
bmcginty has joined #crystal-lang
olbat has joined #crystal-lang
olbat has quit [Ping timeout: 240 seconds]
olbat has joined #crystal-lang