Hacker News new | ask | show | jobs
by pinealservo 4500 days ago
I have a hard time understanding the supposed elegance of C. I know it pretty well and use it all the time, but only because it's what the platform demands.

On the one hand, C has a tiny runtime that can be omitted or replaced. On the other, it doesn't have all sorts of things that would be helpful but not require runtime overhead.

My biggest complaint is lack of a module system. #include is a stupid ugly hack. Second would be the way it doesn't let you portably define and work with low-level data representations in a standard way. I don't count manual bit masking and shifting for this.

I would also really prefer a more advanced type system, including parametric polymorphism integrated with the module system, but not via templates.

1 comments

It sounds like you should take a look at go, if you haven't already :)

I'm not saying C is elegant. What I like about C, is that (in my *NIX/BSD world) it is THE language, that is always available and works the way I expect - even on old FreeBSD machine, that hasn't been touched for a decade.

It is also the language I can use for embedded computing.

In general: the more C and C++ code I have, the more systems I can create well-functioning, speedy programs for. I don't need to learn a new language's pitfalls, bugs, shortcomings, etc... I can just rely on my knowledge of C and get to know the platform I'm developing for.

That said - I recognise that some languages are more suitable for a given problem than others. I currently code a lot of Node.js (which I am starting to regret - I wish I'd chosen Go), but there is no doubt, I gain a lot in terms of not having to think about net layer (too much) and the community has made a wealth of modules of varied quality (myself included).

I think you could say, C is my favorite cordless drill! :) C is a tool that works very well for many cases - at least the once I come across. There is more specialized tools for many things, but I like simplicity.

Actually, I love C and think it is very elegant=P, especially when you read its source code. But my favorite languages are Common Lisp, Ruby and Haskell. Concerning C++, I have to agree with most part of what Steve Yegge said http://bit.ly/1dUsZsv, although I used it on a daily basis... The only reason I am doing it is because the legacy code of the system is written in C++.
I think it's very interesting to note, that there are two (or more) ways to look at languages, when talking about things like elegance.

You can look at it from the perspective of the language's source code, how it handles what is put into the compiler, how it "interprets" what we tell it to do, how it handles machine resources, locking, all of that.

But there is also the perspective of the "daily developer" - how easy is it to organize the code, so it doesn't become one big pile of unreadable code, that no one but the original developer can grasp. How easy or beautiful, if you will, can I express my thoughts AND get a good result?

I am really not one to critisize or have a strong opinion about how well languages work "underneath"... I have spend way to little time reading compilers' source code or developing my own.

What I feel, I can have strong opinions about though, is whether I can create software, that doesn't end up in a cluttered mess, which I can easily maintain, make fast/optimized, find and fix memory leaks in. And of course, there is this final extremely subjective thing: I need to enjoy programming every day and have a feeling, that I am using a tool that helps me, instead if it being a struggle.

With all that in mind, I think I can maintain my love for C++, because I don't use half of it ;) As I have already stated, I use C++ as a "version" of C, where I can let go of handling some of all the pointer stuff, manipulate strings in a way that works better in my brain and can organize my code better, due to classes, etc. I agree, that C++ is an extremely "large" language, but that is something that seems to help some developers.

I think it is good, that we have choices as developers. We can choose a language that matches our way of thinking. I believe we should be a little less religious about our choice of language(s) and realize that some creates their best programs with Go, while others would never succeed in creating a useful peace of software, were they forced to do it in Go.

We are all developers, but we do not all think alike. Why would there be 78.341 languages (<- I made that up ;), if we all thought alike? What we do share though, is a passion for making computers do as we command them to do.

Steve advocates the use of server-side Javascript (I just read that on WikiPedia ;), which is what I have been doing for a couple of years now. I could not disagree more... The more I use Node.js, the more I miss C++ or wish I'd chosen to try Go instead. I am REALLY not saying Node.js sucks or anything, I am just saying, the way scope and asynchronicity is handled, really doesn't fit my brain well.

It is manageable on the client, where you don't have to handle more than 1 session. You only have to think about events, callbacks, scope, etc. for 1 single person. Take that to the server and all hell breaks loose. You take what I have just mentioned, add thousands of connections and the fact that you do not get a fresh state (page refresh on the client), till you stop and start the Node.js server. In all of that, you have to be really careful about security and permissions. (For all fairness, I should mention we use websockets and build our site as a couple of single page apps.)

It is of course solveable. I personally think, we have found a nice way of never retrieving data from data sources without having valid credentials on the user requesting the data. But I have handled easier solutions than this.

Sorry... That became a rant! :)

I have to say I enjoy reading the things you wrote, and there are quite a few helpful suggestions. Thanks a lot(:
Thanks a lot! It means a lot to hear! I'm glad that at least some of made sense ;)