C Programming: What's Next After Learning C?

  • Thread starter Drakkith
  • Start date
  • Featured
In summary: If you can't code in one language, though, you probably can't code in any.This is true, but I also think that you can still learn a lot of useful things even if you can't code in a particular language. For example, I think that I've learned a lot about programming by reading code and trying to understand how it works and how to make it do what I want.
  • #71
and what a universal C to frolic in...
 
  • Like
Likes Aufbauwerk 2045
Technology news on Phys.org
  • #72
jedishrfu said:
I've been looking at Elm and its promise of functional reactive programming and its possible successorship to Javascript. Elm actually compiles to Javascript. Note its time traveling debugger feature where you can replay your sequence of interactions while tweaking the code live. I also like the functional programming aspect of Elm as it makes code far easier to debug since you trace where data came from and where its going.

Julia is another interesting functional programming language with method overloading but without the OO aspect. Its a potential open source successor to matlab. The ijulia notebook is an interesting way to develop or teach coding. Its a webpage input editor and a program output display that's great for setting up a lesson and walking through various snippets running each as you go along.

I'm not totally comfortable calling Julia a functional language -- but I'm happy to see it mentioned in these forums. It is a very cool language that is immensely useful for technical computing. People need at least one other language under their belt first, in my opinion, as it is still an immature language and you'll have to figure some stuff out on your own. But again, its a very cool language.

I haven't used Elm, but a friend went to their hack night last week and spoke quite highly of it.
 
  • #73
I hope someone is not REALLY writing code this way. Making code unnecessarily complicated leads to system reliability problems. The concepts of abstraction is very powerful when one looks at a class as a specification or blueprint. Contractually abstract methods in a base class require the inheritor to implement those methods. Virtual methods require a default implementation in the base class in the event the inheritor does not implement those methods. Hence virtual methods are contractually optional in the derived class. If a virtual method is implemented it the derived class it becomes useful polymorphically in code.
 
  • #74
Here's a Reddit discussion on Julia and its functional programming features.

https://www.reddit.com/r/Julia/comments/5892nc/why_is_julia_called_a_functional_language/

Its not a pure functional programming language but you can do functional programming in it and here's a collection of methods to provide more support for lazy evaluation in Julia:

https://github.com/MikeInnes/Lazy.jl

It I guess it boils down to what your definition of functional programming is unless you prefer alternative facts.
 
Last edited:
  • #75
I don't know about being a functional language (since this depends on what you include in the definition and how strict you are) but Julia clearly draws a lot of inspiration from Lisp (up to and including a representation for code as trees of symbols and other objects, and Lisp-like macros).

One very functional-/Lisp-ish feature is that Julia doesn't seem to make much of a distinction between statements and expressions and some of the block/control-flow constructs can return useful values. So Julia will happily run code like
Code:
println(if i % 15 == 0
            "FizzBuzz"
        elseif i % 3 == 0
            "Fizz"
        elseif i % 5 == 0
            "Buzz"
        else
            i
        end)
and
Code:
# Compute and print 10th Fibonacci number
println(let
            a, b = 1, 0
 
            for n = 2:10
                a, b = a + b, a
            end

            a
        end)
(Though I don't know if you're likely to see much Julia code written like this in practice.)

Julia's version of object-oriented programming (basically structures/records and, separately, methods that you can specialise for different argument types) also looks a lot like a simplified version of CLOS.
 
Last edited:
  • #76
David Reeves said:
"If you think C++ is not overly complicated, just what is a protected abstract virtual base pure virtual
private destructor, and when was the last time you needed one?"

From van der Linden, Expert C Programming.

For those who have not read it, here is the famous anti-C++ rant by Linus Torvalds.

https://lwn.net/Articles/249460/

I would put it differently. C and assembly language is enough. Apply Occam's razor. The time I spent learning C++ and other languages could have been better spent developing tools in C. Now I'm a born-again C programmer and the universe is my oyster.

I won't disagree that C++ finally became an untamed beast but there is a multitude of factors that explain this, not the least of which are ever-increasing complexity, fierce competition and personal ambitions. In a non identical but very similar way, JavaScript was put on steroids and today you can't even think writing your own JS code for any serious sized site. Using a framework is the only way to go. Now, this is definitely not a good think regarding the freedom that have been stolen from the hands of web programmers. But on the other hand that is the course that any widely used programming language takes sooner or later.

Now, saying that C and assembly is enough, is somewhat general and exaggerated in my opinion. I am a also a big fan of C and yes I agree that writing tools in C is a very productively spent time. Assembly programming as far as I can tell - as I am not a system-level programmer, has few uses anymore. I mostly program in Java but I have done a fair amount of programming in C++ in my career and I don't think in any way that we can throw it to the garbage bin just because of its high complexity. There are methods, strategies and frameworks that can make your life a whole lot easier albeit with the price of heavy dependence on others code and constructs. But again, such things are intimately related with the evolution of software.
 
Last edited:
  • Like
Likes Aufbauwerk 2045
  • #77
The thing about programming languages though is that they often build on one another. Java is built on C and C is built on assembler and assembler on machine code at some point.

Its true that there are cross-compilers for various processor hardware but it still boils down to a dependency on assembler and ultimately machine code somewhere back in time.

We stand on the shoulders of giants...

"If I have seen further, it is by standing on the shoulders of giants."[2]

-- Sir Isaac Newton in a letter to Sir Robert Hooke

https://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants

and so it is with programming languages each learning from and depending on the ones of the past...
 
  • #78
I would add that for beginners, or even for people who have studied some C but don't understand how to write simple games and so on, BASIC is a good choice. FreeBasic is OK.

It's amazing what you can do with BASIC if you know enough about programming. For example, Black Annex is a game that got some attention because it was written in BASIC.

http://www.pcworld.com/article/2033318/black-annex-is-the-best-qbasic-game-youve-ever-seen.html

One issue that seems to worry people about C is pointers. They think they lead too easily to bugs, but wonder how to implement certain data structures without them. You don't always need C-style pointers. There's a good book called Visual Basic Algorithms by Stephens, that shows how to implement things like linked lists without C-style pointers. I think this may be useful instruction for the beginner.

Of course I'm not saying BASIC is the language of choice for commercial applications, but I think it still has value for learners.

 
Last edited by a moderator:
  • Like
Likes Borg and Drakkith
  • #80
jedishrfu said:
The thing about programming languages though is that they often build on one another. Java is built on C and C is built on assembler and assembler on machine code at some point.
From a historical perspective, the guys that developed the first version of C were aware of a language called B, a simplified version of BCPL, but it's not clear how much of C was based on B.

http://en.wikipedia.org/wiki/C_(programming_language)#History

High level programming languages like Fortran, Cobol, APL, predate C, and these languages don't have much of a tie to assembler, other than the initial version of a compiler is written using some existing language, which could include assembly.
 
  • #81
rcgldr said:
but it's not clear how much of C was based on B.

Well an early tutorial is available online: https://www.bell-labs.com/usr/dmr/www/btut.html. It contains what is apparently the original "hello, world" example:
Code:
main( ) {
 extrn a, b, c;
 putchar(a); putchar(b); putchar(c); putchar('!*n');
}

a 'hell';
b 'o, w';
c 'orld';
I think the reason for the way the characters are grouped together is that B had essentially only one datatype, which was a machine word on whatever architecture B was implemented on, which happened to be large enough to pack four characters into.

AFAIK the curly brackets {} also come from B.
 
  • #82
David Reeves said:
After several years of professional programming, I have finally settled on only two: C and assembly language.
Those are probably my favorites, as well. My background is pretty mixed, as I taught lots of math classes and lots of programming classes at a community college before switching careers and working as a programming writer at the large software firm in Redmond, WA. I've since retired, but have continued to teach programming classes at one community college (C) and will teach C++ at a different college next quarter. In the falll quarter I'm on the schedule to teach a class in MIPS assembly, something I'm really looking forward to. If someone is learning assembly for the first time, MIPS is a really good place to start.

David Reeves said:
The latter is of course only for special situations where it's truly needed. Although I must admit I will always admire the original Roller Coaster Tycoon, not only because it's an excellent game, but because it was written entirely in assembly.
My first computer was an Apple //e. A favorite game of mine was a pinball simulation called Night Mission, which I believe was written entirely in 6502 assembly. It was very responsive, not easy to do on an 8-bit processor. Back in about that same period, there was a very popular word process called WordStar, that was coded entirely in 8088 assembly.
 
  • Like
Likes Aufbauwerk 2045
  • #83
Mark44 said:
If someone is learning assembly for the first time, MIPS is a really good place to start.
Assuming it's not the version of MIPS with the delayed branch that executes one instruction after the branch before actually branching. I've seen this used on embedded processors like the MicroBlaze, but those aren't intended to teach assembly.
Mark44 said:
My first computer was an Apple //e. A favorite game of mine was a pinball simulation called Night Mission, which I believe was written entirely in 6502 assembly. It was very responsive, not easy to do on an 8-bit processor.
Almost all of the games in those days were written in assembly, with a few exceptions, such as a turn based artillery game that was written in Basic. Most games were only 8KB to 16KB (for the code or in some cases cartridge rom). The Atari 400 / 800 / 65XE / 130 XE were also 6502 based, but they ran at ~1.78MHZ (for NTSC or a bit less for PAL) instead of 1MHZ.

Mark44 said:
Back in about that same period, there was a very popular word process called WordStar, that was coded entirely in 8088 assembly.
Wordstar was originally coded in 8080 assembly for use on CP/M systems. It was ported to the PC with the help of an 8080 to 8088 assembly translator. As a bit of trivia, part of the reason for the 8088 / 8086 LAHF and SAHF instructions was to make translating 8080 assembly code to 8088 / 8086 code simpler (to handle push psw, pop psw, ... ).
 
Last edited:
  • #84
Mark44 said:
If someone is learning assembly for the first time, MIPS is a really good place to start.

rcgldr said:
Assuming it's not the version of MIPS with the delayed branch that executes one instruction after the branch before actually branching. I've seen this used on embedded processors like the MicroBlaze, but those aren't intended to teach assembly.
What I'm working with at the moment is QtSPIM. Apparently there's a switch in the GUI that you can set things like delayed branches, delayed loads, and a few other settings. There's another simulator, MARS. I don't have it, but am considering downloading it.
 
  • #85
jedishrfu said:
Here's a Reddit discussion on Julia and its functional programming features.

https://www.reddit.com/r/Julia/comments/5892nc/why_is_julia_called_a_functional_language/

Its not a pure functional programming language but you can do functional programming in it and here's a collection of methods to provide more support for lazy evaluation in Julia:

https://github.com/MikeInnes/Lazy.jl

It I guess it boils down to what your definition of functional programming is unless you prefer alternative facts.

I'm not totally convinced that every language needs to fit in one of 2 or 3 boxes like functional or object oriented -- though people seem to want to place things in said boxes. Some languages reek of functional, some less so. People tend to be a bit over the top about this kind of thing on the internet, but it's an interesting enough that I'll ask around at Juliacon this year.
 
  • #86
QuantumQuest said:
I won't disagree that C++ finally became an untamed beast but there is a multitude of factors that explain this, not the least of which are ever-increasing complexity, fierce competition and personal ambitions. In a non identical but very similar way, JavaScript was put on steroids and today you can't even think writing your own JS code for any serious sized site. Using a framework is the only way to go. Now, this is definitely not a good think regarding the freedom that have been stolen from the hands of web programmers. But on the other hand that is the course that any widely used programming language takes sooner or later.

Now, saying that C and assembly is enough, is somewhat general and exaggerated in my opinion. I am a also a big fan of C and yes I agree that writing tools in C is a very productively spent time. Assembly programming as far as I can tell - as I am not a system-level programmer, has few uses anymore. I mostly program in Java but I have done a fair amount of programming in C++ in my career and I don't think in any way that we can throw it to the garbage bin just because of its high complexity. There are methods, strategies and frameworks that can make your life a whole lot easier albeit with the price of heavy dependence on others code and constructs. But again, such things are intimately related with the evolution of software.

You make good points. In fact, I may need to do some more C++ programming myself. This is because I am working on a large simulation program, large in the sense that it has many types of entities, and is complicated, and I really think it makes sense to use C++ for this project. OOP was in fact developed for simulations. Those who are interested may enjoy reading about the history of Simula.

I used C++ when I was working on a game project with many kinds of actors, and it did fit very nicely into the OOP paradigm. But at the same time, I hate running into tasks that would be simple in C, but cause me to jump through hoops in C++. I suppose as you say there is a price to pay for the benefits of C++.

I think my main gripe against OOP in general is that I see so much OOP code where it is not necessary. What I do like about C++ is that you are not required to use OOP. I refuse to have anything to do with languages that force OOP on the programmer.
 
  • #87
I want to update my remarks about C++. I was enthusiastic about writing something in C++ again, but that lasted about five minutes. Then my natural skepticism activated, and I decided to see what's happening in the C++ world. Among other things, I looked for a well-known software application that uses C++. I wanted to see what issues came up. The inventor's website lists a number of impressive applications.

http://www.stroustrup.com/applications.html

For example, C++ is used in the F-35. This is very impressive. However, unfortunately the F-35 has been plagued by numerous software problems. I don't know how much of that software is in C++. I know that the DoD has used Ada in the past. I'm not sure why they are now using C++.

As usual, there are lots of posts on various websites by people who are just speculating about this topic. I read these speculations but I tend to regard them as useless. Probably those who know can't say. Meanwhile I am not blaming C++.

I did come across this C++ coding standard for the F-35 project. It seems rather complicated, at least to me.

http://www.stroustrup.com/JSF-AV-rules.pdf

In the old days, they had to use assembly language. Some would say it was primitive computing, but it did take us to the Moon. I saw a video recently by von Braun about the Apollo 11 Moon landing. After the landing party astronauts returned to the Command Module, one of them stated that it was easy. But if memory serves, there was a last minute glitch in the software that required Armstrong to do the landing manually.

https://qz.com/726338/the-code-that...-to-github-and-its-like-a-1960s-time-capsule/

I found these remarks about C++ in an interview with Niklaus Wirth. The interviewer asked him why no one has developed a safe version of C++.

"One may indeed wonder why nobody in the vast software industry has undertaken the task proposed by you: Defining a safe subset of C++. I can figure out two reasons: (1) The software world is eager for "more powerful" languages, but not for restrictive subsets. And (2), such attempts are doomed to fail just like attempts to strengthen the structure of a house built on sand. There are things that you simply cannot add as an afterthought."

http://www.eptacom.net/pubblicazioni/pub_eng/wirth.html
 
Last edited by a moderator:

Similar threads

  • Programming and Computer Science
Replies
8
Views
875
  • Programming and Computer Science
2
Replies
69
Views
4K
  • Programming and Computer Science
Replies
33
Views
2K
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
Replies
10
Views
2K
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
1
Views
726
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
2
Replies
58
Views
3K
  • Programming and Computer Science
Replies
9
Views
1K
Back
Top