16 ms·
The Crystal Programming Language
- sergiotapia 10y agoLast year's discussion for those interested: https://news.ycombinator.com/item?id=10014178 https://news.ycombinator.com/item?id=10014178 This language definitely deserves your attention. It's fast, it's easy on the eyes, and it produces native code. A real workhorse language. Want Go's speed but hate Go's if err nil verbosity? Check out Crystal.
- stcredzero 10y agoHow is the debugging story?
- RX14 10y agoUnfortunately its a compiled language so you can't drop into a pry repl like ruby. It does emit debug symbols, and both gdb and lldb work with it, I just haven't gotten around to working out if they're useful for more than printing backtraces on segfault. Puts debugging works great though!
- stcredzero 10y agoWhat if you also targeted a virtual machine with a Ruby meta-level? Some care would need to be taken to ensure that the two were equivalent, but this should be commensurate with ensuring JIT and bytecode execution in some existing environments is equivalent.
- AstralStorm 10y agoDoes it even have built in concurrency?
- pjmlp 10y agoGo's built in concurrency is oversold. If the language is powerful enough in the expressiveness it offers for building libraries that provide the same features as builtin types, that is also achievable. This is the path being trailed by the languages more expressive than Go.
- fzzzy 10y agoI don't agree. Having an event loop built in to the core of the language is a major advantage. Look at Python and async io: Twisted has been around for over 15 years now. asyncore even longer. Tornado exists because apparently Twisted and asyncore weren't good enough. I'm not even sure I know how many incompatible "coroutine" libraries are built on top of generators. node.js may have a language and standard library that isn't nearly as nice as Python, but it has a built-in event loop. This sidesteps an entire universe of problems. Unfortunately node still has another, similar problem: Does the library use callbacks? Promises? Generator-based coroutines? async/await? If it doesn't use the same style as what your codebase currently uses, you're going to spend a lot of time converting between continuation styles. Languages like Go and Erlang simply don't have any problems like this. Now, one might argue that leaving it up to libraries allows greater exploration of the problem space and that blessing a concurrency method stifles innovation, and that might be right. But having a consistent concurrency story built right in to the language is a large advantage.
- brightball 10y agoI was getting ready to post the exact same thing. The built in event loop is major. Go did a lot of modelling from Erlang, but made tradeoffs that kept it closer to a C-style programming model. It's a great language and the limits of its concurrency model aren't something that will really be apparent to you if you haven't learned Erlang/Elixir. For most people, it provides a concurrency model that's a cut above everything else out there. The main differences in Go and BEAM languages (Erlang/Elixir) are cooperative vs prescheduling, shared memory vs immutable message passing, general garbage collection vs heap per process, and lastly general runtime vs isolation. Cooperative scheduling means that the scheduler has to have control relinquished back to it (such as with I/O events), while prescheduling will take back control. Cooperative means that you can get better end-to-end performance for a benchmark but you run the risk of a code taking over the processor. Prescheduling will allow consistent performance for all operations in the run time without allowing anything to overtake it. That's one of the ways that it's possible to reliably run a database within the runtime alongside the rest of your code on BEAM. Shared memory with pointers is pretty standard and definitely provides some performance perks, especially when dealing with large data structures. The flip side means that native clustering doesn't work. With BEAM languages that lack shared memory and rely on message passing, you can just as easily call a function on a different server in another data center as you can a function in your current heap space. This makes it possible to smoothly distribute everything without having to worry about updating shared memory on a specific machine or having the state get out of sync. The channels model helps to avoid this, but by even including shared memory in the language you make the trade off of losing natural clustering for distribution. With shared memory comes garbage collection and GC pauses, although the Go team has done great work optimizing this. With BEAM every new process (equivalent to a go routine) gets it's own heap meaning that it can be independently cleaned up without pausing the entire stack. This also makes hot deployments possible, so doing things like deploying an update to a codebase with millions of active websocket connections can be done without trigger millions of simultaneous re-connections. The general runtime vs isolation means that a goroutine that blows up and crash the entire system if it's not properly handled at the point of the problem. When writing Go code you find yourself writing a line of error handling for every line of functionality. With BEAM isolation, processes are kicked off with id's and the processes are so inexpensive that the standard method is to create two - one as a supervisor and one as the process. If the process ever crashes for some reason, the supervisor just restarts it immediately. This creates a granular level of isolation and reliability. There is a library for Go that I remember seeing that seems to create a supervisor pattern for reliability though (http://www.jerf.org/iri/post/2930 http://www.jerf.org/iri/post/2930). Go will win benchmarks because of it the choices the language made, but the benefits for long term run time, reliability, distribution and performance consistency in the face of bad actors will be in favor of Erlang/Elixir. That said, the steps that Go took toward implementing the closest thing to Erlang-like concurrency makes it the winner by far among the non-BEAM languages.
- RX14 10y agoCrystal has an excellent concurrency story built into the stdlib which is on by default. All io is evented by default, with events being fed into the fiber scheduler. The nice thing is that the concurrency and evented io is built just using the stdlib in crystal itself, so it's readable and shows that crystal is quite powerful. You can read more here: https://crystal-lang.org/docs/guides/concurrency.html https://crystal-lang.org/docs/guides/concurrency.html
- AstralStorm 10y agoLack of parallelism will cause similar problems to what python faces due to global interpreter lock, killing performance. It is 2017 (almost), parallelism should be available in any new programming language.
- asterite 10y agoYes, it will be available before 1.0. It's on the roadmap.
- RX14 10y agoParallelism isn't easy, so the core team is expending time to get it done correctly and released before 1.0. Crystal doesn't have anything like the GIL, and the compiler already enforces some simple rules, like type flow not being available on instance variables because they could be changed on another thread. You can't expect the world from any new project straight away.
- fzzzy 10y agoParallelism is available to any language through fork().
- JohnStrange 10y agoBut its concurrency uses green threads only, no proper multicore support? That's such a pity. Lack of built-in parallel programming facilities is a big problem of many otherwise nice languages, many scheme implementations have this limitation, too. A relatively new programming language should really use all cores, ideally it should distribute the green threads across the available cores with its own scheduler automatically and have synchronization primitives like channel work across them.
- Xeoncross 10y agoI am very happy with Go, but I love having Crystal and Rust around to keep up innovation for modern, compiled languages. Looks easy enough to jump between the three (though Crystal isn't quite ready on the lib front). A unicode core, useful core packages (MIME, ECC/RSA, Templates, etc...), and easy parallelism are so nice coming from 90's scripting land. Oh, and I love Go's err bubbling (keeps libs from dropping important messages) after years of Exception catching.
- sdegutis 10y agoSounds like it has most of the same goals as Swift. I wonder how they compare?
- devmunchies 10y agoThey are both LLVM languages. But I remember reading that Swift was just barely slower because of the reference pointing or something. Obviously I'm not a reliable source for performance metrics.
- wcarron 10y agoI'm by no means a very experienced programmer, but what was the motivation behind choosing `nil` over `null`? Seems like, from my inexperienced perspective, it was just designed to add unneeded idiosyncratic syntax/semantics to distinguish it from Ruby and/or C. Can't comment on anything more than that right now. Have yet to dive very deep into it.
- marcoperaza 10y agoRuby uses 'nil'.
- jrapdx3 10y agoNot a new terminology. Lisp uses "nil", which is '(), the empty list. Objective-C uses nil as a null pointer to which messages may be sent. Probably others too that I can't remember now. Many languages use "null" in similar ways. I guess it's a matter of particular syntactic conventions.
- kazinator 10y agoThe value, under conventional evaluation, of the expression '() is (), which is the empty list. This '() expression itself is the object (quote ()) which is anything but nil. The nil-()-false correspondence is only specific to the Lisp dialects which are close to the original tree. In Scheme, an empty list is indeed (), and this object also the terminating atom of a list. However, the object isn't a symbol at all, let alone the symbol nil. Moreover, the object isn't a Boolean false; Scheme has #f for that.
- careersuicide 10y agoCrystal started out as being more or less "compiled Ruby" (it's changed a bit since I first came across it). As such that means it uses "nil" just like Ruby does. And Ruby, being heavily inspired by Smalltalk, took "nil" from Smalltalk. You'd probably have to ask Alan Kay to get to the bottom of this.
- jasonm23 10y ago
- qume 10y agoI write aviation software (i.e. running real time in aircraft) - not safety related in any way - and I use Ruby. I use it because iterating quickly and being super productive means I can do more myself and keep the team small. And it's worked brilliantly. So throw this into the mix and my world just got a whole lot better. It's like these folk designed this for my project. Good luck guys!
- stevemk14ebr 10y agoplease don't switch to crystal until it's more developed. I don't want my plane crashing because of a language bug.
- qume 10y agoThe day a plane you're flying on relies on my software to not crash it is the day I'm not letting my family out of an underground bunker.
- Toenex 10y agoOn my god it's worse. I think this guy is writing the in-flight entertainment system. If this goes down we are all in for very bad flight!
- mathgeek 10y agoI don't know what we'd do on those two hour flights to Orlando if the dozens of children had to entertain themselves! Seriously, though, even the antiquated entertainment devices on planes these days make flying with kids so much easier than it used to be.
- kornish 10y agoSounds really interesting! Have you written anywhere about how you got involved in that? I'd be curious to know how one sells into the airline industry. When you say "not safety related in any way", do you mean that your code runs on auxiliary systems, like the entertainment platform?
- bootload 10y ago"The compiler is written in Crystal." If there is any stress test worth noticing it's this. 98.2% of the code is written in Crystal.
- qume 10y agoTry searching the web to see if/how it works with Gems. Go on, I dare you... 'ruby crystal gem', 'crystal gem', ... For that matter, crystal vs elixr. Kind of wishing all these projects just had made up names.
- inopinatus 10y agoReminds me of that time I was trying to debug a TDID problem with cucumber and chef. Searching for prior discussion, all I got was pages and pages of salad.
- h1d 10y agoTalk about real chefs... I find that once a tech becomes somewhat popular and you use specific words to search, technical pages tend to come earlier than the original meaning. Those chefs that search with same terms would suddenly get their results overtaken by voodoo pages.
- deleted 10y ago[deleted]
- adjkant 10y agoAs a Steven Universe fan, I got quite a chuckle out of this.
- devmunchies 10y agoyou have to do "crystal lang" in your searches. But yeah a more unique name would have been nice... or even just crystal spelled like "Krystl" or something.
- yxhuvud 10y agoCrystal use something they call shards. They are extremely basic though and are really waiting for someone to write a more full-featured package manager.
- adjkant 10y ago
- stevemk14ebr 10y agoI wonder how Ruby will compete with this. Crystal basically seems like Ruby 3.0 to me (major improvement is speed, btw Ruby is currently on 2.*).
- eropple 10y agoPretty easily. Crystal looks like Ruby, but it doesn't feel like Ruby or work like Ruby. It seems fine, in a very Golang "it works for projects where you need to fling a blob of binary somewhere" sort of way, but it's not remotely as dynamic-as-a-language as Ruby (and that dynamism is precisely why I use Ruby), nor is it dynamic-as-a-platform--something like CLR assembly loading or Java classloading to get a statically-typed, reflective representation that gives me something similar. And you might not need that, and it's totally cool. But Ruby enables a lot of things Crystal, as designed, seems unable to. It's not bad. It's fine. Not the pejorative, dismissive sort of "fine", but fine. But it's not Ruby. Ruby is slow in large part because Ruby does hard things. Some of them aren't really advisable, from a perf perspective--but they are from a human perspective, and Ruby preferring humans over computers is a huge feature for me.
- stcredzero 10y agoWhat if it had a really powerful debugger?
- eropple 10y agoHaving a "powerful debugger" is orthogonal to "can I dynamically define classes at runtime, when that makes sense to solve my problems?" and "can I load a library that's annotated to make for a simple extension system?". Like, take a look at this[1]. I wrote it for a game engine in C#. It allows for dynamic loading of modules or static packaging on platforms that require it. This is what I would consider a low-end thing for a Ruby application that needed extensibility--just something you do out of hand. Crystal can't do that. Maybe it will in the future, but it's not even a 1.0 feature. So Crystal might be a challenge to a Golang-ish thing, but it's not a challenge to a Ruby or a JVM/CLR thing on that front. [1] - https://github.com/eropple/Exor https://github.com/eropple/Exor
- new299 10y agoSeems like there's a new language popping up every few weeks. This seems strange when the trend in human languages seems to be towards a single common tongue, or at least a common lingua franca. The same seems true of mathematics. At least in the parts that get commonly taught, we trend toward a common representation. In programming, it seemed like we might move toward a core "C-like" syntax with various derivatives, for a while. But now we seem to be moving toward a world where everyone wants to create their own domain-specific language. I can't help but long for a common tongue. One which allows developers in different domains to understand at least the functionality, if not the motivation without having to learn a new language.
- dietr1ch 10y agoWhy hasn't your toolbox evolved to a single hammer? Besides, even if one language ends up being the only one needed, I'd be pretty confident that it's way too early in the study of programming languages, compilers and runtimes too try to stop experimenting and look some language to settle down.
- devmunchies 10y ago> "Seems like there's a new language popping up every few weeks" Crystal was started like 5 years ago. > "the trend in human languages seems to be towards a single common tongue" One of the clear goals of the creator was to make it as similar to Ruby as possible; the creator was striving for some kind of "common tongue", no doubt. Its not some strange eccentric new language.
- woah 10y agoOne possible reason that this is not the case is that natural languages and math have been around for a lot longer. Another one is that programming languages have more in common with mechanisms that natural languages. You could also say that we do have a few lingua franca programming languages which are also very similar to each other, to the point that someone fluent in one can easily read another. Also, what do you think are the odds that a mathematician can understand the intricacies of a fluid engineering paper (in a natural language) and vice versa?
- rad_gruchalski 10y agoVery nice. Something to keep an eye on.
- Turing_Machine 10y agoI'm sorry if I'm missing this, but what's the distribution story? Does it produce stand-alone binaries? In other words, can you just distribute the generated binary without requiring the user to install a runtime package or a bunch of libraries or whatever?
- yxhuvud 10y agoIt produces standalone binaries. I'm not certain the cross compilation story is in place yet though.
- RX14 10y agoTo expand on that, it produces dynamically linked binaries so you do need libevent, libpcre, libgc etc. when you want to run crystal binaries. We hope to get the number of runtime dependencies down in the future.
- faaq 10y agoBut, Also you can try static linking :-) --link-flags="static" The output binary is bigger than dynamic linked and it would needs some dev libraries before compile.
- Turing_Machine 10y agoSure, it's going to be bigger. Not a problem, as long as it works. :-) Requiring the user to install a separate bunch of dependencies adds a huge amount of distribution friction vis-a-vis just shipping a stand-alone application bundle, especially in this day of app stores. Being able to avoid that is very important, IMO. Probably anyone reading this isn't going to be daunted by having to install some extra stuff, but for the average user it's a real pain.
- ChuckMcM 10y agoGo's PASCAL. :-) Interesting language, looks especially interesting for rapidly throwing things together. Add a solid API to a window system toolkit and you've got a logical successor to Visual Basic. Write an editor, cross compiler for some other language, and a shell in it. That will tell you if it is a good "systems" language. Write a distributed service, a web application, and a database in it. That will tell you if it is a good "web" language. Write a physics simulator, a responsive AI, and a real time user interaction model in it. That will tell you if it is a good "game" language. Write a convolution, a linear regression, and a monte carlo simulation in it. That will tell you if it is a good "modeling" language. In my Christmas wishlist is a language that I can write a good 3D CAD package in. The current choice is C++ but that can be really clumsy in many ways. Such a language would have a strong linear algebra library and a boolean solids package. Nobody is working in that problem space from a language perspective as far as I can tell.
- devmunchies 10y agoWhat would it need to be a good embedded system or distributed system language?
- nickpsecurity 10y agoFor embedded, I'd start with the language primitives easily producing efficient primitives of the machine, the cost (esp time/memory) of language primitives must be intuitive (ideally deterministic), be able to size/manipulate variables at the bit level, probably support pointers, have anywhere from tiny to no runtime, probably a good C FFI given existing stuff will be C-based, and ideally support inline assembly for stuff specific to MCU/CPU if not C-based. Any embedded developers want to add to or dispute anything on that list? It's recent draft of a reference I'm working on to answer this common question.
- ChuckMcM 10y agoI think that is a good start, I would add interrupt routines to it. Perhaps interrupt routines, arbitrary memory manipulation on a bit boundary, and tight code.
- wildchild 10y agoRuby?
- RX14 10y agoNo, actually Crystal.
- iamgopal 10y agoWhy language differ syntactically? I understand different platform, runtime, optimisation needs etc. But why syntax ? C is sufficient for most logical implementations, at most we will need hierarchy of implementations but why parallel indecipherable syntax?
- chrisseaton 10y ago> C is sufficient for most logical implementations How do you know this to be true? You don't - it's just an opinion. And that's why we have different syntaxes - because they're driven by different opinions. If you could prove that one syntax was more effective than all the others - for every purpose that people needed - then you could ask why everyone wasn't doing it that one way.
- eropple 10y ago> C is sufficient for most logical implementations Write me a dtor that works perfectly and in all situations without allowing for users to break out of a scope without triggering them. Thanks in advance.
- elihu 10y agoHuh, this is in interesting feature: https://crystal-lang.org/docs/syntax_and_semantics/union_types.html https://crystal-lang.org/docs/syntax_and_semantics/union_typ... If you have code paths that set a particular variable to different types, it promotes the type of the variable to a union. I'm not convinced that's a good idea, but then I don't usually use dynamically typed languages; perhaps this is the most natural way to do static typing for people who come from languages like Ruby.
- yxhuvud 10y agoIn practice, it accomplishes two things. It is the tool used to catch null pointer exceptions at the compile stage and it is what allows you to write duck typed interfaces.
- iheartmemcache 10y agoRE: NPE's - I have a feeling that'll be abused just like void * and interface{}. People will just start throwing Nil around everywhere as a catch-all. You need a stronger construct like Option<T>, Maybe, language-level nullable types, or a mechanism for the caller to handle it dynamically (a la unwind-protect/conditions). The problem you end up getting is basically the dual of the 'expression problem'. You get easy type expandability with class augmentation by these semantics, but any client of the type is subsequently bound to deal with any augmentation of the type. (I.e., if in the method defining class 'a', you insert an elseif in between the consequent and the alternative of type Bool, you now just extended the class signature of 'a' to Int32 | String | Bool. Assuming all consumers of 'a' need exhaustive handling, you've opened your class and extended its functionality at the expense of code which had previously satisfied the dependencies to consume 'a' safely. Crystal still remains a real interesting project to follow. I haven't examined the Crystal type system too carefully, but the concept of Parent+ as virtual types is an interesting concept that is certainly worth exploring.
- RX14 10y agoBecause crystal's nil type can have methods on, it already feels like an Option<T> with `#try`. We've had a lot of discussion about nil handling, but haven't come up with a better solution yet. Simple patterns like `return/raise unless foo` can protect the rest of a method body from nil without adding indentation.
- sdogruyol 10y agoI've been using and contributing to Crystal since 2015 and i can easily say that it's really great potential. It's simple, fast and productive from day 1. I wrote a web framework (http://kemalcr.com/ http://kemalcr.com/) and it's in production without any problem for more than 1 year on a big scale app. You can check my slides for some interesting graphs (http://www.slideshare.net/sdogruyol/kemal-rubyconfbrasil-2016 http://www.slideshare.net/sdogruyol/kemal-rubyconfbrasil-201...) Also be sure to check out http://crystalshards.xyz/ http://crystalshards.xyz/ to discover Crystal projects(shards).
- marcoperaza 10y agoVery cool project. I'm looking forward to making something with it. The performance comparisons to Sinatra and Rails are impressive.
- RX14 10y agoWhat a surprise to see crystal at the top of HN again! I've been using and contributing to crystal since 2015 too, and I've come to really love the language and community. A big thank you to all the community for being so welcoming! What I've felt with crystal is that I find it an immensely practical language. Maybe that stems from the compiler being written in crystal. The stdlib has so many things in that make everyday work in the language a joy. For example JSON/YAML/DB.mapping which help you map objects between JSON, YAML and the DB (they're also really fast). Including a standard, performant http stack in the stdlib is a breath of fresh air. The performance of evented io in general is really nice. The concurrency story (channels + fibers) is simple, and doesn't show itself when not required (looking at you nodejs). Most of all, the type system gets out of your way and usually only shows itself when you're making a mistake.
- stcredzero 10y agoWhat I've felt with crystal is that I find it an immensely practical language. Maybe that stems from the compiler being written in crystal. The question is, how easy is it to make syntax-driven tools? One thing that Ruby never did quite as well as Smalltalk was having low cost of entry for creating language parsing tools on the language itself. (At one time, there were multiple online study groups of multiple people trying to parse Ruby working for over a year. With Smalltalk, you can start hand-coding a top-down parser in the morning and be mostly done in the afternoon.) Most of all, the type system gets out of your way and usually only shows itself when you're making a mistake. Sounds ideal!
- desireco42 10y agoI am really invested heavily in ruby, I've been using it for years, like 10+. I should be natural target group for this, yet, while I appreciate all the features, I really feel that something like Elixir is better suited for future. Also, even though I spent years writing ruby, I don't have problem switching to other languages.
- unusximmortalis 10y agoCan you give details why you "feel" that way about Elixir?
- desireco42 10y agoDefinitely, future is in multi-processor architecture, something Elixir is naturally built for. Plus, even though it is nominally looks like Ruby, it is very different beast, functional and elegant.
- tbrooks 10y agoI feel the same way about Elixir here's why: - docs - testing - Slack chan, IRC, mailing list - package manager (Hex) - build tool (Mix) - web framework (plug & Phoenix) - db framework (ecto) - books from major publishers (manning, pragprog, etc.) - ElixirConf - ancillary teaching (ElixirSips, LearnElixir, Elixir Fountain, etc.) - helpful blogposts and stack overflow answers All these things sum up to lower barriers of entry when trying a new language. Elixir has it in spades. It's really easy to pick up and learn the syntax and predicates of the language (BEAM, OTP, etc.) Even though Crystal is closer to Ruby in syntax and Ruby can be valid Crystal -- Elixir still feels easier, because there is less work to be done with learning everything else.
- desireco42 10y agoWithout taking anything from Crystal, because there is nothing wrong with Crystal... Elixir has so many superstars working on/with it.
- tbrock 10y agoI just played around with it. Wow! Last time this came up on HN I shrugged it off but after playing around with it a bit as a former Ruby programmer I'm in love. Super simple to compile a little binary and it's blazing fast when I run it. I think I'll be donating some money. Bonus: Running `crystal init app <appname>` dumps out an opinionated starter project layout for you complete with travis.yml, test specs, and README. Maybe it's the old Rubyist in me that digs a little convention but this is certainly a refreshing departure from JavaScript madness.
- AstralStorm 10y agoNot strong enough of a package. Add some features to sell it. Safety, design features, testing support, concurrency and more...
- hamandcheese 10y agoYou must not have taken a very close look because the concurrency story is already great (and will one day turn in to a great parallel story), the built in testing library has a very useful set of assertions and an RSpec like BDD syntax, and safety far exceeds Ruby -- the compiler knows the type of all variables and won't ever let you make an "undefined method foo for Nil class" type of error.
- AstralStorm 10y agoIt is a library, not a part of the language. I can have a great testing library in any language. By language I mean actual language, keywords, syntactic constructs. Formal logic descriptions even. I haven't looked closely enough, the concurrency looks decent but it's not as integrated as in certain other modern langs (e.g. Go, Erlang or certain other FP languages, even certain ones riding on JS) It is sad to see something this outdated starting up now...
- RX14 10y agoI'm sorry what? Crystal's type system is both expressive and safe compared to most languages. It has generics, tagged type unions and dynamic dispatch. It has a built in spec runner and testing suite which are highly usable and proven on the compiler. Most of all, it is already concurrent. Crystal has lightweight fibers implemented in assembly for x86, arm and arm64. It has channels to communicate between fibers. All io is evented by default, where the http server manages over 100,000 requests per second per core. Its obvious to me you don't know what you're talking about.
- z3t4 10y agoIt looks very nice, I like that you can have beautiful syntax and performance at the same time. But it lacks a modular interface for modules and libraries that does not import hidden/global variables. They should look at NodeJS for inspiration.
- RX14 10y agoRuby is quite a large language with a large ecosystem of libraries, but I have never seen or heard of major issues with module name clashes. Libraries tend to have quite unique names and stick to their modules. Crystal works pretty much the same, so I personally don't think a change is needed.
- oelmekki 10y agoAn interesting thing: https://github.com/crystal-lang/crystal/blob/master/src/concurrent.cr#L31-L57 https://github.com/crystal-lang/crystal/blob/master/src/conc... Looks like they took the Fiber concept of ruby and made it into something like goroutines, with channels handling.
- sdogruyol 10y agoYou can take a look at Crystal for Rubyists (http://www.crystalforrubyists.com/book/chapter-08.html http://www.crystalforrubyists.com/book/chapter-08.html) for more info on Channels and Fibers.
- oelmekki 10y agoActually, I'm now a golang developer, so there are no big surprise, here ;)
- deleted 10y ago[deleted]
- Doctor_Fegg 10y agoWow. Genuinely fast: benchmarks usually somewhere between C++ and Java, orders of magnitude better than Ruby. https://github.com/kostya/benchmarks/blob/master/README.md https://github.com/kostya/benchmarks/blob/master/README.md
- AstralStorm 10y agoTry something that is more its weight, like Rust.
- thewhitetulip 10y agoHow does this compare with Go? tech and non tech things?
- faaq 10y agoThe first item is the syntax, Go use braces while Crystal is Ruby based syntax. Go has full parallelism support. Crystal is WIP. Go has Windows support. Crystal is WIP. Crystal and Go performance are very similar. Go is backed by Google and his community since 2009. Crystal is backed by Manas.tech and his community since 2012. Go has full featured IDEs like https://www.jetbrains.com/go/ https://www.jetbrains.com/go/ I hope to have Crystal IDE support after 1.0 :-)
- thewhitetulip 10y agoSo I'm happy with Go as long as Crystal gets more features
- cosarara97 10y agoThoughts on the conservative garbage collector? How often is it a problem?
- RX14 10y agoCrystal uses libgc, from the readme: [0] "Since the collector does not require pointers to be tagged, it does not attempt to ensure that all inaccessible storage is reclaimed. However, in our experience, it is typically more successful at reclaiming unused memory than most C programs using explicit deallocation. Unlike manually introduced leaks, the amount of unreclaimed memory typically stays bounded." Having used the language for a year, I've never really had an issue with the gc other than with really large (think 100mb+),infrequrnt, single allocations which get "stuck" and don't get returned to the OS after. This is a by product of the gc being unable to move objects to compact the heap. This situation can usually be rectified by loading a large file as a stream instead of loading it all into memory. Crystal has excellent tools for working with streams (see IO module) however, so it's not that big of a deal.
- stOneskull 10y agoLooks good. I don't like all the 'end' statements though.
- softawre 10y agoI remember thinking that when I first learned ruby. It reminded me of truckers talking over a CB radio. Over.
- asterite 10y agoHere are the reasons for 'end': https://github.com/crystal-lang/crystal/wiki/FAQ#why-isnt-the-language-indentation-based https://github.com/crystal-lang/crystal/wiki/FAQ#why-isnt-th...
- stOneskull 10y ago"there's no point in trying to suggest changing the language to an indentation-based one" Ok. Bit of a bummer though.
- faaq 10y agoWhat are the issues or features that crystal needs to solve before 1.0?
- reednj 10y agoI find ruby plenty fast enough for sites in the 1k/min requests range, but I have serious problems getting it to run fast enough with websockets. Even 40 concurrent websockets connections through ruby is enough to bring down my hosts. Does anyone have any experience using this with websockets? How does it perform?
- RX14 10y agoCrystal has websockets built into the standard library, and as with almost everything built in crystal it uses evented io. Here's a benchmark: http://serdardogruyol.com/benchmarking-and-scaling-websockets-handling-60000-concurrent-connections-with-kemal http://serdardogruyol.com/benchmarking-and-scaling-websocket...
- stewbrew 10y agoCan I create a shared library with it? Can it be used to write a ruby extension?
- spalladino2 10y agoSee https://gist.github.com/spalladino/10c829db3191a89a8ba73bb001d3c921 https://gist.github.com/spalladino/10c829db3191a89a8ba73bb00... We'll probably build it into a more stable shard eventually, but at least we know it's doable
- RX14 10y agoThe answer is technically yes but you probably don't want to. Crystal comes with a managed runtime and gc, which are particularly unsuited for use in a shared library. However you can export c functions (it's a hidden feature) and they do work. Creating a ruby extension in crystal also works and there are a number of libraries which attempt to allow you to do this (too many in fact). They do the hard work of getting crystal to play nice with the ruby extension api for you.
- imaginenore 10y agoFloats defaulting to Float64 instead of Float32 seems wasteful.
- faaq 10y agoUntyped number literals is the second issue with more number of +1 reactions. https://github.com/crystal-lang/crystal/issues/2995 https://github.com/crystal-lang/crystal/issues/2995
- agentgt 10y agoI thought about using Crystal for some roguelike game I wanted to program (but alas with a new baby do not have the time for anymore). The reason being that it is OOP. I eschew OOP (particularly for biz software which is my day job) but have to admit OOP still is a pretty good fit for UI and video game programming. I tried some reactive FP game programming and I just didn't make as much progress as I would have liked. I tried googling for some roguelike crystal programmed games and didn't find any yet (it is difficult because crystal has lots of conflicts particularly with rpg like games)....