9 ms·
Open-sourcing the Sorbet VS Code Extension
- jez 5y agoHappy to answer any questions about Sorbet, the VS Code extension, or anything else you're curious about!
- pxeger1 5y agoI'm just wondering why this wasn't open-source to start with
- chucke 5y agowhen shall we expect RBS support?
- ksec 5y agoI know Shopify are using it [1], Do you know if Github or Basecamp are using it too? [1] https://twitter.com/rafaelfranca/status/1479259699694477312 https://twitter.com/rafaelfranca/status/1479259699694477312
- jez 5y agoI haven't heard anything from GitHub one way or another about whether they use Sorbet. I'd be extremely surprised if Basecamp was using it, as DHH has always been particularly opposed to types, but again, I haven't heard anything one way or another from them.
- stanislavb 5y agoThanks for all the work! I've been wondering, are we to expect v1.0 at some point or we'll rely on daily/hourly new versions/updates?
- jez 5y agoOur goal with new Sorbet versions is to break things where it makes sense (fix bugs, improve types for the standard library) which sometimes introduces new type errors in projects using Sorbet. But wherever possible, we try to build autocorrects that allow for fixing or silencing those breakages. One little known feature here that works mostly well right now but could definitely be better is the `--suggest-unsafe` [1] flag, which will attempt to insert `T.unsafe(...)` in places in the program where there was a type error. Then in places where we improved Sorbet so that it no longer thought something was untyped, and started reporting errors downstream, you could run `bundle exec srb tc --autocorrect --suggest-unsafe` once after upgrading, and commit or delete the autocorrects as desired. It isn't a goal to have some sort of v1.0 milestone where new releases will not introduce type errors to a codebase that doesn't have any, which is I think what you're asking about. [1]: https://github.com/sorbet/sorbet/blob/master/main/options/options.cc#L473 https://github.com/sorbet/sorbet/blob/master/main/options/op... (edited to clarify phrasing in response to child comment)
- jrochkind1 5y agoThanks for the info! I don't use sorbet myself yet (although I am a ruby user), so this is not coming from any kind of educated basis, just an outside observer being curious, but I'm curious: > We don't currently have a plan or a desire to get to a state where upgrading to a new Sorbet version will not introduce new errors on a codebase that previously type checked, which is what I think you might imply you want out of a v1.0 release. That surprises me enough that I had to read it a couple times to make sure I was understanding how all the "not"s came out. I'd think that would be a thing you would straightforwardly want out of at type checker, the thing you said you don't have a plan or desire for. I'm interested in hearing more about why not, here or a link to somewhere else.
- bitwize 5y agoAny chance of this becoming supported in VSCodium?
- jez 5y agoI don't see why it wouldn't be supported! If the APIs are the same as VS Code's APIs, you should be able to build the VS Code extension from source and load it into VSCodium at your convenience.
- bitwize 5y agoYeah, VSCodium is just a build of the open-source VSCode base, it just can't connect to Microsoft's extension store because that's reserved for Microsoft's proprietary build. It should have the same APIs. I just wondered if the maintainers would officially support this use case. I'm not a VSCode user, but I do not trust Microsoft to dominate the entire dev tool ecosystem, and a stronger alternative base built around VSCodium would be a good thing.
- teaearlgraycold 5y agoYou can download the extension off of the official VSCode extension store in a web browser and install it manually in VSCodium.
- pqdbr 5y agoIs there official support for Sublime Text 3? I tried making it work a while ago and it wasn't easy to get it running.
- jez 5y agoWe don't have anything custom on our end, but Sorbet implements the Language Server Protocol which it looks like Sublime Text 3 supports: https://lsp.sublimetext.io/language_servers/#sorbet https://lsp.sublimetext.io/language_servers/#sorbet These docs seem to even already have a snippet you should be able to add to your config to integrate Sorbet with Sublime Text 3.
- square_usual 5y agoTwo questions (sorry if that's too much): 1. Sorbet isn't really great to use with Rails. I tried it out about a year ago - a few things might've changed but from scanning the relevant gems I think this broadly still applies. I used sorbet-rails but there were still a bunch of rough edges, eg. with using a class method on a model as a scope. The general theme was that Rails was doing quite a few things that make it super hard to type. ex - look at what it takes to do a type-safe pluck with sorbet-rails, and I don't think doing a typesafe select with association columns is even supported. Is there any acknowledgement of this from the Sorbet team itself, and will there be more to make the Sorbet with Rails experience better? 2. I'm really excited for the future of the Sorbet compiler. Like above, is there any work on making the AOT compiler work better with Rails?
- zomgwat 5y agoRegarding Sorbet and Rails, I recommend Tapioca [1]. The Rails app that I worked on had a few edge cases Tapioca didn't cover so I wrote a simple script to load the Rails app and generate RBI files (e.g. generate RBI definitions for fixture methods in ApplicationTestCase). The Tapioca codebase helped provide a path for that [2]. Tapioca also continues to add to their DSL compilers. The work to integrate Sorbet paid off very quickly. Also, T::Enum and T::Struct are handy in any Ruby codebase. [1] https://github.com/Shopify/tapioca https://github.com/Shopify/tapioca [2] https://github.com/Shopify/tapioca/tree/main/lib/tapioca/compilers/dsl https://github.com/Shopify/tapioca/tree/main/lib/tapioca/com...
- jez 5y ago1. I don’t know much about using Sorbet with Rails, but I do know that almost every major user of Sorbet that isn’t Stripe is using Sorbet with Rails! You might want to reach out in the #rails channel on our Sorbet Slack[1] for more? 2. Our focus for the Sorbet Compiler has always been more inward focused than Sorbet, so we focused pretty much exclusively on features that make the compiled code run fast on Stripe’s codebase. But you might be curious to read more about YJIT, the JIT compiler that was recently merged into Ruby 3.1—it’s being primarily developed by a team at Shopify where Rails performance is the highest priority. [1] https://sorbet.org/slack https://sorbet.org/slack
- 5y ago
- bilekas 5y agoThis might be a dumb question but is there a chosen license for the this source ?
- jez 5y agoWe open sourced it by merging it into the Sorbet repo, under which all code is Apache 2.0 licensed: https://github.com/sorbet/sorbet/blob/master/LICENSE https://github.com/sorbet/sorbet/blob/master/LICENSE
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- cmer 5y agoWill Sorbet and this extension allow for autocomplete of non-Sorbet signed methods? Or does it only expose methods with a signature?
- jez 5y agoIf Sorbet knows the type of the receiver of the method call, it will suggest completion results, regardless of whether any of the suggestions themselves have sigs, or whether you're inside a method with a signature. But without any sigs, there aren't going to necessarily be as many opportunities for Sorbet to know the type of the receiver as there would be with sigs. Here's an example https://sorbet.run/#%23%20typed%3A%20true%0A%0Aclass%20A%0A%20%20def%20sample_method_without_sig%3B%20end%0Aend%0A%0AA.new.sam%0A%23%20%20%20%20%20%20%20%20%5E%20try%20completion%20here!%0A%0A%23%20T.unsafe%28%29%20throws%20away%20type%20information%0AT.unsafe%28A.new%29.sam%0A%23%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5E%20also%20try%20here https://sorbet.run/#%23%20typed%3A%20true%0A%0Aclass%20A%0A%...
- czbond 5y agoThank you - Great looking release! Other Ruby extensions seemed like afterthoughts or incomplete efforts. Does Stripe use Ruby enough internally to "bootstrap" this from the ground up?
- lambda_lord 5y agoStripe has a huge existing Ruby codebase that powers a lot of the dashboard and more. But there’s also a push towards Java for new services. Notably, Stripe does not use Ruby on Rails: instead there’s a few homegrown frameworks used for routing, storing data in a database, etc.
- altdataseller 5y agoWhy the push towards Java for new services?
- jeffwilcox 5y agoCongrats on this milestone!
- jez 5y agoThanks!
- user1988_203 5y agoCan someone explain how this fits into .rbs files? Would sorbet support adding/reading types as part of .rbs files in the future. I personally find adding types inside ruby files to be unreadable. Well, this is just my personal opinion.
- jez 5y agoThis article might help clear some things up: https://sorbet.org/blog/2020/07/30/ruby-3-rbs-sorbet https://sorbet.org/blog/2020/07/30/ruby-3-rbs-sorbet tl;dr: - RBS files are what Ruby 3 uses to describe types in separate files - RBI files are what Sorbet uses to describe types in separate files - Sorbet invented its RBI file syntax before RBS files existed. RBI files use the same syntax for types and signatures as in type annotations that live inside `*.rb` source code with Sorbet. - We've been meaning to add support to Sorbet to consume both RBI files and RBS files, but we haven't had a chance to get around to it. If someone beat us to it and implemented support for RBS files in Sorbet that would be amazing! Shopify took an early stab at implementing an RBS parser in C++ for performance[1], but I'm not sure what the status of it is today. [1] https://github.com/Shopify/rbs_parser https://github.com/Shopify/rbs_parser
- deleted 5y ago[deleted]
- giovannibonetti 5y agoThanks for this great project. It's amazing that: - It works both for static analysis and runtime checks (unlike Typescript); - Static analysis runs super fast even in a large codebase (unlike Erlang's /Elixir's dialyzer). It's a shame that it didn't become the official Ruby type checker.
- irjustin 5y agoYeah I'm sad about that too. I really dislike the official implementation because I can't easily see the function signature requirements. Maybe w/ a VSCode extension but that means i can't read the signature a browser.
- cutler 5y agoIt's funny how we hear so much about Ruby's decline yet 3 of the highest-valued startups - Stripe, Shopify and AirBnB - are up there making fortunes with it whilst contributing to Ruby's vibrant ecosystem.
- deleted 5y ago[deleted]
- trustfundbaby 5y agoOh wow. they still use Ruby at Airbnb? For some Reason I thought they'd moved to Go or the JVM.
- square_usual 5y agoI don't know about go (some cursory googling reveals a few open source projects, but nothing concrete) but you might be mistaking their work on Android libs for moving their backends to the JVM. For reference, their style guides are for JS and Ruby only so far.
- hack_the_news 5y agothe post mentions "At Airbnb, backend services are mostly written in Java "
- esprehn 5y agoYes, most of Airbnb's backend is JVM: https://medium.com/airbnb-engineering/building-services-at-airbnb-part-1-c4c1d8fa811b https://medium.com/airbnb-engineering/building-services-at-a...
- PaulWaldman 5y agoIsn't this more of a reflection of when these companies originally developed their platforms? Similar to Facebook and their use of PHP. It would be interesting to see in a few years what the next successful unicorns are building with today.
- dluan 5y agoAwesome to see and looking forward to trying it out. Thanks team!
- zelphirkalt 5y agoWhenever I see "xyz VS Code", I still read "xyz versus code" and wonder for a moment: "What is xyz and why don't they like code?".
- FGJFGJF 5y agotryeuyrdutyititFJVKVGKSAdbgbK CVKTFLYIUHGLGUJ GHKFGKMGK KHLB VKJ VKB,B