Crystal 1.0 – What to expect
321–330 of 351 posts
Re: Crystal 1.0 – What to expect
#322Earlier quoted context omitted.
Is this based on experience or just speculation? I have used Crystal to create shared libraries which I've called from various other languages (JS, Dart, Ruby, even C) and it worked well enough.
It's possible, just not officially supported nor straightforward. You need to run the GC yourself and all this kind of stuff. https://stackoverflow.com/questions/32916684/can-a-crystal-l... https://gist.github.com/Papierkorb/02d6ba53c28b5035a80bf7695...
- You do the linking yourself, so that you can pass the flags to produce the kind of library you want. This is something the Crystal compiler helps with (it spits out the LDFLAGS that you need).
- Calling `GC.init` when your library is loaded if you want to use garbage collection seems a bit obvious in its necessity. Using `GC.free` to free memory that has gone beyond Crystal boundaries follows naturally (and most libraries have custom `free_*` functions to clean up complex objects).
The main complexity you have to write a C-friendly API for the library, but that's something that you have to do with C++ and so on as well
Re: Crystal 1.0 – What to expect
#323Earlier quoted context omitted.
I think if you've been bitten by compilation times in e.g. Scala or C++, then compile speed is something you end up caring about. When it comes to modern static languages, it seem like there's a tradeoff where providing all the abstractions and ergonomics to make you not miss any functionality from dynamic languages will instead expand compilation times and make you miss the instant feedback of an interpreted languag…
C++ compile speeds can be easily improved when using binary libraries, incremental compilation, incremental linking, and hopefully modules will help as well. Energize C++ and VA C++ v4.0 showed the way of a Smalltalk like experience for C++, the tools just need to catch up with the past. VC++ and C++ Builder are on the good path for it.
Re: Crystal 1.0 – What to expect
#324Earlier quoted context omitted.
It got MIT backing, no?
But then you've to consider that many languages have been created in academic institutions, few have become semi-popular, fewer have entered the industry sector.
Re: Crystal 1.0 – What to expect
#325Earlier quoted context omitted.
That is because JS was not built for JIT compilation. With a dynamic language like Julia built for JIT compilation from the very start you get both much simpler and cleaner design and higher performance. It uses a method JIT so it is deterministic and easy to analyze unlike JavaScript. You can lookup ahead of time how each function will get compiled with given input types.
I'm not sure what you mean by this. Why do you think Julia was made for JIT from the beginning? You can't analyse functions like this ahead of time: function foo(x) x + y end You've got an Any type interacting with an Any global. There's no better answer than you'd get from JS analysis.
It's very explicit in almost anything the language designers wrote from the beginning. Julia has always had it's language semantics designed around a JIT. Keep in mind, julia's JIT is not at all like JS JITs, julia's style is often called 'just ahead of time'.
For the you quote, the only thing causing a problem is the global y. Using global variables is very frowned upon in julia for this reason. However, if you write
function g(y)
function f(x)
x + y
end
end
or something, then there is no `Any` involved at runtime. What will happen is that say you call g(1.0)(2), as soon as julia sees this, it will do static type inference on the function bodies, knowing that y :: Float64 and x :: Int, all the code can be inferred and compiled down. Julia specializes on all arguments of functions, whether or not you put a type assertion on them.If there's a point in the program where type inference fails to produce concrete types, then the compiler just generates code up to that point and then waits until the types are resolved at runtime, and then using the new runtime type information does static analysis going forward from that point until it either encounters another type instability, or the program is finished.
This is why writing code that isn't concretely inferrable can carry a heavy performance penalty in julia, but it's also why inferrable code can be so fast. The trick is just to keep type dynamism away from performance bottlenecks and you'll be fine.
Re: Crystal 1.0 – What to expect
#326Earlier quoted context omitted.
No, Julia is not statically typed and will outperform pretty much anything, at least when dealing with numerical code. Next generation climate models are built with Julia. You would not pick a slow language for such a high performance dependent task.
Julia is statically typed, or at least it is for the inner bottleneck loops. If you want fast numeric code in Julia then you have to have homogeneous arrays. (Besides, I'd be very surprised if Julia doesn't have Fortran libraries driving it under the hood.) You're confusing dynamic typing and type inference.
As an implementation detail, it has a statically typed intermediate representation that's used for very aggressive and impressive optimization.
But that's an implementation detail, and is not what most people mean when they talk about a language being dynamically or statically typed.
Re: Crystal 1.0 – What to expect
#327Earlier quoted context omitted.
Are you saying Crystal has fast compile times or that it doesn't? You seem to be saying that it does, that that is one of the things you love about it but others below are saying it is slow.
It was really slow last time I tried it. I really like Crystal and wish it the best, but it's hard for me to imagine using a sluggish compiler as a daily driver.
Re: Crystal 1.0 – What to expect
#328Earlier quoted context omitted.
Julia
It got MIT backing, no?
Initial Julia work at MIT was funded by some absolutely tiny grants for distributed linear algebra research. The total amount of funding that Julia has gotten via MIT is definitely orders of magnitude less than the salaries paid to Swift, Go and Rust developers by Apple, Google and Mozilla.
Re: Crystal 1.0 – What to expect
#329Re: Crystal 1.0 – What to expect
#330Earlier quoted context omitted.
It got MIT backing, no?
MIT doesn’t fund anything — that’s not how academic money works. The university doesn’t give out money, researchers apply for grants from the government, companies, or NGOs. The university then TAKES a huge cut of that money — it’s called “overhead” and it’s often more than 50%. Initial Julia work at MIT was funded by some absolutely tiny grants for distributed linear algebra research. The total amount of funding tha…