17 ms·
Ruby 3.1
- soheil 5y agoSigh... why couldn't they drop the : like js? {x:, y:} is a syntax sugar of {x: x, y: y}.
- jaynetics 5y agoI guess because keyword arguments couldn't use the same shorthand if they did.
- BurningFrog 5y agoI definitely like the clear visible syntax
- alex_smart 5y agoBecause unlike js, ruby chose to use {x, y} as the set literal.
- tinco 5y agoOhh since when is that? I've never seen or used that syntax and I sort of like it.
- alex_smart 5y agoSorry I found this page on Google but did not read the note on top. Looks like it was a proposed feature but was not implemented. https://dev.to/baweaver/ruby-3-set-literal-3fp9 https://dev.to/baweaver/ruby-3-set-literal-3fp9 Unfortunately it looks like I can't edit or delete that comment now. :embarassed:
- nauticacom 5y agoThis isn't true; Ruby has no set literal. Sets are provided by a default gem but there is no built-in syntax for them.
- alex_smart 5y agoSorry I found this page on Google but did not read the note on top. Looks like it was a proposed feature but was not implemented. https://dev.to/baweaver/ruby-3-set-literal-3fp9 https://dev.to/baweaver/ruby-3-set-literal-3fp9
- pxeger1 5y agoOtherwise you couldn't drop the braces like you currently can when passing hashes to functions. x, y = 1, 2 puts x: x, y: y # ==> {:x=>1, :y=>2} puts x:, y: # ==> {:x=>1, :y=>2} puts x, y # ==> 1, 2 Which would be inconsistent and annoying. (and knowing Ruby, I imagine there might be some syntactical ambiguities as well)
- soheil 5y agoI'm ok with having x:, y: but couldn't they drop the : if there are braces to indicate this is a hash? {x, y}
- ljm 5y ago{ x }, depending on where you put it, could be a block that returns the value of x. 5.times { x } This could either call the given block 5 times, or pass a hash of :x => x as the first argument.
- soheil 5y agoAh thanks that answers my other question.
- taf2 5y agoIs yjit support available now for more cpu architectures? Super excited to try this out
- thomasdziedzic 5y agoFrom the release notes, it looks like it only supports x86-64. From the bug report [0] it sounds like they may also support ARM64 in the future. [0] - https://bugs.ruby-lang.org/issues/18229 https://bugs.ruby-lang.org/issues/18229
- mabbo 5y agoIt's developed at Shopify, where every developer in the company was handed a new M1 this month. I presume it will support ARM based chips pretty quickly.
- tyingq 5y ago>where every developer in the company was handed a new M1 this month That's pretty interesting. They deploy, I assume to jitted ruby on X64 boxes, but will develop on M1 Macbooks. I suppose they probably have some kind of automated performance/crash/leak/etc regression tests in the pipeline?
- mabbo 5y agoI say it in the third person, but I actually joined Shopify in October. Development can be done locally, or it can be done via on-demand containers in the cloud with the IDE loading the code over a remote mount of the containers filesystem. I'm new to it all, but it's a very slick setup.
- Qem 5y agoBetween Ruby and Python, Ruby used to be deemed the slower language. With all recent improvements from the 3x3 initiative and yjit I wonder, does Ruby officially surpassed Python on performance?
- geospeck 5y agoNo news about Ractors! The new concurrency facilities that Ruby 3.0 introduced. Anyone has an insight if there was any further development on that front?
- ksec 5y agoCorrect me if I am wrong but I dont think much has happened in terms of Ractors. But lots of work happening on Fiber and Async. Edit: LOL ko1 replied [1] on Twitter "ごめんよ。来年頑張るよ " / "Sorry. I'll do my best next year". @ko1: Thanks for all your work on Ruby. [1] https://twitter.com/_ko1/status/1474769727109353474 https://twitter.com/_ko1/status/1474769727109353474
- byroot 5y agoTons have happened in stabilizing them, 3.0 had lots of Ractor related bugs. But no new Ractors related features no.
- Lammy 5y agoIMO the most impactful improvement for Ractors right now needs to come from the community, because third-party Gems with C-extensions need to explicitly opt themselves in as Ractor-safe: https://docs.ruby-lang.org/en/master/doc/extension_rdoc.html#label-Appendix+F.+Ractor+support https://docs.ruby-lang.org/en/master/doc/extension_rdoc.html... "By default, all C extensions are recognized as Ractor-unsafe. If C extension becomes Ractor-safe, the extension should call `rb_ext_ractor_safe(true)` at the `Init_` function and all defined method marked as Ractor-safe. Ractor-unsafe C-methods only been called from main-ractor. If non-main ractor calls it, then `Ractor::UnsafeError` is raised." I've submitted a few such patches for my own personal use, and it's a very trivial change for extensions which keep no state in C-land that would need to be synchronized between Ractors, e.g. https://github.com/dearblue/ruby-extattr/pull/1 https://github.com/dearblue/ruby-extattr/pull/1
- sandstrom 5y ago"The following default gems are now bundled gems." Great to see slow removal (or carve out) of rarely used stdlib stuff. Ruby would benefit from a trimmed down stdlib, where effort could be spent keeping a smaller footprint stdlib more polished than it is today. Turning them into opt-in gems is a good first step. A few examples: - `rss` to parse RSS documents/streams - `win32ole` for Microsoft Windows OLE Automation - `dbm` for DBM databases - `abbrev` for finding the shortest unique abbreviation amongst many strings This page has more details: https://stdgems.org/ https://stdgems.org/
- nerdponx 5y agoPython has a similar issue, with lots of so-called "dead batteries" in the standard library. https://discuss.python.org/t/pep-594-removing-dead-batteries-from-the-standard-library/1704 https://discuss.python.org/t/pep-594-removing-dead-batteries...
- Eric-Guo 5y agoRuby 3.2 will having much shorter default gem list https://github.com/ruby/ruby/blob/master/NEWS.md https://github.com/ruby/ruby/blob/master/NEWS.md Just waiting another year!
- nfm 5y agoFor diff, see: https://github.com/ruby/ruby/commit/a91605c9dafe70a95a1c4a02f265ba8f3280124b https://github.com/ruby/ruby/commit/a91605c9dafe70a95a1c4a02...
- jupp0r 5y agoI was always under the impression that the quality of stdlib was much better than other languages (especially the documentation).
- ljm 5y agoEnumerable alone is enough to outclass many stdlibs. Easily one of my fave things about Ruby, compared to dealing with different types of iterable interfaces (and conversions between them) in other languages.
- gouda-gouda 5y agoThank you Matz and team! Lot of awesome stuff in this release.
- burlesona 5y agoRuby now has “punning.” > Values in Hash literals and keyword arguments can be omitted. [Feature #14579] > {x:, y:} is a syntax sugar of {x: x, y: y}. > foo(x:, y:) is a syntax sugar of foo(x: x, y: y). This is going to be controversial and take some getting used to, but I think eventually everyone will love it. It’s not an easy syntax to learn - I remember when this came to JS it took a while to get my head around all the different ways this shorthand was used in the wild. It’s hard to come up with new syntax that can peacefully coexist with the established language. I think in hindsight it would have been helpful for Ruby if it had done something like square braces instead of brackets for hash literals, or not allowed brackets for blocks. The most ambiguous syntax all involves hash literals vs blocks… this adds to that cognitive load. But typing out a long hash literal just to capture a bunch of local variables or methods is so common, and the duplication is quite annoying, so on the whole I’m glad this was added and am sure I’ll use it a lot :)
- codesnik 5y ago"everyone wants the colon" / Larry Wall. perfect example.
- codesnik 5y agoI wonder, will there be a breaking change for older syntax, where it was previously foo x: [1,2,3] Or maybe that "punning" will work only inside of () and {}?
- jaynetics 5y agoOf course cases where parentheses are omitted will keep working like before, changing this would silently affect huge amounts of code. See also https://zverok.github.io/blog/2021-12-08-value-omission-debug.html https://zverok.github.io/blog/2021-12-08-value-omission-debu...
- sodapopcan 5y agoI'll throw myself out there to say that after being forced to read punning in JS for the past 2+ years, I've never come around to it. Sure it's quicker (and I'll admit even nicer) to write, but even after seeing it daily for so long, I still find myself doing double-takes on what I'm looking at, and I need as little as possible of that while reading code. I'm a little disappointed that Ruby introduced it but no one is forcing me to use it so to each their own (and I'm not writing Ruby or much JS professionally anymore so it doesn't affect me too much).
- dwheeler 5y agoRelated: I believe there is ongoing work (not in 3.1) to modify the CRuby implementation to use shapes/hidden classes. This has significant potential to speed things up. More info: https://chrisseaton.com/truffleruby/rubykaigi21/ https://chrisseaton.com/truffleruby/rubykaigi21/
- ksec 5y agoI thought TypeProf is really interesting but doesn't seems to get much attention. I am also wondering if anyone is using RBS in production. Apart from big shops like Stripe / Shopify.
- thomasdziedzic 5y agoI believe Stripe and Shopify only use RBI in production since Stripe develops Sorbet [0] and Shopify develops Tapioca [1]. Both tools work exclusively with RBI files instead of RBS files afaik. I haven't heard of anyone using RBS in production. [0] - https://sorbet.org/ https://sorbet.org/ [1] - https://github.com/Shopify/tapioca https://github.com/Shopify/tapioca
- byw 5y agoI'm surprised there doesn't seem to be more interest in type-checking in the Rails community at large (maybe I'm wrong). TypeScript has been make-or-break when choosing a company I apply for.
- nitrogen 5y agoRuby's extremely rapid iteration cycle (e.g. by embedding pry for debugging and experimentation), good test coverage, and fast search tools like ripgrep and fzf alleviate a lot of the pain you might get from the lack of static types. There are also gems for schema validation that predate Ruby's type annotations and help with runtime type checking on data coming from the wire or disk.
- zem 5y agorails does a lot of metaprogramming, which makes static type checking much harder
- purple_ferret 5y agoLove Ruby. Personal language of choice. People keep predicting its death, but it just keeps getting better and better!
- barrenko 5y agoYou predict something's (or someone's) death, you better kill it on the spot :).
- dysoco 5y agoWhat a coincidence, I just started learning a bit of Ruby with an interpreter I'm writing a couple of nights ago. I will take the opportunity to ask; does anyone have a good introduction to creating Ruby (not Rails) projects? I'm a bit confused between rake, bundle, testing frameworks, how to debug a program or structure a project and I can't seem to find a good up to date resource on that.
- tinco 5y agoBundler has a nice subcommands for setting up a new gem. Setting up a test framework depends on which one you pick. The big switch from rails is that you get to decide where everything goes. I suggest looking at some recently created gems by prolific rubyists to get a feel for the structure.
- l8nite 5y agoI don’t know a great “how to lay out” guide off-hand, but I’ll take a stab at helping with the confusion. Rake is a Ruby equivalent of Make. Many Ruby gems will include rake tasks (Makefile targets) that can be used to drive pieces of an application. Most of the time your test framework of choice (rspec typically) will include “rake test” as a target for running the tests. The tests usually live in a folder named “spec”, while application code lives in “lib” and your driver code lives in “bin” or just a top-level file… without some of the Rails initialization glue, you’ll have to do a little work to require files via relative paths or set up the $LOAD_PATH variable, etc. Bundler is the package manager, and you’ll often see commands like “bundle exec rake”, this is similar in spirit to a virtualenv. Bundler will use the libraries defined in your Gemfile to run the given program (in this case, ‘rake’). The command “bundle” will read the Gemfile and resolve dependencies to concrete versions of libraries and write out a Gemfile.lock for you with all the versions explicitly defined. For debugging, there are a number of tools out there, but I’m partial to ‘pry’. You add pry to your Gemfile, require it, and then can add a breakpoint by putting a call to “binding.pry” in your source code wherever. This will drop you into a REPL within the context of the program at that point. pry is useful, but there are some other gems and settings files out there that can make it a little friendlier, pry-byebug comes to mind as having saner keyboard shortcuts iirc. If you need help with overall file system layout, etc, the best place to look is going to be existing trivial gems on rubygems.org. Granted these will have a couple of minor differences from a “plain” application because they’re packaging as a library (*.gemspec file instead of Gemfile, and usually has a version.rb file somewhere).
- colesantiago 5y agohas this released on stable with the asdf tool? can't wait to try this out!
- deleted 5y ago[deleted]
- breatheoften 5y agoHow good is `debug.gem`? I'd be excited to try it if I was still using ruby ... I'm not using ruby anymore but the debugger experience I had from vscode via the rdebug-ide library a few years ago was _mostly pretty_ nice aside from very performance limitations ... a massive performance improvement on that front must feel great!
- hemantv 5y agoWhat is best way to master Ruby for generalist engineer? I know C++ and Python, JS, Typescript well enough. Python was easiest, since it took couple of days to master fundamentals and I was writing good code in no time. Also anyone working on Typescript equivalent for ruby?
- mega-tux 5y agono exactly the same as js->ts but Crystal language in a typed, compiled lang. with Ruby like syntax but other nice features like Go like concurrency & speed, macros, great C interop. and they are working on an interpreter, too.
- ljm 5y agoSorbet[0] is probably the closest to what you're looking for. It's not something I would recommend to someone who wants to get started with Ruby, since it would be limiting to learn it as if it was a statically typed language. [0] https://sorbet.org/ https://sorbet.org/
- lloeki 5y agoSorbet is OK if you want to type an app, but falls apart for a lib. RBS (descs) + Steep (type checker) is a bit younger but I found it more usable in general, especially on the corner cases.
- ljm 5y agoYeah I've tried setting it up for a library but Sorbet won't pick it up, Tapioca won't pick it up. It'll generate its own types which are exactly what I don't want. Beyond that, it's too intrusive in the code for me. I could live with 'sig' blocks above methods, but there's an immediate readability cost when you start having to wrap stuff in T.let, T.must, T.nilable, etc. Personally I'd rather improve my testing skills here too. Knowing how to write a good test is a valuable skill.
- oezi 5y agoIf you are already up to speed with many programming languages then getting into Ruby shouldn't be that hard. Some syntax is a bit quirky (blocks in particular) but if you are solid in OOP then you soon see the beauty of the core class setup. The primary difference to Python is that everything really is a method call on a object (even if that object is a class). To master Ruby I would start with toy problems such as Advent of Code.
- nomilk 5y agoI really can't wait to use the IRB Autocomplete feature. Aside from the obvious advantage of tabbing (convenience, fewer typos etc), it's a subtle way to improve discoverability of available methods. Very cool.
- bradgessler 5y agoPSA: Ruby 3.1 isn’t compatible with Rails 7.0.0. There’s a patch in the world that’s coming soon.
- ghiculescu 5y agoYou can use the 7-0-stable branch for now - https://github.com/rails/rails/issues/43998#issuecomment-1001083244 https://github.com/rails/rails/issues/43998#issuecomment-100...
- TedShiller 5y ago
- firemelt 5y agodid you guys know any updates about the static typing ruby? I wish it could be more like typescript