<FromGitter>
<jwoertink> Is there a way to have something call before / after every method is ran? I'm thinking from a profiling aspect where I want to see an overview of my app, and see what methods take the most memory / time to run
<FromGitter>
<Blacksmoke16> wrap stuff in a block?
<FromGitter>
<jwoertink> Well, I want to know the entire application, so wrapping every method individually would be super cumbersome... but maybe that's the only way?
<FromGitter>
<Blacksmoke16> probably?
<FromGitter>
<jwoertink> sounds like time for a macro! π
JuanMiguel has quit [Quit: This computer has gone to sleep]
JuanMiguel has joined #crystal-lang
JuanMiguel has quit [Quit: This computer has gone to sleep]
sorcus has quit [Ping timeout: 240 seconds]
sorcus has joined #crystal-lang
JuanMiguel has joined #crystal-lang
alexherbo27 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 265 seconds]
alexherbo27 is now known as alexherbo2
JuanMiguel has quit [Quit: This computer has gone to sleep]
alexherbo2 has quit [Ping timeout: 255 seconds]
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter>
<andrewc910> Quick question. What makes C 'portable'? Is crystal as portable? Can it be? Why or why not?
<FromGitter>
<stronny> Depends on the context. C is the universal language for every CPU arch and every OS there is. It doesn't mean the same program would compile and run unmodified, but the languange is the same.
<FromGitter>
<tenebrousedge> C is easy to port, but not necessarily "portable"
<FromGitter>
<stronny> Overall the question needs to be more specific, because the word "portable" may mean different things.
alexherbo2 has joined #crystal-lang
<FromGitter>
<j8r> Java is more portable
<FromGitter>
<j8r> Compile once, run everywhere TM
<FromGitter>
<stronny> Think embedded
<FromGitter>
<stronny> Java does not run native, first you will have to develop its jre, probably in C lol
<FromGitter>
<j8r> @andrewc910 I don't know what's exactly your question, can it be more specific?
<FromGitter>
<j8r> Platform support you mean?
<FromGitter>
<j8r> Then it is because C is more widely used
<FromGitter>
<tenebrousedge> Well, as a high level language it's probably less likely to be as portable as C no matter what the context is
<FromGitter>
<stronny> Crystal is as portable as LLVM is
<FromGitter>
<j8r> indeed, C is lower level and can be more efficient
<FromGitter>
<j8r> For instance micro controllers
<FromGitter>
<tenebrousedge> you can make C run on literally anything with enough effort. Crystal is likely to fall short of "literally anything"
<FromGitter>
<stronny> "make C run" sure, if you write your own compiler
<FromGitter>
<stronny> brainfuck is much simpler though
<FromGitter>
<stronny> but as much less useful, so there is potential, but not enough effort
<FromGitter>
<tenebrousedge> this is probably all true
dwdv has joined #crystal-lang
<FromGitter>
<andrewc910> Thanks for all the input! I'm sorry I can't make it more specific. I hear the word portable in Arduino and several other places.
<FromGitter>
<andrewc910> I just didn't know what it meant.
<FromGitter>
<Daniel-Worrall> You know what's better than Java portability? Webassembly :^)
<FromGitter>
<stronny> in Arduino case it's probably about CPU architectures other than amd64
<FromGitter>
<andrewc910> So c is portable because it can run on almost every machine? It's not about size? I figured portable meant the compiler/language was small.
<FromGitter>
<stronny> it means that for any given arch probably at least one compiler exists
<FromGitter>
<andrewc910> Can you even compare haha portability to webassembly? Are they comparable? :O
<FromGitter>
<andrewc910> Got it! So crystal is not portable because it works on Linux and mac and that's it?
<FromGitter>
<stronny> linux and mac are not CPU architectures
<FromGitter>
<stronny> try compiling Crystal for itanium or mips
<FromGitter>
<stronny> maybe it's even possible, idk
olbat has quit [Remote host closed the connection]
<FromGitter>
<andrewc910> So what makes C able to compile on any architecture? What's holding crystal back from essentially universal compilation?
<FromGitter>
<stronny> the work of people that made it possible?
<FromGitter>
<andrewc910> Do you have to write an architectural compliant compiler for each one?
<FromGitter>
<stronny> of course
<FromGitter>
<tenebrousedge> C is a fairly low-level language. It's been compared to a "generic assembly language"
<FromGitter>
<andrewc910> Is crystal not that low? I thought compiled languages were as low as you can go before ASM? Even as a compiled language, there are levels(ie crystal is higher than c?)
<FromGitter>
<stronny> that's a nuanced question
<FromGitter>
<andrewc910> So C is universal because hundreds of compilers have been made? Crystal theoretically could be if people created compilers for each architecture?
<FromGitter>
<andrewc910> How so?
<FromGitter>
<andrewc910> Sorry if this is really basic. I've only worked with ruby and js. This is all new to me.
<FromGitter>
<stronny> Crystal does link native binaries, but it has a substantial amount of "prelude" that goes with it
early has quit [Quit: Leaving]
<FromGitter>
<tenebrousedge> C is something like the least complex useful language. It doesn't take much to implement it, or to write a compiler that implements it
<FromGitter>
<andrewc910> Crystal is more complex than c?
<FromGitter>
<stronny> way more
<FromGitter>
<andrewc910> What do you mean by "links native binaries_?
<FromGitter>
<stronny> I can't answer in small amount of text sorry
<FromGitter>
<andrewc910> What makes it more complex on a technical level? It just has a larger stdlib thus the compiler needs to know more/do more work?
<FromGitter>
<stronny> fibers for one
<FromGitter>
<tenebrousedge> that's more-or-less the case, yes
<FromGitter>
<stronny> event loop for the other
<FromGitter>
<tenebrousedge> garbage collection is a big one
<FromGitter>
<stronny> that too yes
early has joined #crystal-lang
<FromGitter>
<andrewc910> Crystal handles memory for us while c doesn't? Because of that, the C compiler expects you(the programmer) to take care of that which means a simpler compiler?
<FromGitter>
<andrewc910> C isn't multithreaded? Or it can be with a lot of work?
<FromGitter>
<stronny> not going down tha rabbit hole that's a valid statement
<FromGitter>
<stronny> threads have nothing to do with language
<FromGitter>
<andrewc910> So why do fibers make the compilation more complex?
<FromGitter>
<andrewc910> Btw, thanks for all the input! I really appreciate it π
<FromGitter>
<stronny> fibers have nothing to do with threads ;)
<FromGitter>
<andrewc910> Hmmm, il lhave to read about fibers than
<FromGitter>
<andrewc910> Thought fibers == threads but I guess that's wrong
<FromGitter>
<tenebrousedge> fibers and garbage collection tend to be complex in ways that are less portable than e.g. integers
<FromGitter>
<stronny> in crystal fibers work by switching a stack pointer
<FromGitter>
<stronny> in a nutshell
<FromGitter>
<stronny> threads live in kernel
<FromGitter>
<andrewc910> I don't see how threads & garbage collection are comparable to integers. I'll have to read about this more
<FromGitter>
<stronny> they aren't, the example is integers are easier to implement portably
<FromGitter>
<andrewc910> Will also look up stack pointer.
alexherbo2 has quit [Ping timeout: 258 seconds]
<FromGitter>
<andrewc910> Ohhh! That makes more sense
<FromGitter>
<stronny> yes. coming from ruby and js that's indeed a bunch to take on
<FromGitter>
<andrewc910> Fun fact, I can actually read some of that. Pokemon Ron hacking ftw!
<FromGitter>
<andrewc910> But okay I'll make sure to understand this method. I'll look up something later π
<FromGitter>
<stronny> you only need to do that if for some special expertise
<FromGitter>
<andrewc910> So all in all, crystal isn't aiming to be C? Crystal is more complex and will hopefully work on most major architectures but will never reach the portability of c? Is that right?
<FromGitter>
<stronny> if you need C you use C
<FromGitter>
<stronny> you use Crystal if you *don't* need C
<FromGitter>
<andrewc910> Sad face. Hoping crystal would eventually be universal :/
<FromGitter>
<stronny> that would never come to pass
<FromGitter>
<tenebrousedge> Crystal is very much not trying to be a replacement for C
<FromGitter>
<stronny> luckily you don't need C that often
<FromGitter>
<andrewc910> So what is crystal trying to achieve? Faster ruby? Because it feels like most work goes into HTTP
<FromGitter>
<tenebrousedge> high-level languages tend to be more productive. Low-level languages are more flexible. There's nothing wrong with either
<FromGitter>
<tenebrousedge> HTTP is one of the fastest paths to a user interface
<FromGitter>
<stronny> that's for everyone to decide on their own
<FromGitter>
<stronny> for me that's static analysis and simpler deployment
<FromGitter>
<tenebrousedge> I like the speed of Crystal, and I like not having `NoMethodError` in production
<FromGitter>
<stronny> well you can have that in Crystal actually
<FromGitter>
<stronny> but not as often
<FromGitter>
<andrewc910> @tenebrousedge yeah I know you see that error as I see you in the rails gutter lol
<FromGitter>
<tenebrousedge> only at compile time. All methods have to exist at runtime
<FromGitter>
<andrewc910> Luckily I haven't seen that error in crystal
<FromGitter>
<stronny> you can even have that in C with fptrs
<FromGitter>
<andrewc910> "simpler deployment" what makes crystal simpler to deploy than what language you typically deploy in?
<FromGitter>
<stronny> `my_proc.call` and there you go
<FromGitter>
<stronny> you only need the compiled binary and the dlls, you don't need the runtime and every gem/npm dependency
<FromGitter>
<stronny> dlls live in the system repo by the way, you don't vendor them either
<FromGitter>
<andrewc910> Well dart, although can be used for backend, is used for frontend(flutter). Ruby is used with rails and other frameworks but let's be real, typically rails. Js is used for frontend/backend web. C++ for native desktop applications. Does crystal have an aim or are we still figuring that out?
<FromGitter>
<andrewc910> That's why I asked the goal of crystal.
<FromGitter>
<andrewc910> While most languages can do a lot, most languages are typically used for a very specific purpose.
<FromGitter>
<stronny> that's a naive way to look at things
<FromGitter>
<stronny> from where I stand Crystal is cool for client-side programs that finish rather quickly
early has quit [Ping timeout: 255 seconds]
<FromGitter>
<stronny> something like API clients or system utilities
<FromGitter>
<stronny> I'm a minority though
<FromGitter>
<andrewc910> What makes it naive? As a beginner, I seems like a very specific language used for a specific purpose most of the time. Most of time. Most Linux applications are c++(except fucking slack), most Android apps are java, mac is swift, web servers are obviously anything from c# to ruby.
<FromGitter>
<stronny> don't take it as an attack but much to learn have you yet =)
<FromGitter>
<andrewc910> If I'm wrong, I am wrong. Just see most languages used for one specific thing. Tbh, really hoping crystal doesn't become a one trick http pony.
<FromGitter>
<stronny> by the way `pony` looks very promising
<FromGitter>
<andrewc910> Hence why I am asking questions! :) Would never take is as an attack...unless you literally attack me xD
<FromGitter>
<andrewc910> Pony is a language?
<FromGitter>
<stronny> yep
<FromGitter>
<andrewc910> Of course it is.
<FromGitter>
<andrewc910> I'll stick to ruby right now π
<FromGitter>
<stronny> ruby is fine
<FromGitter>
<andrewc910> Oh but can you atleast explain why that thought process is wrong? If not, no worries
<FromGitter>
<stronny> let's go through the list again
<FromGitter>
<andrewc910> In response to "that's a naive way to look at things"
<FromGitter>
<stronny> especially that "C++ for native desktop applications"
<FromGitter>
<andrewc910> Is it used in other areas?
<FromGitter>
<stronny> very much so
<FromGitter>
<andrewc910> That makes me sad. Idk c++ but Reddit has made me not want to know c++ :)
<FromGitter>
<stronny> everywhere, name a field there's a ton of ++ code there
<FromGitter>
<stronny> even embedded and kernel
<FromGitter>
<stronny> even web services
<FromGitter>
<andrewc910> Hmm, I guess I need to expand my knowledge of fields. All I can think of is desktop, mobile and web. I'm gonna take a wild guess and say there is more than those 3.
<FromGitter>
<stronny> that's what I meant by naive =)
<FromGitter>
<andrewc910> I know c++ is used quite a bit in kernels. Tried looking at zircon/fuchisa with little success
<FromGitter>
<andrewc910> What's embedded?
<FromGitter>
<stronny> think pebble watch
<FromGitter>
<andrewc910> Are all smart watches embedded?
<FromGitter>
<stronny> no
<FromGitter>
<stronny> most are just android/ios
<FromGitter>
<stronny> basically you have a 33MHz and 32K ram
<FromGitter>
<stronny> that's embedded
<FromGitter>
<andrewc910> So embedded is 90s computers is small devices?
<FromGitter>
<stronny> yes, small chips
<FromGitter>
<andrewc910> Sorry, realistically embedded is just very small computers?