Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am searching for a month for blog posts about "how C program works". Most of them go like
Compilers do these things
Linkers do these things
Program is put into memory; and stacks, heaps, etc.
I thought I would first read about how compiler works to understand the flow of the program into the machine. Dragon Book seems to be universally preferred. But truthfully, it's too intensive. I am not good enough now to go through it all.
So I began to read about hardware. But There too, they explain about buses, I/O signals, structure of memory, writing cache-friendly code etc. But with no proper examples.
But still I could not find myself satisfied or being able to completely visualize the process.
2 hours ago I decided to ask this question.(Since I am scared of It might be not useful to SO community, or off-topic question or other down-votable categories) and I did not find out any post relating to this exactly. There was one about "how compiler does the compilation", but the answers showed that it's too broad a question.
My question is this:
I would like to know how, in depth, a C program works. If you cannot tell me explicitly, please redirect me to a book or another post on another website that can give me the answer to this.
I am here until I get a response. If you have any suggestions regarding this post, tell me. And It is not my first language, so please take all my sentences as being soft and polite.
Thanks.
UPDATE:
Along with the accepted answer, there are some very nice links as well as suggestions which give partial answers or the way to proceed further to understanding what I am trying to understand.
The best answer to this question by far comes from the book "The Elements of Computing Systems," by Noam Nisan and Shimon Schocken. This book starts from the simplest possible electronic components, assembles them into a working processor, invents a simple assembly language for it, writes an assembler for that, and ultimately shows you how high-level languages can be compiled onto it. Reading the book, and working all the examples (which use a simulator for the hardware, so no workshop required!), will forever change the way you look at computers; he will literally understand everything from the lowest to the highest levels, and see how they work together. See the book's website for more info.
It's too broad a question (as you have observed).
If you really want to understand from bottom up - buy an OLD computer from the 80's off ebay. Sinclair Spectrum/BBC it really doesn't matter but make sure you get plenty of books and manuals that go with it.
You will learn plenty because these machines were well documented and what wasn't documented was discovered and then documented :)
They are also sooooo much simpler than a modern quad core multi-gigabyte memory job. It will all fit inside your head easily
or for a modern start, Arduino or Raspberry pie maybe.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a homework in artificial intelligence.
I need to make a robot go from room A to room B and there are obstacles between the rooms.
The professor asked me to use STRIPS (Stanford Research Institute Problem Solver) but I can not understand how STRIPS works.
Can someone give me a good explanation and examples about what is strips and how it work?
Thank you.
[Please note, this is based on what I half-remember from nearly a year ago]
These days, I would expect that when the Prof. says STRIPS, they would be talking about the problem coding 'language', rather than the planner - check for example the Wikipedia page: STRIPS. I would imagine that your Prof. likely has a particular solver (and quite possibly algorithm too) in mind, and is wanting you to encode the domain and specific problem, to run on the solver. Without knowing more details of the assignment, I can't be sure what you need. If you're looking for a planner, as I understand it, Fast Downward is quite popular among researchers currently. The website has some instructions on how to use it, and IIRC it comes with a bunch of domains and problems for those domains. I would thoroughly recommend looking at those, they're pretty much what I learnt with. I also just found this and this.
STRIPS is essentially a way of encoding information about the nature of the problem you want the computer to find a solution to. Typically you encode a domain, which provides information about the problem overall, such as what objects may be involved, what states they can be in, and what actions can be taken. Then, you also encode a particular problem, which (generally) specifies the starting state of the problem, and what the goal state should look like. Both those files are fed into a solver, which takes them and then finds a solution to the problem. Note that this won't always necessarily be an optimal solution - that depends on what algorithm you use, and how you have told the solver what should be optimised (which I think you can generally do in the problem, though I can't remember for sure now).
I suggest you have a look at those links, and see what you can find out. That should hopefully give you a better idea of what gaps you need filled in your knowledge, and then you can narrow in on exact specifics. If this is a taught course assignment, then I would expect that surely the Prof. would have gone over some of this in lectures (do you have lecture slides available?), or at least pointed everyone towards a recommended planner and material to read up on. If you're still struggling, your best bet is to go back and see the Prof. in office hours.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm a student learning C programming (at the moment).
In the subject I was given, I have to create some kind of Wolfenstein3d clone (hence the name of the project, "wolf3d"). To do this project, I'm allowed to use either the graphic library created by my school, or the SDL. I chose the SDL, because it is more complex to use and therefore more interesting.
Unfortunately, I was not able to find any tutorial for SDL2 in C. Even the SDL wiki links were all oriented C++.
I'd be grateful if you could help me finding good tutorials for the SDL2 in C (even though I know the policy of the website is "use a search engine, which I did, but as I said, I did not find any so far).
I think I might need to explain a few things about my school, in order to not give you the impression I'm asking you for help in order to cheat:
Why don't you look in your class notes?
Because I'm not given any. I'm given projects to do and sometimes few hints as how I should do them. I'm supposed to use Google or any means as long as I understand what I did.
And that's pretty much it. I'm also not looking for a tutorial on "how to create a wolfenstein3d clone using SDL2.0", but only a tutorial on how to use the SDL2 itself, from creating a window to drawing points.
If I were you I would use the tutorials available on SDL's page here:
http://wiki.libsdl.org/Tutorials
In conjunction with the API documentation here:
http://wiki.libsdl.org/APIByCategory
The API is written in C so despite the fact that the tutorials may be in C++ you should be able to follow the tutorial by referencing the API docs and understanding the functional structure of the example programs.
As an aspiring developer you should be able to understand enough of the C++ syntax to understand the conceptual way you need to develop an analogous application in C. The API calls will be need to made in the same way.
Consider this page from one of the linked tutorials (which is stated as being for C++):
http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index2.php
Are any of those code blocks really foreign to you? They shouldn't be, they're written in C. If you come across some expressions you are unfamiliar with as you go through the tutorial, reference the API. If you're still stumped, then maybe it would be time to post on StackOverflow. That particular tutorial may be written completely in C, I'm not sure I only went through the first few pages.
Also note that the function documentation in the SDL API docs gives C and C++ example code:
http://wiki.libsdl.org/SDL_Init
Here you can cross reference two identical programs in C and C++ and begin to learn how the same operations are performed in the two languages. From there you can start to interpret C++ tutorials for high level functional operations and translate that to C as opposed to just copying code samples. You will learn much more going through this process.
To your own admission you decided to go the complex route. You should be prepared to invest some effort in the process!
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
How do you get started with competitive programming and get well versed with various topics in it ?
What all things you can do ?
Get started directly or do some concepts first.
This is a very popular question on Quora, but is generally considered off-topic for Stack Overflow. The best way to use SO for competitive programming advice is to ask specific questions about problems you're having when coding a solution. For example, you might ask how a language feature works. Often you'll find that the question has already been asked.
Here are the 108+ Quora answers to your question: https://www.quora.com/How-do-I-become-a-competitive-programmer
The summary answer is: Get started solving problems. If you have any programming background, which I'm sure you do since you're asking this question, you'll get more benefit from just starting rather than reading a lot first. When you get stuck on something, that's the time to read books or online resources.
If you're having trouble deciding what to start on, here's a suggestion from my blog of how I would get started: http://www.redgreencode.com/about-project-462/
My 2 cents...
Best option is to get registered at the following coding sites..
+ topcoder.com
+ codechef.com
+ hackerrank.com
And, while you hack code here, you can build upon your programming foundation by learning more on
+ Data structures
+ Algorithms
+ Operating system concepts
+ Networking concepts and more ...
You could also start looking at the following books in this area...
+ The Algorithm Design Manual
+ Programming Challenges: The Programming Contest Training Manual
+ Competitive Programming 2
My advice would be to get registered with a Competitive Programming site if you know how to write simple codes in a particular programming language and solve the basic problems(the ones which does not require algorithms or require basic ones).
My suggestion on the choice of site is:-
1)HackerRank:-https://www.hackerrank.com/
Problems are well categorized here.Practice the questions marked 'easy' here followed by a few 'medium' ones.Complete the '30 Days of Coding Challenge' that would give you a good basic idea of the Java language.Also, check other's code and the editorial even if your code passes all the test cases.
2)SPOJ:-
Practice the problems categorized under 'ad-hoc' here.Start by solving the problems which are solved by most people...usually they will be easier.
3)Start implementing basic(or standard) algorithms. It is suggested to read them from Topcoder tutorials or Introduction to algorithms.Also, follow a standard book along with it.Now, practice problems based on those algorithms until you get familiar with them.
4)After you get acquainted with the most common algorithms start competing in coding challenges.Practice makes you better. Try to solve problems from previous contests. Solve as many problem A-s as you can until they give you some trouble. Then move on to B, then C etc.
Hope it helps :)
P.S. Also check the following answer on Quora:-
https://www.quora.com/What-is-the-best-strategy-to-improve-my-skills-in-competitive-programming-in-2-3-months/answer/Sachin-Gupta-6?srid=4gZ6
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Suppose I've been recruited to a university study testing a new AI, and we're going to do a traditional Turing test. I will sit at a computer and interact via text-based chat with something that is either a computer or another volunteer, and then have to guess which it is.
Suppose I've been given a particularly nice incentive to get it right. How can I improve my odds? What sort of things should I talk about?
Should I try to teach the chatter a simple new concept I just made up, and then quiz them about it?
Should I try to make jokes and innuendo and see if they "get it"?
Should I ask philosophical questions?
Should I try practical questions that humans tend to "irrationally" answer in a particular way?
Try some l33t speak, that might do it. Then again I dont even understand some of it at times. Maybe I'm a computer. Maybe you're a computer
Realize that the state of the art in chatbots is still abysmal. The biggest mistake you can make is to try to do something bizarre, in which case both a human and an AI might reasonably respond in a bizarre manner. Instead, just engage in a normal conversation and resist any significant deviations proposed by your correspondent. That should easily let you identify anything operating at the current published state of the art.
If you encounter something well beyond state of the art, I think the next threshold would be a directed inquiry into a aesthetic decision: "What's your favorite [movie|book|artist|meal]? Why? So would you say you never like...? Are there aspects of that you dislike...?" etc.
Since computer programs might be very logical and high performing, but have no experience of being a human being, I would suggest questions of type trivial everyday events that wouldn't get adequate answers on Google, likely. As questions about cleaning, small details on outfits, boring and irritating situations ...
And it might be a good idea to communicate in a spoken careless way with lots of words and sentences with clear and controversial statements of the above type only here and there.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
I've been developing a highly modified version of Lua (including a rewrite of the sources to keep a better maintainability). Right now i'm at a point where I would consider forking Lua, and possibly re-release it under a different name (so people don't mistake it as the original Lua interpreter).
Of course the resulting Interpreter and compiler will be Opensource (MIT License, just as Lua5.0). but I wonder if that would be just fine with the Lua license? Can I use the Lua sources to continue my own work? do I have to keep the copyright notes?
My first suggestion would be to send an email to the Lua folks. I'm 99,9% sure you won't have any problem.
Now that I think about it, another guy create a language called "Idle" which, if I remember well, is heavily based on Lua.
As long as you properly show the due credits and fairly represent the differences with Lua, I'm sure you'll be fine.
The 'polite' thing to do is to use a different name and clearly credit on your documentation; stating that it's based on Lua but not 'official' Lua. AFAIK, the licence doesn't legally require even that; but it's what you're expected to do.
Remo.D mentioned the Idle case; personally, i don't like the attitude of "this fixes the problems with Lua" that i kinda read on Idle's webpage and his messages to the Lua list; but it's widely recognized that he's doing the right thing: a different name and openly showing credits.
If you want to be really popular in the Lua community; you could try to release your code not as a fork of Lua; but as a set of patches to the core. It's more work, I'm sure; but it has a much higher chance of being used by more people; and maybe (big maybe) some ideas could eventually be integrated in the core.