24 ms·
Crystal: Fast as C, Slick as Ruby
- catnaroek 10y agoThe really important questions in any modern language: (0) Does Crystal have a lot of undefined behavior like C? (1) Does understanding Crystal programs require a lot of trial and error just like in Ruby? (2) How good a job does Crystal do at preventing me from shooting myself in the foot? A language isn't to be judged just by the amazing programs you can write in it. (Turing-completeness and I/O facilities have that covered.) Far more important are the totally stupid programs that you can't write in it.
- Illniyar 10y agoIs undefined behavior a thing outside of C? Is that really something you should question rather then just assume that modern language have no undefined behavior?
- catnaroek 10y agoWhat happens if you try to mutate a shared object from two threads, without using mutexes and locks, in languages without either Rust's compiler-enforced ownership or a global interpreter lock?
- dikaiosune 10y agoConcurrentModificationException?
- catnaroek 10y agoThat's hardly any better than undefined behavior. It's not the program you want to write, under any possible circumstance, and the language should tell you so.
- dikaiosune 10y agoPedantically, it's defined behavior, and doesn't use an interpreter lock. Granted, I'm completely head over heels for Rust, and I agree completely that ConcurrentModificationException is a crappy answer, but it is defined behavior (AFAIK).
- catnaroek 10y agoIt's true that throwing exceptions is defined behavior, but it's not defined in a way you'd actually want to use. For your actual purposes, it's undefined.
- lmm 10y agoIt's not defined. The library/VM is very good at throwing ConcurrentModificationException in practice, but it's specified as a best-effort thing, not to be relied upon.
- Athas 10y agoIt is significantly better than undefined behaviour, as it results in a noisy failure rather than silently incorrect results. Compile-time failures are best, sure, but I'll always take an exception over what is essentially data corruption.
- catnaroek 10y ago> It is significantly better than undefined behaviour, as it results in a noisy failure rather than silently incorrect results. This might be true in a deterministic setting, since the likelihood that a test suite will find the error is very high. But in a non-deterministic concurrent setting, throwing an exception that might be only caught once in a blue moon is just as bad as not doing anything about errors.
- dikaiosune 10y agoCorrupting data with no warning or visible signs is far, far worse than crashing the application.
- dbaupp 10y agoJava's collections don't (and can't, without high cost) make any guarantees that they will throw such an exception whenever they are modified concurrently... for one, data races can have weird consequences that aren't easy to detect. On that point, data races in Java are not undefined behaviour, they just have very weak guarantees about what happens (basically isolated loads and stores do reasonable things, and no fancier operations are available) which is another alternative to the Rust approach and the GIL approach.
- catnaroek 10y ago> they just have very weak guarantees about what happens (...) which is another alternative Not a very usable one. It means that atomicity is something you have to fight very hard to actually get, and very easy to accidentally destroy.
- Illniyar 10y agoThats not really what peole refer to in C when they talk about undefined behaviour.
- pw 10y agoI'd love for you to elaborate on (2). I don't think that's a criticism of Ruby I've heard before.
- catnaroek 10y ago(2) wasn't particularly aimed at Ruby, although some “creative” uses of metaprogramming can be very hard to debug. But languages designed for systems programming typically have features that, when used wrong, result in totally catastrophic modes of failure.
- yxhuvud 10y agoWell, you don't have runtime eval or send in Crystal, so some variants of metaprogramming can be ruled out. However, there are compile time versions of method_missing, delegates and instance_exec available (usually with slightly different naming due to not having the exact same semantics as the ruby counterparts), so it is still possible to do some magic.
- jacobwcarlson 10y agoYou could've answered those questions yourself if you actually looked into the language, but you didn't. You instead offered facile and superficial judgement. If you have complaints, state them. Speaking in generalizations just sounds like whining. To be clear, I have no strong opinions about Crystal and will probably never use it. But comments like yours are simply grandstanding and it's annoying that they are confused for contribution.
- Svenskunganka 10y ago(0) It does not. It has a GC, and all features you'll likely use are memory-safe. You can of course use unsafe methods and raw pointers, but those are documented that they are unsafe and are usually only used for writing bindings to a C library. Macros for example are evaluated and constructed at compile-time, so no undefined behaviour can come from those. Most methods have different behaviour. For example, one method may throw an exception, another return an error, and another simply return Nil. You know if you are using `hello!` `hello?` or `hello`, so no undefined behaviour there. (1) Not at all, look at the source implementation of their language implementation. For example, the lexer: https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/syntax/lexer.cr https://github.com/crystal-lang/crystal/blob/master/src/comp... Seems pretty clear to me. (2) Not entirely sure what you mean since that is such a broad case, but as stated, Crystal stdlib is mostly safe.
- catnaroek 10y ago> (0) It does not. It has a GC, and all features you'll likely use are memory-safe. Nice. > (1) Not at all, look at the source implementation of their language implementation. For example, the lexer: https://github.com/crystal-lang/crystal/blob/master/src/comp.. https://github.com/crystal-lang/crystal/blob/master/src/comp.... Seems pretty clear to me. How am I supposed to learn the language's semantics from a lexer? > (2) Not entirely sure what you mean since that is such a broad case, but as stated, Crystal stdlib is mostly safe. Consider this use case: I spawn five fibers. Can I send the same mutable object to all five? If so, can they attempt to mutate the object without properly taking turns? (e.g., using a mutex)
- Svenskunganka 10y ago> How am I supposed to learn the language's semantics from a lexer? Not what I wanted to achieve, but the lexer contains some frequently used methods and is fairly simple and straight-forward, but if you want to learn the semantics why not just go to their docs? https://crystal-lang.org/docs/syntax_and_semantics/index.html https://crystal-lang.org/docs/syntax_and_semantics/index.htm... > Consider this use case: I spawn five fibers. Can I send the same mutable object to all five? If so, can they attempt to mutate the object without properly taking turns? (e.g., using a mutex) Taken from the docs: Crystal has Channels inspired by CSP[1]. They allow communicating data between fibers without sharing memory and without having to worry about locks, semaphores or other special structures. ... Because at this moment there's only a single thread executing your code, accessing and modifying a global variable in different fibers will work just fine. However, once multiple threads (parallelism) is introduced in the language, it might break. That's why the recommended mechanism to communicate data is using channels and sending messages between them. Internally, a channel implements all the locking mechanisms to avoid data races, but from the outside you use them as communication primitives, so you (the user) don't have to use locks. [1] - https://en.wikipedia.org/wiki/Communicating_sequential_processes https://en.wikipedia.org/wiki/Communicating_sequential_proce...
- clessg 10y agoLooks very nice. I hope it gains momentum. For now, if you want a fast language with the beauty and productivity of Ruby, check out Elixir [0] and its web framework, Phoenix [1]. I've been using Phoenix for a year, and it's the first framework that I've actually liked more over time. And I've been a web developer for a decade. With its recent 1.0 release, Phoenix is gaining a lot of momentum. If you want some idea of the performance differences between Phoenix and Rails, see [2] and [3]. [0] http://elixir-lang.org/ http://elixir-lang.org/ [1] http://www.phoenixframework.org/ http://www.phoenixframework.org/ [2] https://github.com/mroth/phoenix-showdown/blob/master/RESULTS_v3.md https://github.com/mroth/phoenix-showdown/blob/master/RESULT... [3] http://www.phoenixframework.org/blog/the-road-to-2-million-websocket-connections http://www.phoenixframework.org/blog/the-road-to-2-million-w...
- pqdbr 10y agoI code in Ruby for about 4 years now, and Elixir still doesn't seem easy for me to get started with. Crystal, on the other hand, is as if I'm writing Ruby.
- acangiano 10y agoElixir is not a fast language. Not even close. Yes, it handles concurrency and parallelism beautifully which in turn enable distributed applications to perform quite well. But the language itself is significantly slower than Crystal / Rust / Go / Swift. It's not in the same category at all. That said, it's a great language worth recommending.
- clessg 10y agoOops, you're right that Elixir is not a computationally fast language. If you're looking for fast, raw number-crunching, look elsewhere. That said, real-world performance tends to be extremely good for real-time and networked applications (read: web apps). It's common for requests to be handled in microseconds, even in development.
- continuations 10y ago
- happywolf 10y agoWhat advantages Crystal has compared to other more modern languages that aim to compete with C? For example D and Rust.
- erelde 10y agoIts similarity with Ruby? It doesn't _feel_ like I would have to learn completely new paradigms
- wmoxam 10y agoIt's somewhat similar, but in Crystal you need to be explicit with types, and you'll likely miss 'send'. Also Crystal has macros
- pjmlp 10y agoIt is Ruby done right if community would have bothered with performance.
- flukus 10y agoI don't think it's really trying to compete with C, it's a much higher level language, just one that happens to be fast as well.
- Athas 10y agoThe claim is "fast as C", so I was surprised that the performance comparison was with Ruby, not with C. On my machine, the Ruby Fibonacci program executes in 47.5s, while a corresponding C program executes in 0.88s - that's a factor 54 difference, while the article reports a factor 35 for Crystal. That's good, but what causes the difference? This benchmark is pretty much all function call overhead, so I doubt it's representative of real performance-sensitive code. The Crystal website itself makes a more modest claim than "fast as C" under its language goals: "Compile to efficient native code", which it clearly does.
- Svenskunganka 10y agoThere's some benches between various languages, including Crystal as well, for those interested https://github.com/kostya/benchmarks https://github.com/kostya/benchmarks EDIT: There's also this: https://github.com/nsf/pnoise https://github.com/nsf/pnoise
- rogerdpack 10y agoHere's a small HTTP style benchmark across various languages (a bit limited, but still interesting): https://github.com/costajob/app-servers https://github.com/costajob/app-servers
- bluetomcat 10y agoAll of these "fast as C" claims about modern, high-level Python-like languages (be they statically typed and natively compiled) are missing the point. It is mostly the minimalistic and terse programming style that C encourages that makes C programs performant. You avoid allocations wherever possible, you write your own custom allocators and memory pools for frequently allocated objects, you avoid copying stuff as much as possible. You craft your own data structures suited for the problem at hand, rather than using the standard "one size fits all" ones. Compare that to the "new this, new that" style of programming that's prevalent today.
- progman 10y agoThere actually is one high-level Python-like language that really is almost "as fast as C". http://nim-lang.org http://nim-lang.org I am using it for years already, and it is really performant, somewhere between C and Rust. I am still wondering why so few people use it. Benchmark: https://github.com/kostya/benchmarks https://github.com/kostya/benchmarks Nim vs Rust: http://arthurtw.github.io/2015/01/12/quick-comparison-nim-vs-rust.html http://arthurtw.github.io/2015/01/12/quick-comparison-nim-vs... Performance discussion: http://forum.nim-lang.org/t/2261 http://forum.nim-lang.org/t/2261 Embedded Nim: https://hookrace.net/blog/nim-binary-size/ https://hookrace.net/blog/nim-binary-size/ Nim on LLVM: https://github.com/arnetheduck/nlvm https://github.com/arnetheduck/nlvm
- anp 10y agoFrom this post, Crystal appears to have some of the things many people have been lusting after in Rust: sophisticated metaprogramming, fewer sigils, a bigger standard library, fibers/coroutines/whatever-they're-called-now. But it still has a GC :(. Rust has completely spoiled me with making it easy to minimize dynamic memory allocation and copies, and to know (almost always) deterministically when something will go away. EDIT: I should also say that if you want to bash on Rust's lack of these things, 3 out of the 4 items I cited have solutions being actively worked on (either at planning, RFC, or implementation phase). I don't think Rust's sigils are going away any time soon, but I have no idea how you'd do that and preserve semantics anyway.
- hubert123 10y agoYeah it's weird how Rust has suddenly made me look for no GC languages everywhere I look. It opened up a whole new desire to not accept no for an answer in that regard. I have this burning thought in the back of my head that there just has to be a simpler way to offer it than Rust does it too.
- ori_b 10y agoYes. I'm currently trying to think of a good way to add it to Myrddin, which currently makes it more or less manual. Doing it in a simple way is a tough problem. The simplest solution is to add the moral equivalent of 'null' -- objects that transition to an idempotently destructable state, which solves a lot of complexity with the data flow and analysis (yay!) at the cost of some safety (boo), and nulls (louder boo).
- jesserayadkins2 10y agoMy language (Lily) handles the problem by trying to avoid the gc where it can. Lily is statically-typed, built-in classes can't be inherited from, and there's no C-like casting. With those rules in mind, most objects can't become cyclical. It's impossible for a list of strings to loop back onto itself, for example. It helps that the value classes backing enums (like Option and Either) are immutable, which I so far suspect prevents a cycle. That at least allows you to group classes into three groups: These never cycle (Integer) These may cycle (List) These always cycle (Dynamic, linked lists?)
- Svenskunganka 10y agoI'd like to put out there that Crystal is absolutely awesome. The language itself is Crystal clear, but the language documentation and API documentation - oh my! I had never worked with compiled languages before I tried Crystal, but had always had a huge interest in getting into that. When I wanted to learn the compiled ecosystem I looked at languages like Go and Rust, but the learning curve for those was a bit overwhelming for a newbie. A while later I found Crystal, and much thanks to the simple syntax of the language I learned a ton of new things about compiled languages very quickly. The absolutely best part of the language is that it is written in plain Crystal, and I've been looking at their own implementations for various things a lot - something I've never done before, having worked mostly with Node, Lua and PHP before. Nowadays I can delve into Go documentation, packages are clear to me and I just understand how things should and should not be implemented to achieve a good efficiency and performance level. The Little Go Book makes sense, the I/O package is simple and this is probably all thanks to the syntax of Crystal, the amazing language & standard library documentation but most importantly the source of Crystal being written in Crystal. I'm currently working on building a business using Go, because I absolutely need Windows target support - something which Crystal does not yet have. But the second it gets that, I'm moving back. Don't get me wrong, Go is really great and nice to work with - but Crystal is my mentor. Please note that I have not worked with Ruby before, so the whole language was new to me. To summarize; even if you only wish to learn, Crystal is in my personal opinion the best choice to go with.
- kristianp 10y agoMaybe the makers of Crystal need to take a leaf out of Go's book. Despite the Go creators not being windows users (AFAIK), they support Windows as a primary target, to help adoption, I assume. Of course the Crystal people probably don't have the same number of developers working on it as Go did even early on. Edit: Go took a little while to support windows, not until around July 2010. See this question from November 2009: http://stackoverflow.com/questions/1717652/can-go-compiler-be-installed-on-windows http://stackoverflow.com/questions/1717652/can-go-compiler-b...
- pyed 10y ago
- gtramont 10y agoAnd it already got a port of Sidekiq: https://github.com/mperham/sidekiq.cr https://github.com/mperham/sidekiq.cr
- boyter 10y agoThe Fibonacci comparison is a poor example of performance gains because Ruby is using large number data types to ensure the correct result. This is according to the crystal language website itself. "However, Crystal might give incorrect results, while Ruby makes sure to always give the correct result." https://crystal-lang.org/2016/07/15/fibonacci-benchmark.html https://crystal-lang.org/2016/07/15/fibonacci-benchmark.html
- piyushpr134 10y agoThat is true. Ruby does a lot in the background and one of the reason why it is slow
- coltonv 10y agoi actually think it's a good example for just that reason. Ruby will automatically use those big number types on production applications as well as the fibonacci application, so it's demonstrating that difference and the effect that it has.
- willlll 10y agoI recently gave a quick 10 minute talk on Crystal if anyone wants a video introduction https://www.youtube.com/watch?v=oC9IknG40po https://www.youtube.com/watch?v=oC9IknG40po
- mokkol 10y agoThanks! Interesting talk!
- westoque 10y agoWas wondering how many companies actually use Crystal in production. I was interested in Crystal but the lack of apps using it in production and proof of concept on the field is making me doubt its usefulness.
- sdogruyol 10y agoI'm the author of Kemal(kemalcr.com), a simple, fast and modern web framework for Crystal. We've been using Crystal in production(at Protel) for more than 6 months for some heavy load APIs (100-200 req/s). We've replaced our Rails API with 64 unicorns to just 1 Kemal process and it's not even breaking any sweat while consuming nearly 100x less resource and 30x less CPU. You can ask me about our experience.
- coltonv 10y agoMy biggest concern if i were to try to use Crystal in production would be the lack of "googleability". I'm guessing your team is very familiar with the language, so it's not as much of a problem that you can't Google a problem when it happens. Do you feel that this is a major roadblock for people new to crystal, or are the majority of errors very intuitive? the second thing is that according to the site crystal is in alpha and making breaking changes sometimes. how often do you have to refactor after an update and how difficult has it been to spot and fix that something is broken by an upgrade? Very interested in using it myself but can't bring myself to commit an app to it.
- sdogruyol 10y agoThese are really nice questions / concerns. - Firstly, we are a Ruby shop and most of the time the errors are pretty self descriptive that we can easily solve. Also the IRC/Gitter room is full of helpful people that you can get instant feedback about any issue (even a compiler bug). Note that we're not afraid of writing code :) - I've updated our application once in the last 6 months. It's only a minor change for adding type annotations which took like 10 minutes. - Actually i think that Crystal is already in beta quality (for us). Calling it Alpha is really an understatement.
- transfire 10y agoI've done some coding Crystal when I have Ruby scripts I really need to run faster. I generally see about a 5x performance over Ruby. It certainly is great to be able to jump right into Crystal coming from Ruby. It isn't very hard to convert most Ruby code to Crystal -- you just have to go through and "typify" everything. A few methods have different names and of course some don't exist but most of it is there. My one grip with Crystal however, and why I haven't adopted it more generally, is that much of the "Lisp-like" features of Ruby are all but lost. Crystal makes up for some of this with macros, but it doesn't quite cut it. For example, you can't splat an array into a lambda in Crystal. Arguments have to be tuples which are compile-time bound. Little things like this feel very limiting to an experienced Ruby developer.
- kimshibal 10y agocrystal on rails. i want this.
- _raul 10y agoThis may be the closest alternative right now: https://github.com/ysbaddaden/frost https://github.com/ysbaddaden/frost
- fuzzythinker 10y agoKemal is the most actively developed. https://github.com/sdogruyol/kemal https://github.com/sdogruyol/kemal
- rogerdpack 10y agowhat would you rename rails to at that point? :)
- costajob 10y agoStick with Ruby then: Rails is great to build monolith application easily, Crystal suits a different use (micorservices?). Also the lack of Ruby meta-programming facilities (send overall) will make to rewrite Rails with Crystal really challenging (pointless?)
- mshenfield 10y agoCrystal doesn't support a REPL yet because inferred static typing complicates incremental compilation. Blog: https://crystal-lang.org/2014/12/06/another-language.html https://crystal-lang.org/2014/12/06/another-language.html Github Issue: https://github.com/crystal-lang/crystal/issues/681 https://github.com/crystal-lang/crystal/issues/681
- twblalock 10y agoScala has type inference with strong static typing, and a useful REPL. A Crystal REPL should be doable, unless Crystal's creators made some bad choices in the design of the type system that Scala's creators did not.
- mshenfield 10y agoMy intuition is also that a Crystal REPL is technically possible. But FTR, the two languages implement subtly different type restrictions. Scala has type inference, Crystal has optional typing. In Scala, there are certain situations when the type is discernible by the compiler, and can be omitted. For example val x = 1 + 2 + 3 the compiler infers that x is an Integer. However, omitting type information in Scala is the exception not the rule. Methods and functions, for example, must have type annotations. In practice, Crystal also infers type. But in Crystal you can omit almost any type annotation, including method and function definition. This probably poses a different challenge for the compiler authors. The Type Restrictions sections provides some more examples https://crystal-lang.org/docs/syntax_and_semantics/type_restrictions.html https://crystal-lang.org/docs/syntax_and_semantics/type_rest...
- ekzy 10y agohere is an implementation https://github.com/greyblake/crystal-icr https://github.com/greyblake/crystal-icr
- mperham 10y ago`crystal play` is a pretty good replacement for a REPL.
- welder 10y agoStopped reading when I saw the `end` keyword... the most annoying part of Ruby. Edit: I'm getting hella downvoted but I'm leaving this here. Ruby fanboys can't silence me!!! ;)
- Svenskunganka 10y agoI wonder how Lua can get by, being embedded in literally every game that supports scripting, in databases and many other tools. It's a personal preference of course.
- exDM69 10y agoThe syntax of a language is about the least interesting thing about them. I don't care about curly braces, end keywords or semicolons as long as it is consistent (and fairly easy to parse, so there can be good tooling). The interesting parts are in the semantics, type systems and runtime features. Choosing a programming language based on the syntax is like choosing your significant other based on looks alone. You're going to be spending a lot of time together, what's inside is what counts.
- smnplk 10y agoOr judging the performance of a sports car by its colour.
- paxcoder 10y agoI've heard this said numerous times, so I'm going to disagree on the record. I think syntax of a programming language is a very important characteristic. A language with a nice syntax is easier to learn, easier to read and understand, and delightful to write. Crystal's syntax is a great differentiator between it and its statically typed, garbage-collecting competition.
- z3t4 10y agoscoped includes are a deal breaker for me when looking at new programming languages. ex: non-scoped (everything in foo is added to the global scope) inport foo { bar.do() } ex: scoped (everything in foo is added to the local scope, and assigned a name-space) { bar = inport foo bar.do() } I find it much easier to manage programs where there are no "hidden" global variables. It's especially hard when the included files also can include files, witch all adds to the global scope.
- rogerdpack 10y agobring it up on the mailing list, seems like an interesting feature to me :)
- erez 10y agoFirst thing I look for whenever I run across another "C competitor" is to look which language it is implemented in. Usually that's C, or C++, but this time, it does look like Crystal is implemented in Crystal, which is, to me, a very good indication that this is a "real" system language. I believe Rust is also implemented in Rust and Go, after a few years of being implemented in C has now a compiler written in Go.
- grobaru 10y agoI believe Crystal will try to compete with Elixir and GO and not with Rust or C
- JonnieCache 10y ago>Go, after a few years of being implemented in C has now a compiler written in Go. Since 1.5 came out, a year ago.
- ethagnawl 10y ago> ... which is, to me, a very good indication that this is a "real" system language. Could you expound upon that point a bit? What's the difference, in your mind?
- erez 10y agoThe rationale is, that once you have a programming language that is implemented in itself (usually that means that the compiler/interpreter is written in that language), then it means that your language has tackled and can deal with many issues that "system languages" deal with. Mainly dealing with the OS in a lower level, dealing with CPU/RAM, etc. This is a large problem space that you can glean over by using C as a layer of interaction between your language and the underlying machine, but it makes your language a: not truly a "system language" and b: it also ties you to C philosophy, API/ABI, calling conventions and so on.
- AstroChimpHam 10y agoSo, this is like Ruby's answer to cython?
- abrookewood 10y agoI don't know why you are getting down voted - the example of Crystal running an existing Ruby file makes it looks like it could be a compiler for unmodified Ruby files. It isn't - it's a separate language - but at first glance that might not be clear.
- yxhuvud 10y agoNo, not in any way whatsoever.
- AstroChimpHam 10y agoCython looks like typed Python. Crystal looks like typed Ruby. Both are compiled, and both are not quite as fast as C, but much faster than the language they're based off of. The point of both is to be able to write something that looks like a clean scripting language while getting close to the speed of C. Was that unclear, or are you just trolling?
- jalopy 10y agoGreat stuff. I love Ruby. Any idea when this will be production worthy, or at least stable enough to trust on internal projects? Will the language change much going forward?
- sdogruyol 10y agoActually it's been stable for the last 6 months. No more expected major syntax e.g changes upwards. (apart from parallelism and gc which will be at compiler)
- coltonv 10y agoThey should really mention that on the website for crystal. I think a lot of people are scared off by seeing the words alpha and breaking changes. Changing those to "beta" and "stable" on the site would help a lot IMO. At the very least calling it stable would be huge.
- deleted 10y ago[deleted]
- sdogruyol 10y agoFor anyone interested in building web applications with Crystal i recently gave a talk about Kemal at PolyConf https://www.youtube.com/watch?v=KJB-nAoRSr8 https://www.youtube.com/watch?v=KJB-nAoRSr8
- jhoechtl 10y agoI seldom whine about blog posts but his one clearly justifies as click-bait. Not because of it's otherwise good content. But if it takes me a Google search instead of having within the very first sentences a link to the obvious target, https://crystal-lang.org/ https://crystal-lang.org/ there is something f~*#ing wrong with the article.
- wtbob 10y ago> Have you ever dreamed of a programming language as beautiful as Ruby but as fast as C? Yeah, I discovered Common Lisp back in 2006 and have been using it ever since … I discovered Go back in 2009 and have been using it ever since, too. What does Crystal get me that these two don't?
- rogerdpack 10y agoruby like syntax that I miss when using go :|
- kusmi 10y agoDoes it have any benefit in particular over lua/luaJIT?
- rogerdpack 10y agoprobably the ruby syntax (built-in regular expressions) and whatever else. I'm not sure on easy embeddability as well.
- untothebreach 10y agooff the top of my head, I would say it's similarity to Ruby means that Ruby devs would have an easier time learning the language than learning an entirely new one. Crystal also seems to have an extensive standard lib, which lua does not. (that's not a criticism of lua, just an observation. I know luarocks has made the lack of a large stdlib much less of a pain point for lua)
- api 10y agoWhy couldn't Swift be this?
- jimbokun 10y agoIn other words, if Apple had taken the RubyMotion path, but added type inference and better performance.
- jheriko 10y agocool. can you make it faster than C though please? (seriously) i think it might even happen by accident in some cases already though. the places where C can be beaten for performance are, in my experience, from design choices in the C standards, users not understanding or leveraging those things for performance and the architecture of the compilation-unit/link process. things like the struct layout rules - instead of the compiler organising things to be optimal it follows those rules for memory layout, or the calling conventions - you often have to use funky extensions to get efficient function calls. other things are the lack of ability to hint the compiler that e.g. mathematical structures underly types that can be leveraged for optimisation. that const or functional purity can be trusted... etc.
- jbbarth 10y agoNot the answer you would expect but still: it can also happen on large projects where the refactoring or the paradigm change is just too costly in C. The pure, raw ability to make C faster is nice, but if it takes you months of development you don't have, it's pretty useless. One typical example of this was a few years ago (if I'm not mistaken) in the monitoring world, when Shinken released a Nagios-compatible engine in Python, and, basically the reactions in the Nagios community was that the modifications involved in Nagios (C) were just too important to be worth it.
- GirlsCanCode 10y agoRuby is not slick.
- libman 10y agoCrystal isn't fit to carry Nim's jockstrap as far as I'm concerned. Ruby's syntax is verbose and illogical compared to Python's. Plus Crystal has a much more restrictive license.
- quotemstr 10y agoIf you require the use of a GC, you can never be as "fast as C" in the general case, since there will always be specific cases where manual memory management will do something more efficient than what an automatic GC would have done --- just like a car with an automatic transmission can never be quite as efficient as a car with a manual transmission used competently. If you want to talk about efficient GCed languages, you have many choices, most of which have more tooling and mindshare advantages than you language has tooling advantages. Really, GCed languages are commodities these days. A lot of people have put a lot of work into the fundamental building blocks, and now people are just combining them in various ways.
- smallbag 10y agoCan someone comments the differences between Nim (old mimrod) and Crystal? Which one do you prefer and why. Thanks.
- smallbag 10y agoGoogling: http://forum.nim-lang.org/t/1246 http://forum.nim-lang.org/t/1246 Python syntax with macros => Nim Ruby syntax => Crystal
- costajob 10y agoApart for different syntax: Plus of NIM: * powerful compiler can produce C, C++, JS, ObjectiveC code * GC can be completely removed to adapt to the program * support parallelism via threading Plus of Crystal: * use of types union permit to mix types in almost every data structure, let you pondering if the langugae is really strong typed * so similar to Ruby that porting a 100-lines library (with no fancy-metaprogramming) to Crystal is often a matter of few hours * use of green threads suits very nicely with HTTP request/response cycle (like GO and Erlang), where using threads/processes is more memory/CPU consuming What Crystal still lacks is parallelism, but core team are working on that. Said that both are modern, fast, elegant languages, with a good standard library and a vibrant community.
- continuational 10y agoI think the macro system looks really interesting. The main ideas seem to be that meta programming can be done anywhere and that everything is quoted by default in macros. What are thes kind of macros called, and where do they come from?
- ksec 10y agoSomeday, someone should write a Ruby VM in Crystal.
- VT_Drew 10y agoNeat, I will check this out. Although, if I am honest I really wish there was "Crystal for python".
- binki89 10y agoNim (http://nim-lang.org/ http://nim-lang.org/) is really as close as you're going to find.
- ksec 10y agoFor anyone familiar with Crystal, are there any plan to add pattern matching into Crystal?
- binki89 10y agoGood question about pattern matching in Crystal. I found this reply by asterite (the creator of Crystal) to a similar question that is worth reading: https://crystal-lang.org/2014/06/19/crystal-0.1.0-released.html https://crystal-lang.org/2014/06/19/crystal-0.1.0-released.h... The question was asked in the comments as with the reply. I'm sorry that I can't link to it directly but it's the seventh comment from the top.