1. 3

    This was quite and interesting reading!

    It would be interesting to see also an example that deals with more complex ocaml structures, like records containing strings, bytes, and (why not) arrays or lists. Or maybe a GADT. Although I think it would just make the plumbing More complex but be not much more than what you do writing the usual C bindings

    1. 5

      I would love to see a language like OCaml (or another ML like dialect) to be able to make use of Rust’s emerging ecosystem, but I’m afraid we’re still a long way from seeing that happen. Also check out Gluon http://gluon-lang.org/ for an ML like language embedded in Rust (personally I’d prefer a standalone language that works with Rust though).

      1. 2

        I’m a little confused. Outside of being developed in Rust what makes gluon “embedded in Rust” vs a “standalone language”? It appears that while gluon is heavily influenced by Rust it can, and does, function as a standalone language as well if you wanted it to. Which, as they point out, is similar to lua.

        I feel like embedded in the context of gluon only applies to their goal of being easy to embed as opposed to being embedded itself.

        1. 2

          I agree that it ‘can’ function as a standalone language as well. But I am not sure if I agree it currently does, AFAIK you can’t create a gluon ‘script’ that runs with #!/usr/bin/env gluon and neither can you compile a gluon source to a binary without embedding it first in a Rust application. I am also unsure whether you can write a gluon module using rust and then import it from your ‘standalone’ gluon program.

          So I disagree that embedded in the context of gluon only applies to their goal of being easy to embed as opposed to being embedded itself.

          But I do realize my criticism might be easily solved (although I have some doubts about the ‘write a gluon module using rust and then import it from your standalone gluon program’ part).

          Please correct me where I am wrong, I’m fairly new to both Rust and Gluon.

          1. 1

            I’m fairly new to both Rust and Gluon.

            Ditto. Thanks for clarification.

    1. 3

      Folks, I recall reading somewhere that OCaml has something like a GIL and threaded/paralleled apps are a bit of an issue. Is this still true? Thanks!

      1. 10

        Yes there is a GIL and parallelism is currently doable with c bindigs as in python, but there is ongoing work for multicore (and algebraic effects) support: https://discuss.ocaml.org/t/ocaml-multicore-report-on-a-june-2018-development-meeting-in-paris/2202

        The work is still ongoing, and went through some iterations in the past few years, but the first bits should start landing by the end of the year

        1. 1

          That’s really great to hear, that things will be moving along in such short order. Do you have any good introductions to the topic of algebraic effects, beyond what I could get by searching on my own?

        2. 3

          Although Ocaml ignored multicore a long time, the Standard ML community keeps doing interesting projects in that space. MultiMLton is one example.

          1. 2

            Although GIL seems like a huge limitation, I’ve been actually quite impressed by how infime it was for most tasks (except if you do require huge throughput).

          1. 2

            When there are new releases of OCaml, usually the first comment is about multicore and modular implicit. They are not yet there, but things will start changing soon. Refer to [0, 1] for more information.

            [0]: Ocaml-multicore: report on a June 2018 development meeting in Paris https://discuss.ocaml.org/t/ocaml-multicore-report-on-a-june-2018-development-meeting-in-paris/2202

            [1]: Modular implicits https://discuss.ocaml.org/t/modular-implicits

              1. 7

                I don’t understand why OP didn’t actually progress from the “evaluating Rust based on online documentation” stage to the “trying to implement a solution in Rust” stage. The exact issue being looked at, responding to certain OS signals, is entirely trivial due to this crate, which came up with a simple DDG search.

                If the language has the problem that people are fighting with the language in order to become productive with it, perhaps something is wrong with the language, and not the programmers?

                This misses the point. Rust is opinionated about how code should handle sharing access to data, and about when data should be shared rather than copied. It has been observed that people often take time to adjust to this, which is noted in the docs. I don’t see why that’s an issue.

                1. 9

                  I don’t understand why OP didn’t actually progress from the “evaluating Rust based on online documentation” stage to the “trying to implement a solution in Rust” stage.

                  Author provided a solution in Rust…did you not read the whole article?

                  1. 3

                    He did a somewhat superficial research on what libraries or crates could be used though.

                    It is the same with ocaml/reason actually: he complains about the lack of a build system but the vast majority of packages are now using dune/jbuilder that is trivial to learn and use, well documented and extremely powerful, and he does not even mention it. He picks Containers as standard library replacement but it seems unclear to me if he has even evaluated base or core for example (even if I like containers myself). He also mention the introduction of multicore as something present even though it is nit yet part of the runtime yet

                    1. 8

                      somewhat superficial research

                      I think that’s pretty realistic for almost anyone in the same situation though. If I’m trying to decide between 3 or 4 different languages for a task that needed to be done yesterday, how much time do I really have to learn all the nuances of the ecosystem?

                      So, yeah, complain that he didn’t know about X, or didn’t know about Y… But, really, if you are a member of the Z community for which X and Y is relevant, instead of complaining that people missed this well known tool, help make sure that a newcomer’s first introduction to Z informs them of X and Y. That’d be super helpful.

                      1. 1

                        I agree with you, but I think the three communities mentioned above are doing the best to make sure that this is the case.

                        And about the reason/ocaml stuff, what I mention appears in most reason tutorials, almost every package and any recent blog or forum thread, and there are dozen of discussions on the current lack of multicore, so I still believe the research was superficial.

                        This said, I wasn’t claiming that the post is bad per se, I have found it quite interesting and I agree that the current situation is not bad but still suboptimal. I was actually pleasantly surprised to see that he dod actually implement some quite non trivial example code in all those, and even contributed to pony!

                        EDIT: updated twice to try and clarify my complaints

                    2. 2

                      Your question confused me for quite a while, as I was unable to find this Rust solution in the article, despite multiple reloads. The page looks like this to me: https://leotindall.com/static/noRustVersion.png

                      Eventually, I looked at it on my mobile phone where, mysteriously, there is a code snippet. I was baffled until I realized that, indeed, the only difference between my mobile device and my laptop is… I have JavaScript disabled in my browser on my laptop.

                      So, my apologies to OP on this one. I was unfair. On the other hand, this serves as a great cautionary tale: make sure your site works without JavaScript.

                      1. 2

                        make sure your site works without JavaScript.

                        Why draw the line at Javascript?

                        1. 1

                          Not him, so I can only answer for myself.

                          JavaScript is turing complete, so it can do everything and can communicate results outside my control, so I want the ability to stop that.

                          CSS is also turing complete, but AFAIK it can’t communicate outside without JavaScript, and unlike JavaScript it’s really hard to make it do something crazy like mine bitcoin (which with JavaScript is very easy to do).

                          1. 7

                            Now I want to write a Bitcoin miner in pure-CSS.

                            CSS is also turing complete, but AFAIK it can’t communicate outside without JavaScript

                            Enter: CSS Exfil and friends.

                            1. 1

                              Good lord.

                          2. 1

                            You’re right, I should revise that statement: make sure your site works without requiring me to allow you to execute arbitrary code just to read an article you wrote.

                            To be clear, there is an obvious tradeoff here: syntax highlight on the server side is annoying. My blog solves this by having an acceptable no-JS fallback that is less pretty but is not missing content.

                          3. 1

                            That sure would be confusing! It looks like the author embedded a gist, rather than using Medium’s code tool. I assume you can embed code in Medium without JavaScript….

                      1. 4

                        So what changed? I even reread the section that it only works with current, but I still don’t know what it is.

                        1. 7

                          In this particular case it is due to the added support for u128

                        1. 7

                          Another language that’s worth taking a look at for CLI apps is OCaml,this blog series has a good rundown of of porting a Python app.

                          1. 11

                            I really want to agree, because I love MLs and love how simple OCaml’s runtime is, but I find OCaml so frustrating in practice. There are, what, three standard libraries, which are incompatible with one another, and then also several incompatible build systems. I’m sure it’s possible to work around this and make them interpolate, but it drove me completely nuts last time I tried that route.

                            1. 1

                              Is the Reason flavour any better in those areas?

                              1. 1

                                I haven’t tried it for the dual reason that I don’t trust Facebook and it’s more a language that can target OCaml than genuinely OCaml. That may be unfair, and some old co-workers of mine love it, but I just haven’t tried it enough to form an opinion.

                            2. 2

                              I really never felt at home in MLs. I like haskell (although I am wary of its laziness, I usually prefer strictness as a default), I like Rust (although I would be happy to just have a GC instead of borrow-checking, but I can see what rust is aiming at, its just not my use case).

                              OCaml in my experience (1-2 years ago) lacked good tooling and the ecosystem I find in Rust or Haskell. Also I miss typeclasses or traits.

                              1. 2

                                The situation is still not perfect in OCaml world, but the new dune (former jbuilder) build system is becoming the de-facto standard and tooling in the last couple of years has been improving a lot. The example of cargo, among other things, has been driving a lot of changes

                            1. 1

                              I tried OCaml for a bit but the weirdness got to me after awhile. There was a ton of magic around project setup and compilation that I didn’t understand and couldn’t find properly explained, and the fact there is more than one “standard” library bugged the heck out of me. I’m hoping that once the Linux story solidifies a bit more around .NET I’ll be able to reasonably give F# a shot.

                              1. 3

                                I’ve been using F# on Linux for a few years now using Mono. It’s a bit more manual than .NET Core, but it’s stable.

                                1. 3

                                  If you’re interested in trying again, I created a build system (yes, yet another one) specifically designed for getting going fast in most cases. I have a blog post here:

                                  http://blog.appliedcompscilab.com/2016-Q4/index.html

                                  Short version: all you need is a pds.conf which is in TOML so fairly straight forward, a specific directory structure (src/<project>) and GNU Make. Then you run pds && make -f pds.mk and you’re done. Supports tests as well as debug builds.

                                  1. 5

                                    I’m not sure it is worth pushing yet another build system that seemingly nobody uses (at least I haven’t yet run across a package which uses it) when jbuilder seems to be gaining so much momentum in the OCaml world lately.

                                    1. 3

                                      Maybe, but pds is pretty easy to port away from for most builds and it’s so trivial to get started and much less confusing than jbuilder’s config, IMO. My personal view is that jbuilder is a mistake but I’ll wait to switch over to it once it’s gained enough momentum. At that point, I can just switch pds over to producing jbuilder configs instead. But I’m a symptom of the problem rather than the solution unfortunately. I also use @c-cube’s containers, so yet another stdlib replacement/extension :)

                                      1. 4

                                        My personal view is that jbuilder is a mistake

                                        Could you elaborate on why? IMO jbuilder is not perfect either but if we get a modern, documented build system which is hopefully easy to setup, it would be a massive win over all the other solutions we currently use.

                                  2. 1

                                    I agree, the different choices in tooling is sort of disorienting and it can lead to analysis-paralysis. For a toy compiler project I started working on, I tried to find the most basic tooling that would work: whatever ocaml compiler came with my distro, ocamlbuild, make, and then eventually, extlib, ocpindent, and then after some more time, opam, ocamlfind, utop. It may make sense to use the tooling outlined in this article if future maintainability is a big concern, but to get started and to learn ocaml, I don’t find it necessary (and definitely not appealing). Having done this, I don’t pine so much for standardization (;

                                    1. 1

                                      There’s more than one standard library in a lot of languages, though. Why does that bother you?

                                      1. 4

                                        It bothers me because it makes the language more difficult to learn. It also wasn’t always clear to me that an alternative was in use because, IIRC, they’re not (always) clearly namespaced. I have run into this in Haskell as well, FWIW.

                                        1. 2

                                          Typically it’s visible when you use an alternative stdlib because you start your files with open Batteries or open Core or open Containers. I agree it’s annoying that the stdlib is not richer, and it’s a bit slow to accept contributions, but in a way the existence of alternative stdlibs/extensions shows how easy it is to roll your own :-)

                                        2. 4

                                          You can’t have two standards, that’s a double standard!

                                          1. 1

                                            Which languages?

                                            1. 1

                                              Haskell, C, and D come to mind. You could also argue that Python has multiple standard libraries because it has different implementations that effectively can’t use some aspects of the normal stdlib (PyPy). Then there’s Java: SE, EE, and ME are the same language with different sets of functionality in the standard libraries.

                                          2. 1

                                            Out of curiosity, have you tried OP’s project setup?

                                            Also, there is only one OCaml standard library–the one that comes bundled with OCaml. The other ‘standard libraries’, Batteries Jane Street’s Core, are optional add-ons made for specific purposes.

                                            1. 2

                                              I haven’t tried OP’s setup, but honestly it seems even worse than what I had. I pretty much followed this: https://ocaml.org/learn/tutorials/get_up_and_running.html. I ended up using Oasis, which was just awful, every time I added a file or dependency I had to fiddle with the config until everything would build again, but at least there wasn’t an entirely separate language.

                                              From OP:

                                              (jbuild_version 1)
                                              
                                              (executable
                                                ((name main)                 ; The name of your entry file, minus the .ml
                                                 (public_name OcamlTestProj) ; Whatever you like, as far as I can tell
                                                 (libraries (lib))))         ; Express a dependency on the "lib" module
                                              

                                              Note the comment, “as far as I can tell”. To me, that’s a terrible sign. A person who has gone to a reasonable amount of effort to explain how to set up a project can’t even figure out the tooling completely.

                                              1. 2

                                                Jbuilder is quite nicely documented (see http://jbuilder.readthedocs.io/en/latest/). The public_name defines the name of the produced executable in the install context. It does not take much effort to read it from there

                                                1. 2

                                                  Of course you still have to find out that Jbuilder exists, which the official site doesn’t seem to mention… I am lazy, I don’t like choices, I just want one, blessed tool that works more or less out-of-the-box if you follow a set of relatively simple rules (I’m even OK with wrapping the tool in a simple, handwritten Makefile, which is what I do in Go). I’m not arrogant enough to think that the way I prefer is the “right” way, in fact in some cases it would be dead wrong (like for extremely complex, multi-language software projects), but that explains why I dropped OCaml for hobby stuff.

                                                  1. 1

                                                    OK, but your criticism is that you have to find out that JBuilder exists, commenting on a post that tells you about JBuilder.

                                                    1. 1

                                                      To be fair, jbuilder is very young (not even 1.0 yet actually) but it might become the “standard” build tool the OCaml community has been waiting for for years (decades?). Then clearly there will be more doc and pointers towards it.

                                                      1. 1

                                                        Well obviously I know about it now, but it still isn’t terribly discoverable for someone new to the language. My actual point, and I probably didn’t make this as clear as I should have, sorry, is that in my experience OCaml isn’t very friendly to beginners, in part because its tooling story is kind of weak and fragmented.

                                                        1. 2

                                                          Yeah. This is true. Especially on Windows. People are working on it but it’s slow and it’s taking time to consolidate all the disparate efforts. I myself am not getting terribly excited about OCaml native but funnily enough I am about BuckleScript (OCaml->JS compiler) because of its easy setup (npm i -g bs-platform) and incredible interop story.

                                                          Others are getting equally into ReasonML ( https://reasonml.github.io/ )because it’s coming from a single source (Facebook) is starting to build a compelling tooling/documentation story.

                                                          1. 2

                                                            I didn’t know about either of these, thanks!

                                                  2. 1

                                                    OP here: I didn’t really make any effort to pursue documentation re: the public_name field, and I have really almost no production experience with OCaml whatsoever. I certainly have complaints about OCaml’s tooling, but I can assure you that any argument against it appealing to my authority is certainly flawed.

                                                    1. 1

                                                      I wasn’t really appealing to your authority, in fact kind of the opposite. I don’t like using systems that converge to copy-paste magic, and that seems to be what you did, and is likely what I would do. I don’t want to use a weird programming language to configure my project, I want something simple, with happy defaults, that can be understood easily.

                                                      I guess I generally prefer convention over configuration in this case, and that doesn’t seem to be what the OCaml community values, which is why I gave up on it. I’m not saying anyone is right or wrong, it’s just not a good fit for me, particularly for hobby projects.

                                              1. 1

                                                I had to patch my infrastructure for XSA-213 as well: XSA 213-215 security patches applied. The commentary from Qubes opens with:

                                                XSA-213 is a fatal, reliably exploitable bug in Xen. In the nearly eight-year history of the Qubes OS project, we have become aware of four bugs of this calibre: XSA-148, XSA-182, XSA-212, and now XSA-213. Coincidentally, all of these fatal bugs have been in Xen mechanisms for handling memory virtualization for paravirtualized (PV) VMs.

                                                The two most recently, XSA-212 and XSA-213 were both discovered by Jann Horn from Google Project Zero, I believe while doing fuzz testing.

                                                We’ve certainly noticed the increased frequency of Xen security issues, I note in my post:

                                                Our average downtime this maintenance cycle was 35 minutes. The longest host server took 67 minutes, while the shortest took 15 minutes. This was less total downtime than previous maintenance windows, representing incremental improvements in our patching process.

                                                Between XSA-212, happening only a ~month ago, and XSA-213 we managed to squeeze in some procedural simplification in our playbook that hasn’t until now been worth spending time on.

                                                1. 2

                                                  Is Xen more vulnerable than others options like KVM? It feels like it anecdotally. As a service provider have you considered switching?

                                                  1. 4

                                                    Xen has seen an unfortunate number of issues recently. So has Qemu though; those would apply to us whether we’re on Xen or KVM. KVM’s architecture is better suited for the present day realities of virtualization, but Xen still solves a real problem–we do host PVM guests that aren’t ready to move to HVM.

                                                    We do discuss moving to KVM: I recall a lunch conversation recently where we discussed what we’d do with a greenfield VPS project, and ‘starting with KVM’ held down one side of the table. I’d rather focus on live migration, as it reduces the impact of security disclosures and also gives me more operational flexibility. With less churn in my stack.

                                                    1. 3

                                                      True, and probably the fact that KVM is younger is helping. But also KVM has had its own share of issues recently as well, e.g. using rowhammer to escape VM memory using Linux memory deduplication functionalities.

                                                    2. 2

                                                      Xen is among the only PV virtualizers, so it’s hard to compare.

                                                  1. 9

                                                    This article doesn’t address my main reason for sticking with Apple despite all the stupidity - OSX. Its support for handicap accessibility features is still by far and away the best of any desktop OS.

                                                    If/when Linux ever catches up I will dive in with wild abandon with a side order of glee.

                                                    1. 5

                                                      How does Windows compare on the accessibility front? I know for a while there they were at least supposedly leading the pack.

                                                      1. 3

                                                        Windows 10 is much better at this than Windows has been in the past. They finally added full screen key chorded zoom which is a huge, huge requirement for me. Keyboard control of system services is still very spotty - for instance, there’s no clean way to control the sound volume from the keyboard.

                                                      2. 2

                                                        Have you seen elementary OS?

                                                        1. 4

                                                          Elementary doesn’t have any specific usability/accessibility features compared to Linux on the whole and more specifically Gnome, making it no different from any other distro on that front.

                                                          The accessibility features aren’t the same thing as UI, they’re things like an onscreen keyboard, magnification features, text to speech.

                                                          1. 4

                                                            A lot of people fall prey to this kind of confusion. In many cases pretty UI can be less accessible than not. For instance, one of the things that makes the Mac the leader in accessibility is that I NEVER use the GUI. My entire workflow is 100% keyboard driven.

                                                          2. 3

                                                            How is it better/on par in terms of accessibility options?

                                                            1. 1

                                                              Sorry I never saw this until just now. Couple things: * Full screen key chorded zoom built into the OS. Works everywhere, no matter which graphics mode you’re in. Even games. * 99/100 apps support resizable fonts across the board * OS is built for accessibility - things like VoiceOver, etc. * Keyboard can control EVERYTHING. OS, apps, you name it. Every time I have to use the mouse it’s a HUGE productivity hit. I have fine / gross motor impairment in addition to crappy vision. * Applescript / app scripting in general means I an customize app behavior to my liking and make it less necessary to interact with the GUI (see keyboard item above). For a sense of what’s possible here, check out Alfred - https://www.alfredapp.com/

                                                              That’s a start.

                                                          3. 1

                                                            Gnome does generally as good a job as MacOS for accessibility.

                                                            1. 5

                                                              I found Gnome to be particularly inaccessible actually. In terms of LInux desktops, KDE was much better, but still markedly lacking, mostly because I still had to layer in various Gnome apps to actually get the job done.

                                                              Particular issues with Gnome: In many places you can’t easily resize the fonts. At all. Keyboard control of the desktop is mostly OK but keyboard control of apps is almost non existent.

                                                              Also, no full screen key chorded zoom. You can maybe kinda sorta do this with Compiz or whatever, but then you have to figure out how to run Compiz with Gnome.

                                                            1. 21

                                                              The Air Force runs a newer version of the software known as “Block 3i” on its F-35s, and gets roughly half the time between significant software glitches—though F-35 program chief Lt. Gen. Christopher Bogdan recently told reporters that a new version of Block 3i software appears to have tripled in stability during tests, going up to 15 hours without a serious software issue.

                                                              Shouldn’t the stability of software on a fighter aircraft be measured in units longer than hours?

                                                              1. 9

                                                                You go to war, I mean measure, with the units you have, not the units you want.

                                                                1. 3

                                                                  Perhaps? However some airborne radars have MBTF’s in the single to double digit ranges.

                                                                  Honestly for as much of a boondoggle as the F35 may be, I think people forget this isn’t uncommon. Example, the P38 Lightning had 2 engines, but the first models only had one generator. What happens when that fails? Well the engine that had the generator would get its propellor feathered and you switch to batteries for the other. So what happens when the batteries die? Well, most of the time the plane crashed.

                                                                  This is just one example from another fighter aircraft that people may know of. I knew an airline pilot and he just noted its pretty common to be rebooting things mid-flight (like the radar). I suppose this whole reply amounts to: what should the stability of flight software be when its still being built?

                                                                  1. 2

                                                                    I think these are somewhat separate issues. MTBF for a single engine failure on a P-38 was at least days, if not months or years.

                                                                    Modern airliners have to reboot software such as weather radar, but generally this does not interrupt the flight itself. A modern fighter jet relies much more on its software for survival, from radar to IFF detection, to the fly-by-wire system (generally more complicated than an airliner’s). The reliability of these components could be the difference between life and death.

                                                                  2. 1

                                                                    I wonder how many non-serious issues (whatever it means) they had in those 15hrs

                                                                  1. 1

                                                                    The video is private? Does anybody have a copy or a working link?

                                                                    1. 2

                                                                      Weird, all of the rest of them are still public. Maybe try asking @duosec on twitter what happened to it?

                                                                      1. 1

                                                                        They are re-shooting it at higher quality: https://twitter.com/tqbf/status/716409446096744449

                                                                    1. 21

                                                                      For the good of the Internet, and in fact humanity, we need to migrate our software from C/C++ to Rust (or something better) as quickly as possible.

                                                                      I feel vaguely embarrassed on behalf of our whole industry that this hasn’t happened already. We’ve seen huge innovation in new languages; we have amazing development tools to make our lives as programmers easier, but the software that users spend 99% of their time directly interacting with is still constructed using the technical equivalent of banging rocks together.

                                                                      Better late than never, I suppose.

                                                                      1. 22

                                                                        I don’t think we should be embarrassed. Rewriting something like DNS in a new language and then having everyone start using that version instead is not something to be taken lightly. To say that’s critical software is an understatement.

                                                                        Frankly, I feel like Rust is just now reaching the point where, as a language, you would even consider using it for software of that nature.

                                                                        1. 4

                                                                          On the other hand, a safe® implementation of DNS was made for Mirage: https://github.com/mirage/ocaml-dns Also a good TLS stack that already passed some tests and is being checked more carefully…

                                                                          1. 6

                                                                            Well, specifically in the case of browsers–don’t you think it would be wise to wait until we as a civilization had learned how to develop at least one rendering engine that doesn’t leave a steaming trail of CVEs in its wake before recklessly proceeding to build more and more technologies that depend on such engines?

                                                                            Webkit, Gecko, and Chromium all have so many critical security flaws reported on a regular basis that the Debian packagers had to special-case their update policies just for them; they are essentially DOSing the distribution with bugs.

                                                                          2. 14

                                                                            Well in our defense, there wasnt really any great alternatives to c before rust became stable, and it just became stable a few months ago.

                                                                            And its a little harder to profile who is using tools like valgrind.

                                                                            1. 14

                                                                              The standard response to this would probably be Ada. The price tag of the early compilers was indeed an important impediment to its adoption, but I am very annoyed when people dismiss it for being verbose or B&M: verbose is not necessarily a bad thing (all things in moderation I suppose) and being B&M (a term I’m not a big fan of) is preferable to the free-for-all chaos of C.

                                                                              1. 15

                                                                                Indeed, ada is definitely an example of already been done.

                                                                                I like rust and all, but people REALLY need to step off the high horse of everything needs to be converted cause memory safety stool.

                                                                                1. Until rust demonstrates itself, it can’t even be considered ada quality, this has NOTHING to do with how well rust works now or will in the future. You do not just rewrite things based on promises of better.
                                                                                2. Can we dial the hyperbole back a bit here? All c/c++ is not bad, we can mitigate most of the problems. And with things like compcert we can prove some c is perfectly fine. Statements like using C/C++ now is bad because of rust is both premature, mostly because of 1, and also the entire software industry as a whole should just flip tables and rebuild an entire process and build chain just for memory safety? Yeah that unrealistic and too ideological. Step it back a notch.
                                                                                3. I LIKE rust and want it to succeed. But I’m going to take a conservative view on this, I do not want to be the guy with arrows in my back to find out that after all no we should not rewrite everything in rust for whatever reason.

                                                                                If we keep hearing stuff like this, and I recognize rust is early in its hype cycle, if things and statements like this one keep getting proffered up by people will set the industry back a lot further than if people are measured and reasonable in how they promote rust.

                                                                                Just my pennyfarthings worth of input.

                                                                                1. 15

                                                                                  I agree with some of your conservative-ness here, but at the same time, the only way that Rust can demonstrate itself is if software like this is written in it. Or at least, something of the same order of magnitude.

                                                                                  In other words, being at different points at the adoption curve is totally fine, but that doesn’t mean that the people who are earlier on it than you are terrible. Their work is needed in order for it to be demonstrated mature in the first place. And early adopters are by nature enthusiastic.

                                                                                  I recognize rust is early in its hype cycle

                                                                                  One final note, this is actually a really interesting question. Rust as a project is:

                                                                                  • 8 years old, if you start from when Graydon first wrote the first line of code.
                                                                                  • 6 years old, if you start from the first public release.
                                                                                  • 2 years old, if you start from when contemporary Rust took shape
                                                                                  • 9 months old, if you go by 1.0.

                                                                                  So it’s a bit strange to be “early” in the hype cycle. We did a lot of research while building Rust, and so while it is new in a sense, that newness is the culmination of years and years of experimentation. So in some ways, it’s both more and less mature than it seems.

                                                                                  1. 7

                                                                                    So it’s a bit strange to be “early” in the hype cycle. We did a lot of research while building Rust, and so while it is new in a sense, that newness is the culmination of years and years of experimentation. So in some ways, it’s both more and less mature than it seems.

                                                                                    Extending Steves point:

                                                                                    That’s why I often use “yes, we tried that and it didn’t work out” as a response when many people ask about certain features. It’s amazing how many things where tried on the way to 1.0 and removed again. GC, evented runtime, classes, interfaces, Ruby-like internal iteration…

                                                                                    1. 3

                                                                                      Is there a collection of these things somewhere? I think it would make for a fascinating blog series.

                                                                                      1. 7
                                                                                        1. 2

                                                                                          I gave a talk “Rust is all that’s left” at Strange Group in Berlin, the end hints to the title and shows some of those things and code.

                                                                                          https://speakerdeck.com/skade/rust-is-the-only-thing-thats-left

                                                                                      2. 4

                                                                                        I say early in the hype cycle mostly due to rust being “new” as far as exposure to most programmers. The same could be said for open source Swift or even open source .NET. Lets go by 1.0 as the demarcation line just to make things simple.

                                                                                        I work with Linux kernel development. My question is this, even if I want to use rust in my work, the problem isn’t the programming language. The problem is shifting an entire ecosystem that way.

                                                                                        That proposition is basically asking to boil the ocean. Not going to happen, there are many man years worth of effort in existing tooling and languages. Asking to throw that out would be like saying we need to rebuild all our cities on the coasts now due to global warming. It is… a bit tone deaf in my mind.

                                                                                        On this:

                                                                                        In other words, being at different points at the adoption curve is totally fine, but that doesn’t mean that the people who are earlier on it than you are terrible. Their work is needed in order for it to be demonstrated mature in the first place. And early adopters are by nature enthusiastic.

                                                                                        I wasn’t trying to judge anyone that wants to rewrite everything in rust, in fact I encourage them to do it. I just don’t want people to continue down this path of C/C++ users are … because they aren’t using rust. That latter bit I am seeing a LOT of lately and honestly, that shit needs to stop. This is an engineering discipline, if we’re going to become political about things with pros and cons that we can measure, I’ll just change careers to become a politician. They get paid better.

                                                                                        That is a good way to start a toxic culture of us vs them. I know rust has done really well by not encouraging this in the past and I’ve been using/playing with rust since about 0.4ish timeframe, but I worry that it will be taken too far and to be honest I only expect it to get more incessant and annoying. And I do not like the needless factionalization of things. Does that explain my view a bit better? Text is hard to convey intent so if I came off as ye grumpy olde c programmer my bad but eh, I only have text. Carry on!

                                                                                        1. 5

                                                                                          It’s all good. I totally understand a lot of this. To be honest, my first reaction when I saw the headline was “oh no.” And then I opened it, saw it was posted by someone at Mozilla who I didn’t immediately recognize, and said “oh, oh no. A lot of people are probably gonna think this is something that the Rust team/world is all about.” And don’t get me wrong, I would love to see reimplementations of this kind of thing in Rust, but I think suggesting it’s “for the good of humanity” is a bit… much.

                                                                                          The problem is shifting an entire ecosystem that way.

                                                                                          Yeah, this is certainly true in kernel dev. I don’t see the kernel adopting Rust anytime soon. But we’ll see for other things; Rust will start at the bottom of the userspace stack and move down from there. There’s already a semi-serious coreutils rewrite, for example. I’m excited to see how this pans out. But I don’t think it will take boiling the ocean, either.

                                                                                          I just don’t want people to continue down this path of C/C++ users are … because they aren’t using rust.

                                                                                          Agreed, very strongly.

                                                                                          I worry that it will be taken too far and to be honest I only expect it to get more incessant and annoying.

                                                                                          I too am worried about this. I was really worried before 1.0, and that went okay. But part of community growth is that unified opinions become a collection of positions; and they’ll differ. But different groups have different loudness, and so a loud minority position can still be perceived as a majority one. That said, there’s only one thing to do: continue to try to uphold the community norms we do have, and hope it rubs off. I have some thoughts here, but not ready to share them publicly, as they’re rather personal.

                                                                                      3. 10

                                                                                        The funny and kinda sad thing is that the Rust core team has consistently been really careful not to make claims like this, and has encouraged people to not make them either. Rust is still new, and while there is a new effort to begin providing rigor to some of its safety claims, it’s nowhere near the point where one can categorically say that Rust solves memory safety.

                                                                                        1. 8

                                                                                          While I am very excited about this work, and agree that Rust should not be portrayed as panacea, I do think it’s also worth surveying existing languages as well. Few of them even have a spec, and very, very, very few of them have a spec that is rigorous enough to be formally proven.

                                                                                          We can make empiric improvements at the same time as formal verification is being pursued.

                                                                                          1. 3

                                                                                            Absolutely! It’s not necessary to wait for Rustbelt to prove everything it can before getting real gains from Rust in real situations.

                                                                                          2. 4

                                                                                            While we have this conversation on Rust actually trying to verify guarantees it gives its users, paleontologists and cs undergrads everywhere are still trying to decipher the masterful cryptographic document that is the current set of ISO C standards, that are not only epic in length, but unspecific and fangless like a pop pomo artist.

                                                                                            I find it hard to be convinced that “we need to test these tools a long time to make sure they don’t suck” is the reason to not uptake new solutions when we’ve “tested” existing heavily flawed tools for so long at the expense of lots of money and privacy. Not that I’m saying that vetting software is a bad thing, but these arguments always come off as electing to stay in the current pile of shit just in case the next system is just as bad.

                                                                                            1. 2

                                                                                              Oh, I completely agree. I think Rust is a strong improvement over C and C++, and I am very excited to see Rust used more so we can begin to get a better sense of how useful its guarantees actually are in production code. I just wanted to point out that the people usually making the hyperbolic claims about Rust are not part of the development team, but instead are usually relatively new to the language and the community (which is usually opposed to claims viewed as too-string).

                                                                                            2. 1

                                                                                              To clarify, my original comment is not about Rust specifically so much as about “It took how many years for an improved replacement for C to become a practical choice?”

                                                                                            3. 1

                                                                                              Statements like using C/C++ now is bad because of rust is both premature, mostly because of 1, and also the entire software industry as a whole should just flip tables and rebuild an entire process and build chain just for memory safety? Yeah that unrealistic and too ideological. Step it back a notch.

                                                                                              How high would the rate of software security bugs that would have been prevented by memory safety need to be for you to say that the entire software industry should just flip tables and rebuild an entire process and build chain just for memory safety?

                                                                                              1. 1

                                                                                                By my understanding CompCert doesn’t help prove theorems about C code. It just proves it’s own optimizations correct so that if your code does do the right thing the compiler won’t then break it.

                                                                                              2. 2

                                                                                                +1 for ada. If it’s good enough for flight software it could run the Internet.

                                                                                                Also I do wonder why Erlang never comes up as a candidate.

                                                                                              3. 6

                                                                                                I’m actually thinking more of the PLT community than applications developesr. But now that I think of it, there have been many attempts at replacing C with something that would be a very practical, genuine improvement; they just haven’t gone anywhere. I suspect this is due mostly to the fact that the improvements over C have been gradual and not dramatic enough to make a splash or mired in kitchen-sinkism (paradigms–gotta catch ‘em all!), though I suspect a big part of it also is that as far as I know no one has had the backing of an org as big as Mozilla.

                                                                                                1. 8

                                                                                                  Well, there’s some history involved too. There were a plethora of languages available to do “systems” stuff around the time C was brought into the world. But C’s tight integration with UNIX was a killer. Network effects are very real.

                                                                                                  Since then, there have also been a number of attempts at doing this, but bridging the academic to industry has always been tough.

                                                                                                2. 3

                                                                                                  This is a good point, although it’s worth saying that Rust hit 1.0 in May of last year, so it’s been more than a few months now.

                                                                                                  1. 1

                                                                                                    i think a lot of the userspace stuff could quite productively have been done in any ML/Haskell dialect (see mythryl and mirageos for proofs of concept). you don’t really need the raw speed and bare-metal access of C for much of it.

                                                                                                  2. 13

                                                                                                    Hilariously unrealistic and potentially undesirable. These projects weren’t built yesterday.

                                                                                                    1. 15

                                                                                                      “The best time to plant a tree is 20 years ago, the next best time is today.”

                                                                                                      glibc is under a half a million LOC. A large undertaking, but not totally impossible. The Rust compiler itself is larger. That said, I am not sure who, if anyone is going to truly give it a go.

                                                                                                      1. 3

                                                                                                        Additionally a rewrite will certainly at least for a period introduce many more bugs than it fixes. See neovim.

                                                                                                      2. 3

                                                                                                        By far most of the bugs in the history of things built on top of libc were NOT memory safety bugs.

                                                                                                        So yes, languages like Rust and D will save us from a large and pernicious source of bugs, but not from all bugs, and certainly not even most of the bugs that have occurred in the history of these projects.

                                                                                                        That said, I would support moving to saner safer languages as soon as possible. Rust addresses certain largish classes of bugs, but ultimately the fewest bugs are in the application built out of the best safest / least buggy frameworks. I’m betting on D for that future.

                                                                                                    1. 2

                                                                                                      What is it? The README is not very explicative and the website (http://www.typed-wire.org) is empty

                                                                                                      1. 5

                                                                                                        I think this is meant to be language agonostic serialization codegen, but for arbitrary algebraic datatypes (at least that’s what I took away from the readme). Think protocol buffers without the emphasis on binary serialization.

                                                                                                        1. 4

                                                                                                          That’s exciting. Protocol buffers really did bring something new to the self-describing-data table, with the ability to generate code targeting a variety of languages. I have a strong personal interest in the problem area, and I’m happy to see the codegen part getting played with more broadly.

                                                                                                          1. 3

                                                                                                            Agreed. And I think there is plenty of room for designing (de)serialization codegen that targets ADTs specifically. As much as I like protocol buffers, their schemas are inherently coupled to the types expressible in Java/C/Python, which can make working with them in other languages (Scala, in my experience) rather inorganic.

                                                                                                        1. 2

                                                                                                          That’s a very welcome news! Thanks

                                                                                                        1. 4

                                                                                                          From Twitter:

                                                                                                          E-reader friendly now too!

                                                                                                          What does this mean, exactly? Is there an extra non-margin PDF, or is there actually an epub version available now?

                                                                                                          1. 4

                                                                                                            I too hope to see an epub at a certain point. The ereader PDF has some code that overflows in the late chapters. It is much better for tablet reading however.

                                                                                                            I’ve read this morning the Monad chapter and the functor/applicative/monad in the wild. They are really top class (as the rest of the book)! I look forward to buy also the paper version when it’s ready!

                                                                                                            1. 3

                                                                                                              I too hope to see an epub at a certain point.

                                                                                                              We’ve tested an epub render, it mangled the content horribly. I’d rather just fix the PDF via the LaTeX.

                                                                                                              Glad you’re liking it so far :)

                                                                                                              1. 2

                                                                                                                Boo, epub would really be a lot nicer for reading on a tablet beside the laptop. Curious what got mangled.

                                                                                                                1. 3

                                                                                                                  The e-reader version of the PDF I made vastly exceeded my expectations. I poked around it a fair bit on my kindle and it was very nice, IMO. Other readers that tested it on various devices gave it a thumbs up as well.

                                                                                                                  epub on my kindle was horrendous and the gaping maw of labor required to fix it by hand isn’t going to happen. I’d have to charge a lot more for the book to cover that and people already complain about the $59.

                                                                                                            2. 2

                                                                                                              The former.

                                                                                                              1. 2

                                                                                                                Ooh goody, I’ve been mostly reading it on my kobo so this is good. The book really has been great so far, things like the structure, you can find exercices sprinkled throughout the chapters instead of all globbed at the end, I usually have trouble getting into a books exercices because of this. They’re even little goodies at the end of chapters in the form of links to recommended extra reading.

                                                                                                              1. 3

                                                                                                                But would that stand in a way of an open source release without any advertising of the sideloading option?

                                                                                                                1. 3

                                                                                                                  I agree with you. And I think one of the main concerns of apple could have been also that they were using the sideload option to install a binary blob…

                                                                                                                  1. 2

                                                                                                                    There are open source applications on the App Store, like VLC, so apparently they are not taking issue with that.

                                                                                                                  1. 2

                                                                                                                    An interesting read.

                                                                                                                    However there is one subtle point which is not discussed enough: while UNIX was a great design for a 70s system, is it sensible to keep it unchanged in newer platforms?

                                                                                                                    Without entering into specific debates (udev, systemd…), and agreeing personally with the claims that configuration stuff moves every couple of years, isn’t that precisely the price of progress?

                                                                                                                    Can a UNIX-like system be as fast, portable, efficient and easy as a modern GNU/Linux?

                                                                                                                    Just my two cents, again, without any agenda or will to enter into eternal debates.

                                                                                                                    1. 3

                                                                                                                      configuration stuff moves every couple of years, isn’t that precisely the price of progress?

                                                                                                                      I used to think so, back when I used Linux. But after using OpenBSD for quite a few years now, I have to disagree. There are some changes of course, but they’re by and far less frequent or intrusive. And the developers often go out of the way to keep familiar config files & tools intact from the user’s perspective even if the code underneath is completely rewritten. And instead of completely replacing some tool every few years, they polish and improve the old one. That’s progress.

                                                                                                                      On Linux, I come across new shiny tools to replace “old, buggy and legacy” ones, and before the new tool grows mature, someone’s already decided it sucks and needs to be replaced by something new and shinier. Lo and behold, the old new shiny is now buggy, legacy, and horrible. It feels more like running in place in a hamster wheel than actually making progress. Heck, as a user, it often feels more like regress, with all the new learning and new bugs and googling around trying to accomplish what was simple with the old tool. Googling around because Fuck actual documentation says the Linux freedesktop.org community between their rewrites. It would get outdated soon after all… now, if I had an easy way to tell which of the google results are outdated help.

                                                                                                                      1. 1

                                                                                                                        The first time I realised the difference was when I happened to read man pages in OpenBSD and FreeBSD. I was impressed by being able to live without googling everything and actually find the informations I needed carefully explained. If only I could use docker or rocket on *BSD I would finalise the jump

                                                                                                                        1. 1

                                                                                                                          I am going to have to start living on Linux full time in the not too distant future and the idea fills me with terror. I wonder if I can still get by with ion (or even twm) + emacs.

                                                                                                                          1. 1

                                                                                                                            notion + emacs + firefox is what I’ve been doing for a while, it’s helped me avoid a lot of this crap. Archlinux + a well supported linux laptop + super old config files have done very well.

                                                                                                                      1. 4

                                                                                                                        “The LibreSSL team is not typically apprised of OpenSSL-related security issues in advance. We will address any previously-unknown issues that are found to affect LibreSSL in future releases.”

                                                                                                                        This is actually quite sad…