5 ms·
What was cool was Rails, IMHO, and Ruby was the surprise inside it. I've had my own personal Advent of Code these holidays, coding a small API for a personal n
by pantulis 5y ago
What was cool was Rails, IMHO, and Ruby was the surprise inside it.
I've had my own personal Advent of Code these holidays, coding a small API for a personal need. Ruby (Sinatra) took one morning to full deployment in Heroku. Then I tried Crystal (Kemal) and it took me a couple of days to figure out how to map JSON to Crystal data structures. Then I rewrote it again in Rust (Rocket). Two weeks till I figured out, well, almost everything.
My opinion: they will take dynamic typing from my dead cold hands.
- brigandish 5y agoI also took a while to get used to the typing in Crystal but once you do get it, it's worth the effort IMO. I occasionally still fire up Ruby but if I have anything more to do than a quick command-line command, I use Crystal, so many less problems.
- pantulis 5y agoCrystal was overall a pleasant experience, which I cannot say for Rust. Although it was probably my fault: 1) for being "rusty" as a programmer myself, and 2) having zero experience with Rust. I want to believe that once you get over the learning curve in Rust development speed becomes much higher. Surprisingly, Crystal seems to be much leaner in runtime size than Rust, with similar performance (although the use case is so simple that even good old Ruby is fast enough). But then again, I feel you cannot beat Ruby in terms of dev productivity.
- m12k 5y agoI've heard it described that Rust allows you to write programs in a specific way. If you try to write them in any other way, you're going to have a very, very bad time, and fight the borrow checker every step of the way. But if you embrace that way of writing programs, it makes it pretty easy, you get really good error messages, and as a cherry on top your program will be provably sound in a way pretty much no other language can guarantee. So it all comes down to whether you're interested in learning that specific way of structuring programs.
- pantulis 5y agoThat's true, but then it is not "allowing" or "enabling" me, it is "forcing" me to do it that way. Of course, the Rust compiler is catching a gazillion bugs beforehand, so this is cool: you finally feel like your program will have no bugs once you manage to compile it. Error management through Option values, the borrowing checker... they are cool technologies for a C-like language, but they are not palatable at the beginning (maybe they are an acquired taste like beer?). I am tempted to stretch it a little bit more and see how productive I can become writing Rust code, but also not so sure about the effort.
- syspec 5y agoThe real cherry on top is that you can put "written in Rust. Modern. Fast" on your project description.
- brigandish 5y agoI also gave Rust a go (last year? Hard to keep track since the pandemic) but the book I was using was geared to C programmers so I quickly lost interest, though I would like to understand what the hype is about. I think the bit about productivity may certainly be true if you have to use libraries, obviously Ruby has many more available now (maybe forever), but I certainly feel more productive in Crystal now, maybe for things other than the language itself, admittedly. For example, producing a binary makes installation a breeze, and I don't worry about which version I'm running as I point the right compiler at the code; no Bundler now, library installs are sane (at last!); and socially I find the lack of "rockstars" in the main team refreshing, I have no fear of being dissed or dismissed, it makes contributing easier.
- Lio 5y agoI think I'd be more interested in Crystal if it was easier to integrate into existing ruby code bases via something like the FFI. As it is from Ruby 3.0 we have built in optional static typing and with interesting projects like Sorbet Compiler[1] we have the option to statically compile making use of that. It's still WIP I believe but it's giving ruby devs some cool options. 1. https://sorbet.org/blog/2021/07/30/open-sourcing-sorbet-compiler https://sorbet.org/blog/2021/07/30/open-sourcing-sorbet-comp...
- brigandish 5y ago> I think I'd be more interested in Crystal if it was easier to integrate into existing ruby code bases via something like the FFI. That would be very nice, I agree, though I've always found the FFI interface an under-documented pain so I'd probably end up just using Crystal or using some other way to interoperate, like pipes or HTTP. On Sorbet, I just hate the look of it. I know it's subjective (possibly that's Ruby's own fault for being so delightful to look at, I'm spoiled!) but I can't abide the syntax. Crystal's is much nicer, and has some extra sugar sprinkled on top for the moments you're most likely to be using it (like external names in method signatures[1] or providing init args) that win out for me. Sorry about the formatting, I can't work out HN's markdown :/ # Ruby # from the Sorbet intro extend T::Sig sig {params(name: String).returns(Integer)} def main(name) puts "Hello, #{name}!" name.length end # Crystal def main(name : String) : Int puts "Hello, #{name}!" name.size end puts main "you" That's so much nicer to my eyes, and you don't need most of it as it will be inferred. Initialisation is nicer, too, (unless Ruby has been updated in this regard too? As I wrote, I use it much less now) # Crystal class A getter name : String def initialize(*, @name); end end a = A.new name: "Hacker News" puts a.name or without the getter and keyword arg: # Crystal class A getter name def initialize(@name : String); end end a = A.new "Hacker News" puts a.name Whatever suits. # Crystal # Example of external names def increment(value, by) # OK, but reads odd value + by end def increment(value : Int, by amount : Int) : Int # Better value + amount end puts increment 1, 2 but those types are easily inferred so it's actually: # Crystal def increment(value, by amount) # Even better value + amount end I could go on because now I'm comfortable with it, it looks much better. I feel the way moving from Perl and C# to Ruby felt. [1] https://crystal-lang.org/reference/1.3/syntax_and_semantics/default_values_named_arguments_splats_tuples_and_overloading.html#external-names https://crystal-lang.org/reference/1.3/syntax_and_semantics/... Edit: formatting, of course
- sam0x17 5y agoCrystal is also my go-to for writing a quick script to do something.
- pelasaco 5y agoThe "you should be using Crystal" post is mandatory in any ruby thread. If everyone saying "yes, Crystal" were actually using Crystal, then: a) they would see how far from "better ruby" is Crystal and b) The Crystal community would be huge.
- brigandish 5y ago> they would see how far from "better ruby" is Crystal Are you accusing us both of lying? How strange.
- pelasaco 5y agowould you mind to post your github/gitlab repositories with your Crystal projects? Looking here I couldn't find anyone https://github.com/yb66?tab=repositories&q=&type=source&language=crystal&sort= https://github.com/yb66?tab=repositories&q=&type=source&lang...
- brigandish 5y agoSo you are accusing me of lying, how lovely of you! Let's see if your accusations can hold up to Socratic questioning: - If I haven't open sourced any Crystal projects does that mean I haven't written any? - I have published several Ruby gems[0], when was the last commit or version bump for any of them? You're more interested that I am, tell me. I really should archive them, thanks for reminding me. - You missed off my Gitlab, what was the last public contribution I made there? (hint[1]) - What's the last gem I created? I reckon it's this one that I didn't publish[2] because the Rack team changed a public API in such a dumb way that I'd have to rewrite it and then mucked me around with a pull request to Rack that one of the core team copy and pasted in as their own commit while arguing against the pull. Weird, but lovely people, like yourself. Meanwhile, your cookies lack security. Yes, I want to continue working within this language and ecosystem… Does the sarcasm come through in my writing? - Why did you not check the Crystal repo?[3][4] Github has a search facility. Put my username in, and pick `commits` on the left. - How did you miss the forks of Docopt.cr[5] and Fancyline[6]? They're right there in my public activity log. Did you not see the merges into Fancyline of my code?[7] I have more to give, just trying to find the time. - Did you not see forks with commits such as xattr.cr[8], xdg.cr[9], and Pope.cr[10] - You didn't see I'd provided a project[11] for Mint so it can be run easier with Docker Compose? - Aside from that I have a whole host of changes to migrate.cr[12] still to push up. You can't know that but you might've guessed that I was at least working with that - and all the other forks of Crystal projects I have. That is all public and not the half of the Crystal code I look at. Should I expect an apology? If you were too cowardly to be straightforward with your accusations then I find it stretches credulity far beyond breaking that you could be big enough to provide one. We'll see, like you, I've been very wrong about people in the past. [0] https://rubygems.org/profiles/yb66 https://rubygems.org/profiles/yb66 [1] https://gitlab.com/arctic-fox/spectator/-/merge_requests/34 https://gitlab.com/arctic-fox/spectator/-/merge_requests/34 [2] https://gitlab.com/yb66/aes-gcm https://gitlab.com/yb66/aes-gcm [3] https://github.com/crystal-lang/crystal/pull/11201 https://github.com/crystal-lang/crystal/pull/11201 [4] https://github.com/crystal-lang/crystal/blob/1.1.0/CHANGELOG.md#files https://github.com/crystal-lang/crystal/blob/1.1.0/CHANGELOG... [5] https://github.com/yb66/docopt.cr https://github.com/yb66/docopt.cr [6] https://github.com/yb66/fancyline https://github.com/yb66/fancyline [7] https://github.com/Papierkorb/fancyline/pulls?q=is%3Apr+yb66 https://github.com/Papierkorb/fancyline/pulls?q=is%3Apr+yb66 [8] https://github.com/ettomatic/xattr/pulls https://github.com/ettomatic/xattr/pulls [9] https://github.com/dscottboggs/xdg.cr/pull/1 https://github.com/dscottboggs/xdg.cr/pull/1 [10] https://github.com/yb66/pope.cr/commits/master https://github.com/yb66/pope.cr/commits/master [11] https://github.com/yb66/Mint-Docker-Compose https://github.com/yb66/Mint-Docker-Compose [12] https://github.com/yb66/migrate.cr https://github.com/yb66/migrate.cr
- rattray 5y agoSurprised you didn't try Elixir? What about Sorbet?
- pantulis 5y agoWell, I did a little bit of research on Elixir a couple of years ago, so I felt like I had that covered. Using Kotlin + Ktor was also tempting.
- dnautics 5y agoit's way different now. I've actually never deployed elixir on a deployment service till last week (either: "was R&D and never deployed to prod", "I ran elixir on-prem inside a DC", "my prod environments have been managed by ops team"). It was surprisingly easy, had my first deploy (including installing the service provider's tool) in about... 3 hours?
- syspec 5y agoI would love to try elixir, but JetBrains still does not have an IDE for it. I'm addicted to their IDEs. I did try the community made plug-in for elixir, but had trouble getting the debugger to work which was a show stopper for me.
- dnautics 5y agoYou probably don't want to use an ide-driven debugger for elixir, you'll want to use :dbg which has a different "conceptual model" than what you are used to and doesn't map well onto Conventional debuggers. It's simply not the same due to the extreme high degree of concurrency in the beam VM
- syspec 5y agoWell, no I actually do want that in my local environment where the only request is my own. The fact that you are telling me that I don't want something, is why people some people find the Elixir community off-putting.
- sam0x17 5y agoHot take: I'd love to see JSON die and get replaced with something more strongly typed and safer to work with. What, I'm not sure, but it is, as you say, a major pain point no matter what language you're in. Either it's easy to work with, but insecure, or it's difficult to work with.
- mhoad 5y agoI moved to gRPC and protobufs for this exact reason. It’s so nice to work with.
- teleforce 5y agoApparently Rails is the killer application for Ruby just like Unix/Linux is a killer application for C. What Ruby enabled is something that was not feasible to be done by Java, PHP, Perl and Python (top four most popular languages for web at the beginning of Rails). For better perspective on the matter please check an excellent article by Patrick Lee, the author of the new Stanza language. [1]Stop designing languages. Write libraries instead: https://jaxenter.com/stop-designing-languages-write-libraries-instead-126738.html https://jaxenter.com/stop-designing-languages-write-librarie...