<FromGitter>
<Blacksmoke16> so given 1.0.0 is nearing, whats the ideal `crystal` string these days. IIRC just including like `crystal: 0.35.1` isn't good enough for `1.x.x` versions?
<FromGitter>
<naqvis> `1.0.0-alpha` ?
<FromGitter>
<ImAHopelessDev_gitlab> hai
<FromGitter>
<naqvis> hi Girng
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 240 seconds]
<FromGitter>
<Blacksmoke16> But wouldn't that prevent it from work with 0.35.x
<FromGitter>
<3n-k1> shouldn't that be the case? wouldn't you want it to break because it's the first major release?
<FromGitter>
<Blacksmoke16> Well in my case 0.35.x will be essentially the same as 1.x
<FromGitter>
<3n-k1> but why?
<FromGitter>
<Blacksmoke16> None of the breaking changes affected things, so is bc
<FromGitter>
<3n-k1> add a special case in shards?
<FromGitter>
<naqvis> then you shouldn't be bumping the version number
<FromGitter>
<3n-k1> i agree. 1.0 is a *fantastic* time to make any huge breaking changes you want. if you aren't making those, i think you're wasting it
<FromGitter>
<Blacksmoke16> to be clear im not talking about releasing 1.x of my shard
<FromGitter>
<Blacksmoke16> so heres maybe a silly question
<FromGitter>
<Blacksmoke16> say im doing something like `response = HTTP::Server::Response.new IO::Memory.new`
<FromGitter>
<Blacksmoke16> in order test a web context without actually running a server, but im trying to figure out how to actually access the response body...
<FromGitter>
<Blacksmoke16> or maybe im going about this the wrong way
<FromGitter>
<naqvis> i mostly run a webserver inside a TC
woodruffw has quit [Ping timeout: 260 seconds]
<FromGitter>
<Blacksmoke16> TC?
<FromGitter>
<naqvis> test case :P
<FromGitter>
<Blacksmoke16> ah, thats what im doing now but was hoping to avoid the need to actually run the server
woodruffw has joined #crystal-lang
<FromGitter>
<Blacksmoke16> like i dont really need to test the stdlib implementation
<FromGitter>
<Blacksmoke16> and all the system related things that comes with
<FromGitter>
<naqvis> yeah, but shouldn't we be mocking the actual call to validate the code working properly?
<FromGitter>
<naqvis> also this way we can mock the networking error etc
<FromGitter>
<Blacksmoke16> thats an idea, maybe do something like that and yield the response
<FromGitter>
<naqvis> should be okay if client code is expecting a HTTP::Response
<FromGitter>
<Blacksmoke16> to add more context, mainly making something for integration testing controllers
<FromGitter>
<naqvis> aah gotcha
<FromGitter>
<Blacksmoke16> which in my case i dont really need the server as i can mock the request going in, just dont have a way to mock the response that comes back since i cant access the response body
<FromGitter>
<Blacksmoke16> i mean not really "mock" but like make it write to something that isnt a client IO or something
<FromGitter>
<Blacksmoke16> i wonder
<FromGitter>
<naqvis> just a thought, how about monkey patching the `HTTP::Server::Response` ?
<FromGitter>
<Blacksmoke16> yea thats what i was thinking
<FromGitter>
<naqvis> that is just a wrapper against an IO
<FromGitter>
<Blacksmoke16> hmm, downside its going to have all the other http stuff like headers
<FromGitter>
<Blacksmoke16> prob could just split on like `\r\n\r\n`?
<FromGitter>
<Blacksmoke16> i would have thought i could access the ivars in the child scope
<FromGitter>
<Blacksmoke16> that were added in the parent scope
<FromGitter>
<naqvis> yeah, but macro expansion happening at compile time
<FromGitter>
<naqvis> so don't think compiler will first expand the parent, update the AST and then forward that updated AST to child macro expansion
<FromGitter>
<naqvis> seems its happening without giving the updated context back to child
<FromGitter>
<Blacksmoke16> :sad:
<FromGitter>
<naqvis> rip
<FromGitter>
<naqvis> :P
<FromGitter>
<Blacksmoke16> plan b
<FromGitter>
<naqvis> 👍
tsujp has quit [Ping timeout: 264 seconds]
<FromGitter>
<Blacksmoke16> plan c
<FromGitter>
<naqvis> hahaha
tsujp has joined #crystal-lang
<FromGitter>
<Blacksmoke16> might need some DI updates to support what i want
<FromGitter>
<naqvis> so that's more work
<FromGitter>
<Blacksmoke16> naw, 3 lines
<FromGitter>
<Blacksmoke16> so this is what i did
<FromGitter>
<Blacksmoke16> `class MockableServiceContainer < ADI::ServiceContainer; end` made a new container class that i use in place of the real one in test context
<FromGitter>
<Joe23232> Hi I am checking out this language but I have a few questions regarding this language. ⏎ ⏎ 1) Does it use a GC or reference counting by default or something that can cause overhead during runtime execution of the program? ⏎ 2) Is it a compiled language? ⏎ 3) Is this a typical programming language used to develop applications or is it for for web development and can be used as a replacement of the Ruby
<FromGitter>
<naqvis> Welcome aboard @Joe23232 . I'll try to provide my answer to your questions (based on my own understanding and experience). ⏎ ⏎ 1) Crystal is GC enabled language and by default comes with GC. But it does allow you to turn the GC on/off (rare case, but functionality is provided) ⏎ 2) Yes , Crystal is type safe and compiled language ⏎ 3) Crystal is General purpose programming language ...
<FromGitter>
<Joe23232> By any chance do you know a system programming language that is as easy to use as Crystal/Python/NIm?
<FromGitter>
<naqvis> Nim touts itself as a System programming language
<FromGitter>
<naqvis> so you might consider that
<FromGitter>
<Joe23232> But it also has GC as well
<FromGitter>
<Joe23232> just like Crystal
<FromGitter>
<naqvis> but Nim allows to disable GC
<FromGitter>
<Joe23232> Isn't that the same as Crystal?
<FromGitter>
<naqvis> if you are more into C syntax then you might take a look into Zig (https://ziglang.org/)
<FromGitter>
<Joe23232> as you mentioned above for no 1?
<FromGitter>
<Joe23232> > if you are more into C syntax then you might take a look into Zig (https://ziglang.org/) ⏎ ⏎ AH yeah I have heard of Zig
<FromGitter>
<naqvis> if you are targeting for system programming, I would say look no further but into Modern C++
<FromGitter>
<naqvis> modern C++ is far more better and easier to learn and is the right language for such tasks
<FromGitter>
<Joe23232> I see
<FromGitter>
<Joe23232> what about Rust?
<FromGitter>
<naqvis> modern C++ features like smart pointers, RAII and its huge ecosystem offer the right tool
<FromGitter>
<Joe23232> I thought Rust was more suited over C++ due to its safety features?
<FromGitter>
<naqvis> Rust Borrow-checker concept is hard to grasp
<FromGitter>
<naqvis> modern C++ RAII and smart pointers takes that borrow-checking burden away from programmer
<FromGitter>
<Joe23232> does it have overhead?
<FromGitter>
<naqvis> no
<FromGitter>
<Joe23232> Oh interesting
<FromGitter>
<naqvis> C++ is what they call zero cost abstractions
<FromGitter>
<Joe23232> But I thought it can be very easy to cause memory leaks?
<FromGitter>
<Joe23232> and its very hard to do memory management with C++ compared to Rust
<FromGitter>
<naqvis> if you stick to modern c++, trust me you won't
<FromGitter>
<Joe23232> > if you stick to modern c++, trust me you won't ⏎ ⏎ Oh ok cool then
<FromGitter>
<naqvis> STL and their libraries are designed and developed by professionals
<FromGitter>
<Joe23232> What is STL?
<FromGitter>
<naqvis> don't do manual memory management in C++, you will be fine
<FromGitter>
<naqvis> STL = Standard Template Library
<FromGitter>
<Joe23232> > STL = Standard Template Library ⏎ ⏎ I see
<FromGitter>
<Joe23232> > don't do manual memory management in C++, you will be fine ⏎ ⏎ How come Rust people keep stating that it is better than C++ etc?
<FromGitter>
<Joe23232> If C++ can do memory management just fine?
<FromGitter>
<naqvis> they must be comparing it to C++ with manual memory management
<FromGitter>
<Joe23232> > they must be comparing it to C++ with manual memory management ⏎ ⏎ Oh I see. Have you used both languages before?
<FromGitter>
<naqvis> C++ is 40 years old language, but it has grown and evolved into what they call modern C++
<FromGitter>
<naqvis> C++11 and onwards
<FromGitter>
<naqvis> C++20 now
<FromGitter>
<Joe23232> > C++11 and onwards ⏎ ⏎ Oh that is awesome
<FromGitter>
<naqvis> use smart pointers and you needn't to worry about memory management
<FromGitter>
<Joe23232> > C++20 now ⏎ ⏎ So is C++20 just as safe as Rust?
<FromGitter>
<Joe23232> > use smart pointers and you needn't to worry about memory management ⏎ ⏎ Awesome
<FromGitter>
<naqvis> learn and target yourself for C++17, as not every compiler fully support C++20 at this moment :P
<FromGitter>
<naqvis> i would say, you should learn and evaluate yourself and see which language clicks for you
<FromGitter>
<naqvis> as 10 people and you will get 10 different answers :P
<FromGitter>
<naqvis> > ask 10 people and you will get 10 different answers :P
<FromGitter>
<Joe23232> > ask 10 people and you will get 10 different answers :P ⏎ ⏎ Yep that is the unfortunate truth, a lot of people say things that are incorrect about other languages and really it makes it a huge problem :(
<FromGitter>
<Joe23232> > use smart pointers and you needn't to worry about memory management ⏎ ⏎ If I wrote an OS with modern C++, would it be just as safe as if it were written in Rust?
<FromGitter>
<Joe23232> with memory safety?
<FromGitter>
<naqvis> I would say yes
<Andriamanitra>
it is possible to write unsafe code with rust, and it is possible to write safe code with c++
<FromGitter>
<naqvis> C++ is well suited for such things
<Andriamanitra>
it's all about how you use the language
<FromGitter>
<Joe23232> I see
<Andriamanitra>
that said, rust *really* tries to steer you in the right direction, it's very hard to accidentally write unsafe code
<FromGitter>
<Joe23232> > *<Andriamanitra>* that said, rust *really* tries to steer you in the right direction, it's very hard to accidentally write unsafe code ⏎ ⏎ That is one good thing about Rust
<FromGitter>
<Joe23232> > C++ is well suited for such things ⏎ ⏎ Just out of curiosity, have you ever used Rust before?
<FromGitter>
<naqvis> Yes I did
<FromGitter>
<Joe23232> Are you proficient in it?
<FromGitter>
<naqvis> I've used and developed in languages which I mentioned above and share my own personal opinions
<FromGitter>
<Joe23232> Ah I see
<FromGitter>
<Joe23232> Is it difficult to learn modern C++
<FromGitter>
<naqvis> nope
<FromGitter>
<Joe23232> Cool
<Andriamanitra>
i have written short bits of code in rust but nothing major - it's a nice language
<FromGitter>
<naqvis> modern C++ is much easier to learn, as it has evolved and get influenced from other modern languages
<FromGitter>
<Joe23232> > *<Andriamanitra>* i have written short bits of code in rust but nothing major - it's a nice language ⏎ ⏎ Oh I am glad you had a better experience with it compared to me
<FromGitter>
<Joe23232> > modern C++ is much easier to learn, as it has evolved and get influenced from other modern languages ⏎ ⏎ Oh nice mate
<FromGitter>
<Joe23232> Well another question, I have heard that OOP languages are slower languages than structural languages such as C, is this true?
<Andriamanitra>
i don't like c++ myself, i find the syntax a bit cumbersome and the long history is a bit of a burden
<yxhuvud>
downside of c++ is that it is a *big* language with lots of old cruft though. And that cruft can come back and bite your ass, especially if you end up working on an existing code base
<FromGitter>
<Joe23232> > *<yxhuvud>* downside of c++ is that it is a *big* language with lots of old cruft though. And that cruft can come back and bite your ass, especially if you end up working on an existing code base ⏎ ⏎ Oh wow, is this the same case with Rust?
<Andriamanitra>
yxhuvud: yeah, i completely agree with that
<yxhuvud>
no. Rust don't have the history of old cruft
<FromGitter>
<Joe23232> I see
<FromGitter>
<Joe23232> Which language do you personally find easier to use, Rust or modern C++?
<FromGitter>
<naqvis> you won't get unified answer :P, it varies from programmer to programmer
<FromGitter>
<Joe23232> Ah right
<FromGitter>
<Joe23232> =D
<FromGitter>
<naqvis> as I said above, you should learn and evaluate things by yourself
<Andriamanitra>
and as for the performance, of course nothing usually beats C but you can get reasonably close with high level languages, i wouldn't worry about it
<FromGitter>
<Joe23232> THanks bro
<FromGitter>
<Joe23232> > as I said above, you should learn and evaluate things by yourself ⏎ ⏎ True mate
<FromGitter>
<Joe23232> Just one last question, do you know good artificial inteligence libraries for C++
<FromGitter>
<Joe23232> which is easy to use?
<FromGitter>
<naqvis> your specific use case?
<FromGitter>
<naqvis> AI is broad term
<FromGitter>
<Joe23232> maybe like image processing
<FromGitter>
<naqvis> OpenCV
<FromGitter>
<Joe23232> Is that easy to use
<FromGitter>
<naqvis> yeah
<Andriamanitra>
with python it is :p
<FromGitter>
<naqvis> but again that will depend on your use-case
<FromGitter>
<Joe23232> > *<Andriamanitra>* with python it is :p ⏎ ⏎ What about if I used it with C++ instead?
<FromGitter>
<Joe23232> > but again that will depend on your use-case ⏎ ⏎ Image processing
<Andriamanitra>
well then you'll just have to deal with c++ syntax, so not quite as easy
<FromGitter>
<Joe23232> I see
<FromGitter>
<Joe23232> but if I am calliing the functions, would it be done in a similar manner?
<FromGitter>
<naqvis> yeah
<FromGitter>
<Joe23232> I see
<FromGitter>
<Joe23232> thanks man
<FromGitter>
<naqvis> you are welcome
<FromGitter>
<naqvis> if you are new to C++ or programming i would highly recommend https://www.learncpp.com/
<FromGitter>
<Joe23232> > if you are new to C++ or programming i would highly recommend https://www.learncpp.com/ ⏎ ⏎ Sure I will check it out
<FromGitter>
<Joe23232> By the way why did they create Rust if modern C++ already has safety features?
<FromGitter>
<naqvis> 👍
<FromGitter>
<naqvis> languages exists for their own specific use-case or reason
<FromGitter>
<naqvis> or else we would just had only one language
<FromGitter>
<naqvis> each language offers the functionality that will be unique
<FromGitter>
<naqvis> or one language is suited for specific kind of tasks as its standard library/runtime etc offers those functionality which in other languages you had to start from scratch
<FromGitter>
<naqvis> also being a programmer, you will be (i will say should be) learning multiple languages and use the ones which are suited for specific tasks
<FromGitter>
<naqvis> for sure you can use one language to do each and every task, but that will be just waste of effort and resources
<FromGitter>
<Joe23232> I ee mate
<FromGitter>
<Joe23232> *see
<FromGitter>
<Joe23232> Do you know any free and open source game engines that is written in C++ and is ECS and the user can program in C++?
<FromGitter>
<naqvis> there are so many of them
<FromGitter>
<naqvis> just search google or github
<FromGitter>
<naqvis> and you will get plenty of them
<FromGitter>
<naqvis> majority (if not all) of game engines are written in C++ :P
yukai has quit [Ping timeout: 246 seconds]
<FromGitter>
<mattrberry> If I want to be a bad person and read UInt16s out of a UInt8 array, is this my best bet? ⏎ ⏎ ```@framebuffer.to_unsafe.as(UInt16*)[idx] = @pram.to_unsafe.as(UInt16*)[pal_idx]``` [https://gitter.im/crystal-lang/crystal?at=5faa4d608d286f20769e3b1b]
<FromGitter>
<mattrberry> Or even worse, if I want to index into the array with an offset as a uint8, then read a uint16 ;) ⏎ ⏎ ```screen_entry = (@vram.to_unsafe + screen_base).as(UInt16*)[se_idx]``` [https://gitter.im/crystal-lang/crystal?at=5faa4e12d5a5a635f2b0cfb0]
<FromGitter>
<mattrberry> I feel like a c programmer and I hate it
<FromGitter>
<mattrberry> But I kinda love it
Vexatos has quit [Ping timeout: 244 seconds]
<FromGitter>
<mattrberry> Plus if I use this in the bus impl for my gba emulator, I bet I'd get a noticeable performance gain over reading 2 - 4 times out of an array for uint16s and uint32s. I'll throw it in a macro so I don't have to look at it, then actually benchmark it :)
Vexatos has joined #crystal-lang
<jhass>
mattrberry: if you want some safety (in favour of some performance) in there, you could use slices. Otherwise it seems fine, it's assuming endianess of course
<FromGitter>
<mattrberry> I'll take a look! What will a Slice give me other than the `#+(offset : Int)` which would make my second example slightly shorter?
flaviodesousa has quit [Remote host closed the connection]
early` has quit [Quit: Leaving]
sorcus has quit [Ping timeout: 264 seconds]
early has joined #crystal-lang
<FromGitter>
<Joe23232> Thanks
<FromGitter>
<naqvis> 👍
melthelesbian has quit [Read error: Connection reset by peer]
melthelesbian has joined #crystal-lang
kevinsjoberg has quit [Ping timeout: 272 seconds]
kevinsjoberg has joined #crystal-lang
Elouin has quit [Quit: So long and thanks for all the fish!]
Elouin has joined #crystal-lang
<FromGitter>
<j8r> I wonder if there is a "strict mode" in C++, like in JS
<FromGitter>
<j8r> to have backward compatibility while enforcing a better subset of the language
<FromGitter>
<HertzDevil> the general consensus of the committee seems to be that they'll leave that up to third-party static analyzers
<FromGitter>
<j8r> Maybe there are some compiler flags?
<FromGitter>
<j8r> to print warnings
<FromGitter>
<j8r> like `-wall`
<FromGitter>
<HertzDevil> and third-party "guidelines"
<FromGitter>
<HertzDevil> like microsoft's gsl
<FromGitter>
<HertzDevil> (they got their `span`, which is essentially our `Slice`, into c++20, which is nice btw)
<FromGitter>
<j8r> C++ is such an enormous language
<FromGitter>
<j8r> is there a more complex one that it (on the implementation side)?
<FromGitter>
<HertzDevil> warnings are implementation-defined, and it shows
<FromGitter>
<HertzDevil> they had to pull the contracts ts at the last minute because they couldn't agree on compiler-specific warning behaviour iirc
<FromGitter>
<ImAHopelessDev_gitlab> good morning!
<FromGitter>
<Blacksmoke16> o/
<FromGitter>
<ImAHopelessDev_gitlab> I've been away from the community (not from coding in crystal though), any new things happen in the past 2-3 months?
<FromGitter>
<Blacksmoke16> prerelease of 1.0.0 is coming out soon
<FromGitter>
<asterite> You should try using Benchmark.ips
<FromGitter>
<asterite> You don't need to do that n.times, plus you get memory usage
wmoxam has joined #crystal-lang
gangstacat has quit [Ping timeout: 272 seconds]
<FromGitter>
<incognitorobito> Hi everyone, I'm working with a c function that takes a pointer to a preallocated array. How would I notate that in the crystal c bindings? Or should I just do ** in the bindings and then pass a slice?