6 ms·
I'm not sure that either of those languages are usually GC'd, but they'd be good choices, too, if they were. (I just don't like Wirth languages. I don't like t
by cbd1984 11y ago
I'm not sure that either of those languages are usually GC'd, but they'd be good choices, too, if they were.
(I just don't like Wirth languages. I don't like their type systems and I don't like the definition-before-use requirement. They're better than C, in some respects, but worse in others, and the net isn't always an improvement.)
- nickpsecurity 11y agoAll of Wirth's after Modula-2 were GC'd. C programmers would reject a GC'd language, though. So, I stayed with originals that enhanced safety, predictability, readability, and so on while capable of low-level, fast stuff. Wirth's stuff and industrial variants of it often let you do unsafe stuff in dedicated modules for that so you could turn off GC or checks. Plus they wrote OS's in Modula-2 and Pascal on ancient hardware. Whole platforms. So, they're proven for the use case C programmers often say you need their language for.
- cbd1984 11y agoWhole OSes were written in Lisp, too, as well as other GC'd programming languages (Smalltalk, Mesa, perhaps a few others), and they ran on rather underpowered hardware by modern standards as well. I get your point, but having to check for allocation failure is a substantial source of bugs in non-trivial programming without GC, and having to manually allocate RAM makes string handling, for example, orders of magnitude less safe than it is in a language with GC.
- nickpsecurity 11y agoLet me be clear: could a C programmer understand and effectively use Genera OS without significant, paradigm-altering changes in mindset about programming? Probably not. So, I don't include LISP in a C-replacement discussion given they're in two, different ballparks. And LISP is universally hated by almost all programmers outside its own fans and those Clojure is attracting. That's despite the fact that I promote its advantages elsewhere where they might get take-up. ;) Now, back to imperative languages with some familiarity to C programmers. For allocation failure, some languages provide exceptions to handle such things but I usually recommend allocating what you need at the beginning and being sure you'll know your max for later. Do the checks plus reserve early so you worry less from then. Shouldn't be a problem. It's work to keep in mind but straight-forward. Far as string-handling, there's safe libraries and approaches to it. We just use them with whatever performance or syntax hit we get if our language doesn't do it inherently safe. The issues with it are why I recommend prefix strings for clean-slate stuff over null-terminated. If you can get away with it. Having separate types for the two can highlight interface errors.
- paliderek 11y agoFor anyone interested in Modula-2 as a potential replacement for C as a systems language, there is a small but hopefully growing revival of the language occurring on the Gnu Modula-2 mailing list and (especially) on comp.lang.modula2 . Right now there is a call on the newsgroup for testers of the Modula-2 to C (M2C) compiler. This is part of a larger effort for the Modula-2 Revision 2010 (M2 R10) language definition and implementation by Benjamin Kowarsch and Rick Sutcliffe.
- nickpsecurity 11y agoAppreciate the tip: that's exciting. Also an ideal time to extend it with improvements learned from experience since Modula-2 and avoid problems learned similarly. I actually downloaded the old Modula2-to-C compiler, Lilith technical paper, and A2 Oberon sources in case any of that ended up being useful. Maybe it will. :)