<FromGitter>
<arc512> I've noticed crystal compile time is very slow, is there a reason for this?
<FromGitter>
<AustinPaquette> :point_up:
<FromGitter>
<AustinPaquette> Desperately want a solution for this as well. Super excited about using it, but compiling needs to be faster :/
<FromGitter>
<arc512> Golang is quite fast at this, I'm wondering if Crystal binaries are fatter than Go's
<FromGitter>
<arc512> how does Crystal binaries compare to Go?
<FromGitter>
<fridgerator> I don't know much about the compiler process, otherwise I would try and answer your questions
<FromGitter>
<fridgerator> A sample web app with the entire amber web framework is 4.4 mb ?!?
<FromGitter>
<fridgerator> I don't know if that helps at all
<adam12>
If you compare binary sizes, make sure you do so with the --release flag on Crystal. It can be 1/3 less the size than non-release flag.
<FromGitter>
<drosehn> For the kinds of programs I write, crystal compiles pretty fast if you don't use the `--release` flag. But then `--release` does do a really good job of speeding up your program.
<FromGitter>
<AustinPaquette> I want to use it for a pretty sizable application but it’s just not possible cause compiling already takes a while (even out of the box)
<FromGitter>
<AustinPaquette> I do agree though that it’s super fast when it *is* compiled. I just need dev time not to suffer as a result of it.
Philpax_ has joined #crystal-lang
Philpax has quit [Ping timeout: 246 seconds]
hightower2 has quit [Ping timeout: 258 seconds]
<FromGitter>
<bigtunacan> @drujensen I see you are working on a mailer shard. What's the status on that one? You used it with anything yet?
<FromGitter>
<bigtunacan> Was wondering since that smtp lib hasn't been updated in quite awhile if it's working with the latest version of Crystal.
<FromGitter>
<bigtunacan> Would be good to see smtp in the core APIs
rohitpaulk has joined #crystal-lang
pleiosau1 has quit [Remote host closed the connection]
Kug3lis_off is now known as Kug3lis
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
Kug3lis is now known as Kug3lis_off
rohitpaulk has quit [Ping timeout: 268 seconds]
<crystal-gh>
[crystal] MakeNowJust opened pull request #4591: Semantic: specify Void alias type as yiled output restriction (master...fix/crystal/type-alias-restriction-yield) https://git.io/vHjDV
olek_poz has joined #crystal-lang
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Yxhuvud>
svenskunganka: what happens if you use crystal tool format on the file
<FromGitter>
<bew> svenskunganka, I think it's because how you define blocks: `register_up |db| do` should be `register_up do |db|`
rohitpaulk has joined #crystal-lang
pleiosaur has joined #crystal-lang
<FromGitter>
<bew> Also, your variable `Migrations` should be a hash not an array, as you do `Migrations[ver] = mig`, and additionally identifiers starting with an Uppercase (like `Migrations` denotes a type, you should use class variables for this imo
<FromGitter>
<bew> @AustinPaquette can you give examples? What time is slow for you?
<crystal-gh>
[crystal] MakeNowJust opened pull request #4592: Parser: fix #4590, correct to parse empty parenthesis "()" (master...fix/crystal/4590-wrap-paren-nop) https://git.io/vHjy5
<FromGitter>
<bigtunacan> @fridgerator I'm trying out Crecto and running into some errors.
<FromGitter>
<bigtunacan> Macro didn't expand to valid program...
hightower2 has joined #crystal-lang
<svenskunganka>
@bew thanks for the response. Is class variables mutable from "another file"? I don't come from a Ruby background so the whole syntax is new to me
<svenskunganka>
On the `Migration.migrations[ver] = migration` line, `ver` is an `Int` so I add the migration to the index `ver`.
<Yxhuvud>
They are.
<Yxhuvud>
I can recommend doing a dupe check on the versions, by the way
<svenskunganka>
Yeah I have some error checking and blanks yet to fill in of course
hightower2 has quit [Ping timeout: 246 seconds]
olek_poz has quit [Ping timeout: 240 seconds]
<FromGitter>
<bew> svenskunganka, in crystal you cannot insert a new value at a specific index of an array
<FromGitter>
<bew> If you create an empty array, the array has a size of 0.
<FromGitter>
<bew> From the doc you linked: Raises IndexError if trying to set an element outside the array's range.
<svenskunganka>
Ah yeah, I think I need to use Macros to create the size of the array at compile-time, since the size of the array will be known at compile-time.
<Yxhuvud>
no, just use << to insert new elements and make certain you insert them in the order you want to
<Yxhuvud>
(or use a hash table or whatever)
olek_poz has joined #crystal-lang
<svenskunganka>
@Yxhuvud: Alright, I've made some changes now which I feel better about, but I still run into an error: https://gist.github.com/Svenskunganka/27d7831187520bc63609ea6eceaed97c. The problem is that I want the 1.cr code to pretty much run at compile-time, so that the `@@migrations` hash in `Project::Migration` is already populated at runtime, which was why I thought I might need to use a macro.
<Yxhuvud>
the problem there is that the code assume that there is a migration in the next slot, but there is no such guarantee. Put it in a variable, and check it for nil and the problem go away.
<Yxhuvud>
Hmm, actually no. That is not the issue. I have no idea what
<svenskunganka>
I'm just unsure what code the compiler "optimizes" away
<FromGitter>
<bew> Yxhuvud it's part of it at least, because if he doesn't call `register_up` the `@up` won't be set, and be defaulted to Nil
<Yxhuvud>
bew: Right, but neither up or down is declared or initialized in the initializer. @svenskunganka: what version of crystal do you use?
<svenskunganka>
I've made some changes to the gist now with nil checking.
<svenskunganka>
0.22
<svenskunganka>
Same error tho
<FromGitter>
<arc512> is this a good way to call an external json file:
<Yxhuvud>
apart from your strange way of words, yes that would *read* the json file unless it is really huge
<svenskunganka>
Yxhuvud: in migration.cr, I explicity set the type of `@up` variable to be a `Proc(DB::Database, Bool)`, but why does it then assume it's a union type of `(Proc(DB::Database, Bool), Nil)`? Is it because the procs are not passed in the `initialize` method?
<Yxhuvud>
yeah, they can be uninitialized.
<svenskunganka>
From my testing, it is not possible to pass multiple procs to a method, if I were to pass the up & down procs directly to the initializer
<svenskunganka>
Instead of using the `register_up` and `register_down` methods
<svenskunganka>
I.e this does not work: `def initialize(@version : Int32, &up, &down) { @up = up; @down = down }`
<svenskunganka>
Ish
<svenskunganka>
Psuedocode
<FromGitter>
<bew> svenskunganka, usually a migration is defined by a class that defines 2 method `up` and `down`
rohitpaulk has quit [Ping timeout: 240 seconds]
<svenskunganka>
Yeah, but that seems very inefficient to me. Having to create `Project::Migration1` `Project::Migration2` etc?
rohitpaulk has joined #crystal-lang
<FromGitter>
<bew> it's quite the same as having versions, and it should force you to name your migration against what your migration do, instead of just a number (which desn't mean a lot in my sense)
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter>
<arc512> @yxhuvud what do you mean by huge json, my json is 200 lines but I get runtime errors like:
<svenskunganka>
@arc512: That error says that it can't find the file `./blocks.json`.
<svenskunganka>
@arc512: what Yxhuvud means is that if your JSON files is large in size (say, 200MB) it would require the machine where your program runs to have at least 200MB of available memory to use.
<FromGitter>
<arc512> the file is in the same folder as the executable
<crystal-gh>
[crystal] ysbaddaden opened pull request #4594: Fix: use platform specific Pointer sizes (master...fix-platform-specific-pointer-sizes) https://git.io/vHjNy
splitty__ has joined #crystal-lang
splitty_ has quit [Ping timeout: 240 seconds]
svenskunganka has quit [Read error: Connection reset by peer]
svenskunganka has joined #crystal-lang
<FromGitter>
<drosehn> Before the read, try: `p Dir.current`
zipR4ND has joined #crystal-lang
zipR4ND has quit [Ping timeout: 260 seconds]
<FromGitter>
<arc512> what is the best way to cast unstructured json data from a file
<FromGitter>
<arc512> I've tried ```blocks = JSON.parse(file).as(Array)``` but doesn't work
davidbe[m] has quit [Ping timeout: 264 seconds]
<FromGitter>
<straight-shoota> `JSON.parse` returns an `JSON::Any` (https://crystal-lang.org/api/0.22.0/JSON/Any.html) so you can use `#as_a` to cast it's raw value to an Array if you're sure it is always an Array
<FromGitter>
<straight-shoota> You can also iterate it directly (`JSON::Any` is an `Enumerable`)
zipR4ND has joined #crystal-lang
davidbe[m] has joined #crystal-lang
<FromGitter>
<sdogruyol> 7 stars to pass Scala on GH programming languages list :P
<Yxhuvud>
svenskunganka: no, I mean that if it is larger than 2GB then File.read doesn't work anymore.
splitty___ has joined #crystal-lang
splitty__ has quit [Ping timeout: 240 seconds]
svenskunganka has quit [Quit: leaving]
zipR4ND has quit [Ping timeout: 240 seconds]
<FromGitter>
<bararchy> I just made a CSV db of 4.2Gb using Crystal , it was fun hahah :)
_whitelogger has joined #crystal-lang
<FromGitter>
<sdogruyol> @bararchy how's the speed
<FromGitter>
<bararchy> well .... It's a huge text processeor, the CSV has 2 tables ⏎ Huge text | small string ⏎ the huge text is begin converted to array of int32 based on `char.ord`, so each char is tested and converted, all in all it's a big effort on CPU and a huge mem eater, I do think that right now MultiThreading would have been nice :)
olek_poz has quit [Ping timeout: 255 seconds]
A124 has quit [Quit: '']
A124 has joined #crystal-lang
<FromGitter>
<bigtunacan> @fridgerator I'm just starting to try out Crecto in a project I'm working on. I was wondering if it supports custom validators in the models and if so how that would look?
<FromGitter>
<bigtunacan> Thanks; I think that's what I need
<FromGitter>
<fridgerator> :thumbsup:
jfontan has quit [Remote host closed the connection]
jfontan has joined #crystal-lang
<crystal-gh>
[crystal] ysbaddaden closed pull request #4594: Fix: use platform specific Pointer sizes (master...fix-platform-specific-pointer-sizes) https://git.io/vHjNy
hightower2 has joined #crystal-lang
<FromGitter>
<nickbclifford> how does one use `Slice#move_to`? I'm trying to use this to convert a `Slice` (used in a `File.read`) into a C `struct`.
<FromGitter>
<nickbclifford> I'm not convinced that this is the right way though, so feel to tell me if there's a better way to read bytes into a C `struct`
<RX14>
@nickbclifford why do you want to do that?
<RX14>
reading directly into a struct sounds like a bad idea to me
<FromGitter>
<drujensen> @bigtunacan yes, it works. sorta. I will be adding multi-part support so you can send text/html/attachments soon.
<FromGitter>
<bew> When I run that kind of code without spec-related methods it works perfectly, the types are ok, and I can call `target_result.succ`. But in the spec's `it` block the types are somewhat broken..
<FromGitter>
<bew> ok, but I don't get why the block capture will make it behave like that
<FromGitter>
<bew> my 2 `if`s are in the block
<FromGitter>
<bigtunacan> @drujensen is that a change in the SMTP shard layer or is that a change that needs to happen in your shard?
<RX14>
@bew because any variable which is in the block closure can be changed at any time
<RX14>
it's essentially like an instance variable
<FromGitter>
<bew> oh
Kug3lis has joined #crystal-lang
<RX14>
make copies of the variables
<RX14>
inside the closure
<FromGitter>
<bew> ok I'll try
<FromGitter>
<bew> works now, thanks RX14 ;)
<FromGitter>
<bew> now I'm having a hard time to find another name for the original variable (which will be closured), I have `_target_result` or `outer_target_result` or `target_result_original` which are quite ugly...... I take any suggestion!
<FromGitter>
<bigtunacan> @bew are usually just use the same name and add an __in at the front
<FromGitter>
<bew> so be it! thanks
olek_poz has joined #crystal-lang
saadq has quit [Ping timeout: 246 seconds]
<FromGitter>
<bigtunacan> @fridgerator I tried inserting a duplicate record where I have a unique constraint on a column with Crecto to see what would happen.
<FromGitter>
<bigtunacan> It completely freezes the application. Just hangs and never finishes.