News for hackers. Stuff that matters.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by echelon on Wednesday December 09, 2020 @06:22PM (#25366914)
A lot of languages are doing single static binary deploys now. Rust, Nim, Go. It's a really nice pattern.

Static binaries are so much easier that the gross PHP / Ruby / Python pattern that has to ship directories full of files that (usually) have to be put in the correct place.

It's also easier than shipping a runtime like a JVM.

With a single binary, containers get even slimmer.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by Hokusai on Wednesday December 09, 2020 @06:35PM (#25367105)
> A lot of languages are doing single static binary deploys now

As a developer for more than 30 years, I find that statement quite interesting. When I was a kid I was very happy to find a way to compile Basic to an executable like I was doing in Pascal and C++. For me is the standard way of thinking about applications.

Is it a common experience to actually have to ship many files for one application? I thought that it was just common for the web as it fits how HTML evolved not for anything else.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by pjmlp on Wednesday December 09, 2020 @06:46PM (#25367225)
Same here, the static linking hype feels real strange, given that was the only option we used to have back in the day, and having access to dynamic linking on 16 bit platforms felt like liberating.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by simias on Thursday December 10, 2020 @06:36AM (#25372563)
I don't really see the hype, I think it's just the intersection of a few factors:

- Languages like Rust which have an ecosystem that evolves very quickly (and uses complex symbol mangling schemes that would break all the time) wouldn't fare very well with dynamic linking in the first place. What good is dynamic linking if you need a different version of your .so file for every binary?

- Dynamic linking is not quite as useful today a it was in the past. Code size is not usually very significant, either on cold storage or in RAM. Actually for RAM it's cache usage that matters most, and static linking can usually be more efficient here through LTO.

- Over the past ~2 decades a new generation of developer arrived and many of them (in my experience) barely use "low level" compile-to-machine-code languages. They often specialize in scripting languages or languages that require a framework. Some of these developers are now learning Go or Rust and for them the idea of shipping a single ELF binary that packages the entire app might be seen as a novelty or maybe even as an innovation.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by eeZah7Ux on Sunday December 13, 2020 @10:03AM (#25407007)
> Dynamic linking is not quite as useful today a it was in the past

Linux distributions need to be able to backport security fixes to shared libraries, test them and deliver updates to all users quickly.

With static linking it becomes practically impossible.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by oblio on Thursday December 10, 2020 @02:50AM (#25371006)
PHP, JavaScript, Python, Ruby, even Java and C# didn't (don't?) have a mainstream way to create a single binary with unused code and unused dependencies removed.

Dynamic linking was cool because you could use system dependencies which people don't want to use because you can't rely on them, especially for cross platform apps and also for efficiency, RAM (which people stopped caring about) and, disk space (this boat sailed a loong time ago) and compilation (we have 10000x as powerful computers now).

Re:Deno 1.6 supports compiling TypeScript to a single execut... by pjmlp on Thursday December 10, 2020 @04:07AM (#25371498)
Java has had static linking support since around 2000, for embedded deployments.

C#, yes it has been mostly dynamic.

PHP, JavaScript, Python, Ruby, don't count, they are scripting languages, bundled with an interpreter.

Still, Python and Perl bundlers exist since around 2000 as well.

Compiled languages like Basic, Pascal, Modula-2, Ada, Eiffel, Modula-3, C, C++, Haskell, OCaml, SML, .... all started in days where static linking was the main option.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by oblio on Thursday December 10, 2020 @04:14AM (#25371557)
> Java has had static linking support since around 2000, for embedded deployments.

Yeah, but for non-embedded deployments i.e. 99% of Java code out there?

> Still, Python and Perl bundlers exist since around 2000 as well.

I don't know the Perl one, but the Python ones definitely aren't mainstream. They're finicky and relatively hard to use and definitely not distributed with the Python distribution, which would make them ubiquitous and well supported.

> Compiled languages like Basic, Pascal, Modula-2, Ada, Eiffel, Modula-3, C, C++, Haskell, OCaml, SML, .... all started in days where static linking was the main option.

Every language in the olden days had static compilation support :-))

That's why we had articles such as these: https://www.joelonsoftware.com/2004/01/28/please-sir-may-i-h... (which I agree with)

Re:Deno 1.6 supports compiling TypeScript to a single execut... by pjmlp on Thursday December 10, 2020 @04:29AM (#25371664)
> Yeah, but for non-embedded deployments i.e. 99% of Java code out there?

100% of commercial JDKs have support for AOT compilation, what you are getting nowadays on OpenJDK is the free beer version of it.

> I don't know the Perl one, but the Python ones definitely aren't mainstream.

They surely were mainstream on Windows back in .com days, specially via py2exe and ActiveState tooling.

> Every language in the olden days had static compilation support :-))

Many of which are still mainstream languages.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by oblio on Thursday December 10, 2020 @04:32AM (#25371686)
I know you're aware of this, but 70% of the languages in your list are niche languages and especially for web development they weren't that popular.

It was (is?): PHP, Javascript, Java, Python, Ruby, C# or nothing.

Especially the dynamic languages are extremely popular, primarily with smaller companies and startups.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by pjmlp on Thursday December 10, 2020 @05:11AM (#25371987)
The whole point of my discussion doesn't have anything to do in which field the languages are popular.

Zope and AOL Server teached me that those dynamic languages are really only good for OS scripting tasks anyway, but that isn't the subject of this thread.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by oblio on Thursday December 10, 2020 @07:08AM (#25372803)
It is the point of the thread :-)

For many developers, maybe the majority, those languages are their objective reality. They haven't used anything else, they might not ever use anything else.

So things which extend the range of their tools are very much appreciated.

They're not going to shun their existing programming languages because other people don't like them and they're not going to switch to OCaml or to commercial Java compilers, either ;-)

Re:Deno 1.6 supports compiling TypeScript to a single execut... by strzibny on Thursday December 10, 2020 @09:50AM (#25374215)
Ruby has some options too, one of them being ruby-packer. Here's[0] how I used it to generate single executables.

[0] https://nts.strzibny.name/making-a-ruby-executable-with-ruby...

Re:Deno 1.6 supports compiling TypeScript to a single execut... by gouggoug on Thursday December 10, 2020 @03:14AM (#25371152)
I imagine dynamic linking solved a problem for a long time that no longer is: binary size.

With internet speeds of today and immense storage sizes, the main attractiveness of dynamic linking vanished.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by pjmlp on Thursday December 10, 2020 @04:04AM (#25371471)
Not everyone is blessed with such connections, without data caps.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by simias on Thursday December 10, 2020 @06:28AM (#25372511)
Even then, in general code size is not a significant part of an application's size, various assets are. I'm working on a 10k lines rust application with 74 direct and indirect dependencies and the resulting static binary is less than 3MB in size (less than 1MB xz-compressed). That would've been a significant amount of storage in the 90s but it's almost negligible nowadays.

And given that shared libraries need to be installed and updated separately and they have to ship the entire code of the library (whereas a static binary can be link-time-optimized to get rid of unused code) it might not always be a win in terms of total bandwidth.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by zelly on Wednesday December 09, 2020 @11:18PM (#25369646)
Containers changed the game. 99% of Deno/Go/Rust server software will be running on containers in practice. You're no longer deploying to a system running other programs which may share pages. It's a container, not a process. Dynamic linking in a container is just a vestigial useless step.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by DougBTX on Thursday December 10, 2020 @02:57AM (#25371046)
Interesting, that’s the opposite of my experience. Containers allow bundling up lots of dynamic dependencies together so that they can be installed as a single unit. Static binaries can just be deployed as a single file, no need for containers.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by nickjj on Thursday December 10, 2020 @08:18AM (#25373356)
> Static binaries can just be deployed as a single file, no need for containers.

Sure but most web apps are more than a single binary. There's generating static files, a database, background worker / cache, and more. Then there's wanting to be able to develop that project as a whole on Windows, macOS and various Linux distros as well as deploying it to a specific distro of Linux (most likely). Then there's the distribution of the binary across a network in a reasonable way.

Docker and its ecosystem of tools solves all of those problems once your app is containerized. And if you want to go 1 step further and run a distributed system with load balancers and friends, container orchestration tools let you solve this problem at a level above your application.

And the best part is you can do all of that in the same way with any tech stack.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by pjmlp on Thursday December 10, 2020 @02:32AM (#25370904)
Not if plugins come into play, unless you want to go OS IPC for that.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by mpoteat on Wednesday December 09, 2020 @07:51PM (#25367967)
The issue I see with this approach is that library code is duplicated among applications. In the limit, this is how you get every Electron app bundled with Chromium.

It's a little more complicated, but modern Node development is a huge step forward to the old days of sadly attempting to get the LINPACK header configuration correct in your C project.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by dljsjr on Wednesday December 09, 2020 @06:44PM (#25367206)
In the case of the above listed languages, it's not just that the application is compiled to a single executable, it's that they're statically linked/truly self-contained. The only thing they dynamically link against is the OS's standard library. So there's no "DLL hell" either.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by loosescrews on Wednesday December 09, 2020 @06:31PM (#25367042)
Do they? As far as I know, Go is the only mainstream language that supports static binaries with normal non-trivial programs. Rust for example depends on dynamically linked libc if you use the standard library. While you technically can statically link libc, it is unsafe with glibc.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by kibwen on Wednesday December 09, 2020 @07:20PM (#25367646)
I think the belief that Go does no dynamic linking whatsoever is outdated; I seem to recall that they recanted this approach on Mac and Windows since these platforms only offer a stable system interface via dynamically-linked libraries, and trying to re-implement all of it ended up being a lot of work only to end up with broken code after system updates. On Linux I think Go still tries to link mostly statically, but if you use parts of the stdlib (e.g. `net`) you'll still end up dynamically linking to libc unless you instruct it otherwise. If anyone more knowledgeable could speak up I'd welcome it.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by loosescrews on Wednesday December 09, 2020 @09:38PM (#25368955)
Go supports dynamic linking and most Go binaries will be dynamically linked. On Linux, this is mostly due to optional features which can be easily disabled. The optional features are all related to supporting rare and unusual system configurations and do not affect normal operation. Note that cross compilation with Linux as the target does not support dynamic linking, so all Go Linux binaries compiled on a non-Linux OS will be statically linked.

Regardless of how we scope it, Go is still the only mainstream language capable of producing statically linked Linux binaries without libc while still allowing full use of the standard library.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by pjmlp on Thursday December 10, 2020 @02:34AM (#25370916)
C with musl does just fine.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by sim_card_map on Wednesday December 09, 2020 @08:17PM (#25368244)
This is correct.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by hetman on Wednesday December 09, 2020 @09:22PM (#25368818)
Rust has supported statically linking to MSVC and musl for a while now but also added static glibc support on Linux very recently:

https://github.com/rust-lang/rust/pull/77386

Re:Deno 1.6 supports compiling TypeScript to a single execut... by loosescrews on Wednesday December 09, 2020 @09:42PM (#25368995)
Is it possible to compile with statically linked musl with the pre-built Rust toolchain on a standard glibc based distribution?
Re:Deno 1.6 supports compiling TypeScript to a single execut... by SomaticPirate on Wednesday December 09, 2020 @10:31PM (#25369324)
Re:Deno 1.6 supports compiling TypeScript to a single execut... by saagarjha on Thursday December 10, 2020 @05:13PM (#25379495)
musl is generally not optimized for performance.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by mkj on Thursday December 10, 2020 @01:43AM (#25370582)
Yes, it works well. The main caveat I've found is you need the rustls feature of packages rather than openssl. Though perhaps that was more related to cross compiling for Arm.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by pjmlp on Wednesday December 09, 2020 @06:43PM (#25367185)
Ada, FreePascal, C and C++ do perfectly fine.

Not everyone is using Linux with glibc linking issues.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by loosescrews on Wednesday December 09, 2020 @09:43PM (#25368999)
Using C and C++ without libc excludes the use of nearly all common libraries.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by pjmlp on Thursday December 10, 2020 @02:30AM (#25370881)
glibc is the problem, other C and C++ standard libraries don't have any issues with static linking since these languages exist for about 40 years now.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by remexre on Thursday December 10, 2020 @02:03AM (#25370721)
libc's other than glibc don't have issues with being statically linked.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by mrkurt on Wednesday December 09, 2020 @06:37PM (#25367130)
Rust and Deno qualify as a "single executable" for what I need, but you're basically correct. It's not quite as dependency free as a Go binary.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by lucacasonato on Wednesday December 09, 2020 @06:48PM (#25367253)
We currently do dynamically link to glibc. But we could in theory support musl, which would remove our dependance on the glibc dynamic link.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by lock-free on Wednesday December 09, 2020 @06:54PM (#25367329)
That's why you statically link musl C
Re:Deno 1.6 supports compiling TypeScript to a single execut... by qeternity on Wednesday December 09, 2020 @06:30PM (#25367025)
> With a single binary, containers get even slimmer.

Not really. I agree on the other benefits of binaries but our containers usually only have the final layer change (the source code). This means that all the lower layers, python base image, requirements, etc are cached. So we can ship 100 times and add maybe 100mb of new container overhead. Binaries will ship 100% every time.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by momokoko on Wednesday December 09, 2020 @09:47PM (#25369022)
It’s funny you say that because when PHP / Python / Ruby were all the rage, most people considered needing to compile everything into a single binary gross.

What’s old is new is old again!

Re:Deno 1.6 supports compiling TypeScript to a single execut... by Cthulhu_ on Thursday December 10, 2020 @04:07AM (#25371502)
It's a circular argument and a false dichotomy tbh, they both have their place.

Ex: I maintain an 'old' PHP / JS application while building a new Go / TS one. With the old one, I change a file, it gets automatically ssh'd to my dev server, and my changes work instantly. I'm sure that if the PHP and JS had to be comp/transpiled, it would take a minute or so (it's just under 100K LOC, some files 13K LOC).

For the new application, I get the same fast feedback because Go does incremental compiles and create-react-app with TS also does incremental compiles with live reload (without requiring a full page reload).

For production builds, the old is pulled through tools like ioncube and uglify, the new one churns out an optimized binary and webpack-flavored .js files.

I mean if you zoom out enough there's no noticeable difference.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by zeroc8 on Thursday December 10, 2020 @07:14AM (#25372852)
Because compilers - apart from Pascal dialects - were quite slow. With Go, you aren't wasting time waiting for the compiler. So it feels like a script language, but gives you that extra security of a compiler.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by axaxs on Wednesday December 09, 2020 @09:03PM (#25368651)
Python has had packagers for many years...cxfreeze, pyinstaller, and others. I hear Nuitka works well. Just pointing out the fact, not disputing your statement. I also wish it was more of a first class citizen.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by stevetodd on Wednesday December 09, 2020 @09:31PM (#25368890)
> It's also easier than shipping a runtime like a JVM.

jlink has shipped since JDK 9 and can package all dependencies and the JRE into a single file. Hello world clocks in at about 22 MB.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by tryptophan on Wednesday December 09, 2020 @06:35PM (#25367100)
Yeah, its especially horrible in python for webdev. How are you supposed to deploy django/flask projects when NOT using docker or some PassS?

I haven't figured out anything better than a git pull script to update things. I can't imagine there is nothing better in 2020.

Re:Deno 1.6 supports compiling TypeScript to a single execut... by marcopolo on Wednesday December 09, 2020 @08:29PM (#25368360)
You may be interested in Nix. It can track all the dependencies of your project. So you d an copy them to a server, or Tarball them, or just run them with Nix on the server. It also has a nice property that you only ship what is necessary, since it keeps track of all dependencies.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by dglass on Wednesday December 09, 2020 @06:53PM (#25367320)
Prior to docker some common patterns were to rsync the files up to each server, or compress the files to .tar or .zip on a build server, rsync it to the servers and then uncompress into your desired directory.
Re:Deno 1.6 supports compiling TypeScript to a single execut... by ric2b on Thursday December 10, 2020 @04:39PM (#25379083)
Pip freeze?
Re:Deno 1.6 supports compiling TypeScript to a single execut... by aabbcc1241 on Thursday December 10, 2020 @09:50PM (#25381698)
The single binary still have to embed the runtime somehow. So the container size would be similar?

Except the single bundle trimmed off unused part from the standard runtime