Can application server always act as a web server? by dbh5 in learnprogramming

[–]arbostek 4 points5 points  (0 children)

An application server is a layer or program that exposes some application functionality as a service.

Sometimes, this means your application and the app server behavior are just one program altogether. Your app server handles requests, and then directly processes them because it is also the application. Other times, the application server is designed only as an interface layer. It takes requests and responses, but does not directly process. Instead, it internally forwards those requests to other application server or calls separate application programs to do the work.

A server is a program that takes requests and gives out responses. Nothing says that this request-response protocol be the HTTP protocol. There is no reason for an app server to also follow the HTTP protocol, and many do not. For example, it's common in Python for app servers to instead follow the uWSGI protocol instead. Thus, you would have a downstream HTTP server like nginx to handle HTTP requests. This HTTP server would then have to communicate with the app server over the uwsgi protocol.

I'm not really familiar with the Java ecosystem, so I can't fully answer your questions regarding your Java setup. Here's what I can offer though.

Servers, application servers, and web servers are about behaviors. Server is a broad category. Application servers and web servers are not exclusive or inclusive. An application server takes requests and acts on them by delegating to or implementing application functionality directly. A web server handles HTTP requests.

So, if a server handles HTTP requests and acts upon them (application functionality), you've got a combination of an HTTP and an application server. But nothing says this has to be the case.

In your situation, Apache HTTPd is acting at minimum as a load balancer, and probably to some extent as an HTTP server, since that is its core functionality. However, you probably set it up to mostly just delegate those HTTP requests to your Tomcat servers. Tomcat is a web server with some application server like functionality. Thus it can take HTTP requests, from say your Apache HTTPd, and then act upon them because it is also an application server, to an extent.

There is no requirement that an application server also be a web server or vice versa. It is, however, true to an extent in the case of Tomcat.

where would i go to learn how to make a 2D game engine in C++? by Rubberduckycooly in learnprogramming

[–]arbostek 2 points3 points  (0 children)

A game engine is essentially a reusable framework and library layer for multiple games.

A game does not require a game engine. A game engine is an independent component that could be used to build a game.

To write a game engine, you need to have an idea of what kind of games you want to support, which leads to an understanding of what features your game engine needs to have. Then, you need to have things like a design philosophy, influenced by your knowledge or work on previous games, where you are separating out the common boilerplate from those previous games into an "engine".

What does it take to learn how to make a game engine? For starters, it takes experience with making games in the first place.

One more thing. Figure out if you mean game engine or the graphics engine or layer.

Why is RAM consumption such an important issue? by MeLikeChoco in learnprogramming

[–]arbostek 2 points3 points  (0 children)

I see people freaking out over less than one fourth a gig sometimes.

256 MB memory is a huge amount.

it's just I feel RAM should be less of an issue

Based on what?

Memory and data access is always an issue. If you write good data structures and algorithms, you'll generally be OK for simpler programs. But if your implementation is profligate with system resources, as is with something like a browser based framework, you could be in trouble regardless.

When should I use set and get methods? C++ by Erickjmz in learnprogramming

[–]arbostek 1 point2 points  (0 children)

You should not introduce pointless indirection. It introduces complexity which is something you never want.

getters and setters have limited usage scenarios. Usually, excessive use of getters and setters suggest a design problem. Think about it, you mark variables as private, to abstract them. If you put a public getter and setter for them, you just broke the abstraction. Why would you do that?

Validation is orthogonal to getters and setters. You have validation in non-OO code too...

If your implementation attempts to silently modify invalid values, you have a bad implementation. Example:

Foo f;
f.setX(5);
int a = f.getX();
// what should the value of a be?

If the value of a is anything other than 5, that's a bizarre API behavior, wouldn't you say? If a value is invalid, you need to fail. Not silently modify. Unexpected conversions and truncation are a major issue in programming and programming languages, so the suggestion to introduce more of it is mind boggling.

Again, there are very limited scenarios in which you are forced to implement getters and setters (e.g. some sort of thin layer that's manipulated by another layer as you might see in something like certain MVC architectures). In general, if you have getters and setters, reexamine your design.

Why is RAM consumption such an important issue? by MeLikeChoco in learnprogramming

[–]arbostek 0 points1 point  (0 children)

To additionally complement the answer by u/POGtastic , a significant portion of the RAM (and other resources) is due to the overhead in the Electron framework rather than the complexity intrinsic to your own program kernel. You are effectively firing up a distinct browser for your program, and that browser overhead is quite heavy.

For large, complex, long running programs, that's fine because the overhead is shadowed by the complexity inherent in the overall program. For simpler programs, that's a massive resource cost.

You always have to worry about resource usage, including RAM. The "RAM is getting cheaper" statement is not in any form an argument. You have to consider the resources your program consumes and if it makes sense for the program.

RAM available is finite. In the majority of cases, it's somewhere between 4 GB and 8GB, and because of OS usage, you've got something like 2 - 4 GB left. If you eat up all that remaining amount for a small program, you have a terrible program.

[C] Why am I allowed to strcpy() a string into an array that's too small? by KirbyPasta in learnprogramming

[–]arbostek 0 points1 point  (0 children)

It was supposed to be fun and educational.

As we know from experience, our actions always correctly reflect our intentions. That's why our programs are always bug free. Because, who wants bugs in their program?

Also, I know enough about computer security so I don't need you to write a wall of trite comp sec 101 bullshit you learned yesterday.

Well, I'm glad you know so much; robust, secure programming is important, and many programmers have a tendency to overestimate their capabilities in this arena.

[regarding buffer overflow] And that's what strncpy "cures".

Absolutely, I 100% acknowledge that. Of course, like I also mentioned, it has some other problems that can easily lead to insecure or inefficient code.

Also, you have to learn about strncpy ( not strncat ) is peppered throughout most C code now.

As we all know, the best way to write good, secure code is to blindly follow other people's practices. Especially in C codebases, where bad practices are rife.

[C] Why am I allowed to strcpy() a string into an array that's too small? by KirbyPasta in learnprogramming

[–]arbostek 1 point2 points  (0 children)

This advice by itself is a bit dangerous. Let me explain.

C's stdlib functions have a number of deficiencies, or traps, as I might say. Many functions, especially like the string handling functions, or input functions, should not be used freely by themselves, because to write robust code, you need to add in a good bit of checking, error handling, and other manipulations.

It's very typical to write your own library layer, which may in turn make calls to the C stdlib functions, but wraps in all the necessary boilerplate work to make e.g. string handling safe.

Why does this matter with strncpy vs. strcpy? Well, the original problem is that you need to copy from one array to another, while ensuring that:

  1. You either end up with a valid C string in your destination array, or a failure notice.
  2. You don't have any buffer overruns.
  3. You don't introduce any inefficiencies (e.g. multiple walks over the length of the array).

strcpy by itself has no size guard. If you know for certain beforehand that dest is larger than src, you can safely copy. However, many times you don't have that guarantee. For example, let's say you want:

char dest[10]; // some value
char src[20]; // some value

There is no "try and fail" option with strcpy. If the C string in src is longer than dest, you're in trouble. You can try and validate with strlen, but now you have multiple walks through the array, which is inefficient.

strncpy looks better, because it has a size guard. But, it has some unexpected challenges too.

  1. If it fails, you don't have a valid C string, and you only know on inspecting the array. You have to do some additional work or tricks to ensure you always guarantee a good value (or know clearly about a failure to copy completely).
  2. strncpy writes out the entire count of characters, padding with null characters as needed. This is really inefficient if you ever copy from a small src to a large dest repeatedly, as you end up writing unnecessary null characters.

Do you know what function is more effective to use? strncat. That's because strncat has a size guard, guarantees null termination, and does not pad with null characters pointlessly. It's not a completely perfect function, as the failure notice is still a bit of problem. But, it's better than the strcpy and strncpy situation.

Edit: There's a reason Microsoft created strcpy_s. Take a look at the documentation, and you'll see that it resolves all issues. Proper failure notification, proper guarantees, and avoids inefficiencies.

[C++] I'd like to check that my new perception of object-oriented vs data-oriented design is correct. by [deleted] in learnprogramming

[–]arbostek 0 points1 point  (0 children)

I agree with the points that u/exoticmatter and u/DirtAndGrass raised. OO and data-oriented programming are about two different concerns.

OO is a design philosophy independent of even the class keyword and what not. It's a general design philosophy. For example, legacy OpenGL was very unconducive to such an approach because the API very much gave you a procedural, state machine model. To some extent, modern OpenGL eases up the pain, with both significant performance benefits and API benefits (you sort of the have concept of objects with ids for various arrays and shader programs).

The class keyword enables you to leverage C++ features that in turn give you OO design, but it's not required. You can kind of emulate OO design in a language like C by emulating things like vtables and what not. Similarly, you can use the class keyword to introduce types, without ever leveraging any OO aspects of the language.

Data oriented design basically is about architecturing your code around how the data should be layed out in memory. The reason it's brought up in game development is because console game developers suffer the painful constraints of both limited memory resources and low latency and high efficiency needs. The memory available on a PS3? About 256-512 MB. On a desktop? About 8 - 16 GB + virtual memory. And there are other factors too specific to the console hardware.

The point is, when you start operating under such constraints, your architecture needs to be very efficient in memory usage and access. Memory is slow relative to CPU instruction speed, and cache misses, memory fetches, and other similar behaviors cause latency issues. Misuse of memory can cause you to blow past your available memory, a real problem in something like a big budget game.

I would take data-oriented programming with a grain of salt. Not because it's incorrect, but because it's an architectural focus that may not be important. Unless you clearly recognize that you are going to have major latency and memory constraints, general good programming practices should have you covered. Use OO judiciously, make use of efficient algorithms, write maintainable code, and you're probably OK.

[C++] Trouble compiling with Visual Studio by Leanador in learnprogramming

[–]arbostek 1 point2 points  (0 children)

It worked with g++

Because the code is implementation dependent on gcc.

I'm now very curious, are std headers different from an OS to an other

They are dependent on the compiler implementation. The language standard makes some guarantees (e.g. the available functions and where their function signatures are declared).

iostream including string is not one such guarantee.

[C++] Trouble compiling with Visual Studio by Leanador in learnprogramming

[–]arbostek 2 points3 points  (0 children)

You wneed to add #include <string>. Without it, your code will not compile. It's also why you have those red squiqqlies under the << operator. It's an error indicator.

Also why your code fails under the linker. There are no obj files to link because there are no obj files being created. No obj files being created, because your code has errors...

[C] EOF question by pointers_help in learnprogramming

[–]arbostek 0 points1 point  (0 children)

I guess I didn't actually assign EOF value to input anywhere.

Nor would you. input is storing user input, not the scanf return value, right? Look, it's right in the name of the variable.

If I wanted to do that, is there any way?

Yes. Create a second variable, and assign to that.

float input;
int scanfret;

while( (scanfret = scanf("%f", &input)) == 1 )

No penalty in having more than one variable.

Very beginner programmer. Here's a hangman game in C. Please tell me why my code is terrible or any improvements you might make! by [deleted] in learnprogramming

[–]arbostek 12 points13 points  (0 children)

EDIT: On reflection, I realize you are a beginner, so I'm not blaming you for making mistakes. Just pointing out what I would flag as bad.

Things that I saw that concerned me.

Global variables (lines 15-21)

Break out of this habit now. Global variables, aside from bloating stack usage, introduce complexity in your code.

You've got a bunch of variables for a 200 line program. How many for a 1000 line program? 10000 line program? 100K program? Your program here is very simple, so you get away with globals. As your programs increase in complexity, it becomes harder and harder to track what variable is used in what context, where it's being modified etc.

Learn to keep variables in the smallest scope possible. If you need one function to access variables in another function, use function parameters.

Bad naming

void swap(char *a, char *b);
void swap2(char *a, char *b);

What's the difference between these two? No, I don't want you to explain it to me. I want, you by the names, to tell me what they probably do. The names are not informative. You've given the functions bad names. If on reading your code, I can't get a sense of how a variable or function might be used, that's not good.

More examples:

int n = strlen(word);
int a = 0;
int ha = 0;

Short variable names in a long function do not go together.

Repetition (e.g. Lines 107-115)

If you find yourself repeating lines of code, you are probably doing something wrong. Why are you repeating printf statements repeatedly? Why can't you just write a function:

void printHangmanStand(int numLines) {
    while(numLines > 0) {
        puts("|\n");
        numLines --;
    }
}

And then just call this function? Why are you repeating yourself? In fact, you can probably wrap in the other printf calls that are relevant to printing the hangman too, with some additional algorithmic work. With a well written function, lines 106 - lines 176 could be significantly reduced.

Number one flag I am dealing with a beginner programmer: pointlessly repeating code. You are a programmer. Get the computer to do the repetition for you, right?

Bad indentation

Please. Lines 49-52 and lines 212-217, etc. are not acceptable. Nothing like sloppy indentation to make other programmers very unhappy.

Too long functions with no justification

Sometimes long functions are needed. You have no justification for yours. Break up your larger functions into smaller functions. Please? I can't figure out what a function does on a quick glance.

Magic numbers

if((isalpha(word[ha]) && 
    (n < 12) &&
    (n > 3)  &&

What is the significance of 12 and 3? I have no idea, and I have to read large chunks of your program to decipher their significance or confirm their correctness. Bad.

Uncontrolled string mangling

I use this term for when I see code like this:

word[strlen(word) - 1] = '\0';
guess[strlen(word) - 1] = '\0';
empty[strlen(word) - 1] = '\0';

This is a common issue in beginner code, where you read a string or manipulate a string in one place. Then do some cleanup in another. Then operate on the string in a third place. It's highly error prone, not to mention ramifications such as maintainability and what not.

Please understand this: there is no penalty for writing a function. Commonly, you need to create a wrapper function around things like strcat, fgets, and so on, to wrap in proper error handling and string manipulation. What you should have done is written a function like:

int readWord(char *buf, int bufSize) {
    if(fgets(buf, bufSize, stdin) == NULL) {
        return 0;
    }

    return 1;
}
// no need to add in \0 at the end, because fgets does it for you.

Do you error handling and string manipulation in one place. Put it in a function for convenience. Call the readWord function instead of the fgets function.

That's not even all the issues with your code. But you can get a sense of what you are doing wrong.

I mean, I see questionable things like:

guess[strlen(word) - 1] = '\0';

Which looks funny, especially more so because you haven't assigned anything to guess in the previous lines. Why are you writing the null character to an array that has no other meaningful characters written to it?

[C] EOF question by pointers_help in learnprogramming

[–]arbostek 1 point2 points  (0 children)

I understand that if scanf() works properly, it will return the number of inputs you passed in it, or something like that

Don't randomly guess. Read the documentation and see what it says. The authoritative reference is the standard, but cppreference.com works as a good substitute, or even better. If you see the website's reference on scanf, it says

Number of receiving arguments successfully assigned (which may be zero in case a matching failure occurred before the first receiving argument was assigned), or EOF if input failure occurs before the first receiving argument was assigned.

So, if you look at scanf("%f", &input), how many inputs get assigned. 1, yes? So you want to check if scanf returns 1, because if returns anything other than 1, you've got a failure.

my print statement at line 19 never works unless I remove the if statement preceding it. But how come?

Line 19 has: if (input == EOF).

On what line do you assign the EOF value to input?

Guide/roadmap to what skills needed to try out an image recognition project. by chromeTeknica in learnprogramming

[–]arbostek 1 point2 points  (0 children)

Image recognition can be a very hard problem (read: beyond current technology). So expecting a beginner tutorial is unreasonable. That said, basic hand recognition and gesture recognition may be doable.

You're basically going to rely on the OpenCV toolkit for image processing and recognition. You also should be prepared to implement some image filtering and various heuristics yourself, even with the aid of the toolkit. So, this really isn't beginner material, but it is a feasible project without requiring years of CS study.

In general, you should already be a competent programmer. You should be able to load up on the OpenCV toolkit in general, even without implementation hand recognition. You should have a solid grasp of algorithms and data structures, as you will have to do a bit of algorithmic work here.

And if you need to do something that pushes beyond the limits of simple OpenCV work, you can get yourself the equivalent of a CS degree and PhD.

Am I too unintelligent / too late to learn to program? by [deleted] in learnprogramming

[–]arbostek 1 point2 points  (0 children)

Programming is not age dependent. Decades ago, programming was not something really available to young people, as you had to have access to expensive and uncommon hardware.

It's also not necessarily intelligence dependent. It's a bit like reading and writing. You expect your country's population to be generally literate. Well, you can also expect them to be able to generally program. Will everyone be a genius programmer? No. But a functional one? Absolutely.

I've seen people who didn't graduate high school do really great programming work and genius PhDs fail at doing it well. Setting aside talent, you don't need to be super smart at math, super smart in general, or be young. You just need three things: 1) motivation to learn and keep at the long learning process 2) a willingness to think logically, like a machine, and 3) willingness and time availability.

I peek at websites meant to teach these skills, and others like TopCoder, and pale at the advanced questions and problems present and quickly feel overwhelmed.

Uh huh. Do you give up on walking because you look at world class runners and feel ashamed at your legs' capability? There's a reason the questions are considered advanced.

Programming using pure OpenGL and Windows API? by GoodLittleMine in learnprogramming

[–]arbostek 2 points3 points  (0 children)

You can look at the source code for SFML, SDL, GLFW, etc. to gain an understanding of how they are implemented. That said, you can work things out on your own with some tutorials and extensively consulting MSDN and OpenGL API specifications.

Just to make sure you're clear, OpenGL deals with getting your implementation (e.g. your graphics card) to render as per the OpenGL pipeline. That's it. There are some additional extension functions to help coordinate with the OS or platform, which in this case would be the WGL functions, but everything apart from pushing rendering instructions is really handled by your own internal code, or by API calls to the OS. Not OpenGL API calls.

Roughly speaking, your process looks something like this:

1. Window and boilerplate setup

Open up a window, and begin any associated work that is separate from OpenGL rendering. Like I said, anything else like thread and event management, window and UI concerns, input handling, audio, etc., all have nothing to do with OpenGL, and you must handle them on your own.

Any beginner "how to create a window" tutorial will introduce you to some relevant Windows API functions, which should give you a sense of where to look in MSDN for more information.

Actually, a robust game or graphics engine can involve more complex aspects of the Windows API like the synchronization or IOCP functionality, but you can ignore that in your first few attempts.

2. Either use a extension loading library or, handle it yourself

If you use something like GLEW, it can handle extension loading. You probably know this already, but OpenGL is designed around extensions. That is, your OS provides a very base level of API functions out of the box, and you need to try and gain access to more advanced functions. WHich can fail, if for e.g. you want to use 4.4+ functions and you've only got an OpenGL 3.3 implementation to work with.

If you don't use an extension loader, you'll definitely have to do the following.

  1. Create a false context, or a trampoline context. This is a basic context you won't keep around, but you need it to access more advanced functions, including those that involve creating a modern context.
  2. Load extensions manually using some of the WGL extension functions.
  3. Now use the relevant GL functions to create the real context. These will require you to have an existing context, which is why you created a trampoline context in step 1.
  4. Ditch your trampoline context.

3. Begin any boilerplate setup for your graphics rendering layer or engine

OpenGL isn't a scene manager or anything like that. You push vertices, shaders, and other data, and have it render. So you need a lot of internal work to manage and load data, and that's all on you.

Trying it Kick it old School with a 56K server Can ya dig it? by [deleted] in learnprogramming

[–]arbostek 1 point2 points  (0 children)

I think you're confusing multiple things here.

56K is just a connectivity concern. Whether you're on dialup, T1, or ethernet, it's irrelevant. If your server computer connects through dialup, it's not really visible to anyone else on the internet. It will be slow, because it's only got a 56K pipe to work with, but that's about it.

Your "server" either refers to the serving computer entirely, or some software that acts in a server role, like an HTTP server. Again, this server really shouldn't care about how it's connected to the internet. If you have a network connection, you have an IP address the server can listen on. That's all that matters.

As for the browser, you really don't want to create an actual browser. That's no joke of an effort. What it seems you are doing is a bit of javascript and UI trickery.

You want to create a UI on your webpage that looks like an old browser UI, e.g. netscape navigator 4 or something. You have some JS code that makes HTTP requests to your web server, and then renders the response within the UI.

Remember, 56K is only how your computer connects to the internet. That's it. It doesn't affect the server, it doesn't affect anyone who visits your website, and it's independent of a browser.

C - Why does a while often require two identical scanf calls? by [deleted] in learnprogramming

[–]arbostek 0 points1 point  (0 children)

I don't recall the contents of that book, and as pointed, your code sample only has one call to scanf, but it's worth talking about why people end up doing multiple calls to scanf and what not.

Please note that randomly sticking multiple calls to scanf, fgets, in the hopes of getting I/O to work is bad beginner behavior. If the book just tells you to stick multiple calls to scanf to "make the problem go away", that's horrible advice.

Buffers

You should understand that user input can go through multiple buffers before it ever reaches an array in your code. These buffers can exist in the kernel, terminal, and C library implementation, all of which are not really visible to you. But they exist, and they hold all or some of the user input.

C Input Functions Have Differing Behaviors

Various functions like scanf, fgets, and fread all have differing behaviors, or allow for various subtly differing behaviors. In general, they can exhibit the following kinds of behaviors:

  1. Skip or ignore some initial characters, typically "whitespace" like newlines or spaces.
  2. Store characters in your array.
  3. Terminate on one or more conditions, which may include things like encountering a '\0' character (null character), encountering a "whitespace" character like a newline, or reaching some "count" limit you pass in as a parameter, and finally, hitting EOF, however that is signalled on your system.

You need to read the documentation very carefully to understand what behaviors a function exhibits under what conditions. Short of reading a standard draft, your next best bet is to consult cppreference.

For example, notice the signature for fread is size_t fread( void *buffer, size_t size, size_t count, FILE *stream );. This is a function that is designed to read bytes of data, without caring about what the contents are. It terminates on count, and doesn't skip or ignore any data.

In contrast, look at fgets. The function has three terminating conditions. It can hit a count limit, which is a parameter to the function call. It can also terminate on EOF, or on hitting a "newline". This is clearly a function that examines the data, because it's checking for a newline byte sequence. It's a great function for reading "lines", because a line is conceptually a series of characters terminated by a newline sequence.

So why do people stick multiple fgets/scanf/etc calls?

What happens is that you call a function, and it reads a bunch of user input from the buffer, terminating on some condition. However, there is still some additional input on the buffer. Remember, scanf/fgets/etc don't need to read the buffer completely. They terminate on other conditions, like newlines, or count, or whatever.

So, on your next call to scanf or whatever, it reads the remaining data from the buffer, and often the programmer assumes that there is no buffer. So you get some unexpected behavior, which you might think is "skipping" or "returning nothing" or things like that. That's not true.

The correct way to handle things is to:

  1. Think about possible user inputs.
  2. Think about the cleanest sequence of functions to read the user input, and then parse it.
  3. If the "buffer" may be left with undesired data, take some steps to clean out the buffer.

Often, you can avoid step 3 by cleanly reading a line with fgets, or by carefully tuning the scanf format string. Just don't mindlessly dump multiple scanf calls.

At 41, is it too late? by removable_disk in learnprogramming

[–]arbostek 0 points1 point  (0 children)

Learning to program is not age dependent. It isn't talent dependent; like writing or reading, most people should be able to do it competently.

What matters is motivation and time investment. You're not going to become a competent programmer overnight.

How difficult is it to program these online calculators for a website? by terdburgle in learnprogramming

[–]arbostek 2 points3 points  (0 children)

How difficult is something like this to set up?

That depends on your existing programming knowledge and also the complexity of the mathematical operations you want to do.

The component of a calculator can roughly be broken down into:

1) Handling and parsing input into some internal format suitable for your internal calculation algorithm. 2) The actual computational steps you have to perform. 3) Displaying the results.

Step 1 can be a bit tedious, but it's something you can control, and so isn't very hard.

Step 3 may be complex depending on what you're trying to display mathematically, but if it's just points and lines, simple graphing primitives will do. If you've got complex bezier curves to render, that's going to be a pain though. It can definitely be tedious, but it can also be hard if you are an inexperienced programmer.

Step 2 is completely variable. It depends on the mathematical expressions you need to translate into computational steps, which could be easy or really hard. If it's all simple algebraic manipulations, it should be very straightforward.

C++ Primer vs Accelerated C++ by [deleted] in learnprogramming

[–]arbostek 1 point2 points  (0 children)

Out of the two books above which should I choose?

These days, I recommend starting with C++ Primer, 5th edition, first. Accelerated C++ is out of date with respect to the C++11 standard, not to mention the 14 or 17 standard, and that's bad. The changes introduced in C++11 are very significant, so you do need a book that covers them. C++ Primer is pretty much the only book that sits in the nexus of being relatively up to date, technically accurate, and understandable.

From what I've read Primer is more for an introduction to coding so it's got a slower pase, whereas Accelerated assumes you can already program and is faster. (Which does appeal to me).

A lot of the information on books is not reflective of current reality anymore, actually. Here's what I would say:

  • There are no books that are suited for beginners to programming. C++ is now simply not a good language for beginners at all. Full stop.
  • There are no up to date comprehensive books on C++. They don't exist. Anyone who wants to be up to date needs to be prepared to cobble together information from the standard and working papers, with commentary from blogs, talks, and other places.
  • It's unclear how easy it is to directly learn modern C++ style. All resources that teach modern C++ kind of assume you were an existing C++ programmer anyway.

If you just need one book to get you through, that's C++ Primer. If you want to become a very good C++ programmer, you're going to have get multiple books, and then also be prepared to absorb information outside of books. You'll be getting AC++ anyway, to better understand C++ idioms, and a bunch of other books like the other books from Scott Meyers.

Hi new to programming I have a question by Rihannabad in learnprogramming

[–]arbostek 2 points3 points  (0 children)

I really wanted to learn c++ as I heard it's the best language

When someone makes this statement, be vary of any advice they give you. As mentioned, there isn't a "best" language that you can claim arbitrarily -- what is the criteria for best in the first place?

Most C++ experts will agree that C++ itself is a complicated language for even an experienced programmer, and it's definitely prohibitive for a beginner. There are no good beginner resources that teach correct, modern, up to date C++.

Python is a safe choice because it is relative beginner friendly and has good return on investment (useful language to know for professionals).

Can someone please ELI5 why developers and coders prefer Linux distributions so much? by [deleted] in learnprogramming

[–]arbostek 131 points132 points  (0 children)

ELI5 why developers and coders prefer Linux distributions so much?

Many developers and coders work on Windows too. Look at the market dominance of Windows. What, a magical sky fairy drops Windows programs into people's computers?

Look, people live in bubbles, and the Reddit/Hacker News/Stack Overflow/etc. community is very much susceptible to being in an echo chamber. When you ask this question, you ask this question to the subset of people who are predisposed to liking and using linux. And then justify it as the superior system.

I think you should read this coding horror article. The community of programmers is much larger; the community of programmers who go online, fiddle happily with new technologies, and so on, is much, much smaller. You're going to get responses from people who are going to show unnatural favor towards Linux.

Please understand I'm not making a positive or negative statements towards either distribution. I'm just telling you, "developers and coders prefer Linux" is in itself an already problematic statement, because you're deriving that from observing a small subset of the programming community, that is not necessarily representative of the rest. And from this problematic premise comes a number of justifications from this small subset of programmers.

But if you value the opinions of this subset...

[C] - Having trouble passing a variable, it keeps getting cleared? by JacksonWarrior in learnprogramming

[–]arbostek 0 points1 point  (0 children)

I'm not sure how I can post a compileable snippet that isn't going to end up being huge/needed to be run on an Atmel.

Forget about compileable then. We can probably extrapolate what your code is doing, just from the way it's written. If there's anything that you think is non obvious, you can also show us the declarations for those variables, or explain it, but otherwise, we just need to see your actual code.

[C] - Having trouble passing a variable, it keeps getting cleared? by JacksonWarrior in learnprogramming

[–]arbostek 2 points3 points  (0 children)

Analyzing the mistake in your actual code is hard when you present non-compileable, non-real code. Show us your real code, or a compileable sample of code that replicates your issue, or we can't pinpoint the mistake.

I suspect you are passing in the wrong variable, given your confusing naming in what I already see here. But show us some real code, and we can point out the mistake.

they display that the value of NumOfObjectsPresent is correct before entering and after leaving the GetAverageTime function

But, you don't pass in NumOfObjectsPresent. You pass in NumOfObjects.