Trying to decide which programming language I want to learn

In summary: C++ is considered a lower-level language, meaning that it is closer to the hardware and gives you more control over how your program runs. However, C# is a high-level language, which means it is easier to learn and use and has a lot of built-in libraries that make coding faster and more efficient. Both languages have their advantages and disadvantages, and it ultimately depends on what type of project you are working on. For gaming, C++ is often preferred because of its speed and control, but C# has become increasingly popular in game development as well. It's worth trying both and seeing which one you prefer working with.
  • #36
I can see there is a big learning curve already, I have no idea what are QT, glwf , SDL, Unreal engine etal.! I just google these terms, they are about open platform and cross-platform software. What is this? Is it like someone write a big library of subroutine to do things that you can use? For example, someone wrote a subroutine to read from keyboard and another routine to display on the screen. So you just call the subroutine to read keyboard, then do something, and call the subroutine to display on the screen?

I am still trying to learn a little bit more what is Visual Studio. I am an analog, RF and hardware guy. I can only think as far as designing micro controller pcb and program some simple stuff at this point. For this, I don't think I have to call a lot of subroutine from those cross platform stuffs.

Tell me am I right, I am trying to learn the new lingo!
 
Technology news on Phys.org
  • #37
yungman said:
I am still trying to learn a little bit more what is Visual Studio. I am an analog, RF and hardware guy.
Visual Studio is, IMO, pretty straightforward. Basically it is a development environment with an editor, debugger, and some other tools all combined. With it, you can write code in C, C++, C#, x86 assembly, as well as some other languages.

With your background experience in assembly and Fortran and Pascal, it shouldn't be too hard for you to get started with C++ or C# or C. You might do a web search for tutorials in whichever language you decide to use. Or you mentioned a book you have -- that's a good place to start as well.
yungman said:
I am an analog, RF and hardware guy. I can only think as far as designing micro controller pcb and program some simple stuff at this point. For this, I don't think I have to call a lot of subroutine from those cross platform stuffs.
Cross-platform programming is where you write code in a particular environment that is intended to run on a different architecture and/or operating system. If you're just starting out, I wouldn't advise trying to do anything like that.

I would advise learning about writing functions, though, as monolithic programs are a lot harder to debug. Both C++ and C# extend the C struct concept (called a record in Pascal) to the class concept, a data structure that can contain data members (properties) and function members (methods).
 
  • #38
I am surprised nobody has mentioned it, but Cython seems well suited to what you want. You can even write straight C in Cython if you want. As an old time programmer whose first languages learned were Fortran and Pascal, but spending 20 years of my programming life writing in a language called Natural, when going back to do a bit of programming Python was a breeze. Cython converts your Python to C, which is why you can write your Cython code as C code if you want, but except for speed in critical parts why bother. Personally I do not do that, I use NUKITA (another Python to C compiler, but does not allow inline C) and Luajit - but it's not as compatible with C (it requires the Luajit interpreter) - although interestingly is nearly as fast as C thanks to the highly optimised just in time compiler built into the Luajit interpreter.

See:
https://honnibal.wordpress.com/2014/10/21/writing-c-in-cython/

Thanks
Bill
 
  • #39
yungman said:
I can see there is a big learning curve already, I have no idea what are QT, glwf , SDL, Unreal engine etal.! I just google these terms, they are about open platform and cross-platform software. What is this? Is it like someone write a big library of subroutine to do things that you can use? For example, someone wrote a subroutine to read from keyboard and another routine to display on the screen. So you just call the subroutine to read keyboard, then do something, and call the subroutine to display on the screen?

I am still trying to learn a little bit more what is Visual Studio. I am an analog, RF and hardware guy. I can only think as far as designing micro controller pcb and program some simple stuff at this point. For this, I don't think I have to call a lot of subroutine from those cross platform stuffs.

Tell me am I right, I am trying to learn the new lingo!

You're right.

Code that depends on the operating system tend to be a pain, and need to be maintained to keep working with new OS versions. Regular C++ code is cross platform (meaning it will compile and work on a mac, or windows, or linux, or whatever) but GUI stuff (graphical windows, mouse input etc.) requires low level system dependent stuff. To make your life easier, you can just use a library (just some code developed by others and packaged to be reused), that does that complex and tedious stuff and automatically does it correctly for whatever system you're on.

QT, glfw, SDL, etc. are just examples of some code that some companies or people have written to do some of those types of things. You don't need to know those things unless you want to use them and there are a bunch of choices. So I would just forget about it for now. If you decide one day you want to make a video game with graphics, just start googling to see what is available to make your life easier, or ask for advice on a forum.

To start with, you'll probably just be making console programs and won't require anything extra.

Hallo
I am really having a hard time navigate the Visual Studio. I have been going through the example of "Hallow World" and run Ctrl F5 to look at in command mode and all. I even copy the syntax and all another line "How are you" and display in the command mode. I saved in the desktop folder. I closed the program, I tried to open it and I can't even open it back. I went through the help tab, it is absolutely of no help.

I went on Youtube, there is only one or two on C++ for Visual Studio 2019. They have for older version, but it's not the same. I am going around and around.

All I need is to have explanation how to open an existing file and edit and save and I can't even do that so far.

Any book or site you can suggest? There is only two books for 2019 I can find on Amazon, both are rated very low, I don't want to waste money buying them.

Please Help.

Thanks

I feel for you. I started with Visual Studio as well and hated it. It's like having a control room to run a city when you just want to turn the lights off and on in your house.

Maybe you could just try the command line. Get some text editor like sublime text or notepad++. Then just compile your file directly. Once you want to do a large project, or use a debugger, or profiler, then consider using an IDE?

https://www.sublimetext.com/
https://notepad-plus-plus.org/

You can try from the command line.
$ cl /EHsc yourfile.cpp

Or follow these instructions.
https://docs.microsoft.com/en-us/cp...-cpp-program-on-the-command-line?view=vs-2019

You can also use an online tool just to try running a simple program https://ideone.com/ (you can select from a bunch of languages here as well).

Otherwise, if you want to use Visual Studio as an IDE, have you tried creating a new project? I think it will create a directory for you somewhere and manage all your files for you and everything. I haven't used it in years, so I can't give specific advice.
 
Last edited:
  • Like
Likes yungman
  • #40
Jarvis323 said:
You're right.

Code that depends on the operating system tend to be a pain, and need to be maintained to keep working with new OS versions. Regular C++ code is cross platform (meaning it will compile and work on a mac, or windows, or linux, or whatever) but GUI stuff (graphical windows, mouse input etc.) requires low level system dependent stuff. To make your life easier, you can just use a library (just some code developed by others and packaged to be reused), that does that complex and tedious stuff and automatically does it correctly for whatever system you're on.

QT, glfw, SDL, etc. are just examples of some code that some companies or people have written to do some of those types of things. You don't need to know those things unless you want to use them and there are a bunch of choices. So I would just forget about it for now. If you decide one day you want to make a video game with graphics, just start googling to see what is available to make your life easier, or ask for advice on a forum.

To start with, you'll probably just be making console programs and won't require anything extra.
I feel for you. I started with Visual Studio as well and hated it. It's like having a control room to run a city when you just want to turn the lights off and on in your house.

Maybe you could just try the command line. Get some text editor like sublime text or notepad++. Then just compile your file directly. Once you want to do a large project, or use a debugger, or profiler, then consider using an IDE?

https://www.sublimetext.com/
https://notepad-plus-plus.org/

You can try from the command line.
$ cl /EHsc yourfile.cpp

Or follow these instructions.
https://docs.microsoft.com/en-us/cp...-cpp-program-on-the-command-line?view=vs-2019

You can also use an online tool just to try running a simple program https://ideone.com/ (you can select from a bunch of languages here as well).

Otherwise, if you want to use Visual Studio as an IDE, have you tried creating a new project? I think it will create a directory for you somewhere and manage all your files for you and everything. I haven't used it in years, so I can't give specific advice.
Thanks for clarifying this.

About Visual Studio, it's not about taking time to learn a lot of things, it's their documentation is not right. I read their "Hallo World", it is all over the place. I even type in exactly the added line according to the picture showed and did Ctrl F5. It said 3 errors. I check and I check, I typed it in correctly. There is no explanation on anything, and when the example is totally wrong, it make it very hard to learn.

I decided to go with Visual Studio because it also support C# and Python and other languages. This means even if it is painful to learn, I don't have to learn the second time when I learn another language ( If I want to learn another language!).

Any suggestion on links or books that explain Visual Studio 2019? Seems like it's so new that not many people publish stuffs. I saw a pretty good youtube on 2015, but the it is quite different and I stop watching after about 15 minutes as I cannot follow what he was doing in 2019. The two youtube on 2019 was not good, not only the content are no good, it really doesn't help if both people are foreigners with heavy accent. I am a foreigner, last thing I need is to try to understand someone speaking with heavy accent! No offense!

Thanks
 
  • #41
Books are not very popular in the context of programming, anymore. I think for Visual Studio you can just Google for particular questions. For example, your 3 errors with no explanation sounds like you are looking at the last line of the build report. Visual Studio has an explicit error tab where you get a list of all errors and warnings and can also click on them to jump to the offending code location. Trying to find a picture of it for you I googled "visual studio errors" and quickly came here: https://docs.microsoft.com/en-us/visualstudio/ide/find-and-fix-code-errors?view=vs-2019 .
 
  • #42
yungman said:
I am really having a hard time navigate the Visual Studio. I have been going through the example of "Hallow World" and run Ctrl F5 to look at in command mode and all. I even copy the syntax and all another line "How are you" and display in the command mode. I saved in the desktop folder. I closed the program, I tried to open it and I can't even open it back. I went through the help tab, it is absolutely of no help.
The Help link is very useful, but you have to know what to look for.
CTRL F5 opens a command prompt window and starts the program.
You can't type your program into the command prompt window -- that's just where the output from your program goes.
When you open Visual Studio, your first step is to create a new project. I usually create either a Console App or an Empty Project. There's a default name (Project1 for the first one you create), but I prefer to enter a more explanatory name. After you click OK, the top line in theSolution Explorer pane will have "Solution 'Project1'" or whatever name you've chosen for your project. Immediately below it will show the name of your project in bold. Under that there are several folder icons, among which are Header Files and Source Files. The only one that you need to use at your stage is Source Files.
Right-click the Source Files icon, and Add a New Item. This is where you create your C++ (or C) source file. The default name is Source.cpp, but you should give it a more descriptive name.
After you do this, type in or copy-paste in the source code for your program. Once you've done that, select Build from the menu, and click Build Solution. If your program builds (compiles and links) with no errors, you can then run it by pressing F5 (run in debugger) of CTRL F5 (run in command prompt window).
yungman said:
I went on Youtube, there is only one or two on C++ for Visual Studio 2019. They have for older version, but it's not the same. I am going around and around.
Don't search for examples in Visual Studio 2019. Just search for more general C++ tutorials. For what you're doing, I doubt that there's all that much difference between examples in VS 2019 or those in older versions.
yungman said:
All I need is to have explanation how to open an existing file and edit and save and I can't even do that so far.
After you have created your project and the source code file, look in the Solution Explorer pane, and select the top item there. In the properties for the solution, it will show the directory path where everything is saved. Inside that directory, there's a file named <project name>.sln. If you double-click that file, it will open Visual Studio, showing the file that you typed in.
 
  • Like
Likes yungman
  • #43
Thanks for the new information.

I have been playing around and I am going somewhere ( a little bit). This is like chicken and egg, if I spend time reading the C++ book without actually typing into VS, it's hard to sink in. But if I play with VS to get a feel of the program and how to edit it, then I don't know what the hell am I typing!

I just follow "Halloworld!" and experiment with some of the information here. I found a few interesting things I don't quite understand. This is the program I modified ( just by copying the line by guessing)

#include <iostream>

int main()
{
std::cout << "Hello World!";
std::cout <<" How are you!" << std::endl;
return 0;
}


I managed to run and display "Hallo World! How are you!" and in cmd mode ask me to press any key to go back. My error last night was "endl" I typed end1 as the picture from the VS help file is end1. I read it, even with magnifying glasses!

My question is

1) There is a #include <iostream>. This is obviously a group of subroutine to perform the display. My program is NOT stored in repos, I saved in my own folder on the desktop. How can VS know where to get the <iostream>?

2) Is VS a compiler or interpreter(like Basic)?

3) I made sure the repos folder is empty. Then I create a new file in "Console App" in C++. I put the project name "Holloworld" in repos, then I UNCHECKED "place solution and project in the same directory.", The whole Halloworld.cpp displayed without me typing anything. I did say creating new file, why the whole .cpp comes out as if it is already written?

4) Why is it if I CHECK "place solution and project in the same directory.", nothing comes out?

Sorry to ask stupid question like these, as I said, it's chicken and egg, I guess I choose eggs, blind playing with the VS to get a feel how to input .cpp, create .cpp and all first before reading the C++ book to learn the command. I don't think I can learn if I read the book without actually typing it in and try.

thanks
 
  • #44
It seems that you are making some progress.
yungman said:
1) There is a #include <iostream>. This is obviously a group of subroutine to perform the display. My program is NOT stored in repos, I saved in my own folder on the desktop. How can VS know where to get the <iostream>?
When you installed Visual Studio, it "knows" where the header files are. The usual place is in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include. Your installation might have Microsoft Visual Studio 15.0. I'm running VS 2017, which is one version older.

The header files don't contain the subroutines for the most part -- just the declarations or prototypes for the functions and types that you use. When you build a program, the linker adds in the code for whatever functions you're using.
yungman said:
2) Is VS a compiler or interpreter(like Basic)?
VS is an integrated development environment (IDE). It contains a compiler (called VC) and a linker and some other tools.
yungman said:
3) I made sure the repos folder is empty. Then I create a new file in "Console App" in C++. I put the project name "Holloworld" in repos, then I UNCHECKED "place solution and project in the same directory.", The whole Halloworld.cpp displayed without me typing anything. I did say creating new file, why the whole .cpp comes out as if it is already written?
It depends on what sort of application you have chosen. I usually select Empty Project, so it doesn't create a source file for me. If you choose Console Application, VS will prepopulate a source code file for you to help you get started.
Here's what I get:
C:
// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
int main()
{
    std::cout << "Hello World!\n";
}
I didn't copy the whole thing -- there is a block of comments with tips on getting started. VS 2019 might be slightly different.
yungman said:
4) Why is it if I CHECK "place solution and project in the same directory.", nothing comes out?
I don't know what you mean "nothing comes out."
When I created the application I showed above, VS created a direction in my repos folder. Here's the file hierarchy.
Code:
repos
...ConsoleApplication1
...ConsoleApplication1.cpp  <--- this is your source code file
... plus 3 other files that VS uses
...ConsoleApplication1.sln
When you build your program, VS will create a bunch of other files.
 
  • Like
Likes yungman
  • #45
Thanks Mark44
I just want to acknowledge you first. It will take me some time to digest these.
 
  • #46
I have been looking for the location of the subroutines. I found it. It's different from yours. I think it's because mine is 2019. That's the reason there is a good youtube on VS2017, but I couldn't follow as it looked very different.
Include file for VS.jpg


Now I know I can click the "External dependency" to view what subroutine it has and can click each to see the code inside to understand more ( not that I understand any line at this point, but it's a start).

My question is whether I can redirect the program to look for subroutine somewhere else where I can write my own subroutines? Or do I have to add my subroutines into the location where VS store the rest of the files? That won't be very convenient.

I still have to try create and dummy .cpp file using Empty Project command so I know how to start my own .cpp. I think I am going somewhere, I am stoked.

I decided to go with VS even though it's hard to learn, but it support C#, Python etc. I hope if I ever learn another program, this extra effort learning how to navigate VS will pay off.

Thanks
 
  • #47
yungman said:
My question is whether I can redirect the program to look for subroutine somewhere else where I can write my own subroutines? Or do I have to add my subroutines into the location where VS store the rest of the files? That won't be very convenient.
Actually, the header files don't contain the subroutines (which BTW isn't terminology that is used in C, C++, C#, etc.). Most of what's in the header files, such as iostream, are the declarations or prototypes of the functions that you use. These declarations provide information about a function: how many parameters, the parameter types, and the return type. The actual code is in the lib directory -- the linker inserts the code for the functions you use.

And yes, you can write your own header files. I was working today on a program I wrote about a year ago, adding more functionality to it. The application consists of two projects -- one written in C++ and the other in C#. There is also a header file. The entry point (a Main function) is in the C# file. The C++ portion gets compiled to a DLL (dynamic link library). The C# code uses (calls) the functions in the DLL and does I/O. In C# parlance, this is called interop (short for interoperability).

The compiler generates an object file -- machine code for the code your write, but nothing else. The linker adds the code for library functions, to make the complete application.
yungman said:
I still have to try create and dummy .cpp file using Empty Project command so I know how to start my own .cpp. I think I am going somewhere, I am stoked.
Good. With an empty project, I think it's easier to not get confused by a bunch of extra stuff.
 
  • Like
Likes yungman
  • #48
So those are not called subroutines, they called declarations or prototypes of the functions now a days?

The Include folder, in the C drive is called "Header files"?

I am trying to learn the new names which is very important to understand what I am reading. I find Google is very good at that. I read about Solutions, Build solution, Clean Solution. These are all new to me. That Solution and just Compiling the program and Link the Prototype function in the Header files to produce the final executable file( I don't know the name yet). is it .exe?

Can you tell me what other important terms I need to look up?
 
  • #49
I just looked at the VS help documentation, I realize what I missed. In the explanation like Build and Run C++, the screen pictures are actually moving showing where to point and open files and run the build.

I have neck problem and it's not comfortable reading on the laptop, so I copy onto word file and print them out to read. Obviously the pictures are NOT moving anymore and I miss the whole picture instructions! No wonder there's a big disconnect from reading on paper to the real operation.

Now I know, it becomes a lot clearer. Wow, I wasted so much time on this! Luckily I was told here the documentation is very good, so I give it another chance.
 
  • #50
C++ is an old language but still one of the most important (the other one is Java, a much slower and buggy and annoying language), and it's very fast.

The new alternative to C++ is Rust.

And would also suggest Julia, the future for scientific programming. It's a very fast and capable scientific language which is going to supersede R+Python+Fortran.
 
  • #51
yungman said:
So those are not called subroutines, they called declarations or prototypes of the functions now a days?
What you're calling subroutines are functions. Both Fortran and Pascal distinguish between blocks of code that return a value (functions) and blocks of code that perform some action (subroutines in Fortran and procedures in Pascal).
Some additional terminology that is used in object-oriented languages is method, a function that is associated with a particular class.

Here is an example of a function prototype. The prototype (or declaration) provides the name of the function (triangleArea), the number of parameters (four) and types of the parameters (all are type double), and the type of value returned (double)
C:
double triangleArea(double sp, double a, double b, double c);
Here is an example of a function definition. The function definition includes the function header and the code for the function.
C:
double triangleArea(double sp, double a, double b, double c)
{
    double area = std::sqrt(sp * (sp - a) * (sp - b) * (sp - c));
    return area;
}
In large programs, it's often convenient to place the function declarations in their own file -- a header file, usually with a .h file suffix.
yungman said:
The Include folder, in the C drive is called "Header files"?
The Include folder contains the standard library header files. If you write your own header files, you could add them to the Include folder, but this is not a good idea. Usually any user-written header files would be placed in the same folder as the source code for your program.
yungman said:
I am trying to learn the new names which is very important to understand what I am reading. I find Google is very good at that. I read about Solutions, Build solution, Clean Solution. These are all new to me. That Solution and just Compiling the program and Link the Prototype function in the Header files to produce the final executable file( I don't know the name yet). is it .exe?
An application (called a solution in VS) can consist of a number of projects, but at your stage of learning, an application will involve only one project. Building an application entails compiling the code your wrote, which translates the code that you wrote to machine code, and then linking any library code together with your object file. The net result of this is usually an executable (.exe extension), but it's also possible to create a static library file (.lib extension) or a dynamic library (.dll extension). These library files are containers of function code that can be linked into programs that you write.

At this stage, though, you shouldn't concern yourself with library files.
 
Last edited:
  • Like
Likes sysprog and yungman
  • #52
yungman said:
Hi

I just want to learn a language, but I don't know which one is best for me. I did programming back in the 70s and early 80s, mainly in assembly language. I learned Fortran, Basic and Pascal before, but they are so old. I since changed my career to analog and RF electronic designs and had not tough programming since. This is mainly for mind excise, I rather this than crossword puzzles for retirement.

I am thinking about C# or C++ as this is used in firmware design. Another one is like Python because both my grandkids are into gaming, I bought a book of Python for Kids to my teenage grand daughter and she is learning it. So that is like playing with grand kids. One kind I don't want is language for business, I have no interest in business, mainly scientific or maybe gaming.

Any suggestion will be appreciated. Also how to get started when I decide on one language.

Thanks

Python is fine, but if you are interested in numerical simulations, Fortran is still worth considering. The language is old, but it has evolved considerably -- the latest standard is Fortran 2018. It has neat array features like Matlab of Python with numpy. I use the free gfortran compiler, part of gcc.
 
  • #53
yungman said:
Hi

I just want to learn a language, but I don't know which one is best for me. I did programming back in the 70s and early 80s, mainly in assembly language. I learned Fortran, Basic and Pascal before, but they are so old. I since changed my career to analog and RF electronic designs and had not tough programming since. This is mainly for mind excise, I rather this than crossword puzzles for retirement.

I am thinking about C# or C++ as this is used in firmware design. Another one is like Python because both my grandkids are into gaming, I bought a book of Python for Kids to my teenage grand daughter and she is learning it. So that is like playing with grand kids. One kind I don't want is language for business, I have no interest in business, mainly scientific or maybe gaming.

Any suggestion will be appreciated. Also how to get started when I decide on one language.

Thanks
If you have already learned a programming language, then learning another should be easy. I also learned BASIC, FORTRAN, PASCAL in my youth. When I learned BASIC, I also had to learn coding logic. After BASIC, I knew coding logic, so learning the other languages were only a matter of becoming familiar with new syntax. Today, I can pick up a new language in a few days just by looking at example programs and imitating them for other purposes, and that's how I learned Python and Prime Programming Langauge (HP Prime) and whatever that language is that those high-end Casio calculators use. Really, learning another computer language after you've already learned several isn't all that difficult. The biggest problem I have is that, sometimes, while programming my HP Prime, I'll mistakenly use Python syntax for the top line of a loop, and then have to correct it when the compiler detects an error.
 
  • Like
Likes yungman
  • #54
Jenab2 said:
If you have already learned a programming language, then learning another should be easy. I also learned BASIC, FORTRAN, PASCAL in my youth. When I learned BASIC, I also had to learn coding logic. After BASIC, I knew coding logic, so learning the other languages were only a matter of becoming familiar with new syntax. Today, I can pick up a new language in a few days just by looking at example programs and imitating them for other purposes, and that's how I learned Python and Prime Programming Langauge (HP Prime) and whatever that language is that those high-end Casio calculators use. Really, learning another computer language after you've already learned several isn't all that difficult. The biggest problem I have is that, sometimes, while programming my HP Prime, I'll mistakenly use Python syntax for the top line of a loop, and then have to correct it when the compiler detects an error.
I hope so, I am still trying to learn all the terminologies like Class, Object, Object Oriented programming etc. When it comes down to reading the codes, it's not that intimidating ( I hope).
 
  • #55
Some general comments

Python is extremely slow compared to other languages, unless most of what the code is doing is Python's library code which is written in other languages like C.

Java has limited functionality with native types versus object types such as "int" versus "Integer". Java's native linked list and iterators are terribly designed. There's no way to rearrange a list similar to C++ std::list::splice(), which can "move" one or more nodes within a list or from one list to another. Any operation that changes the linkage in a list will break all iterators to that list (except for the iterator that made the change).

Most low level embedded stuff, like hard drives are written mostly in C with some assembly (for interrupt handling, context switches, ...).

Knowing how to program with common languages will require some adaptation for uncommon languages like APL, with it's fairly large number of greek letter generalized operators that work with scalars, vectors, mutli-dimensional arrays, ... . A somewhat popular example of APL code is an implementation of Conway's game of life, which would normally take quite a few lines of code in a common language, but just one line of code in APL. This example uses some statement separators for a delay and to change display output.

 
  • Like
Likes sysprog
  • #56
@rcgldr from https://www.dyalog.com/uploads/files/presentations/CodeGolfWebinar.pdf $$\mathtt{(\{≢⍸⍵\}⌺3~3∊¨3+0,¨⊢) ~W}$$or in J (with explanation quoted) from https://rosettacode.org/wiki/Category:J
$$\mathtt{life=: (3~3 (+/~e.~3\text {+0,4}\&\{)\text{@,;._3}~]\text{)@(0,0,}\tilde{~} \text{0,.0,.}\tilde{~}\text{])}}$$
In other words, given a life instance, the next generation can be found by:
  1. adding extra empty cells, surrounding the life instance,
  2. tessellating the result, finding every overlapping 3 by 3 subinstance,
  3. totaling the number of live cells in each subinstance,
  4. treating a subinstance as a live cell iff that total is a member of the sequence 3,x where x is 3 if the center cell was previously dead, and 4 if the center cell was previously alive (that said, note that 4 is also the index of the center cell, with the sub instance arranged as a flat list).
 
  • #57
yungman said:
Thanks

So I just download Visual Studio and I can write the code and compile C#?

My grandson told me just now that C++ is better for writing game programs, is that true? I have no idea.

I went on google, it said C++ is more compact thereby run faster, C# needs a lot of library, it's slower and bigger. That C++ is superior for needing speed and much smaller. Maybe I should look into C++ instead.
I am an "early retired" Visual C++ programmer, and I have switched over to C# WinForms. Writing Windows programs is always a good skill to have as a hobbyist as you can make nice Windows applications. I do still like the C++ language, just that I fund Visual C# to be nicer than Visual C++.

If I recall, I think Microsoft has an API to build gaming apps for the XBox system that uses any of its languages. The fact that the top-level code is in slower C# doesn't really matter since such code would be calling functions that have been written in C++ (or even assembly) to be optimized for performance.
 
  • #58
Regarding Visual Studio, it is possible to create hybrid programs comprised of C#, C / C++ and assembly, by creating a DLL (dynamic link library) for the C / C++ / assembly "unmanaged" code. Visual Studio even supports source level debugging for both the C# and the C / C++ / assembly code.
 
  • #59
I just put in and ran a little program on my own! This started out as an exercise, but I added in display and making new lines by using <<endl command and put text in it. It worked! this is my little program:

#include <iostream>
int main()
{
int x = 8;
int y = 6;
std::cout << std::endl;
std::cout << "x-y=" <<x - y << "" << std::endl
<< "x*y=" << x * y << "" << std::endl
<< "x+y=" <<x + y << "";
std::cout << std::endl;
return 0;
}The cmd.exe shows:
C++ Class Object 2.jpg


This is my first one. I am stoked.
 
  • Like
Likes jtbell and sysprog
  • #60
I had a really hard time starting in C/C++ years ago. Might I suggest that you look at Starting Out With C++ Early Objects, Tony Gaddis. I learned from it, still refer to it every time I start a new coding project. (I found some versions online in pdf form.) I have a paperback on my desk and have it loaded on pretty much every computer I work with.

He explains enough to get going and be able to ask intelligent questions on google for what you need to know.
 
  • Like
Likes sysprog
  • #61
Jenab2 said:
If you have already learned a programming language, then learning another should be easy. I also learned BASIC, FORTRAN, PASCAL in my youth. When I learned BASIC, I also had to learn coding logic. After BASIC, I knew coding logic, so learning the other languages were only a matter of becoming familiar with new syntax.

These are all procedural programming languages that are very similar to each other though.

I think there are broadly two reasons to learn a new programming language. The first is that you want to get into or learn more about some specific kind of programming, e.g. systems programming, video game programming, scientific computing, web development, etc. There it's fairly straightforward: you want to look up what programming languages and libraries people in these domains use and start using them yourself.

The second is to learn more about programming and different kinds of programming concepts and approaches in general. What you want to do there is learn some programming languages that are very different from each other. On that:

1) There are a lot of good "single issue" programming languages that concentrate on doing one thing or a few related things well that you can learn a particular programming style from. Some potentially interesting languages I'm aware of:
  • ML, Haskell, and similar languages for their pure functional programming approach and the strict static-type inferencing system that this makes possible.
  • Smalltalk, for object-oriented programming.
  • Erlang, for concurrency.
  • Prolog, for its relation/query-driven approach to programming.
  • Forth, for its stack-driven model of programming.
  • Scheme, for its minimalism and extensibility.
  • I'd also include C here, since its model of computing is basically just the von Neumann architecture. (C's features are all meant to map straightforwardly to the basic resources and operations supported by a typical computer consisting of a processor and memory. All of C's basic data types are meant to fit in one or at most a few processor registers.)

2) Most "mainstream" programming languages roughly fall somewhere on a spectrum between C and Lisp in terms of their features and programming styles they support. Java, C#, and C++ are closer to the C end while the more popular dynamic languages (Python, Ruby, Javascript, etc.) are closer to the Lisp end.

Concentrating on Python (it's the language of its "kind" that I happen to be most familiar with) then if you look past its syntax and look at its features and major decisions about how it does things -- supports interactive programming, strong but dynamic typing, all variables are references, automatic memory management, built-in easy-to-use aggregate data types, exception handling, first class functions, supports multiple programming styles, etc. -- then it looks rather like a simplified Lisp dialect but without Lisp's metaprogramming capabilities. AI researcher Peter Norvig wrote a fairly detailed comparison of Python and Lisp here; his reply to this Quora question also succinctly explains what different Lisp programmers might like or dislike about Python.
 
Last edited:
  • #63
yungman said:
I have a question, this it the program:

#include <iostream>
int main()
{
std::cout << "Hello Buggy World"<< std::endl;
std::cout << "this is a test" << std::endl;
std::cout << "test again" << std::endl;
return 0;
}


Is the function main() defined in the <iostream> ? Because if I change to some other names, the build failed.

I am learning to define a function inside the program, I thought
main() is just defined by my program, I guess it's not true.
Every C and C++ program has to have a function named main(). This serves as the entry point for the program. It is not defined in any header -- your code is providing the definition of this function.

The main function can appear in another form with two arguments, which makes it possible to pass arguments to main. If you want to learn more about this feature, do a web search for "C arguments to main".

If you post code, it's a good idea to use code tags. They look like this:
[code=c]
<< Your code >>
[/code]
The above tag can be used for C or C++.
Also, you can eliminate some typing by a using statement, like so.
C:
#include <iostream>
using std::cout;
using std::endl;

int main()
{
    cout << "Hello Buggy World"<<endl;
    cout << "this is a test" << endl;
    cout << "test again" << endl;
    return 0;
}
 
  • Like
Likes yungman, sysprog and pbuk
  • #64
yungman said:
This is my first one. I am stoked.
Congratulations!

I can sense your struggles, because I started by programming in FORTRAN in college and graduate school (mid 1970s through mid 1980s), although not at the microprocessor level. Then I learned Pascal so I could teach intro programming courses in it, then switched those courses to C++ in the mid 1990s, and stopped teaching them in the mid 2000s.

For introductory teaching and learning, I've always preferred a simple command-line interface. In my C++ days, we used the Unix command line, and the basic commands for compiling, linking and running simple programs. In more advanced classes (taught by other people), students were introduced to industrial-strength IDEs: Eclipse in our case, Visual Studio in your case. The only one I've dabbled with is Xcode for MacOS.

IDEs are valuable and even essential for managing complex projects, but IMHO they get in the way when you're starting to learn programming. You spend more time trying to figure out where everything is, than on the details of the programming language.

For my simple hobby-level programming, I still prefer to use the Unix command line in a MacOS Terminal window, or an xterm window in Linux.
 
  • Like
Likes yungman and sysprog
  • #65
This needs a large amount of emphasis!
jtbell said:
IDEs are valuable and even essential for managing complex projects, but IMHO they get in the way when you're starting to learn programming. You spend more time trying to figure out where everything is, than on the details of the programming language.
 
  • #66
jtbell said:
IDEs are valuable and even essential for managing complex projects, but IMHO they get in the way when you're starting to learn programming. You spend more time trying to figure out where everything is, than on the details of the programming language.

For my simple hobby-level programming, I still prefer to use the Unix command line in a MacOS Terminal window, or an xterm window in Linux.
That's all very well but the OP is using Windows and doesn't have any experience at the command line. Python (or more accurately Python dependency management using conda and especially pip) can be a real struggle on the Windows command line due mainly to admin/non admin user issues and PATH problems, even if you know what you are doing. For a Windows user, Anaconda or PyCharm takes away this problem and means you can concentrate on your code.

Edit: mixed up threads, this one is about C++ not Python - the same applies though, compiling C++ in Visual Studio is much easier than the Windows command line.
 
Last edited:
  • Like
Likes Astronuc
  • #67
Mark44 said:
Every C and C++ program has to have a function named main(). This serves as the entry point for the program. It is not defined in any header -- your code is providing the definition of this function.

The main function can appear in another form with two arguments, which makes it possible to pass arguments to main. If you want to learn more about this feature, do a web search for "C arguments to main".

If you post code, it's a good idea to use code tags. They look like this:
[code=c]
<< Your code >>
[/code]
The above tag can be used for C or C++.
Also, you can eliminate some typing by a using statement, like so.
C:
#include <iostream>
using std::cout;
using std::endl;

int main()
{
    cout << "Hello Buggy World"<<endl;
    cout << "this is a test" << endl;
    cout << "test again" << endl;
    return 0;
}
What is Tags? I search google, still don't quite get it.
C++ program 1.jpg

this is the program I am working with, it looks like what you show, but when I do Ctrl C and copy into the post, I lost all color and indent. This is a screen capture instead of copy, you can see it looks like what you have.

I still don't know what is Tags.
 
Last edited:
  • #68
jtbell said:
Congratulations!

I can sense your struggles, because I started by programming in FORTRAN in college and graduate school (mid 1970s through mid 1980s), although not at the microprocessor level. Then I learned Pascal so I could teach intro programming courses in it, then switched those courses to C++ in the mid 1990s, and stopped teaching them in the mid 2000s.

For introductory teaching and learning, I've always preferred a simple command-line interface. In my C++ days, we used the Unix command line, and the basic commands for compiling, linking and running simple programs. In more advanced classes (taught by other people), students were introduced to industrial-strength IDEs: Eclipse in our case, Visual Studio in your case. The only one I've dabbled with is Xcode for MacOS.

IDEs are valuable and even essential for managing complex projects, but IMHO they get in the way when you're starting to learn programming. You spend more time trying to figure out where everything is, than on the details of the programming language.

For my simple hobby-level programming, I still prefer to use the Unix command line in a MacOS Terminal window, or an xterm window in Linux.
So far, VS is behaving for me, I am on chapter 3 of the book and I play with quite a few program by creating new projects on VS and type in the lines, experimenting by changing and adding my lines. So far, (knock on wood) it's...I dare to say, smooth! ( I hate saying this!)

So far, I deal with colsole cout and cin to input variables, display strings of words, perform simple arithmetic function and display in cmd.exe. Creating a function like "int customfunction()" and call the function in main(). So far so good. no question yet...Knock on wood.
 
  • #69
I speak too soon, I do have a question. I am going through all the examples in the book, the book tends to build on the last example for the next. Meaning the next example is using like 90% of the code of the last example. It would be very convenient to save the program of the last example and rename as new program so I don't have to retype the whole thing.

I look at "file", there is no "Save as" option that I can save the program in another name. Is there any way to do this?

Thanks
 
  • #70
yungman said:
I still don't know what is Tags.
@Mark44 was referring to bbcode tags (BBcode Guide is linked at the bottom left of PF pages, next to the LaTeX Guide link) which are a kind of markup used on the forums to assign attributes to parts of a post ##-## the suggestion was to wrap your code in between code and /code tags like this:
Mark44 said:
If you post code, it's a good idea to use code tags. They look like this:
[code=c]
<< Your code >>
[/code]
The result would be:
C:
<< Your code >>
 

Similar threads

  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
4
Replies
107
Views
5K
  • Programming and Computer Science
Replies
8
Views
878
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
2
Replies
54
Views
3K
  • Programming and Computer Science
Replies
13
Views
1K
  • Programming and Computer Science
2
Replies
58
Views
3K
  • Programming and Computer Science
Replies
16
Views
2K
  • Programming and Computer Science
Replies
9
Views
1K
Back
Top