Yup, I’ve looked at at 5-10 shell implementations, and all of them are essentially AST interpreters + on-the-fly parsing/evaluating.
Just like Ruby was an AST interpreter that recently became a bytecode interpeter, R made the same jump recently:
A byte code compiler for R
https://scholar.google.com/scholar?cluster=1975856130321003102&hl=en&as_sdt=0,5&sciodt=0,5
Do you happen to know how recently they’ve switched? (And an example of a large project written purely (or almost purely) in that language?) Thanks.
Ruby switched in 2007, i used it for a few years before that and the speedups were quite dramatic. See https://en.wikipedia.org/wiki/YARV for a bit more info.
Cool! That links to some benchmarks which saves me from trying to do them.
Looks like its only about 4x on average which is hopeful (for having no bytecode).
It looks like it’s around R release 2.13 and 2.14, which was around 2011. R is from the early/mid 90’s, similar to Ruby, and I think they both switched to bytecode compilers at around the same time.
https://csgillespie.github.io/efficientR/7-4-the-byte-compiler.html
https://cran.r-project.org/src/base/R-2/
R is for data analysis, so it’s hard to say what a “large project” is. It’s also a wrapper around Fortran numeric libraries in the same way Python is a wrapper around C (or NumPy is a wrapper around Fortran.)
There are thousands of libraries written in R:
https://cran.r-project.org/web/packages/available_packages_by_date.html
Thanks! This actually looks like a pretty good example. That website even lists package dependencies so I can try to find a long chain of pre-2011 dependencies.
Unix shell, for sure. GNU awk and mawk compile to bytecode. Not sure about nawk, though the regexp implementation in nawk uses bytecode.
GNU awk and mawk compile to bytecode
Really? That seems wierd, since gawk is both slower than nawk and mawk. Or is it because of the features the GNU project added, that it’s overall slower?
One big difference is that gawk operates on sequences of Unicode characters, while mawk and nawk operate on sequences of bytes. If your text is all ASCII, setting your locale to ‘C’ will cause gawk to also operate on bytes, which should close at least some of the performance gap. But gawk’s Unicode support can be nice if you have UTF-8. mawk and nawk will often still produce the right result on UTF-8 input, especially when non-ASCII characters are only passed through unmodified. But sometimes you get:
$ echo $LANG
en_GB.UTF-8
$ echo "ÜNICÖDE" | gawk '{print tolower($0)}'
ünicöde
$ echo "ÜNICÖDE" | nawk '{print tolower($0)}'
�nic�de
$ echo "ÜNICÖDE" | mawk '{print tolower($0)}'
�nic�de
Thanks for the example. I don’t know how they work internally. Although to me, they are in the write-more-primitives-in-a-faster-language category. The primitives being the external commands called (maybe awk a bit less?).
Are there examples of multi-layered library (or use) for awk and shell?
Edit: typo
What does “multi-layered push” mean?
As for awk, when I use it, I never shell out. If I need to shell out from awk, I just write the whole thing in Go or something. So I just use the primitives exposed by awk. Though, before Go, I shelled out of awk more often.
multi-layered push
Oops, that’s the wrong words. That’s what I get for alt-tabbing between the comment window and a shell.
I mean something like calling a library which calls another library which calls another library, with all intermediate libraries written in awk (or shell). (Or the same thing with functions if there are layers one on top of each other. By this I mean functions in one layer treats functions in the previous layer as primitives).
As for awk, when I use it, I never shell out.
That would be a good example then if you also have at least two layers of functions (although more would be nice).
I’m very excited about the 2.0 release, since I’ve been using the new version for about half a year while it was still in development, and it was still rock solid, just with a better user experience.
The new features now mean that I’ll be able to write much more readable scripts and code in Nix and can start pushing for more adoption in my company.
I’ve been using Nix for about 3 years now, and NixOS as my workhorse desktop/server, MacOS config, and for production machines for about 2.
I used Nix(OS) at a startup via NixOps to replace some fragile Ubuntu setups. It nicely deploys and maintains their servers, and took me a few days to package all their custom software reliably.
We got acquired afterwards, and in the new and much bigger company nobody had heard of Nix, nor were they willing to support us with it, so instead I utilized proot and dockerTools.buildImage to achieve almost the same stability (minus docker bugs…).
It’s also a great tool to share your development environment with other people, so you don’t need everyone to remember to install libzmq-dev or libpg etc. You simply put it into your shell.nix, and can use direnv so everyone who enters a project automatically gets everything they need to run it. That same configuration can then be used for building production packages.
I have a sick fascination with studying language-specific package managers and replacing them with reproducible, hashed, offline-usable derivations that can’t touch any part of my system that they’re not meant to.
IMHO the biggest things holding Nix back are its “strange” language syntax and a lack of mainstream use, so I’m really hoping at least that it gets a bit more popular and picked up by bigger players.
I love dockerTools.buildImage - Though I wish someone would make a musl libc + busybox configuration somehow, though maybe it exists.
Work on adding musl to nixpkgs (probably as an overlay) is going on. See https://github.com/dtzWill/rfcs/blob/feature/musl-rfc/rfcs/0023-musl-libc.md and https://github.com/NixOS/nixpkgs/pull/34645 where dtzWill did a tremendous amount of work to make this happen.
So in theory it should be possible now. In practice I haven’t tried it yet.
This seems like a step in the right direction, with a more accessible user interface.
What does “released” mean, though? How do I upgrade my existing nix install?
nix-channel --update ; nix-env -i nixdoesn’t get me 2.0.Did some more digging. I am on
nixpkgs-unstable(not on NixOS though). But it seemsnixpkgs-unstabledidn’t get the 2.0-release of nix yet, either. There’snixUnstablethough, which is at version2.0pre5968_a6c0b773: https://hydra.nixos.org/build/69873027.Digging further, it’s just not in
nixpkgsyet: https://github.com/NixOS/nixpkgs/commits/master/pkgs/tools/package-management/nix. And the relevant PR for switching nixpkgs’s nix to 2.0: https://github.com/NixOS/nixpkgs/pull/34636(And as an aside, this kind of need to dig to figure out the answer to a pretty straightforward question is typical for my nix experience – it always ends up making sense in some way, but you need so much knowledge and have to dig so deep to find out how/what/why.
git grepin a nixpkgs clone seems part of the required tool set for a nix user.)Yeah, I think there have been great strides on documentation over the past year, but there’s a long distance still to go.
I’ll keep talking to myself here. Following a suggestion from the announcement post on news.ycombinator, I got the new nix:
Which… doesn’t seem to know about nixpkgs? At least
nix searchdoesn’t find anything. Andnix log nixpkgs.hellodoesn’t findnixpkgs.Hey, that was my suggestion, so I perhaps should also mention that
nix log nixpkgs.hellodepends on you having something likeNIX_PATH=nixpkgs=/path/to/your/nixpkgs/checkout.Nix ≠ NixOS. But in NixOS, Nix 2.0 would be present in 18.03 release, which would be released in March this year. But you can also freely upgrade to their “unstable” channel (I forgot the proper name though) which has these all nice things with cutting edge versions available.