(Learning) Programming / Coding

I wish to develop some programming ability, specifically to help improve FreeBSD (obviously in the long-term). How do you, accomplished programmers, recommend I go about achieving this goal? I am even willing to go back to university to obtain whichever degree would be most conducive to developing my programming abilities. Perhaps I may even change careers as a result.
 
I am considering this degree comprised of the following:

All of these units:
Internet Publishing
C/C++ for Scientists and Engineers
Systems Analysis and Design
GUI Programming and Interaction Design
Web and Internet Programming

Plus:
Algebra and Differential Calculus
&
Integral Calculus, Differential Equations and Introductory Statistics
or
Introductory Mathematical Methods in Science and Economics
&
Statistical Modelling for the Sciences I
(probably take option 1)

And only four of the following:
Introductory Information Technology
Computer Architecture and Assembler*
Internet Security*
Knowledge Management Systems
Decision Support Systems
Parallel and Distributed Computing
Data Mining
Programming Languages for Artificial Intelligence
Compiler Construction*
Computer Networks*
Graphics and Games
Special Topics in Computing 1
Advanced Web Technologies
Probability and Simulation
The Art of Good Thinking
Linear Algebra
Professional Skills Development
*likely choices


Alternatively,

All of these units:
Internet Publishing
Internet Security
Parallel and Distributed Computing
Web and Internet Programming
Computer Networks

Plus:
Algebra and Differential Calculus
&
Integral Calculus, Differential Equations and Introductory Statistics
or
Introductory Mathematical Methods in Science and Economics
&
Statistical Modelling for the Sciences I
(option 1, again)

And only four of the following:
Introductory Information Technology
Computer Architecture and Assembler*
C/C++ for Scientists and Engineers*
Systems Analysis and Design
GUI Programming and Interaction Design*
Knowledge Management Systems
Decision Support Systems
Data Mining
Programming Languages for Artificial Intelligence
Compiler Construction*
Graphics and Games
Special Topics in Computing 1
Probability and Simulation
The Art of Good Thinking
Linear Algebra
Professional Skills Development
*likely choices

Which units would you think more beneficial to develop a sound technical programming base? I also like the network/internet and security units too.
 
As far as university goes if you have the will, time and money it's worth it IMO.

If you want to learn to programme on your own (which is something you will have to do regardless of university) my suggestion is you learn C because you are interested in FreeBSD development which is a UNIX and well "UNIX is C" but also if you master C you won't have problems switching over to another programming language. In general once you learn one language or should I better say once you develop a "programmers way of thinking" it's just a matter of syntax to code something up in a another language.

Ok C is a procedural programming languages and Java for example is object orientated. But if you look at it historically it was C -> C++ -> Java. And IMO it's always better to start at the beginning and then work your way to the top (I'll skip assembler for now but, every one should know at least the basics of any assembler). Learn procedural and then learn object oriented!

Since you start from scratch I would suggest you go over this tutorial and after that that you tackle K&R

The reason why I suggest you go through the online tutorial by Carl first is because K&R can be a bit heavy for beginners.

After that you should be fairly familiar with C as a language and after that it depends on what you want to do. If you want to write device drivers you get something like FreeBSD device drivers. If you want to programme a simple client-server chat you read Beej's Guide to Network Programming etc. but basically there is a book/tutorial for just about anything.

Now, reading book's is great but with out programming and experimenting it's pointless and best way to learn programming is to give your self a simple project (like a client-server chat) and try to realize it. Ask questions on appropriate forums/mailing lists as you progress along and also look and learn from other's people source code.

Knowledge of algorithms, data structures and computer architecture (this is where assembler should kick in) are also a must.
 
@taz, thank you very much! Your post is very informative. I will follow these steps immediately. I have the time and resources to go back to school, so I think the abovementioned degree will be a good choice! Thanks, again.
 
Last edited by a moderator:
Another option is starting with a scripting language like Perl or Python. Write some sysadmin type utilities and you'll build up the core of file I/O, how variables work, how to use looping and condition statements, subroutines -- the basics of programming. Those will translate over to any compiled language. Scripting languages are more forgiving than C. Learn to read/write Bourne shell scripts (sh) and you can then read/write all of /etc/periodic/... and the various system scripts.

I agree with @taz that the only way to learn is by doing. Simple things you might want to do:
  • poll your DSL modem every minute to check the SNR
  • find the largest file in some directory (deal with subdirectories appropriately)
  • write your own version of lastlogin by reading /var/log/utx.lastlogin
Learning C is all fine and well, but it's a dated language written by a pair of greybeards back before they were grey (they always had beards). Some people will tell you that doing your own garbage collection will make you righteous and that strncpy is the sign of a morally-advanced mind. But that is nonsense. If you want to do FreeBSD work, alas you'll need to learn C. If you want to earn a living, you should learn Java.
 
Last edited by a moderator:
I strongly disagree.

Operating systems (as a whole), networking code, basically anything that fits into "high-performance" was, is, and will be written in C. Unless its programming model would substantially benefit from OOP. Then it's C++.

I won't even mention the difference between average salaries of senior Java and C programmers. Supply and demand. For every hundred experienced .NET/Java programmers you have 1 C. Saying senior because I'm not even sure that Junior C programmers jobs exist anymore in meaningful numbers.

Regardless of what IT hipsters told you, computers are still the same as they were 30 years ago. Digital and binary, with screens and keyboards. You can program a computer in a most efficient way if you're using its native language, not yours.

C is not a dated language, it's still the optimal choice for systems programming as it was 30 years ago.
 
Zare said:
Regardless of what IT hipsters told you, computers are still the same as they were 30 years ago. Digital and binary, with screens and keyboards. You can program a computer in a most efficient way if you're using it's native language, not yours.
Its language is binary, which can be mapped into the more human-readable assembly language. Writing computer software in assembly however is not efficient at all, as compilers for high level languages can track instruction scheduling specifics better than even the most proficient software engineers, and assembly also makes things unclear to human developers, resulting in side effects or bugs.

It's quite the opposite. The easier a language is to formulate a problem's solution in, the more efficient it's implementation will be. Developers should leave the optimization to the compiler and bother with the problem instead.

Operating systems (as in whole), networking code, basically anything that fits into "high-performance" was, is, and will be written in C. Unless it's programming model would substantially benefit from OOP. Then it's C++.
The performance of our network stack vs. most slower implementations originates from our's design to use character buffers. It's written in C because C offers straightforward memory access, which simplifies a character-buffer implementation considerably - i.e. C is used because it's easy to implement and maintain a performing solution in, not because it's "performant".

I won't even mention difference between average salaries of senior Java and C programmers. Supply and demand. For every hundred experienced .NET/Java programmers you have 1 C. Saying senior because I'm not even sure that Junior C programmers jobs exist anymore in meaningful numbers.
Most "senior" Java or dotnet developers don't really have the knowledge of general software design nor the experience that "senior" C developers have. Not to mention dotnet originated merely a decade ago. Plus a project and therefore it's developers are payed for well-servicing customer's demands and not for the language used.
 
markbsd said:
@taz, thank you very much! Your post is very informative. I will follow these steps immediately. I have the time and resources to go back to school, so I think the abovementioned degree will be a good choice! Thanks, again.

I don't know old are you but I admire your will. Programming can be "hard" or confusing for some people (and I'm not implying that this is your case, just to give you a heads up) but that is just because they are not used to a "programmers way of thinking". Every person can learn what another person knows, it's just a matter of time and persistence.

Important thing is not to skip stuff in your beginners journey. First learn basic programming idioms then algorithms and data structures (I suggest you use C for both) and in parallel learn about computer architecture (memory, storage, CPU architecture etc. how stuff works and how are they implemented at the lowest level). Once you are done with that you can branch to whatever field you are personally interested in. And that field will then dictate what new technologies you need to learn. So start at the beginning and work your way up, otherwise you will have holes in your knowledge and thees holes will bite you later on (just as they bit me because stupid people gave me stupid advice) I guarantee it.

K&R is an all time classic and you can't go wrong with it BUT prepare your self first by taking a "lighter" introduction to C like the one link I already provided (and I strongly suggest you use that link because I know what is written and taught in that tutorial). Otherwise it might backfire resulting in giving up. Also try to solve as much as possible exercises from the K&R (preferably all of them).

Do your self a favor and stay away from books that have titles "Learn C/C++/Java/whatever in 30 days". Programming is a skill that is developed over the years and yes it takes time to become a good programmer (I'm talking years). Do no strain your self to just one programming language, one framework, one library etc. A professional knows what is the right tool (which at the end a programming language is, just a tool) for the given task and experience is what will give you this confidence to choose right. But experience comes with time (again I'm talking years), so forget about becoming a programmer in 30 days.

I would also like to say bit more about collage. Odds are you won't learn much of real life stuff at collage BUT it should give you a god background from which you can then continue to upgrade your knowledge and skills. Also never forget to work/learn at home besides what they teach you at collage.

Another problem with "self teaching" is that it requires a lot of discipline. And collage can "force" you to stay in one mind set. Plus you will meet a lot of people that are into programming and this is a good think because you have to talk and share your ideas with others.

Scripting languages are more forgiving than C.

True, but it's a pit fall for beginners IMHO.

Learning C is all fine and well, but it's a dated language written by a pair of greybeards back before they were grey (they always had beards).

C is not dated and is still heavily used in the real world. Odds are you wont end up with a job that requires you to programme in kernel space but embedded domain uses C on a daily basis (and that won't change in the near future).

Not a prof but it counts: link

If you want to do FreeBSD work, alas you'll need to learn C. If you want to earn a living, you should learn Java.

It's more like you should learn tools, frameworks, libraries, protocols, enviroments, architectures and etc. JUST the programming language won't count for much. And btw. I use C almost every day and I get paid for it.
 
Last edited by a moderator:
In the gamedev world, Java is pretty much non-existant outside Android. Unfortunately, everyone who is too inexperienced to code in C++ is absolutely obsessed with C#. It doesn't help that Microsoft has invested many millions in advertising C# to young developers (with XNA etc...). Products like Unity3D also use C# (to keep developers locked into their engine).

This is changing though. Microsoft is getting over its distraction with .NET and is now pushing native C++ (albeit /cx) for its latest Metro lockdown platforms.
The Android NDK is as popular as ever and in gamedev, C and C++ are the only languages that run on all mobile operating systems. Obviously clang for iOS compiles C and C++.
Epic games are dropping their own scripting language to go with C++ in their free SDKs too.

In other words, keep with the following rule...
"C for systems development. C and C++ for applications development. Nothing else matters" ;)
 
What is the lure to Java? It's buggy, has security issues, and doesn't work as expected (i.e. platform differences). I manage a PBX that uses Java and I end up having to go to the console because it crashes after it's used for more than 5 minutes.
 
tzoi516 said:
What is the lure to Java? It's buggy, has security issues, and doesn't work as expected (i.e. platform differences). I manage a PBX that uses Java and I end up having to go to the console because it crashes after it's used for more than 5 minutes.

The lure is that is cuts development time. Something might take 1 day development in Java and a month in C (figuratively speaking).

P.S

Not defending Java or something like that, just saying how it is.
 
taz said:
Something might take 1 day development in Java and a month in C (figuratively speaking).

Hmm, really. Lets test it out.
Code:
// C
char* test = "Hello World";

// C++
std::string test = "Hello World";

// Java
String test = "Hello World";

That took about the same amount of time to write. How about...
Code:
// C
SocketWrapper* wrapper = SocketWrapper_Create("localhost");
SocketWrapper_Send(wrapper, "Hello World");
SocketWrapper_Destroy(wrapper);

// C++
SocketWrapper test("localhost");
test.send("Hello World");
// Socket is closed when it goes out of scope

// Java
SocketWrapper test = new SocketWrapper("localhost");
test.send("Hello World");
test.close();

Nope.. About the same there too. How about..

Code:
// C
FILE* f = fopen("somefile.txt", "w");
fprintf(f, "Hello World\n");
fclose(f);

// C++
std::ofstream file("somefile.txt");
file << "Hello World" << std::endl;
// File is closed when it goes out of scope

// Java
FileWriter fw = new FileWriter(new File("somefile.txt"));
BufferedWriter bw = new BufferedWriter(fw);
bw.write("Hello World");
bw.close();

They seem about equal to me. Though the deterministic (automatic) resource cleanup in C++ is pretty nice.

I honestly don't see how development takes longer in Java or C++ or even C when using libraries with a similar API. If by C you mean you feel you must use very low level and complex libraries, then just imagine how much easier it would be to use those libraries directly with C rather than attempting to wrap them up in a Java JNI binding layer before using them.
 
Code:
public class Parent() {

 ...

 private void Bla() {
 ...
 }
}

public class Child1 extends Parent {

 ...

 @Override
 private void Bla() {
 ...
 }
}


public class Child2 extends Parent {

 ...

 @Override
 private void Bla() {
 ...
 }
}

...


public void SomeRandomMethode(Parent parent) {
 
 ...

 if(parent instanceof Child1) {
 ...
 }
 
 if(parent instanceof Child2) {
 ...
 }
}

C implemementation of such abstraction?
 
I would generally use the following when dealing with OO C.

Code:
struct Parent
{
void (*blaFunc)(); // Function pointer to the bla function

};

struct Child1
{
struct Parent parent; // Node: Parent struct is in contiguous memory

};

struct Child2
{
struct Parent parent;

};

I can simply do (can be done in one statement but I have split it up for simplicity)...

Code:
Child1* test = Child1_Create();
Parent* test2 = (Parent*)test;
test2->blaFunc(); // Will call Child1's bla function

Note, the above is how Gtk+ does it. Since the function pointer is in the same place in the child struct, you can just cast it to the Parent type and call the function.

To be fair, in gamedev it isnt so common to use classic object orientation like this anyway. The latest trend is to use the component entity system which actually works much better because it is much less rigid and allows you to change the behaviour of objects much easier at runtime.

If you want something tricky, perhaps try to convert the following to Java (from C++) but not introduce a memory leak.

Code:
class Test
{
  Thread thread;

  Test()
  {
    thread.start(someFunction);
    // Emulate something going wrong
    throw std::exception();
  }
};

Depending on how the thread is wrapped, in C++, the thread will be joined / stopped as the exception propagates. How would you implement something that doesnt leak resources in Java without adding a lot more code and something like the C# IDisposable (anti)pattern?
Hint, you can't since the garbage collector will never clean up a unit of execution (a thread). C++ uses RAII which avoids this issue. So what is like ~5 lines in C++ is a whole lot more in languages like C# and Java. Vanilla C also gets round this issue by not having exceptions in the first place ;)
 
taz said:
I don't know old are you but I admire your will. Programming can be "hard" or confusing for some people (and I'm not implying that this is your case, just to give you a heads up) but that is just because they are not used to a "programmers way of thinking". Every person can learn what another person knows, it's just a matter of time and persistence.

Just cracked 30, but still feel like I'm 20! I'm finding it very confusing, but extremely interesting. I'm not entirely sure what sort of mindset is required for a programmer, but I look forward to developing it :)

Important thing is not to skip stuff in your beginners journey. First learn basic programming idioms then algorithms and data structures (I suggest you use C for both) and in parallel learn about computer architecture (memory, storage, CPU architecture etc. how stuff works and how are they implemented at the lowest level). Once you are done with that you can branch to whatever field you are personally interested in. And that field will then dictate what new technologies you need to learn. So start at the beginning and work your way up, otherwise you will have holes in your knowledge and thees holes will bite you later on (just as they bit me because stupid people gave me stupid advice) I guarantee it.

I'm enjoying the tutorials you provided. I won't be skipping anything, if I can help it, because I can see it will require a very solid foundation in the basics, and I find it all fascinating enough to not want to skip anything yet anyway.

K&R is an all time classic and you can't go wrong with it BUT prepare your self first by taking a "lighter" introduction to C like the one link I already provided (and I strongly suggest you use that link because I know what is written and taught in that tutorial). Otherwise it might backfire resulting in giving up. Also try to solve as much as possible exercises from the K&R (preferably all of them).

Thanks for the advice.

Do your self a favor and stay away from books that have titles "Learn C/C++/Java/whatever in 30 days". Programming is a skill that is developed over the years and yes it takes time to become a good programmer (I'm talking years). Do no strain your self to just one programming language, one framework, one library etc. A professional knows what is the right tool (which at the end a programming language is, just a tool) for the given task and experience is what will give you this confidence to choose right. But experience comes with time (again I'm talking years), so forget about becoming a programmer in 30 days.

I fully expect several years of focused training just to grasp a solid understanding of programming basics, let alone develop the skills of a journeyman.

I would also like to say bit more about collage. Odds are you won't learn much of real life stuff at collage BUT it should give you a god background from which you can then continue to upgrade your knowledge and skills. Also never forget to work/learn at home besides what they teach you at collage.

I think college will be good for the structured syllabus and, ultimately, for the qualification which will be required to obtain a decent paying job as a coder. However, I do expect that there is plenty more to learn, on my own time, with the help of the programming community outside of the formal learning institution.

Another problem with "self teaching" is that it requires a lot of discipline. And collage can "force" you to stay in one mind set. Plus you will meet a lot of people that are into programming and this is a good think because you have to talk and share your ideas with others.

True, the networking opportunities will be valuable.



True, but it's a pit fall for beginners IMHO.



C is not dated and is still heavily used in the real world. Odds are you wont end up with a job that requires you to programme in kernel space but embedded domain uses C on a daily basis (and that won't change in the near future).

Not a prof but it counts: link



It's more like you should learn tools, frameworks, libraries, protocols, enviroments, architectures and etc. JUST the programming language won't count for much. And btw. I use C almost every day and I get paid for it.


The ongoing discussion is a bit beyond me. From my very limited knowledge, I believe C will be a valuable language to be proficient in, and I would very much like to know it well.
 
Note, the above is how Gtk+ does it. Since the function pointer is in the same place in the child struct, you can just cast it to the Parent type and call the function.

Right so in order to get "OO" in C you need to learn gtk where Java can do it nativity.

In other words, keep with the following rule...
"C for systems development. C and C++ for applications development. Nothing else matters"

I could not agre more, and trust me I do not like Java, but the question was "What is the lure to Java" and form C stand point (not C++) you can implement higher abstraction with out having to learn a seperate library first.

Anyhow, our disscusion has nothing to do with markbsd question so let's agree to disagree.
 
taz said:
Right so in order to get "OO" in C you need to learn gtk where Java can do it nativity.

Java does not provide a native GUI library. I.e javax.swing cannot be found in Android's Dalvik VM, JavaME, JavaEE or gcj. It is not fully available when embedding a Java plugin into a webpage either.
You are likely going to have to use the platforms native GUI system or draw your own components in exactly the same way as C and C++ unless you are specifically targeting the desktop version of Oracle JavaSE runtime (open-sourced as OpenJDK).
Most platforms are written in C or C++ and so it is almost always easier to interface with their GUI library directly than through some poorly maintained Java binding.

Plus, javax.swing is pretty basic and primitive. Often Java developers use a 3rd party GUI library anyway (via a binding). Like Gtk, Qt etc... Or to give the application a native look and feel (i.e via Swt).

taz said:
I could not agre more, and trust me I do not like Java, but the question was "What is the lure to Java" and form C stand point (not C++) you can implement higher abstraction with out having to learn a seperate library first.
Learning a separate library or one bundled with the Java classpath makes no difference to me. Especially with package managers, it is trivial to install and get started with.
As far as users go, I am sure they would rather drag in one dependency specific to the application rather than the whole Java runtime, VM, classpath etc...

taz said:
Anyhow, our disscusion has nothing to do with markbsd question so let's agree to disagree.
Apologies, I guess I instantly go into "Defend uncool languages" mode without realizing. ;)
Other than scripting languages (Python, perl, etc...) I think developers should be forced by law to use C or C++. Where I work we spend far too long integrating (often rewriting) libraries originally written in novelty languages. Unfortunately when Java and C# finally die out, there will be the newest trendy hipster languages ready to take their place (or perhaps Microsoft will just start pushing VB6 again) :/.
 
xibo said:
Its language is binary, which can be mapped into the more human-readable assembly language. Writing computer software in assembly however is not efficient at all, as compilers for high level languages can track instruction scheduling specifics better than even the most proficient software engineers, and assembly also makes things unclear to human developers, resulting in side effects or bugs.

It's quite the opposite. The easier a language is to formulate a problem's solution in, the more efficient it's implementation will be. Developers should leave the optimization to the compiler and bother with the problem instead.

You are generalizing too much. Humans can still program computers better than computers.
It's just a matter of reaching the goal with your budget.

There are software projects where compiler choice and optimizations used have a lot of importance.
Assembly does not "make things unclear" to human developers, it rather makes the situation perfectly clear. You're filling registers, applying ALU operations and jumping through instructions. It's a perfect situation awareness for someone that knows the target architecture.


xibo said:
The performance of our network stack vs. most slower implementations originates from our's design to use character buffers. It's written in C because C offers straightforward memory access, which simplifies a character-buffer implementation considerably - i.e. C is used because it's easy to implement and maintain a performing solution in, not because it's "performant".

I have trouble understanding this.

C is "performant" for low level operations. That's why it doesn't force additional levels of abstraction atop of character buffers. There's no such thing as "string" as far as your computer is concerned. If you think that general abstractions slow down your code, you can resort to low levels of implementation.

xibo said:
Most "senior" Java or dotnet developers don't really have the knowledge of general software design nor the experience that "senior" C developers have. Not to mention dotnet originated merely a decade ago. Plus a project and therefore it's developers are payed for well-servicing customer's demands and not for the language used.

Of course, I'm talking about general statistics.
 
Back
Top