ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've talked to people about this and most seem to point me to C++ as the language to learn and branch out from there. In your opinion what is the best language to build a solid foundation of the fundamentals of coding? As of now am more interested in security and non-gaming applications.
Without having much experience to back me up, I'd hafta say C in one of its forms, if you're looking to do Linux programming in the areas you mention..
My first language was BASIC, followed by assembly (both many years ago) and of late I got into PHP. I don't do much programming any more, not like I used to, but it's mainly BASH these days, since getting into Linux.
Well, you've opened the proverbial "can of worms."
For my , when I hired programmers, I always gave a big plus to anyone with solid assembly language experience.
But the programming world has changed a lot since I managed a programming group in the 1970's. Still, without assembly, you might have a hard time understanding how a high level language is converted to machine instructions, and why some construction that worked well on some piece of hardware might not work so well on another.
Since C can easily be converted to assembly code, it's a good second choice for a "first language." (The first C compilers were derived from the B compiler, and that "complier" was, I believe, just as set of assembly macros that directly expanded B statements to assembly code. I'm not sure about this, but I think that the A language was "assembly.")
Since C++ is, as it's name implies, an "increment" on C, learning C is implied by learning C++, and it used to be true that some schools make C a prerequisite for C++. (I don't know if that's still true.)
You should note that the Linux kernel is still written in C.
Thank you for the reply, am reading about assembly language and it's uses in making you better in HLL's with knowing what the complier is doing, although the article is 10 years old. Do you think assembly language would still be applicable in today's world in building a foundation of knowing what the computer is doing with that code and/or doing with anything for that matter? Oh and learning a language is just for fun.
The first C compilers were derived from the B compiler, and that "complier" was, I believe, just as set of assembly macros that directly expanded B statements to assembly code. I'm not sure about this, but I think that the A language was "assembly."
BCPL -> B -> C
The first was BCPL and not B. And even BCPL wasn't directly assembly 1:1 related. BCPL was a simplified version of CPL... which was designed with compilers and system programs in mind... so it was low level... but again, not directly related to assembly. There was no "A" language in the series.
C++, also, does not teach good C skills. A C programmer can move to C++ fairly easily (mainly because C code still compiles in C++) but the reverse isn't always true.
I think the first language to learn is the bash shell. It will familiarize you the unix philosophy and improve your productivity.
The C Language was written to compile Unix. So the language and its libraries are tightly coupled to the unix OS. For example, look how some files in /etc/ are the database files for standard C library functions:
hosts gethostbyname(3)
networks getnetbyname(3)
passwd getpwent(3)
shells getusershell(3)
nsswitch.conf nsdispatch(3)
Generally for programs that operate in the shell, use C. For programs that run in the desktop, the C++ language is best because the desktop frameworks are written in C++. It is still possible to use other languages using wrappers for these C++ libraries.
Thank you all for your comments and a little insight into other aspects of coding for i didn't even know about B. I've been learning bash just by using Linux which i try to do things in the shell instead of point and click. That point and click doesn't necessarily emerge into a deeper understanding of the computer. One may argue why do you need to know everything, surely you don't need to know what that register does or some other obscure thing, but i say why not. Although as of now am like the child asking what does the color blue taste like.
The historic languages like BCPL and B aren't really things you need to concern yourself with. But I felt compelled to correct the history a little there. The following language recommendations are roughly in order of how I would recommend learning them.
If you are going to do a lot of shell scripting, learn bash... but also know where it deviates from the original bourne shell. Many systems do not have bash installed and keeping scripts as compatible with the bourne shell (as possible) will make portability less of an issue. Shell scripting is an important step for really improving your productivity at the command line so I can't encourage learning it enough. What you learn in scripting will pay off in your daily use. Just keep in mind the portability issue.
I would recommend python as a good language as well as perl. Python because I happen to like it better, perl because it is pretty much the standard language for complex tools these days. It helps to understand and be able to read some of the code. Although, perl can be written so "well" that reading it becomes an absolute chore if it even remains possible.
I also recommend learning C and lisp (not as first languages though). They are both very important languages and will teach you a lot. C is very hard to keep secure if you don't know what you are doing, though. So it doesn't fit in well with your original criteria. These languages remain the two I am most likely to use when a task becomes more involved than a shell script.
Assembly... the second "language" I learned after BASIC. And it did provide me with a good understanding of how programs worked at the lower levels. It may be beneficial for you to learn (if you are planning on doing some systems programming). But it is very OS and hardware dependent. Even the manner that different versions of *nix use to make system calls changes at the assembly layer and any code which pretends to be portable will have to account for that. Interesting to learn... impractical for general use. Still, for very specific use and within strongly defined confines... a good thing to know.
Recap:
Shell scripting: /bin/sh & bash
Basic programming: python & perl
Other languages: C & lisp
Optional: assembly
If you are going to do a lot of shell scripting, learn bash... but also know where it deviates from the original bourne shell. Many systems do not have bash installed and keeping scripts as compatible with the bourne shell (as possible) will make portability less of an issue.
More importantly, learn the POSIX standard for shell scripting. Every system for at least the last 15 years has a POSIX shell. The POSIX shell offers important improvements over the Bourne shell, making it a much more efficient programming language. It is more of a guarantee of portability than even the Bourne shell, where there are incompatibilities between versions.
Whenever possible, use a Bourne-compatible syntax, but don't hesitate to use POSIX features where they make a difference to the script.
Learn also the extensions found in Bash (and Korn Shell 93), and use them when they improve the script, not just because you can use them.
Encapsulate the non-POSIX code in functions that can easily be replaced by POSIX (or even Bourne) code if it should become necessary.
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705
Rep:
Nobody should start learning with C. Start with BASIC or PYTHON (the BASIC of the new century) and when you get bored then move on to C, C++, etc.
Edit: Nobody should start learning with C or Perl unless you want them to never code again.
Getting started means needing to understand basic concepts. C and Perl are MUCH too terse and can do way too much without you understanding anything about them to be useful as teaching tools. Those languages are expert's tools to get a lot done with not much code and to be able to do sytems programming (in the case of c).
BASIC or PYTHON let you start gently with the idea of variables, control structures (different types of loops) flow-control (if this, do that) while at the same time being more READABLE. You have to start with the basics or you will get lost quickly and if it's not fun you won't learn and you won't continue.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.