Page 10 of 20

Re: C++/C programming discussion

Posted: Thu Sep 23, 2010 8:32 pm
by Scott
I know but how would that help?

Re: C++/C programming discussion

Posted: Thu Sep 23, 2010 8:47 pm
by Matthew
It would have been interesting. A program that converts itself. Also it would have been easier in Python.

Re: C++/C programming discussion

Posted: Thu Sep 23, 2010 8:48 pm
by Scott
Always against the low level languages eh? :lol:

Re: C++/C programming discussion

Posted: Thu Sep 23, 2010 8:52 pm
by Matthew
Python is easy but it is slow. I want to experiment with making Python faster. Something fast and easy would be nice.

I have some sort of stack overflow somewhere it seems. A char array being freed breaks another char array. There must be stack corruption.

Re: C++/C programming discussion

Posted: Thu Sep 23, 2010 8:58 pm
by Scott
I've done a bogoMIPS of C++ and Ruby and it's quite funny how slow Ruby is in comparison. I like C++ over Ruby, and Python (although admittedly I have done little with Python). Ever language has a purpose though.
Matthew wrote:Python is easy but it is slow. I want to experiment with making Python faster. Something fast and easy would be nice.
Screw Python. Why not read up on compilers (or reverse engineer one) and make your own language! Okay, I take back my "screw Python" statement, but creating your own language would be much cooler.

Re: C++/C programming discussion

Posted: Thu Sep 23, 2010 9:08 pm
by Matthew
I'm quite keen on the Pytohn language. I'm just making my own Python implementation. I could have made a Python compiler but I like the idea of a Python to C converter.

This simplistic problem baffles me:

http://stackoverflow.com/questions/3783 ... completely

Re: C++/C programming discussion

Posted: Thu Sep 23, 2010 9:17 pm
by Scott
Matthew wrote:I'm quite keen on the Pytohn language. I'm just making my own Python implementation. I could have made a Python compiler but I like the idea of a Python to C converter.
I have desperately hoped for a Ruby compiler but the only experimental compiler sucks and does not work. Creating your own language is still an interesting concept (at least to me) but I do not have nearly enough experience to program a compiler. Here is a link I was going to edit in but you beat me to the next post: http://www.cplusplus.com/forum/lounge/27892/
Matthew wrote:This simplistic problem baffles me:

http://stackoverflow.com/questions/3783 ... completely
Page Not Found

Re: C++/C programming discussion

Posted: Fri Sep 24, 2010 12:45 pm
by Matthew
I deleted the question because I was stupid. It was not the problem. There is a problem somewhere though.

Re: C++/C programming discussion

Posted: Fri Sep 24, 2010 3:15 pm
by Scott
Matthew wrote:I deleted the question because I was stupid. It was not the problem. There is a problem somewhere though.
I hate tinkering with the stack and memory. Too many places to go wrong but I guess sometimes there aren't ways around it.

Re: C++/C programming discussion

Posted: Fri Sep 24, 2010 3:40 pm
by Matthew
No need to look at the memory at all. I just printed lots of variables and found the problem. I wasn't replacing the pointer which will point to a freed memory block with the new pointer returned by a function.

Never a good idea to use pointers to freed memory blocks.

Re: C++/C programming discussion

Posted: Sat Sep 25, 2010 12:39 pm
by Scott
To maintain this thread (as it's an interesting topic) I have something of a conversation starter I've brought up on cplusplus.com...
MottMan wrote:How would someone go about making a calculator? I mean a physical calculator not simply a console based or GUI calculator. Obviously parts would be needed, ect, ect, but I am interested in knowing that if anyone here was told to make a calculator how you would do it.


Of course a calculator is not a beginner project for coupling hardware and software, but what is? Coupling the two together has been an interest of mine for a while but I never knew where to start.

Re: C++/C programming discussion

Posted: Sat Sep 25, 2010 1:47 pm
by Matthew
You can buy simple electrical components for not too much money. It seems making your own circuit boards is rather awkward. You could try out wiring components with a breadboard.

For a calculator, you obviously need some pressure switches, LED 8-segment displays and a processor.

When I did electronics AS, we looked at PIC chips. You might want to try one of those. You can get a development board to program and test them. We used PIC assembly but I think you can get simple compilers also.

Re: C++/C programming discussion

Posted: Sun Sep 26, 2010 4:20 pm
by Scott
Matthew wrote:You can buy simple electrical components for not too much money. It seems making your own circuit boards is rather awkward. You could try out wiring components with a breadboard.

For a calculator, you obviously need some pressure switches, LED 8-segment displays and a processor.

When I did electronics AS, we looked at PIC chips. You might want to try one of those. You can get a development board to program and test them. We used PIC assembly but I think you can get simple compilers also.
AS? :?:

Would you think this would be impossible? Or plausible? I'd really like to try but if you think there's no chance I probably wouldn't have much faith then either.

Re: C++/C programming discussion

Posted: Sun Sep 26, 2010 5:04 pm
by Matthew
It is entirely possible. It might look crap but it would work.

There seems to be a few PIC chips. The one I was using had only 13 bits for I/O. If you get one like that 4 bits could be used to get a digit to display, maybe 5 bits for the input (0-9,+,-,/,*,=,C,M,M+,M-,^ etc),If you have room for 15 digits on display, you could use 4 more bits to select the digit for display.

AS is a qualification in England, Wales and Northern Ireland.

Re: C++/C programming discussion

Posted: Sun Sep 26, 2010 5:11 pm
by Scott
I'm not too worried about the electronics side of things but more about the software. I'm sure I could pick up any language to learn arithmetics but would I need native code? Or Assembly? Sorry for all the questions but if I try this I want to be informed and prepared.