18 ms·
Microsoft rewrote Q# compiler in Rust
- avestura 3y agoIt was previously written in C# and F#: https://github.com/microsoft/qsharp-compiler https://github.com/microsoft/qsharp-compiler
- nwah1 3y agoWas there a write-up of what the goals of the rewrite were, and why they switched the language and made the new engineering decisions?
- bitwize 3y agoI don't think any language sparks joy the way Rust does -- not even Lisp and certainly not C# or F#. Rust gives the compiler lower memory overhead and attracts a broad base of developers.
- lionkor 3y agoWhichever language one prefers sparks joy like Rust does for you
- miohtama 3y agoWhile this is true on individual level, Rust has been ranked most liked programming language in many surveys and sparks joy to most of people more than other languages https://survey.stackoverflow.co/2023/#section-admired-and-desired-programming-scripting-and-markup-languages https://survey.stackoverflow.co/2023/#section-admired-and-de...
- antonvs 3y agoWhat's missing from a survey like that is correlation with prior experience and education. Python was a previous winner on those kind of surveys, and it's a terrible language in many ways.
- IshKebab 3y agoYeah someone needs to do a ranked preference test. Rank all the languages you are familiar with...
- tmtvl 3y agoFunnily enough I'm not very familiar with languages I don't like, probably because I elect not to use them.
- antonvs 3y agoLimiting to relatively well-known general-purpose languages I've used in commercial system development: Haskell, Scheme, OCaml, SML, Rust, Typescript, Smalltalk, Java, Scala, Common Lisp, Kotlin, C, C++, C#, Javascript, Forth, Delphi/Object Pascal, Turbo Pascal, Python, BASIC (various flavors), Fortran. How about you?
- nequo 3y agoWhat was your commercial application for SML?
- antonvs 3y agoWe developed the definitional model of a financial instrument modeling and simulation system in SML. The system included a DSL for specifying instrument models, so part of what the SML implementation did was act as a denotational semantics for that language. The intent was never to deploy it using SML, it was to flesh out and formalize the design, and act as a specification for development of the full system. The system was designed to run on a cluster long before the Kubernetes days, and so had to deal with many of the distribution, scaling, and concurrency issues itself, in addition to its business logic. One of the experiences I had while working on that system was that at the time, I was reading "Monad Transformers and Modular Interpreters" - a seminal paper by Liang, Hudak, and Jones - and I thought I could probably quite easily implement the paper's approach using ML parameterized modules, instead of the Haskell typeclasses used in the paper. I tried it, and was soon disabused of that notion. Partly as a result of that, we wrote the distributed simulation engine for a later version of the system in Haskell.
- Dudester230602 3y agoWhile I admire it I most certainly do not desire it - like Haskell. I need to ship things, not figure out some borrow of a monad.
- bitwize 3y agoLanguages with built-in checks for correctness, like type checking and borrow checking, help you ship software faster in the long run, cheaper, and with fewer bugs.
- antonvs 3y ago> I don't think any language sparks joy... Let the Marie Kondofication of programming languages begin. But one of Kondo's points is that "Only you can know what kind of environment makes you happy," i.e. there are no universals.
- ohgodplsno 3y agoBegin? The entire reason we have people trying to cram JavaScript everywhere is that, for some reason, it sparks joy for them. Hell, even going back, K&R vs Allman brace style was about what sparked joy. Color themes? Spark joy. At this point, I am convinced that the way to get a software developer to do anything is to just play on that need for joy.
- rmwaite 3y agoI agree with this. I use Fantasque Sans Mono for the same reason - k with a loop makes me feel warm and fuzzy for some reason.
- insanitybit 3y ago> The entire reason we have people trying to cram JavaScript everywhere is that, for some reason, it sparks joy for them. Wait really? I feel like it's just "you literally have no choice for frontend" and the various side effects of that.
- ohgodplsno 3y agoThat would explain frontend, yes. But that would not explain NodeJS, JavaScript for embedded microcontrollers, and so many more. Some might say it's Stockholm syndrome, but then there's the Python developers doing the same thing everywhere. And the LISP enthusiasts. So unless there's a lot of Stockholm syndrome (although it's not out of the question when it comes to LISP), a lot of it is easily explained by "me like language here, me go put language elsewhere to keep language"
- sudodude 3y ago
- tmtvl 3y agoYMMV, of course, I have a hard enough time managing with one style of brackets, Rust has, what, five (round brackets, square brackets, curlies, angles, and vertical bars)? Never mind the fact that some operators are prefix: do_something(a_thing); Others are infix: x = a + b * c; And yet others are postfix: foo.frobnicate()?; My sole braincell can't handle all that complexity, which is why I'll just stick with simple old Lisp.
- HumblyTossed 3y agoI actually don't like Rust. It just doesn't fit me. To each their own, I suppose.
- systems 3y agoWell Rust was written OCaml on which F# was based So i think this was probably for performance, not for any expressive reasons And personally i consider Rust to be from the OCaml/SML family of languages similar to F#, so i guess they moved within the family
- reocha 3y agoIf it isn't clear from this comment rust is no longer written in OCaml and is fully self hosted (as far as I know).
- klabb3 3y agoCorrect. In this context it’s perhaps also worth mentioning that Rust depends on LLVM.
- tialaramex 3y agoYes. Rust's compiler, rustc, is a bunch of Rust code that parses Rust syntax into an Abstract Syntax Tree to which it can apply macros, then this is lowered through two levels of intermediate representations, where more Rust code does the type inference and type checking and eventually borrow checking and various optimisations, until eventually it's lowered to LLVM Intermediate Representation LLVM IR, which LLVM will further optimise then produce machine code for the target architecture.
- reocha 3y agoImpressive knowledge o7
- Dudester230602 3y agoWhat do Rust developers tend to do while the code is compiling? Vote 'Rust' in all the programming language surveys?
- xedrac 3y ago
- pjmlp 3y agoI guess yet another minus for F# at Microsoft. Really funny how they manage it.
- progmetaldev 3y agoReally puts me off learning it, other than dipping my toes in functional programming and being experienced in C# and the .NET Core/Framework libraries. I thought it may be easier to start with F# before moving to another functional language.
- Jenk 3y agoThe tooling (Visual Studio, LSPs, etc.) around F# is very lacklustre, I wish it had better support from MS. At the moment F# just seems to be a playground for experimenting with FP ideas that then get ported to C#. As for learning a functional language, I recommend this Haskell tutorial[0], and accompanying video series of an experienced haskeller (Brian McKenna) running through it[1]. I've read countless texts and tutorials explaining Haskell and FP to me but it didn't fully click until I saw someone with experience using the language and tooling effectively. [0]: https://github.com/system-f/fp-course https://github.com/system-f/fp-course [1]: https://www.youtube.com/playlist?list=PLly9WMAVMrayYo2c-1E_rIRwBXG_FbLBW https://www.youtube.com/playlist?list=PLly9WMAVMrayYo2c-1E_r... There are a few other video series from other experienced haskellers available that may be better, too, I just haven't watched them so I cannot comment.
- progmetaldev 3y agoI appreciate the response. As someone that struggles with higher-level math, am I going to get a benefit out of starting with Haskell? I have built financial systems in various languages, so my issue isn't necessarily how to code math functionality. It's more of the abstract concepts that get me.
- Jenk 3y agoI believe you will, yes. You may not be able to jump right in to some of the deep discussions about type categories, I certainly can't, but I still have learned a lot from Haskell and both continue to use Haskell itself and use what it has taught me in other languages to my betterment.
- adamnemecek 3y agoMicrosoft gets developer relations.
- zohvek 3y agohttps://www.youtube.com/watch?v=EMldOiiG1Ko&ab_channel=fb https://www.youtube.com/watch?v=EMldOiiG1Ko&ab_channel=fb tldr: developers
- Dudester230602 3y agoKeep nerds around by letting them re-write things for no good reason?
- asylteltine 3y agoWhy not…just use rust then? I don’t understand the point of all of these niche languages in real life. Python, Go, rust, c, cpp, js, C#, kotlin, but why use others? Each of these have clearly defined strengths and community support.
- hu3 3y agoWhile I understand your sentiment, Q# is specialized for Quantum Computing: https://en.wikipedia.org/wiki/Q_Sharp https://en.wikipedia.org/wiki/Q_Sharp It's arguably different enough of a domain to justify a new language.
- Alupis 3y agoThis strikes me as a bold (probably marketing) claim more than anything. Looking at the example code, it seems to make use of many "quantum" libraries, but why could those libs not be made available to C# or whatever? Quantum computing is a niche, to say the least, and the field is far from clearly defined. This sounds a lot of IBM proclaiming RPG will be the best "big iron" language ever - and today nobody uses it.
- erk__ 3y agoProgramming languages for quantum computing needs to uphold some rules normal programs does not need to. The biggest is likely that no information may be destroyed when the program is run, from this follows that it needs to be reversible. This means that from any result you should be able to compute the input. Rules like these can be hard to uphold in normal languages (I have done it with a subset of rust in the past) so a specialized language is often used instead. There is probably more to it, but these are the parts I know a bit about.
- ko27 3y agoThe simple reason is that if you design your language with limitations of a quantum computing you can make certain guarantees about your program being able to physically execute on any quantum computer. You can find more details here: https://learn.microsoft.com/en-us/azure/quantum/overview-what-is-qsharp-and-qdk https://learn.microsoft.com/en-us/azure/quantum/overview-wha...
- FrustratedMonky 3y agoSo sad. Love F#, and Q# seemed like a natural extension, or at least brotherly. At a high level, it seemed like F# is more functional like OCaml, than Rust is. I'd like to hear more about the reasoning, was it just performance? How different was it to justify a re-write?
- hu3 3y ago> I'd like to hear more about the reasoning My guess is because Rust is great with WebAssembly and they seem to target it with Q#: https://github.com/microsoft/qsharp/tree/main/wasm https://github.com/microsoft/qsharp/tree/main/wasm
- ilc 3y agoMaybe WASM is going to finally deliver the dream of the JVM, and CLR. Maybe.
- pjmlp 3y agoOr P-Code, M-Code, TIMI,...
- FrustratedMonky 3y agoWell, wasm runs slower right? I'm not that familiar. Seems that if wasm is a goal, then that might negate they did this for performance. What other benefit is there to wasm that would make it a fit for Q#?
- hu3 3y agoSlower than native perhaps. But usually faster than JavaScript on V8. So if you want fast browser perf, Wasm is a great choice. There's also Wasm on the edge with the likes of Cloudflare Workers and Vercel https://vercel.com/docs/concepts/functions/edge-functions/wasm https://vercel.com/docs/concepts/functions/edge-functions/wa... It also has some interesting isolation properties.
- FrustratedMonky 3y agoThis got me thinking of switching from F# to Rust, so did search and found this article that was good comparison. Others thinking of F# and Rust might dig. https://jkone27-3876.medium.com/f-is-the-net-rust-62f71f8dae41 https://jkone27-3876.medium.com/f-is-the-net-rust-62f71f8dae...