Hacker News new | ask | show | jobs
by rehack 4518 days ago
>7. There is no convenient string type

This the reason, which stops me from going back to C. After coding in Java (mostly) for past 10 years. I wanted to switch back to C or C++. Mainly to save on ton of memory being used which I think is unwarranted.

So I experimented with a new service, and coded it in all three C, C++ and Java. When I did this I had not coded in C++ for 10 years, but it did not hurt at all. I could switch back easily with almost no great difficulty. There were some minor inconveniences of foregoing the Eclipse editor. I think, I might have missed Autocomplete the most.

But within hours after I started, I was getting my previous feeling of the Vi(m) editor coding of C++ back. And with the benefit of having STL (vectors, strings, etc.) I did not feel much discomfort.

But coding the same service in C was painful. And it was mainly because of not being able to basic things on strings easily like copy and concatenate.

But thankfully I still managed to do it. And on comparing the three services for latencies and memory usage, I found little difference between C and C++.

So eventually that service was deployed in C++ and still runs the same way.

This above episode happened about an year back, and recently I am using Go to do a lot of services (new as well as moving some old). Mainly I have been motivated by the promise of an easier C, which it seems to offer.

Some services, coded in Go, I have deployed and are already running very well. But even now, I need some more experience on the results side, to have a definitive opinion on whether Go is indeed C with strings lib (and other niceties) for me.

Edit: rephrase for clarity

2 comments

Most languages get string processing (and its closely related cousin, localization) wrong, even the ones with string classes, so I don't really get my jimmies rustled on C's anemic native string support.

http://www.joelonsoftware.com/articles/Unicode.html

On large enough projects, you end up with all kinds of custom logic around user-entered and user-facing strings, so the lack of native string processing is really only a drawback for tiny and proof-of-concept projects, which aren't really what you use C for anyway.

That being said, the right way to do string processing usually ends up looking a lot uglier than the way we are used to.

Did you use a string library when working in C? C's deficiencies when it comes to string handling are well-known.
Sorry for the delay in replying. No I did not, actually. See I was coming back after a while, I had quickly shifted to C++ (after coding briefly in C) in my career, so did not remember using any libraries.

I am sure, my task would have been easier if I had used some lib. But my main concern (and goal) was performance and memory usage comparison.