LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-05-2022, 02:59 PM   #1
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Rep: Reputation: 110Reputation: 110
A good C shell for learning C?


I thought that maybe I might perhaps possibly learn to learn C.

I had that same idea almost 20 years ago when I still used Windows 98, and I had a good shell that would run C lines/commands etc. I could also run little C programs in "script" mode, as an interpreter rather than a compiler. It was very convenient. Obviously, I can't remember its name.

There has to be something like that for Linux, right?

Let's see.

So I found SoftIntegration's Ch but it's not free and I am broke.

Picoc sounds interesting, but it's not available in the Debian repository and the source won't build on my machine.

Cint sounds interesting, but it's not available in the Debian repository and the source won't build on my machine.

Ups sounds interesting, but it's not available in the Debian repository and the source won't build on my machine.

I'm pretty sure there was another one that I can't remember and it seems I have deleted it, but anyway, it wouldn't build either.

Can you nice people perhaps recommend me something in that general direction?

TIA
 
Old 09-05-2022, 03:27 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by lucmove View Post
I thought that maybe I might perhaps possibly learn to learn C.

I had that same idea almost 20 years ago when I still used Windows 98, and I had a good shell that would run C lines/commands etc. I could also run little C programs in "script" mode, as an interpreter rather than a compiler. It was very convenient. Obviously, I can't remember its name.

There has to be something like that for Linux, right?

Let's see.

So I found SoftIntegration's Ch but it's not free and I am broke.

Picoc sounds interesting, but it's not available in the Debian repository and the source won't build on my machine.

Cint sounds interesting, but it's not available in the Debian repository and the source won't build on my machine.

Ups sounds interesting, but it's not available in the Debian repository and the source won't build on my machine.

I'm pretty sure there was another one that I can't remember and it seems I have deleted it, but anyway, it wouldn't build either.

Can you nice people perhaps recommend me something in that general direction?

TIA
C is a compiled language, end of story. It cannot be run in any interpreted or script form.

Why do you feel the type of shell matters?

Whichever shell you have should be fine. Ensure you have the build-essential package to be able to compile C code.

All that matters are the terminal properties of the console, and any helping paths to compile and debug tools

The shell is not as relevant as the C programs you write.

Last edited by rtmistler; 09-05-2022 at 03:49 PM.
 
1 members found this post helpful.
Old 09-05-2022, 03:33 PM   #3
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by rtmistler View Post
C is a compiled language, end of story.
Interpreters do exist so it's not end of story.
 
Old 09-05-2022, 03:34 PM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by lucmove View Post
Interpreters do exist so it's not end of story.
Apologies for my potential error, please enlighten me with a reference so I can learn more.

A little more constructive is an old blog I wrote about how to get started with C programming in Linux Linux Set-Up, Write, Compile, & Debug of C Programs for Beginners

Or there are plenty of references in sticky threads in this forum.

Last edited by rtmistler; 09-05-2022 at 03:53 PM.
 
1 members found this post helpful.
Old 09-05-2022, 03:55 PM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,219

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
You want a C REPL. Google for that.

I'd do it for you, but you can do it as well as I can.
 
1 members found this post helpful.
Old 09-05-2022, 04:29 PM   #6
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
I was surprised to see that there are quite a few "interpreters" for C.

My first thought was that they might implement/emulate some of the language and some of the standard library features, but that it would be very difficult to implement C as an interpreted language, at least in a useful way.

That seems to be the case because the few that I looked at just now (admittedly a quick glance) all began with a disclaimer of sorts, this from Picoc: "It's not intended to be a complete implementation of ISO C but it has all the essentials."

But I have to ask another question, not being argumentative, but seriously: Why not just learn C in its common form, as it exists on your Linux system? What advantage do you expect to get from an interpreted C? Consider also that perhaps it was the intepreter that actually kept you from learning C 20 years ago!

Whatever the case, best of luck with you learning experience!

Last edited by astrogeek; 09-05-2022 at 04:38 PM. Reason: expando-comments
 
1 members found this post helpful.
Old 09-05-2022, 04:37 PM   #7
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Understanding thar there's a term REPL was not in my experience.

A website or tool you can install which will allow you to run C code in the manner of a script is beneficial to learn and also helpful to use in interviews, where I have used online collaboration tools to evaluate candidates.

This seems to have been the OP's intended question, to find recommendations for something like a C REPL.

Unfortunately I have no specific recommendations if this is their need.
 
Old 09-05-2022, 04:49 PM   #8
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,136
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
My 2 cents. If you have a text editor, a terminal, and whatever development tools that your distro has The GNU Compiler Collection in, you have what you need to start learning C/C++.

https://en.cppreference.com/w/
https://cplusplus.com/reference/
https://developers.google.com/edu/c++/getting-started
https://code-reference.com/c

Start at the beginning. And build upon that.

Here are 2 examples to get you going.

test1.cpp
Code:
#include <iostream>

int main(int argc, char *argv[])
{
    std::cout << "Number of args: " << argc << std::endl;
    std::cout << "Args you entered: " << argv[1] << std::endl;
    return 0;
}

//g++ test1.cpp -o test1
test2.c
Code:
#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("%s%d\n", "Number of args: ", argc);
    printf("%s%s\n", "Args you entered: ", argv[1]);
    return 0;
}

//gcc test2.c -o test2c
As far as running C code in a shell with an interpreter, sounds like you want python.

Last edited by teckk; 09-05-2022 at 04:51 PM.
 
2 members found this post helpful.
Old 09-05-2022, 05:42 PM   #9
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 997

Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
OP - I suggest giving modern gcc and gdb a try.

gcc -Wall is very good at flagging potential problems. I can't think of anything that an interpreter can do that gdb can't. You may be surprised by how good these tools have become.
Ed
 
Old 09-05-2022, 05:45 PM   #10
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by dugan View Post
You want a C REPL. Google for that.
I'd do it for you, but you can do it as well as I can.
I had come across that term in my own research already, when I found out about those tools I mentioned that I could not build. Being aware of that term does not help much. I found something, but I am dissatisfied with what I found.

What someone here (obviously not you) could do for me is to point out some tool like the one I am looking for that was helpful to them in their own experience. Something along the lines of, "Hey, yeah, I needed that at some point of my life and tried this and that tool, and I thought that XC is better because YC is too ______ or not _____ enough, especially considering that ______ ______ ______." It doesn't seem to me that you have any such experience. Or maybe you do, but somehow you think it's more appropriate to tell me to go ask my annoying question elsewhere (more specifically, a website that obtains a huge portion of its answers from forums like this one which puts us in an opposite mirrors kind of recursive situation, but I digress). Hopefully, someone else will show up with the right kind of experience.

Quote:
Originally Posted by rtmistler View Post
A website or tool you can install which will allow you to run C code in the manner of a script is beneficial to learn and also helpful to use in interviews, where I have used online collaboration tools to evaluate candidates.
This seems to have been the OP's intended question, to find recommendations for something like a C REPL.
I don't know how the tool I am looking for would be useful in interviews, but "beneficial to learn," YES. That is absolutely it. You get it.
By the way...

Quote:
Originally Posted by astrogeek View Post
But I have to ask another question, not being argumentative, but seriously: Why not just learn C in its common form, as it exists on your Linux system? What advantage do you expect to get from an interpreted C? Consider also that perhaps it was the intepreter that actually kept you from learning C 20 years ago!
That is in fact a very good question.

I've been self taught on many occasions, many situations, and I know I am a very good learner. For example, I taught myself English for the most part, in a time when there was no Internet as we know it. I can get across well, don't you think? But I have my own way of learning. Two things I really like: lots of involvement and visual input. And no hurry. That's how I learn best. So I want to be able to test and try a lot of small things and see what happens until those mechanisms become very predictable, like some kind of second nature. It's also good and necessary to do that in very quick and brief sessions. I will not put up with the concept of reading a lot of information at once and writing up long programs and compiling, and reading the error output, and rewriting, and recompiling, and reading the error output, and rewriting, and recompiling, and reading the error output, and rewriting, and recompiling, and again and again and again... Quick and casual shots of coding and watching the result will whet my appetite to learn more - no hurry. I will eventually embrace more traditional approaches when I feel that I am ready for them. Not before. Before wouldn't work. That would make me lose my patience and quit. Maybe it works for you and a lot of people, but I am neither you nor a lot of people. I've taught myself many times before and I know how my brain works. I will work in harmony with it, not in conflict. I will not "tough it up" or subject myself to silly notions of "tough love." That wasn't always such a bad idea when I was young, but now I am a lot older, more tired and with a lot less time, including brain CPU time. I will do the smart thing and learn it the way it works for me.

Quote:
Originally Posted by astrogeek View Post
Consider also that perhaps it was the intepreter that actually kept you from learning C 20 years ago!
It was definitely not. In fact, the interpreter is the sweetest memory I have of that very short lived personal project. I can't remember for sure, but I believe I probably just decided to go with scripting because it was easier, more convenient, more practical.

Quote:
Originally Posted by teckk View Post
As far as running C code in a shell with an interpreter, sounds like you want python.
I loathe Python. Always have. I would gladly push a button and make Python disappear from the face of the Earth right now if I had the chance, without a hair of care about all the crying and grinding of teeth it would cause. But thank you for the links. I will certainly read them and see what I can learn from them. I am hunching over this right now:

https://www.w3schools.com/c/c_getstarted.php

Quote:
Originally Posted by rtmistler View Post
A little more constructive is an old blog I wrote about how to get started with C programming in Linux Linux Set-Up, Write, Compile, & Debug of C Programs for Beginners
Thanks. I will read that too. It's not what I asked, it's just more documentation and there is plenty of that on the internets already, I want an interactive tool that will make learning more digestible to me, but yes, I will read it.
 
Old 09-05-2022, 05:56 PM   #11
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
https://replit.com/languages/c

First search result. Enjoy your exploration. And I personally find that one to be fine, it works.

No one's intentionally trying to be rude, there are many results when you search for "c repl" and people figure you would prefer to select from a possible variety of options.

Last edited by rtmistler; 09-05-2022 at 05:59 PM.
 
Old 09-05-2022, 06:53 PM   #12
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by rtmistler View Post
https://replit.com/languages/c
First search result.
Yes, I saw that one in my search. It's online. I prefer to have a tool installed on my own computer.
 
Old 09-05-2022, 09:29 PM   #13
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

you could try cling, or the older cint. See for example https://root.cern/cling/

Evo2.
 
Old 09-06-2022, 12:41 AM   #14
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Is there any error message when some software "won't compile"?
Edit: I've found an old source for cint (http://www.hanno.jp/gotom/cint.tar.gz), but it is in C++, so it won't compile, indeed.

Last edited by NevemTeve; 09-06-2022 at 04:05 AM.
 
Old 09-06-2022, 08:43 AM   #15
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 997

Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
I think the OP's problem may be that setting up a developer environment on Debian is non-trivial, especially for building programs not in the repository. He would have an easier time on a distro that is a developer environment by default (i.e. Slackware).
Ed
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
learning the shell and shell scripting jazzo Linux - Newbie 10 10-05-2014 08:09 AM
[SOLVED] RHCSA learning... RHEL6 or CENT OS for learning shejin983 Linux - Server 4 10-27-2012 09:16 AM
E-learning learning, VLS want to help other learn? scheidel21 General 0 04-06-2010 11:19 AM
What are some good books for learning shell programming? hexstar Linux - General 10 05-09-2007 07:57 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration