News for hackers. Stuff that matters.
Re:The Resurgence of C Programming by rb808 on Tuesday December 27, 2016 @01:13PM (#13264779)
I keep changing my mind about C/C++.

I loved my junior days programming in C & C++. It was really fun writing your own logging framework, container classes etc. OTOH spending weeks looking for root causes of memory problems was fun the first few years then became an annoyance.

Higher level languages are much more productive - which was initially great, but now I feel more like a sysadmin than a programmer. Its a lot of researching, wiring up and configuring libraries. Probably results in better results but not as fun as hitting the metal.

So sometimes I wish I could go back to the old days but my nostalgia is probably rose tinted. I'd love to do it, but I don't think its commercially productive enough, so I'm skeptical of talk of a resurgence.

Re:The Resurgence of C Programming by bsharitt on Tuesday December 27, 2016 @01:21PM (#13264845)
I find myself doing most of my hobby programming in C. I think it kind of evokes the same thing other hobbyists(like wood working) get by building something from scratch even though there are easier ways to get close to the same end result. There's just something fulfilling about building something with your own two hands as it were and seeing it work.

That being said, I don't think I'd like to do C professionally and I'll happily stick with languages the manage my memory and have all kinds of libraries that give me "free" stuff.

Re:The Resurgence of C Programming by sh_tinh_hair on Tuesday December 27, 2016 @02:19PM (#13265411)
Agreed. My first choice for a project on *nix is usually in C: it feels like real coding rather than including half the packages/modules from 'pick your glue language here' where the opacity is blinding. But many times I'll stop after working through the first data structures and IPC elements and decide to go higher level in the interest of time and energy (and for other (younger) people being able to maintain it).
Re:The Resurgence of C Programming by fuball63 on Tuesday December 27, 2016 @02:21PM (#13265431)
I love the analogy to woodworking. When I am working on game dev, I prefer to use a old SDL based engine I developed in C++ instead of some of the new popular frameworks which are more productive and powerful. I just like tinkering and that "built from scratch" feeling for my hobby projects.
Re:The Resurgence of C Programming by cryptarch on Tuesday December 27, 2016 @01:16PM (#13264796)
Try Rust maybe?

It has a different learning curve from C, as initially you'll be having a hard time getting programs to compile at all, but from that point the ergonomics are much better and you don't ever have to deal memory bugs unless you're developing a low-level library.

Re:The Resurgence of C Programming by echelon on Tuesday December 27, 2016 @01:27PM (#13264919)
I second this notion. I'm quite productive in Rust now and can string together web services quickly. (To date I've written a text to speech engine, a laser projector renderer, and some image processing stuff.)

Rust is so awesome. Unlike Python or Ruby it's typesafe at compile time. Unlike Java and Go, it has no dumb GC, and unlike C and C++ it's memory safe. At compile time!

Programs can be distributed as a single binary, which makes deployment a breeze.

If that weren't enough, Rust innovates beyond every language I know of with its compile time threadsafety and fucking sweet package manager. (Cargo is seriously the best package manager I've ever used--perhaps the best in existence right now.)

Give Rust a try. It's freaking awesome.

(I'll buy you a coffee if you do and don't like it!)

Re:The Resurgence of C Programming by keldaris on Tuesday December 27, 2016 @05:08PM (#13266627)
Rust certainly seems to have a very enthusiastic (albeit small) user base. I'm someone who usually feels comfortable rapidly switching between a wide variety of languages, including unpopular ones (D is one of my favorites), but I've never seriously tried Rust. There are two reasons for this.

First (and this is the less important one), the syntax seems second only to Java in verbosity and often seems different for no readily evident reason. Secondly, virtually any time someone's advocating for Rust, you get a long lecture about how memory safety is the most important thing in the world and anyone who disagrees is so hopelessly backward that they should be disqualified from writing any code at all. Well, it happens to be very low on my list of concerns. In fact, for most of the low level code I write, memory safety, ownership tracking, borrow checking, etc. are wholly irrelevant. So, given that, should I look at Rust (as compared to C++ and D, which I use and enjoy)? Does it have meaningful advantages that compensate for its syntax, immaturity and performance limitations (vectorization, etc.)?

I've asked a few Rust users this before, but never really gotten a satisfactory answer that didn't involve the same memory/thread safety argument. Give me one and I'll happily give Rust a try, no coffee necessary. :)

Re:The Resurgence of C Programming by jjnoakes on Tuesday December 27, 2016 @05:58PM (#13266984)
Can you give examples of C++ code which would not require you to keep the ownership or borrowing straight in your head, and which a port to Rust would cause you unnecessary verbosity?

I usually find that if my C++ code required little to no mental tracking of ownership or borrowing or lifetimes, the rust was straight forward. And if the rust was complex, the C++ required me to keep too much in my head (or even had bugs).

Re:The Resurgence of C Programming by keldaris on Tuesday December 27, 2016 @08:59PM (#13267882)
Technically, all code requires you to keep track of ownership and borrowing. In cases where these are intellectually trivial concerns (which, I would argue, are by far the most common cases), Rust's forcibly explicit approach is, if you accept the assumption of the previous sentence, unnecessarily verbose by definition.

I cannot address the latter part of your argument (the more important part, I think), however, because as I stated, I have not invested serious effort in Rust. Intuitively, from the code and documentation I've seen, I'd be wary of trying to implement, say, highly performant (emphasis on the performance) cyclic graphs in Rust rather than C++, but that's merely an impression, hence my interest in learning more. And certainly, whatever the difficulty, the likelihood of bugs in C++ would be higher.

Re:The Resurgence of C Programming by jjnoakes on Tuesday December 27, 2016 @10:24PM (#13268211)
I don't find rust verbose unless I am dealing with complex situations though; that was my point.

Move-by-default, elided lifetimes on many parameters, etc, are all verbosity-free.

Re:The Resurgence of C Programming by steveklabnik on Tuesday December 27, 2016 @06:34PM (#13267236)
https://news.ycombinator.com/item?id=13265758 has a lot of discussion on this topic.

Not your parent, but instead of writing my own thoughts here, I think I'll write a blog post tomorrow :)

Re:The Resurgence of C Programming by keldaris on Tuesday December 27, 2016 @09:08PM (#13267913)
FWIW, I've seen people praise traits, but never seen any in depth discussion of their advantages and limitations with respect to, say, C++ polymorphism (both dynamic and static, via CRTP etc. for zero cost OOP) and trait classes. Similarly, algebraic types are frequently mentioned, but only with simple matching examples and scarce discussion of the limitations. I'm sure other aspects of the language I'm not immediately aware of also deserve more discussion.

Anyway, looking forward to your post.

Re:The Resurgence of C Programming by tatterdemalion on Tuesday December 27, 2016 @06:43PM (#13267295)
Ownership helps me design code which is decoupled and easy to refactor.

Rust traits are more powerful, expressive, and maintainable than other polymorphism systems like inheritance.

Re:The Resurgence of C Programming by CorvusCrypto on Tuesday December 27, 2016 @01:41PM (#13265018)
Idk if I share your enthusiasm, but rust is pretty cool. Certainly has its uses though for bare metal I'd still say go with C (and ASM) if using atmel's AVR chips. At least until rust gets a working compiler to AVR. Seems it is getting ever closer https://github.com/avr-rust/rust
Re:The Resurgence of C Programming by cm2187 on Tuesday December 27, 2016 @01:47PM (#13265091)
How developed is the ecosystem? One thing I enjoy about .net is the huge number of free and commercial libraries, the great IDE, and the ability to code a very broad range of applications with a single language (website, CLI, GUI, service, etc). Is Rust comparable?
Re:The Resurgence of C Programming by echelon on Tuesday December 27, 2016 @01:54PM (#13265159)
Not at all. Rust has a long, long road ahead before it has an ecosystem comparable to Java or .NET. These systems have literally man centuries of work poured into them.

That said, I still predict Rust becoming the most important language of the decade, if not the decades that follow simply due to the strength of its foundation. Rust solves problems that no other language has--real problems with actual costs--, and fits into a very interesting space where it can eat away at the lethargic incumbants.

Rust is a web service language [1]. A desktop application language [2]. A CLI tooling language [3]. A core system library language. A game development language (eventually) [4]. It has a bright future ahead in so many different domains, and the tooling and libraries will come and reinforce this.

[1] Hyper, Iron

[2] Servo

[3] Ripgrep

[4] Piston

Re:The Resurgence of C Programming by naasking on Wednesday December 28, 2016 @11:38AM (#13271633)
I suggest a thought experiment: take a few random projects you have or plan to work on, go to [1] and search for the kind of packages you need and see what's missing. It's getting better all the time, and you'll find most straightforward projects are totally doable in Rust.

[1] https://crates.io/

Re:The Resurgence of C Programming by rb808 on Tuesday December 27, 2016 @01:28PM (#13264927)
That does sound freaking awesome, I really will have to try it out.
Re:The Resurgence of C Programming by echelon on Tuesday December 27, 2016 @01:48PM (#13265102)
The borrow checker is hard to deal with at first, but after you power through the initial difficulty it becomes second nature. I rarely have to fight the compiler, and when I do it's because I'm trying to do something stupid.

In a way I'd liken learning Rust to learning Vim. There is an upfront cost, but the payoff is going to be huge.

Re:The Resurgence of C Programming by dwc on Tuesday December 27, 2016 @01:51PM (#13265131)
> So sometimes I wish I could go back to the old days but my nostalgia is probably rose tinted.

It seems like nostalgia is a big thing over the past few years. Old game emulators, people getting back into C64 or whatever. I guess it's fun for some people. I've considered playing with such stuff, but I know I'd miss some of the real advances we've made since then.

But my major projects at work are in C. My previous job was about 50% C, 50% scripting languages. For all C's deficiencies it's a known quantity and does its job well enough. And knowing C well is a rare enough skill to be valuable, apparently.

When I don't need C I'd much rather reach for something like ocaml/haskell, a lisp, erlang/elixir, or something. Basically I ignore all the "C replacement" languages because I can either use C or pick something way better.

Re:The Resurgence of C Programming by liuliu on Tuesday December 27, 2016 @01:33PM (#13264956)
The tools and stdlib improved ton too. I had address sanitizer and undefined sanitizer default on for a while and that helped a lot on memory issues. Things such as int32_t, intptr_t, ptrdiff_t made it is easier to be confident about your pointer math as well.
Re:The Resurgence of C Programming by CalChris on Tuesday December 27, 2016 @01:27PM (#13264917)
Well, C and C++ are very different languages. But going forward, this long time C programmer is writing in Rust unless required by exigencies beyond my control. A gun pointed at my head or writing an LLVM backend qualify. Not much else.
Re:The Resurgence of C Programming by gertef on Tuesday December 27, 2016 @01:45PM (#13265059)
The reality is that anything you do for the first time is fun, and then gets boring.