Are there any alternatives to C? [closed] - c

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
C++ is often touted as the evolution of C, which it is not. To draw an analogy for the kind of language I'm looking for:
Perl, Python, Ruby, Groovy
C++, D
Java, C#
C, Fortran, Modula-2?, Pascal?, Go?, Rust?
Do any proposed, or implemented languages fit in the same (enormous) niche as C, with the intention of being an alternative, while maintaining all the applicability to OS, high performance, embedded and other roles?

I think the problem with this question and subsequent discussion is that very rarely are languages intended to replace others. Sure, as you attempted to clarify and defend some of your groupings, they share similar feature sets or accomplish similar things, but ultimately, I don't think anybody is going to sit down and write a language that is designed to replace another. What is far more likely is that language designers want to accomplish a goal and will pick and choose aspects of certain languages that already do that. For instance, take a look at Go which is designed to up the ante a bit with regards to ultra-high performance systems programming which, arguably, competes with C a bit. However, if you look at the FAQ on the mission of the project, they aren't seeking to replace C, but simply augment it and address issues it faces (such as dependency management to name one) (so perhaps this is the answer you're looking for).
So really, whether something is an evolution of something else, depends entirely on the perspective from which you examine and evaluate the evolution. C++ can be considered an evolution of C because it introduced a new feature set (OO programming) that many consider a step forward in systems design while still retaining a similar syntax and compatibility with C code. However, it is not entirely an evolution because it is also missing some features that make C a language currently used today. No one language can do everything (except for maybe Lisp ;-) I kid, I kid) and never will. No one language is without tradeoffs. The abstractions that make web development easy are the same abstractions that make low-level systems development impossible (or prohibitively difficult). So I really think it's hard to say X is an evolution of Y. Rather, I would say "I want to do W and I know I can use language X but is there something that accomplishes my goals of A, B, and C better?" Unfortunately programming languages aren't black and white enough to make sweeping statements like that and like every decision you make in programming, it's about trade-offs.

The following picture will say more than I could write:

Maybe Google's Go language will be. At least, that's what I'd expect Google's Go team hopes it will become.

Pascal would be an equivalent, so would Modula-2.
Mozilla also has a new language called Rust, this is a really nice modern language that is targeted at the same kinds of applications as C/C++
https://www.rust-lang.org/

C has more than one niche, really. For low-level systems programming, C replaced platform-specific assembly languages, and nothing has really challenged C in that domain. C++ would be the only other possible candidate, there (BeOS, many device drivers, etc.).
C was/is also used a lot for high performance numerical code. In that domain, FORTRAN still has the edge, and there are many other challengers (C++, Matlab, Numpy, Fortress, Scala).
At some level, C is the lowest common denominator that has cross-platform portability.

Related

Why everything low-level is written in C? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Why everything low-level is written in C?
I mean kernel code, drivers, Run-time libraries, compilers, embedded systems s/w are mainly written in C/C++.
Why not use Fortran, COBOL, Pascal or even Java/C# or some other third-generation programming language that produces machine-independent code but also gives you the freedom to do low-level ,tweaks and optimizations.
My question is why developers and companies ended up using mostly C for these purposes.
Edit: Most of you here talk about performance. So, is the reason that there is no other general-purpose low-level language faster than C?
A few points:
Pascal is not low level language but there are kernels and even whole OS written in it.
You would not want to have a OS written in Java\C# because it will be darn slow.
C is probably not the best language. It has many cavities, and improvements like D or C++ have been tried. The only "problem" is inertia, C is still popular because C is the most widely used programming language (weather you like it or not). There is a plethora of kernels\OS\libraries\books\course with this language. It would take decades to replace it. And it seems that despite its cavities, there is very little will to completely replace it.
Java (and all JVM-based languages) and C#/F# run inside "virtual machines". That means the applications written in these languages cannot use hardware resourses directly, they are contained weithin a "sandbox". It helps portability ("runs everywhere where a VM is implemented") but can hurt performance (and does).
Some would say that the type of mind capable of writing low-level stuff can only be forged by years of damage caused by using C :-)
On a more serious note, the whole purpose of C was as a systems programming language and, as such, it mostly keeps out of your way. Other languages have different purposes: COBOL is really for transactional/business stuff, C# is for applications running under MS Windows, LISP is for people who have love counting parentheses, and so on. They can be used for other things but I wouldn't write an operating system in COBOL.
Or an accounting package in assembler.
Or anything in Pascal :-)
C allows you unfettered access to the lowest levels without having to concern yourself with things like garbage collection which may adversely affect your code in ways you can't foresee.
Because, comparatively, C and C++ are low level programming languages. Some people still write in Assembler. I hope no one still writes in machine code. Anyway,
Why not use Java, C#, COBOL, Pascal or some other third-generation programming language that produces machine-independent code but also gives you the freedom to do low-level tweaks and optimizations?
Those languages are classified as high level languages. They provide a level of machine abstraction that is beneficial for programming, but not useful for low level bare metal development. Also, relevant might be Why Pascal is Not My Favorite Programming Language by BWK.

Integrate C library with Java, Ruby, Node, Python, Go, .NET [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Status Quo
For a project of mine I need a client library that communicates with my API for every major programming platform. Currently I implemented just one (Java) and was thinking 'I don't want to do this 8 times (or hope someone else will)'.
The client is relatively small, but not trivial; does mostly JSON reading/writing and sending TCP/UDP data over SSL. Every call to the client is fire-and-forget, so it works completely asynchronously in its own thread.
Problem
I was asking myself if it made sense to write a single C library and integrate it with the other platforms.
I did a bit of research and it seems every platform deals with this differently (obviously) with varying necessary efforts. I also realised that I never saw something like it - for example database drivers always seem to be written from scratch rather than using a C library at the core. Is the overhead too big?
I also read about Thrift, Protocol Buffers etc. - but this seems to be aimed at network interoperability?
Question
So the final question is:
Is it feasible to use a single C library at the core of each platform's client? If yes: how should it be done?
Using a C library makes sense if you want to consolidate all implementations of the same functionality into one piece of code - it is probably the only language that can be universally used by higher level languages.
Your work would be significantly easier if you could automate the process to a degree. You might want to have a look at SWIG. It is a binding generator that allows C/C++ code to be used with a large number of other programming languages, including most, if not all, of the languages that you mentioned.
For my rather superficial experience with it, SWIG does a rather decent job, although the generated code does occasionally need some tweaking...

Game programming in C, where do I get started? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I started programming about 6 months back and have a decent knowledge in how to code in C. I have mainly used it to implement elementary algorithms or solve Project Euler questions (reached 50 now :) )
What I really want to learn since a long time is game programming. Ie make simple 2D games like snake, or pocket tanks. By simple, I no way mean the amount of work or effort it's going to take to make these games
I've tried searching the net but have had no luck with that. Could anyone point me in the right direction?
What exactly will I need to learn? Where do I start?
Game Programming requires a lot of Computer Science stuff on top of creativity. By Computer Science stuff I mean Algorithms, Data Structures, Computer Architecture, Computer Graphics, Operating System Internals, Artificial Intelligence & at least basic familiarity with Mathematics & Physics + experience on playing Games + Passion for Games. As you seem to be a good Algorithmic coder (Coding problems on Project Euler) so it should not be very difficult for you.
Now coming to your question one simple way to start is: Microsoft XNA (which lets you just go into game programming without having too much knowledge on above areas, ofcourse having it will be an advantage for you in longer run). Check it out: http://en.wikipedia.org/wiki/Microsoft_XNA
You can also check out this book: http://www.amazon.com/Beginning-Game-Programming-Michael-Morrison/dp/0672326590/ref=pd_sim_b_4
I have read the above (It's in C/C++/Win32) and it is really a good resource on implementing basic games which will give you a very good start to jump to XNA as a next step.
You could go with graphics.h. I am saying this because, when I were in your stage, I began with Worm and nibbles game, a very easy game, which can be constructed with drawPoly function. I used drawPoly as my implementation, but you could use you won.
In addition to that, graphics.h will provide many user-defined functions, to draw lines,rectangles,polygens. It also provide functions to color them in many different ways.
So, When you want to start gaming in C, I would suggest graphics.h as a good starting point.

What does good, modern c code look like? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I'm primarily a c#/.NET programmer, but the hobby project that I am about to take on will involve coding in c.
I know that there is a ton of c code out there, but its very hard to separate a well structured c project from a badly structured project if you did not "grow up" with the language. Can anyone point me toward a newer, non trivial (but not enormous) project that is considered a good example of how to structure c code?
Edit
If you cannot find a project, feel free to discuss in words how you think a c project should be structured.
Dave Hanson's C Interfaces and Implementations is a very well-crafted library of about 7000 lines of code. The book is great if you can afford it.
The implementation of the Lua programming language and libraries is about 17,000 lines of C code and is very well done but quite sophisticated in places—compilers and garbage collectors are not so easy to understand without background in those fields. But the code is beautifully engineered.
Git is over 125,000 lines of code. I can't recommend that anyone study it as an example of how to engineer C code. Just the design and public interfaces, let alone the implementations, are hard to understand—which is why there are so many git tutorials.
Check out git source code: http://github.com/git/git/tree/master
I consider Steve Dekorte's IO language implementation to be a good example for clean and pragmatic modern-day C.
This is completely anecdotal, but I've heard that the SQLite project is considered good code.
How about:
"The C Programming Language", 2nd edition, Kernighan and Ritchie
Answers to Exercises
http://users.powernet.co.uk/eton/kandr2/
The following book (with code examples) could ease your paradigm shift a bit:
Stephen Kochan
Programming in C, Third Edition
http://www.kochan-wood.com
The SVN project is written entirely in C and it is well maintained: consistently styled, good comments, low code smell. I recommend perusing it.
C: A Reference Manual contains a variety of example code usage, with implementations centric to Standard C; A definite document to look into, perhaps along with the C Std.

Great C tutorial? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I really want to learn C. What would be a good tutorial?
The C Programming Language (often referred to as "K & R") is almost universally considered to be the best resource for learning C.
While "The C Programming Language" is certainly a great book and a very good introduction to the C language, it has several drawbacks:
It is somewhat dated, the 2nd edition (the last one) covers only C89 which is now 20 years old. While C99 (the current Standard) isn't universally supported, there are a number of features from it that are supported by many implementations and exposure to them is useful.
It isn't comprehensive. It doesn't cover many of the standard library functions in any detail and certain intricacies are not explored in depth.
The text assumes you are already an experienced programmer and has a very terse style which doesn't work well for everyone.
If you are looking for a more beginner-friendly, comprehensive, or up-to-date book, I would strongly recommend C Programming: A Modern Approach, 2nd Ed. It covers every aspect of the language and the standard library in depth, including C99, and is extremely well-written. While the list price is rather high, it usually isn't difficult to find a copy for around $60 USD.
The Official GNOME Developer's Guide: http://oreilly.com/catalog/9781593270308/
Tutorials might be semi useful at first, but I always learned a language by actually developing useful code.
I'd recommend you check out some of the Gnome Love Projects.
They are generally smaller tasks for people who are interested in joining the gnome development community. They will help you get used to the dev environment, and submitting patches and the style & conventions they use. Most will teach you something you didn't know about C also.
The C book is a good and free ebook.
Here is one resource. http://www.physics.drexel.edu/courses/Comp_Phys/General/C_basics/
You may refer C Programming Notes meant to supplement K&R.
It's more a faq than a tutorial, but it is quite useful: C - faq.
Concerning Gnome programming: Gnome guidelines
And here are some tools every C programmer needs:
gcc
gdb - debugger
Valgrind
gprof - Profiler
Always avoid tutorials (written by kids, for kids)
Read KR
I would seriously advice you to check out Bruce Eckel's freely available "Thinking in C", which is a flash-based introduction to the C family of programming languages:
A Flash-based audio-visual seminar to introduce you to the fundamentals of the C language which will help you move on to C-based languages like C++, Java and C#.

Resources