News for hackers. Stuff that matters.
Re:Modern terminal-based text editor by int_19h on Thursday September 28, 2017 @09:35PM (#15362137)
The advantage of Nano is that it is written in C, has zero required dependencies other than libc, and the compiled binary is 200 kilobytes. This makes it possible to include it in the base system, even on very tiny distros.
Re:Modern terminal-based text editor by deathanatos on Thursday September 28, 2017 @09:47PM (#15362177)
Why is C an advantage?

(I get "no dependencies", but that seems orthogonal to being written in C. Specifically, what does C bring that isn't minimal dependencies, or a small binary?)

Re:Modern terminal-based text editor by int_19h on Friday September 29, 2017 @01:03AM (#15362808)
It adds a massive new dependency to the build process for base system. C is itself a massive dependency, but it's already there for pretty much everyone.

This matters more for distros and OSes where building things from source - either everything, as in e.g. Gentoo, or at least the base system, as in the BSDs - is pretty common and expected.

Re:Modern terminal-based text editor by jlebrech on Friday September 29, 2017 @04:06AM (#15363555)
>>> C is itself a massive dependency

the C standard library?

Re:Modern terminal-based text editor by int_19h on Friday September 29, 2017 @05:22AM (#15363854)
No, the C compiler. Both gcc and Clang are pretty big, even before you account for the standard library. I suppose you could get away with something like tcc, though.
Re:Modern terminal-based text editor by jlebrech on Friday September 29, 2017 @10:02AM (#15365320)
lots and lots of edge cases, I minimal compiler can be kbs
Re:Modern terminal-based text editor by tedunangst on Thursday September 28, 2017 @10:05PM (#15362243)
C compiler backend support is pretty broad.
Re:Modern terminal-based text editor by noobermin on Friday September 29, 2017 @01:18AM (#15362887)
Probably the biggest understatement I've ever seen on HN.
Re:Modern terminal-based text editor by defined on Friday September 29, 2017 @12:30AM (#15362725)
Supported on virtually every OS and embedded platform in existence.
Re:Modern terminal-based text editor by exikyut on Friday September 29, 2017 @02:27AM (#15363191)
Abstractly, very much yes.

In the context of nano and editors, you also have to contend with POSIX, tty I/O, etc.

Re:Modern terminal-based text editor by ktta on Thursday September 28, 2017 @09:49PM (#15362185)
It isn't, except for the fact that most people who can code low level programs know it. But what you don't want into consideration is pretty much the important part of shipping a software you want to proliferate easily.
Re:Modern terminal-based text editor by megous on Friday September 29, 2017 @05:28AM (#15363887)
Statically linked C programs are the easiest to ship. Copy and run. No runtime required.
Re:Modern terminal-based text editor by pjmlp on Friday September 29, 2017 @07:23AM (#15364341)
A feature of any AOT compiled language since compilers exist, nothing C specific.
Re:Modern terminal-based text editor by rmrfrmrf on Friday September 29, 2017 @08:18AM (#15364589)
Java and .NET would like a word with you.
Re:Modern terminal-based text editor by pjmlp on Friday September 29, 2017 @08:59AM (#15364800)
When correcting someone on Internet be sure to know what you are talking about.

ExcelsiorJET, JamaicaVM, Aonix PERC, IBM Websphere Real Time, Xamarin on iOS, .NET Native, Bartok.

Re:Modern terminal-based text editor by jcelerier on Friday September 29, 2017 @12:49PM (#15366885)
yes, good idea, let's make a modern console-based text editor that comes with IBM Websphere Real Time
Re:Modern terminal-based text editor by atilaneves on Friday September 29, 2017 @08:38AM (#15364686)
You can embed their runtimes. I'm not saying that's desireable, just that it's possible.
Re:Modern terminal-based text editor by schrodinger on Friday September 29, 2017 @06:52AM (#15364195)
Same with go
Re:Modern terminal-based text editor by coldtea on Friday September 29, 2017 @04:05AM (#15363549)
>The advantage of Nano is that it is written in C, has zero required dependencies other than libc, and the compiled binary is 200 kilobytes.

The advantage for whom? Surely not the user.

Re:Modern terminal-based text editor by nl on Friday September 29, 2017 @04:31AM (#15363663)
Having been stuck on a system where the only editor was Ed, I'd say nano availability can be a big win for the user.
Re:Modern terminal-based text editor by zimpenfish on Friday September 29, 2017 @06:12AM (#15364036)
When I was a lad, I had to port ed in order to have a console-based editor.

(True story - A5000 with RISCOS back in about 1993)

Re:Modern terminal-based text editor by joosters on Friday September 29, 2017 @08:32AM (#15364647)
Can we start a !Zap vs !StrongEd argument here? :)

(Zap wins, of course!)

Re:Modern terminal-based text editor by pjmlp on Friday September 29, 2017 @07:21AM (#15364334)
The advantage for anyone trying to find out-of-bound exploits in text buffer handling.
Re:Modern terminal-based text editor by petre on Friday September 29, 2017 @12:13AM (#15362666)
Micro also has zero drpendencies after it's compiled. And Go makes cross compiling easy as childsplay: just set two env vars, type go build and you're done.

I'd love a working replacement for Sublime Text written in Go rather than all of these Electron based editors. Lime Text is kind of alpha quality.

Re:Modern terminal-based text editor by int_19h on Friday September 29, 2017 @01:08AM (#15362846)
Fun fact: on Linux, mac OS and BSDs, it does that by invoking syscalls directly. Syscalls are not considered a stable API on those systems by their respective developers. This means that your precompiled zero-dependency binary will just stop working next time Apple changes or removes a syscall: https://github.com/golang/go/issues/16570.

Coincidentally, code written in C doesn't have that problem.

Re:Modern terminal-based text editor by exDM69 on Friday September 29, 2017 @02:44AM (#15363266)
Linux considers syscall API stable and there's a pretty hard rule of not breaking user space.
Re:Modern terminal-based text editor by int_19h on Friday September 29, 2017 @04:03AM (#15363542)
Linux does, yes. MacOS and BSDs do not. (Neither does Windows - but so far as I can see, Go doesn't try to invoke the NT APIs directly there.)

Stability is guaranteed on userspace API level - e.g. libc. So well-behaving apps are supposed to just use that, and let it handle syscalls. But Go doesn't.

Re:Modern terminal-based text editor by yazan94 on Friday September 29, 2017 @08:44AM (#15364713)
I am not all that familiar with kernel/low level programming, but wouldn't the C API/library internally use syscalls as well? If a C program is written with a dependency on a syscall, and this syscall is changed. Does the code still work after, or does it need to be recompiled with an updated compiler?
Re:Modern terminal-based text editor by int_19h on Friday September 29, 2017 @03:44PM (#15368503)
The compiler doesn't really play a role in this. If a syscall changes, then you'll need to change the arguments in the C code that invokes it.

The system libraries like libc themselves use syscalls internally, yes. But on those platforms I'm talking about, they're maintained by the same people who maintain the kernel, and both components are versioned together. So they can go and change a syscall, and then also make the corresponding change to libc (without changing the latter's public ABI), and ship the updated versions together as the new OS release. Well-behaved apps dynamically link against libc, so the change is completely transparent to them.

On Linux, different people maintain the kernel and libc (and, in fact, there's no single officially blessed libc - this is one case where the old adage that "Linux is just a kernel" is in full force). Consequently, the interface between the two has to be treated as a public API, with stability guarantees.

Re:Modern terminal-based text editor by jjnoakes on Friday September 29, 2017 @12:27PM (#15366689)
The system's C library would use the syscalls directly and the application would use the C library routines. So if/when the OS updates the syscall ABI, it would also update the system's C library to use the new syscalls, and the application would continue to use the stable C library API and get the new syscalls under the covers automatically.
Re:Modern terminal-based text editor by mnd999 on Friday September 29, 2017 @04:02AM (#15363540)
FreeBSD also doesn’t break the ABI on major versions.
Re:Modern terminal-based text editor by int_19h on Friday September 29, 2017 @05:24AM (#15363870)
That's good to know, but it still means potential breakage every 2 years on average.
Re:Modern terminal-based text editor by pjmlp on Friday September 29, 2017 @07:24AM (#15364348)
Historical accident, it is all a matter how libc of a specific compiler was implemented.
Re:Modern terminal-based text editor by int_19h on Friday September 29, 2017 @03:36PM (#15368414)
I would rather say, it's a matter of having libc and kernel developed as a single package ("base system") by the same people, and versioned together, versus having the kernel and the userland separate.
Re:Modern terminal-based text editor by ericfrederich on Friday September 29, 2017 @12:23AM (#15362691)
As easy as childsplay as long as your target is supported. I cannot run Go code on my router which runs OpenWRT... Nano works there just fine.
Re:Modern terminal-based text editor by petre on Friday September 29, 2017 @12:59AM (#15362794)
Go was likely never intended to run on space constrained platforms like Broadcom MIPS, but point taken.
Re:Modern terminal-based text editor by lewiseason on Friday September 29, 2017 @04:57AM (#15363766)
What?
Re:Modern terminal-based text editor by atilaneves on Friday September 29, 2017 @08:39AM (#15364690)
Unless you'd want to contribute, why would you care what language it's written in? Why Go and not C++, Rust, D... ?
Re:Modern terminal-based text editor by FullyFunctional on Friday September 29, 2017 @12:31PM (#15366736)
Because you want to run it on your favorite platform, which might not be x86 and thus need compiler support? I wrote my own editor for exactly this reason: to always be able to have it on any platform.