7 ms·
Redescovering the beauty of C seems quite similar to city-dwellers redescovering the beauty of nature: everything is rainbows and butterflies, while in reality
by blub 8y ago
Redescovering the beauty of C seems quite similar to city-dwellers redescovering the beauty of nature: everything is rainbows and butterflies, while in reality - if you are away from the safety net of civilisation - there are hundreds of ways nature will crush you if you make even a small mistake.
- skummetmaelk 8y agoAnd then you have the rugged outdoorsmen get serious about nature and venturing into the wilderness. They plan for the worst. They bring enough supplies. They don't try to climb mountains in flip flops. They shake their fists at the city touristers leaving trash at the campsite and causing memory leaks. No garbage collectors out here. They know to respect the ecosystem flora and fauna or get ripped to pieces.
- hestefisk 8y agoSkim milk!
- tonyarkles 8y ago> No garbage collectors out here. Pack in, pack out. :)
- mmphosis 8y agomalloc, free :) in that order
- wildrhythms 8y agoThis is actually an amazing analogy.
- blobjectivist 8y agoand then there's the guy whose back in the city who knows the world is designed by aliens and that nature is artifice, all decent processor architectures are designed using dataflow HDL languages and the notion of "bare metal" nature is a delusion held by hipsters and unix greybeards
- blitmap 8y agoYou. I like you. I hope FGPAs become more commonplace and efficient.
- signa11 8y agofpga's seem to be encumbered more by design/synthesis toolchain rather than anything else (imho)
- z3phyr 8y agoBut god created in nature three basic elements (resistance, capacitance and inductance) and with holy will and power forged the foundations. The wisdom of the first borns say there are more basic elemental that god intended (memristors...)
- henrikeh 8y agoBut even these are approximations and false gods. Electromagnetism and solid-state physics are more fundamental still.
- red75prime 8y agoTHE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE Better to be ashamed than ripped to pieces though.
- kqr 8y ago> They shake their fists at the city touristers leaving trash at the campsite and causing memory leaks. Do these truly exist? I'm doubting it more and more for every day, with more and more trash being found around campsites used by the most rugged of outdoorsmen.
- paulddraper 8y agoThey certainly do. Are their fences occasionally weak, or their cabins sometimes crude? Yes, but the fundamentals can be overwhelmingly good. See the Linux kernel which for all its warts is arguably the greatest software engineering achievement, and is by any measure one of the most widely deployed software programs.
- kqr 8y agoNow you're just making me feel bad! Of course, no disrespect to the kernel devs. What they are doing is insane, in the most positive way. ...buuut... they also leave trash around their campsites... I'm not saying I could do it better. I fully understand the business decisions and they are doing the very best they can. I'm consciously ignoring the big picture and pointing to this one flaw, which isn't even their fault. It's C's fault!
- agumonkey 8y agoliving on the edge is also a natural way to experience deeper balance the comfort of accumulated knowledge with your animal instincts
- loeg 8y agoThe author isn't comparing against Rust or Java or something like that — they're comparing C against C++. C++ doesn't really provide much in the way of a safety net and actively gives you tools to hurt yourself.
- kqr 8y agoBecause RAII isn't amazing?
- jeremyjh 8y agoSmart pointers and vastly more type safety is not a safety net?
- fao_ 8y agoCan a turing-complete type system be sanely considered safe?
- dbaupp 8y agoTuring completeness of the type system isn't what causes C++'s unsafety: in a sense, being turing complete theoretically allows encoding more safety into the type system. It also allows encoding more impossible-to-write-a-program into the type system, but that's orthogonal (plus, if you can't compile anything, you can't run anything unsafe!). C++ improves on C in some respects, but still suffers from undefined behaviours like use-after-free/dangling references, dereferencing of null (e.g. a moved-from unique_ptr) and iterator invalidation, none of which are caused by a Turing complete type system (they all, in various forms, exist in C too).
- vvanders 8y agoHaving used smart pointers extensively in C++ I'd much rather debug a malloc/free issue. Finding cylces is not trivial or quick.
- winter_blue 8y agoYou’d rather debug malloc/free than try to find and eliminate shared_ptr cycles? You really think that’s easier? Besides, you shouldn’t be using shared_ptr much at all, and should try to use unique_ptr everywhere.
- backpropaganda 8y agoWhat you're saying is basically a city-dweller's perspective of what nature is like. Tonnes of people live close to nature (both literally and figuratively) without any serious threat from nature crushing you.
- brianberns 8y agoReally? What's the life expectancy of someone living without doctors or modern medicine? For reference, 17th-century English life expectancy was only about 35 years.
- gaius 8y agosomeone living without doctors or modern medicine? So-called modern languages are more like junk food and daytime TV.
- tluyben2 8y agoWhat? There is a pretty huge distance between what you suggest and living in nature a helicopter ride away from those things. Not that it is anymore than an anecdote but I live in nature and I have not had funerals of people under 85 so far.
- kqr 8y agoThe low life expectancy of old times is almost fully explained by child mortality. If you lived beyond, say, 15 years, you could expect to live nearly as long as we do today.
- phendrenad2 8y agoBad analogy - in programming languages there's no wild animals waiting to attack, no pathogens in the waters. Your only enemy is the enemies you create in your codebase. And if you know what you're doing, C is as safe as C++. It's just that everyone learns the C++ way of thinking about problems, so they can't figure out how to do the same things in C.
- adrianratnapala 8y agoTricky. I prefer C and use it at home for fun. C++ is strictly for work. But I also like to program in ways that are safe by construction, and C++ gives me tools like unique_ptr and std::vector for doing that. But I agree those tools are limited. The class of bugs which C++ protects you from are the shallow ones. Coding with discipline will prevent more bugs than switching to C++. Languages with real memory safety however are a genunie step up. Rust for example makes it painful to not code with discipline. Unfortunately I find it makes programing painful in general -- so I am still waiting for a safe language that is as much fun as C.
- setr 8y ago>Your only enemy is the enemies you create in your codebase I'd say your primary enemy are those using your codebase, who can and may exploit any hole. And ofc, its not just your codebase, as it sits on top of libraries, maybe a runtime, an OS, and hardware; you're not safe just because your onw program is fine, within the context of its internal machinations
- IloveHN84 8y agoIt's the same for JavaScript.. without safety nets (browser sandbox), it is just a massive problem to security. Looking at the latest security issues, with JavaScript hackers found a faster way to break in: examples, like crypto mining in JS delivered to websites and so on
- floatboth 8y agoMining is not a security issue though. It doesn't break into anything. It just wastes CPU cycles. If by "delivered to websites" you mean without the site owner's consent, via ad networks or comments/whatever user generated content, then it's a problem of trust and/or content filtering, it's orthogonal to browser sandboxing.
- gaius 8y agoit's orthogonal to browser sandboxing Not at all, the owner of a website should not be able to coerce your browser to anything but display the page.
- floatboth 8y ago"Displaying the page" has meant "running arbitrary application code" since Netscape. If you don't agree, disable JavaScript completely and enjoy the 100% working pages everywhere ;)
- gaius 8y agoThere is a big difference between executing a little JS to do a button rollover, and performing arbitrary computation!