1. 17

    The complaints listed here for Rust are exactly what I have been struggling with!

    However, I can’t actually pattern match like this in Rust because I don’t have DLists, I have Arc<Dlist>, and you can’t pattern match through Arcs and Rcs and Boxes.

    When trying to create thread safe recursive data types, I have struggled a lot with managing Arcs. Instead of normal pattern matching, you have to dereference the Arc within your match statement and then use ref to declare that you don’t actually want to access the data but a reference to it (I think I’m interpreting that correctly?).

    match *instruction {
        Instruction::Jump(ref j) => {
    

    Want to make this mutable? Yikes! Shoving Mutex into here makes things far more complicated because that’s another dereference you have to do every pattern match. Paul ended up doing this:

    match args.iter().map(|v| &(**v)).collect::<Vec<_>>().as_slice()
    

    which I would say is unreadable! I had a huge number of mutable concurrent data structures and I ended up switching all of them to immutable which simplified things greatly, but this had its own costs. I wrote this up thoroughly on my own blog.

    I’ve been writing Rust for quite a while now, enough to where I start thinking with the borrow checker and I know what structures/patterns won’t work before I write them, but I still hit walls pretty hard. Refactoring that codebase from mutable to immutable was very challenging in Rust, whereas in Java refactoring can be a lot faster. I feel like taking the wrong step in Rust can end up costing much more time compared to other languages, which ends up making prototyping difficult. (Non-concurrent, non-recursive prototyping is substantially easier)

    1. 9

      This is definitely an area that can be challenging! I think learning the AsRef and AsMut traits can be really useful for this case. In this case, Arc has an AsRef implementation that gives you an immutable reference to the contained type.

      Here’s an example from the Rust Playground on the use of as_ref on an Arc, along with Mutex::lock to access the value inside the Mutex as an owned value by blocking (to attempt locking without blocking use Mutex::try_lock, for mutable reference use Mutex::get_mut instead).

      1. 3

        Question: How does the Rust compiler itself solve these problems? Or does it not have to?

        1. 7

          The internals of the Rust compiler actually intern a lot of data, tied to the lifecycle of the memory arena containing the data. So for type information (the most widely shared information), you’re working with lifetimes rather than Arc. Here’s a section of the rustc dev guide explaining: https://rustc-dev-guide.rust-lang.org/memory.html

        2. 3

          In my experience with Rust, the best way to write recursive data structures like Parse Trees is to simply reference Nodes by their indices in the backing data structure (usually a Vec).

          struct Node {
              id: usize,
              parent: usize,
              children: Vec<usize>,
          }
          
          struct Tree {
              nodes: Vec<Node>,
              root: usize,
          }
          

          I imagine this isn’t quite as efficient as using a tonne of Arc<> and unsafe but it’s plenty fast enough for anything I’ve ever needed to write and it circumvents a lot of extremely ugly code.

          1. 2

            Seems like a significant compromise on type safety though.

            1. 1

              That can be mitigated with something like:

              type NodeID = usize;
              
              1. 4

                That’s a type alias. You want a newtype, like this:

                struct NodeID(usize);
                
                1. 1

                  Sorry, yes, you’re quite right.

        1. 53

          TLDR - Drew hates the modern web, gripes about Mozilla management, and wants the scope of web browsers to be reduced.

          Edited to remove snarkiness.

          1. 38

            I’m forgiving the rantiness because I’m upset and angry about the Mozilla thing too. What I’m taking from this:

            1. Google is actively saturating the web with complexity for its own ends, one of which presumably is creating an insurmountable barrier to entry into the browser market
            2. All the other existing players but Google clearly have no interest in trying to stay in that market
            3. The resulting mess isn’t doing anyone but Google any good

            Of course it’s possible my interpretation is somewhat motivated. ;)

            I don’t think this really adds any factual information to the pool, but opinion pieces aren’t always a bad thing, and it could start some important conversations about the future of the open web.

            1. 18

              Mozilla just fired everyone relevant

              It feels like Mozilla management finally accomplished what Microsoft and Google tried unsuccessfully for decades:

              Burning the company to the ground.

            2. 6

              Exactly, I feel like this isn’t saying anything that Drew hasn’t already said in the past.

              1. 10

                And he is right in every word.

              1. 4

                Whenever these articles come around, there are always comments by people who specialize with the language, or at least know it well enough to point out obvious mistakes. When writing a comparison about languages, does it not make sense to get input from people who know the language really well?

                Also, I hate the conclusions. This isn’t saying anything that hasn’t already been said. They read like the front page of the languages respective landing pages. I don’t think “If I build exceptionally/mostly for Linux” is a good reason to pick Go as a language. This entirely misses its strengths. I primarily write Rust on Linux and, even when doing very advanced build configurations, I’ve never run into an issue so big I’d switch to Go.

                1. 10

                  I don’t understand all the hate. The OP states he wants to write about his experience learning two new languages. This should be read as a post-mortem of impressions and lessons learned along the way, not as a olympic-level competition of which language is better. Yes, the author missed go modules, used async functions instead of threads, but those are normal mistakes of those who are just picking something from the first time. This post is a diary of their journey more akin to a travelogue with some recommendations in it. I think that experts coming here to just point a finger at it and shout “YOU’RE DOING IT WRONG!” are approaching this kind of post wrongly.

                  1. 3

                    When writing a comparison about languages, does it not make sense to get input from people who know the language really well?

                    I think it’s fine to write about one’s experiences on a personal blog. It’s a good mechanism for getting thoughts and feedback from others — either the specialists you mention, or just your friends and local community. I don’t think there needs to be an expectation that you hunt down experts in each language and get feedback before publishing on your own website.

                    This is the first post on a new blog, by someone who describes themselves as a self-taught developer. I doubt this is intended to be the the definitive comparison article between Go and Rust. ;-) It’s simply a post about one developer’s experience implementing the same project in two languages.

                  1. 23

                    There are also two environment variables we need to know

                    Uhhh… Kinda not really. You don’t need to know about GOROOT or GOPATH or virtualgo.

                    Something like this will work.

                    $ cd $HOME
                    $ mkdir hashtrack && cd $_
                    $ go mod init github.com/cuchi/hashtrack
                    $ go get github.com/Laisky/graphql
                    

                    All your code and deps get scoped to the module.

                    Go doesn’t have a package manager

                    Oookaay, this is just wrong. It might help to read up on Go Modules. Go’s official package manager is built into the go tool. https://blog.golang.org/using-go-modules

                    or official registry

                    Kinda. There is an official central place to search for modules: https://pkg.go.dev/

                    1. 3

                      Go doesn’t have a package manager

                      Oookaay, this is just wrong. It might help to read up on Go Modules.

                      When did this happen? It is news to me (but then again I only try Go every now and then :-)

                      1. 2

                        Go 1.11. Since it wasn’t proposed until 2018, a lot of people who tried the language years ago aren’t aware of its existence.

                        1. 5

                          I think the author is mostly just confused about the GOPATH/Module situation. Modules are not really a “package manger” in the same sense that npm or whatnot are (it’s better!) and there’s a lot of “legacy” advice and documentation across the internet. Never mind that the tooling is rather weird as well, where things behaving in different modes depending on how/where you invoke them.

                          It’s all pretty confusing especially for newcomers; I’ve seen quite a few people get confused by it. I started writing a comment about this last night, but ended up just sending it as an email to the article’s author.

                    1. 16

                      Here is the issue where this all started. Here is the library documentation that had the error, and you can now see it’s fixed and links to git.sr.ht. I feel like I’ve seen Drew harass OSS developers on GitHub far too often.

                      Here is the actual source code that contains the regexps filters for domains. One thing to note here is that it assumes any site beginning with gitlab., gittea., or gogs. is a valid instance of those git services, which is in direct contrast to what Drew tell us. He paints this as a malicious attack on decentralized git instances, when you are free to name your git instance appropriately or submit a change that adds your domain. This seems very standard for the service pkg.go.dev is providing, and I don’t think this flamebait is useful.

                      1. 8

                        you are free to name your git instance appropriately

                        s/free/constrained/

                        This assumption doesn’t hold in practice. See e.g. salsa.debian.org or source.puri.sm.

                        or submit a change that adds your domain

                        This doesn’t really fly. If I host a small instance of GitLab/sr.ht/Gitea I don’t want to chase down each programming language specific tooling requiring a special case for my instance, and wait for the changes to propagate in releases etc.

                        1. 5

                          The entire thing is that just the source code links don’t work for self-hosted instances; this is not great, but certainly quite a bit different than the entire repo not working as the article makes it out to be. When I pointed this out on HN last night I got handwaving “but Google sucks!” replies first, and a slew personal insults when I pressed the matter.

                          This is the kind of attitude these things are written with… meh. But hey, “Google bad” confirmation bias makes it get to the front page anyway 🤷‍♂️

                          There’s is some valid criticism here, as the entire way this works is kinda hacky and confusing; but it worked like that on godoc.org too, which was originally developed outside of Google. It might be a good idea to improve on that, but I can’t blame the devs for continuing on what’s already here, rather than taking the initiative to develop an entire new specification for this. If you feel such a thing is vitally important then maybe create it?

                          I’ve got a few other gripes with pkg.go.dev as well, but wrapping it all in an article like this isn’t helping anything. Indeed, if anything it’s going to put the developers in the defensive.

                          I feel like I’ve seen Drew harass OSS developers on GitHub far too often.

                          Well, that was a fun read 🙃 (that wm4 fella doesn’t seem … very pleasant … either)

                          1. 1

                            Thanks for sharing this. I’ve always had a feeling about the way he communicated and expressed himself, but this made it a lot more clear!

                            1. -5

                              Thanks, that made me uninstall mpv.

                              Looking for a new “simple” video player that doesn’t shit into my $HOME now!

                            1. 2

                              Chapel took the longest total time but consumed the least amount of memory (nearly 6GB RAM peak memory)

                              D consumed the highest amount of memory (around 20GB RAM peak memory) but took less total time than Chapel to execute

                              Julia consumed a moderate amount of memory (around 7.5 GB peak memory) but ran the quickest

                              What an interesting find! Just looking at the graphs, Chapel doesn’t look like an amazing contender. It’s quite close, but Chapel isn’t turning any head. With the memory consumption, however, this becomes much more interesting! The Chapel code came out very readable (imo, looking only at the calculateKernelMatrix example) and ended up using 14 GB less memory than its D counterpart, which looked very similar. I’m more familiar with Julia and D, so I’m interested to see what language features are at play in optimizing the Chapel code for speed and memory.

                              1. 1

                                Remember that Chapel is designed to let your code run on everything from multicore to clusters. Its competition was stuff like C++ with MPI with user juggling code and data over potentially thousands of CPU’s. Chapel was designed for high productivity with as close to manual performance as the compiler can get. Other contenders were X10 and Fortress languages.

                              1. 1

                                I love using Rust for parts of my infrastructure toolchain like this! For a recent work project I wrote a configuration builder that took configuration templates repos and constantly updated running servers with the current configs, and writing it in Rust was a breeze. Tools like this could be written in Python or Shell, but I like the type-level safety that Rust provides here.

                                1. 6

                                  I feel like a lot of what is being discussed here has already been talked about at length in various other posts. Is it not odd that there seems to be a collection of C/C++ users who are misrepresenting Rust’s capabilities? Steve already talked about this in his post You can’t “turn off the borrow checker” in Rust which is mentioned in this article. I’ve seen many false statements across Reddit, HN, Discord, etc, that could easily be resolved by reading the documentation. What is causing this? It’s not like Rust’s documentation doesn’t spell out what it restricts.

                                  All Rust checks are turned off inside unsafe blocks; it doesn’t check anything within those blocks and totally relies on you having written correct code.

                                  This is objectively false! Granted the original video is in Russian, but if you’re giving a talk about Rust it seems like it would make sense to learn what unsafe actually does before preventing your idea of it as fact.

                                  My greater question is: why does this happen this much? Am I disproportionately seeing more false comments about Rust than most people, or is there a real issue here? In contrast, people voicing their opinions on Go are founded on Go’s actual flaws. Lack of generics, error handing, versioning, et al. are mentioned, but when it comes to Rust, the argument shifts. Rust has flaws, and they are discussed, but there is quite a lot of misrepresentation. IMO

                                  1. 14

                                    It seems like a fairly normal human reaction, I think. People have invested large portions of their life towards C++ and becoming important people in C++ spaces. In that group of people, most are deeply sensible geeks that have reasonable reactions to Rust. But there will be some that have their own egos tightly coupled with C++ and their place in the C++ community, that see the claims made by Rust people as some form of aggression - attacking the underpinning of their social status.

                                    And.. when that happens, our brains are garbage. Suddenly the most rational person will say the most senseless things. We all do this, I think.. most of us anyway. Some are better than others at calming down before they find themselves with all the lizard brain anger organized on a slide deck, clicking through it on stage.

                                    1. 2

                                      While I love this explanation, I do want to point out the complexity and length of the list of actions one must do to build a misleading slide deck and speak on stage about it with absurd confidence.

                                      1. 1

                                        Hm that might be true, I think this also happen to a lot of people attacking graphQL, they do not want to accept an alternative to REST.

                                      2. 6

                                        I think these are different crowds. People who use Go instead of X vs. C/C++ people looking into Rust. Based on my very limited experience talking to C/C++ developers they got this sort of Stockholm syndrome when it comes to programming languages and they always try to defend the shortcomings of their favorite language. UB is fine because… Overflows are fine because…. They does not see any value in Rust because their favorite language has all. I do not know that many Go developers, but the ones I know are familiar with the shortcomings of Go and do not try to downplay it. All of this is anecdotal and might not represent reality but one potential explanation of what you observed.

                                      1. 3

                                        Spending a birthday in quarantine and enjoying the end of my sophomore year! Only two left (bar grad school)!

                                        I’ve been reading a million papers on dependent type theory and I’m planning out building an implementation of my own. I have a few ideas of how to make it run efficiently, but we’ll see if they stick.

                                        1. 0

                                          Go is garbage collected, rust is not. That means rust is faster than go, right? No! Not always.

                                          Why does it mean that, generally?

                                          1. 2

                                            The assumption is that if you have a garbage collector stopping the world a lot, your application is going to run slower. In small benchmarks like this (although this once was broken), it impacts the perceived performance quite a bit. In practice, while it’s debated, languages with GCs do achieve high performance and can achieve similar speeds to manually managed languages. The JVM, Julia, & Go are all great examples of this.

                                            1. 0

                                              Yes, GC has costs, but so does reference counting. Making such a blanket statement is just misinformation.

                                              1. 4

                                                My (non-expert) understanding is that “gc is slow for managing heap memory” is a misconception, and than in fact the opposite is true – for allocation-heavy workloads modern gc schemes are faster than traditional malloc/free implementations.

                                                However, languages without tracing/reference counting GC tend to use heap more frugaly in the first place, and that creates the perf difference in real-world programs.

                                                1. 1

                                                  The Go compiler does escape analysis and can (to some extent) avoid putting things on the heap if they do not have to be.

                                                2. 3

                                                  But rust doesn’t do reference counting most of the time.

                                                  1. 2

                                                    Rust only does reference counting when you ask for it by typing Rc, generally yourself.

                                              1. 34

                                                This allows you to use them independently and compose them however you please, which maps well onto the reality of how many projects are organized. Compare this to platforms like GitHub, GitLab, Gitea, and so on, resources like bug trackers and pull requests map 1:1 to a git repository.

                                                I think this is a great leg up on the competition. Having repositories be 1:1 with issue trackers always annoyed me on GitHub and results in hacky workarounds like sending issues between repositories or having one repo act as “the issue tracker repo”.

                                                1. 4

                                                  This is awesome, specially for mirror repositories and stuff like that.

                                                1. 1

                                                  https://jadon.io/blog - I write about programming language design & type theory. I’m working on a set of articles for introducing Computer Science Topics without the Jargon. So far I have only completed a few, but by the end I hope to have a lot of articles explaining deeper topics like dependent types, CoC, Homotopy Type Theory, etc. I also write about my own language design adventures.

                                                  1. 3

                                                    I must be becoming old, words do not have the same meaning anymore. reverse engineered reading src? …

                                                    1. 1

                                                      That’s exactly what I was thinking. This isn’t reverse engineering in any sense that I’ve seen that term used. The real title for this post is Rewriting the LastPass CLI in Rust.

                                                    1. 5

                                                      Spoiler Alert: the new backend is CraneLift! It’s great to see progress on it since this was started back in 2016. Another great project using CraneLift is rcc which is a C compiler written in Rust.

                                                      1. 3

                                                        Since every uni is online now, I’ve got a load of free time to work on all my overdue projects! #1 on that list is my programming language Alox. I haven’t touched it all year and I’m hoping to get an alpha release within the coming months. The tagline is “GPU Accelerated, Distributed, Actor Model Language”.

                                                        Currently, the compiler contains lexing, parsing to an AST, translating the AST to an IR, and the beginnings of a backend using CraneLift. I just wrote up a blog post detailing my designs for the language, and what big changes I’m going to make to the compiler. In this post, I explain the struggles I’ve been having with the Rust implementation and thoughts on switching to a Zig implementation. I’m not exactly sure if this is the direction I want to go considering Zig is so young but I’m till rattling the idea around in my head. Either that or I refactor the Rust codebase a lot.

                                                        1. 2

                                                          That sounds really interesting. If you want some inspiration, you might want to look at parallel languages Chapel by Cray, ParaSail by Taft, and Pony. They might have things you can copy and/or improve on.

                                                          Regarding Rust vs Zig, I warn about trying to build a language on top of experimenting with an experimental language or one with limited, tool support. You might be doubling the work for yourself in a way that negatively impacts Alox. If people want to actually deliver, I usually recommend them picking a mature language with lots of tools, libraries, and docs. If not that, then just pick one to play with, stick with it, and use it in a way that reduces obstacles.

                                                          Personal example: I recently had to ditch a nice language for Python in some projects just because my velocity in Python would be so much greater due to existing IDE tools, libraries, and docs. Choosing the niche language would’ve required clean-slating too much. However, I am writing straight-forward code that some automatic translator could port to a better language later. py2nim is an example path I could take.

                                                          1. 2

                                                            I’ve been studying Pony heavily since it models what I want to do so well. Chapel I’ve seen around but ParaSail looks new to me, I’ll look into them!

                                                            And speak of the devil, I instantly ran into compiler bugs when doing basic things. I decided to majorly refactor the IR to be more idiomatic, making the code a lot cleaner. I had to use two IDEs to do this: rust-analyzer in VSCode and the Rust IntelliJ plugin show different errors at different times which made for some interesting debugging. I guess I’ll be sticking with Rust!

                                                            1. 2

                                                              Boom! There it is. Good that you figured it out before cranking out tons of code. You got lucky. :)

                                                        1. 2

                                                          A more in-depth article covering the same topic was published in 2013 and echoes my sentiments.

                                                          On the plus side, this does mean that none of my classmates ask to borrow my computer (since it has tiled terminals everywhere).

                                                          1. 3

                                                            Wow that was a good article. Being the “computer science major” in the friend group, I am regularly called when tech support is needed. Most of these situations are resolved in seconds, even if I have never encountered the issue before. Examples include:

                                                            • embedded YouTube video won’t play on our school portal because it was blocked by safari. Having never owned a MacBook, I had to google how to fix it. It was a check box in the settings.

                                                            • friend needed to graph a linear regression fit line over her data points in excel. Her lab instructions included the steps on how to do this (with pictures!), but I still needed to assist with pressing buttons

                                                            • printer was out of ink. I opened the printer and put in the new cartridges.

                                                            • google chrome was displaying ads. I deleted the extension that was doing so

                                                            • google docs formatting was “weird”. I hit backspace a few times. I’ve done this one a lot.

                                                            • instead of logging into her university google account, it was logging into her high school google account by default, except it would fail because the high school account no longer existed. She went to the IT department we have on campus and they had no idea how to fix it. I cleared the cache and logged her in

                                                            It’s ridiculous how often this happens. I hate IT, but I am happy to help my friends out. No one knows how to use computers, including the kids majoring in CS…

                                                          1. 37

                                                            I appreciate you giving V another chance and taking a more constructive approach, but how are people still taking this seriously? I don’t understand how people are eating up a product that doesn’t exist yet. None of the features that were claimed are here.

                                                            Memory Management

                                                            As an example, how is memory being cleaned up? The answer to that question determines where the language can and will be used. Is there a GC? Then it probably won’t be used on embedded devices. The answer?

                                                            (Work in progress) There’s no garbage collection or reference counting. V cleans everything up during compilation. If your V program compiles, it’s guaranteed that it’s going to be leak free.

                                                            How? How does it clean up everything during compilation? If V adds something similar to linear types then it will be targeting a completely different audience than the one it has now and the language will change dramatically. People still complain about Rust’s steep learning curve. If V did the same, it would alienate its entire userbase.

                                                            this compile leaked 3,861,785 bytes of ram last time. This means that the compiler has overall gained 0.8 megabytes of leak in the last 6 months

                                                            This is ridiculous! Is this massive problem being completely ignored? V is not cleaning up everything during compilation! I’m scared to profile the slack client.

                                                            Compilation Times

                                                            Claim that is currently on the website:

                                                            Intel i5-7500 @ 3.40GHz, SM0256L SSD, no optimization

                                                            between ≈100k and 1.2 million lines of code per second per CPU core

                                                            @cadey’s setup & time:

                                                            Intel(R) Xeon(R) CPU E3-1245 V2 @ 3.40GHz

                                                            average of 2000 lines of code per second

                                                            2k vs. 100k is a huge difference. How on earth are the numbers this off? It’s hard to believe that there is this big of a discrepancy depending on what machine you have, but if there is: don’t put this on the front page of your website. This is false advertising.

                                                            A few weeks ago, Alex changed the benchmark at https://fast.vlang.io/. He changed one line in a commit titled do not allow calloc(0) that had nothing to do with the benchmark:

                                                            https://github.com/vlang/v/commit/54707ff#diff-06200e5dbd187e51b3598047044f9dfbL41

                                                            - Running on a $3.5 instance. <br><br>
                                                            + Running on a 2014 MacBook Pro. <br><br>
                                                            

                                                            This is incredibly suspicious! The times for the commits that are currently on the site date back to 2019-11-07 17:38. Did he rerun all of those commits on this mysterious macbook? I would bet not. Why hasn’t that page been updated since he made that commit? It appears the benchmark has been turned off. The 13 commits in the table before that are titled fast and link to commits that don’t exist. I have no idea what is going on here: https://archive.is/aHssL

                                                            Pure by Default

                                                            Currently @ https://vlang.io/docs#recvs :

                                                            V functions are pure by default, meaning that their return values are only determined by their arguments, and their evaluation has no side effects.

                                                            Hello World in V:

                                                            fn main() {
                                                            	println('hello world')
                                                            }
                                                            

                                                            Well that sure as hell looks like a side effect to me. No monads here, just a complete lack of understanding. To mutate function arguments or struct fields, you add the mut keyword. Side effects don’t look like they’re checked at all, meaning that V functions are not pure by default.

                                                            Release Dates

                                                            1.0 was set to be released by the end of 2019.This was a huge claim, and it obviously fell flat on its face. We’re still on 0.1 and only a few languages features have been added since V started getting traction.

                                                            This is confusing to me given he claims that 0.2 will be out in January, but whatever I can let this slide.

                                                            V makes enormous claims but doesn’t explain how it will do anything. The many features we were expecting aren’t here. I can not let this slide because he is still blatantly lying.

                                                            If I misunderstood anything here, please correct me!

                                                            1. 12

                                                              I understand the article to be a kind of a hobby pleasure, if maybe slightly perverse, of hunting and diplomatically dissecting all the false claims the V’s author was and is making about the language. I totally appreciate this as such, and also find a pleasure in reading it, thoroughly enjoying the showing off of diligence, precision and mastery of subtle diplomatic and ironic expression on the part of @cadey. I do sometimes have to use a similar device in my life, so I am fully aware how much self-control it takes and proves one has, and know how much the author longs for the text to be properly understood, especially given that this is a tough balancing act, because in writing it’s hard to signal sarcasm. Finally, I also appreciate the articles providing an up-to-date stream of nice reference links for other fellow engineers, like myself, tired of the weird PR distortion field around V - thus making them a generous public service act.

                                                            1. 10

                                                              If you’ve been keeping up with WASM development then you’ll probably notice most of this isn’t new information. These companies have been working on these technologies (CraneLift (previously names Cretonne), Wasmtime, Lucet, & WAMR) for months or in some cases years and they’re coming along nicely. This is definitely a nice recap of the work that has been done and I for one am excited to see if there is a next big step that these companies will take now that they’re explicitly working together.

                                                              1. 2

                                                                I don’t know much about Nim, but I’m pretty tired of the implication that scripting languages can’t be compiled. Nearly every well-known scripting language has a compiler; stop perpetuating 1990s stereotypes.

                                                                1. 5

                                                                  It’s funny how you say “1990s stereotypes” when PHP didn’t have a compiler until 2010.

                                                                  1. 7

                                                                    While a fair criticism, 2010 was nearly a decade ago. There are certainly many of us who still think of the nineties as merely a decade or so ago.

                                                                    1. 3

                                                                      One’s perception doesn’t matter, 2010 is 9 years ago (9 and a half if we consider February 2010, the release date of Hip Hop), and calling it “1990s stereotypes” to bring forward an incorrect and overblown statement is not a valid move.

                                                                      1. 2

                                                                        Perceptions definitely matter when it comes to language and communication. This is because you must communicate such that it is received by the listener’s expectations. A speaker who communicates to the listener’s perceptions will be far more effective. 90’s stereotypes for example may not have been meant to be taken so literally. Now you can say as a listener, “It didn’t work for me, I took it literally” and that’s a fair criticism, however you’re not the only listener, and not every listener will receive it the way you did.

                                                                    2. 4

                                                                      Ruby was a tree-walking interpreter until 2009 (based on this page).

                                                                      Python is said to be compiled but has, and will continue to have, a “Global Interpreter Lock”.

                                                                      @technomancy is getting way too overwrought over the imprecise but useful phrase, “compiled language”. Wikipedia: “The term is somewhat vague.” There is a useful separation here. Until we come up with a better name for it, let’s be kind to usage of “compiled language”.

                                                                      1. 10

                                                                        Python is said to be compiled but has, and will continue to have, a “Global Interpreter Lock”.

                                                                        These things are not in opposition to each other. OCaml has a native code compiler, and its runtime system has a GIL (a misnomer: a better name is “global runtime lock”).

                                                                        1. 1

                                                                          Interesting!

                                                                        2. 4

                                                                          imprecise but useful phrase

                                                                          What do you find this phrase to be useful for?

                                                                          You can see in the comments below that the author’s intent was not to describe programs that compile to machine language, but actually to describe programs that can be distributed as single-file executables. (which is also true of Racket, Lua, Forth, and many other languages)

                                                                          So it seems that even by declaring “compiled” to mean “compiled to machine language” we haven’t actually achieved clear communication.

                                                                          1. 2

                                                                            I’m actually rather interested in how you get single file executables with Lua? Is there a tool that makes it easy, or is it something out of the way?

                                                                            EDIT: I know how to get single file executables with Love2d, and I vaguely recall that it can be done with Lua outside of Love, but it’s certainly not an automated/well-known thing.

                                                                            1. 4

                                                                              Many people simply embed Lua in their C programs (that was the original use case it was designed for) but if you’re not doing that you can streamline it using LuaStatic: https://github.com/ers35/luastatic/

                                                                            2. 2

                                                                              You’re pointing out a second way in which it is imprecise. I’m pointing out that for me – and for a large number of people who don’t know all the things you do – it was useful since it perfectly communicated what the author meant.

                                                                              1. 3

                                                                                Oh, interesting, so you mean to say that when you read “compiled language” you took it to mean “produces a single-file executable”?

                                                                                This is honestly surprising to me because most of the time I see “compiled language” being misused, it’s put in contrast to “interpreted language”, but in fact many interpreted languages have this property of being able to create executables.

                                                                                It’s just a tangled mess of confusion.

                                                                                1. 5

                                                                                  Indeed it is. I didn’t mean that I understood “produces a single-file executable.” I meant that he’s pointing towards a divide between two classes of languages, and I understood the rough outline of what languages he was including in both classes.

                                                                                  Edit: I can’t define “compiled language” and now I see it has nothing to do with compilation. But I know a “compiled language” when I see it. Most of the time :)

                                                                                  1. 3

                                                                                    Perhaps a good way to put it is “degree of runtime support that it requires”. Clearly, normal usage of both Nim and Python requires a runtime system to do things for you (e.g. garbage collection). But Nim’s runtime system does less for you than Python’s runtime system does, and gets away with it mostly because Nim can do many of those things at compile time.

                                                                                    1. 4

                                                                                      Even if a language retrofitted a compiler 20 years ago, it’s hard to move away from the initial programming UX of an interpreted language. Compilation time is a priority, and the experience is to keep people from being aware there’s a compiler. With a focus on UX, I think all your examples in this thread have a clear categorization: Perl, Python, Ruby, Racket, Lua, Node and Forth are all interpreted.

                                                                                      1. 4

                                                                                        I would frame it differently; I’d say if a language implementation has tooling that makes you manually compile your source into a binary as a separate step before you can even run it, that’s simply bad usability.

                                                                                        In the 90s, you had to choose between “I can write efficient code in this language” (basically C, Pascal, or maaaaybe Java) vs “this language has good-to-decent usability.” (nearly everything else) but these days I would like to think that dichotomy is dated and misguided. Modern compilers like rust and google golang clearly are far from being “interpreted languages” but they provide you with a single command to compile and run the code in one fell swoop.

                                                                                        1. 4

                                                                                          I’m super sympathetic to this framing. Recent languages are really showing me how ill-posed the divide is between categories like static and dynamic, or compiled and interpreted.

                                                                                          But it feels a bit off-topic to this thread. When reading what somebody else writes my focus tends to be on understanding what they are trying to say. And this thread dominating the page is a huge distraction IMO.

                                                                                          I also quibble with your repeated invocation of “the 90s”. This is a recent advance, like in the 2010s. So I think even your distraction is distractingly phrased :)

                                                                          2. 3

                                                                            Are you not barking at the wrong tree ? I don’t find a line where the author implies anything close to it.

                                                                            1. 0

                                                                              I was referring to the title of the post; as if “scripting ease in a complied language” is not something provided by basically every scripting language in existence already.

                                                                              1. 3

                                                                                Specifically, most scripting languages make it nontrivial to package an executable and move it around the filesystem without a shebang line. On Linux, this isn’t a huge issue, but it’s convenient to not have to deal with it on Windows

                                                                                1. 1

                                                                                  OK, but that has next to nothing to do with whether there’s a compiler or not. I think what you’re talking about is actually “emits native code” so you should like … say what you mean, instead of the other stuff.

                                                                                  1. 1

                                                                                    Fair enough.of a point, I suppose. Many people use “compiled” vs “interpreted” to imply runtime properties, not parsing/compilation properties, it isn’t exactly the proper definition.

                                                                                    I’ll try to be more precise in the future, but I would like a term for “emits native code” that is less of a mouthful.

                                                                            2. 3

                                                                              Scripting languages can be compiled, but, out of Python, Ruby, Tcl, Perl and Bash, most of them are by default written in such a way that they require code to follow a certain file structure, and if you write a program that is bigger than a single file, you end up having to lug the files around. I know that Tcl has star deploys, and I think that’s what Python wheels are for. Lua code can be wrapped into a single executable, but it’s something that isn’t baked into the standard Lua toolset.

                                                                              1. 3

                                                                                I think it would be helpful to a lot of people if you could give examples for node, Ruby, python, … Maybe you’re just referring to the wrong usage of the word compiler ?

                                                                                EDIT: typo

                                                                                1. 1

                                                                                  For python there is Nuitka as far as I know.

                                                                                  1. -1

                                                                                    Node, Ruby, and Python are all all typically compiled. With Ruby and Node it first goes to bytecode and then usually the hotspots are further JIT-compiled to machine code as an optimization pass; I don’t know as much about Python but it definitely supports compiling to bytecode in the reference implementation.

                                                                                    1. 7

                                                                                      When talking about “compiled languages”, people typically mean “AOT compiled to machine code”, producing a stand-alone binary file. Python’s official implementation, CPython, interprets bytecode and PyPy has a JIT compiler. V8 (the JS engine in Node) compiles JavaScript to a bytecode and then both interprets and JIT compiles that. Ruby has a similar story. The special thing about Nim is that it has the same ease of use as a “scripting language” but has the benefits of being AOT compiled with a small runtime.

                                                                                      1. 1

                                                                                        The special thing about Nim is that it has the same ease of use as a “scripting language” but has the benefits of being AOT compiled with a small runtime.

                                                                                        The idea that only scripting languages care about ease of use is just plain outdated.

                                                                                        In the 1990s it used to be that you could get away with having bad usability if you made up for it with speed, but that is simply not true any more; the bar has been raised across the board for everyone.

                                                                                  2. 3

                                                                                    Some languages like Dart [1] have first class support for both interpreting and compiling. I dont think its fair to say something like “some random person has a GitHub repo that does this” as being the same thing.

                                                                                    1. https://github.com/dart-lang/sdk
                                                                                    1. 0

                                                                                      That’s the whole point; Dart has a compiler, and any language that doesn’t is very unlikely to be taken seriously.

                                                                                      1. 1

                                                                                        The point is:

                                                                                        Nearly every well-known scripting language has a compiler

                                                                                        That may be true, but nearly every well-known scripting language doesnt have an official compiler

                                                                                        1. -2

                                                                                          Also false; Ruby’s official implementation has had a compiler (YARV) since the 1.9 days; Node.js has used the v8 JIT compiler since the beginning, (not to mention TraceMonkey and its descendants) and python has been compiling to .pyc files for longer than I’ve been a programmer.

                                                                                          According to this, Lua has had a compiler since the very beginning: https://www.lua.org/history.html I don’t know much about Perl, but this page claims that “Perl has always had a compiler”: https://metacpan.org/pod/perlcompile

                                                                                          The only exception I can think of is BASIC, and that’s just because it’s too old of a language for any of its numerous compilers to qualify as official. (edit: though I think Microsoft QuickBasic had a compiler in the 1980s or early 90s)

                                                                                          1. 6

                                                                                            QuickBasic compiled to native code, QBasic was an interpreter, GWBasic compiled to a tokenized form that just made interpretation easier (keywords like IF were replaced with binary short codes)

                                                                                  1. 2

                                                                                    I just watched the talk the other day! You did a great job, but I was surprised there was no mention of WASI. Was there a reason you opted for making your own instead of implementing WASI? It seems to be feature complete enough to run programs using libc.

                                                                                    1. 1

                                                                                      Two main reasons:

                                                                                      1. My work initially predates wasi.
                                                                                      2. I don’t think wasi goes far enough in terms of presenting a next generation API. It has two different system calls for “write to file” and “write to socket” that’s bloat in my opinion. It should just be write.