Administrator
Administrator
Posts: 3307
Joined: Thu Dec 24, 2009 2:06 am
Allegiance:: Space Rome
Location: ON, Canada
User avatar
Administrator
Administrator
Re: C++/C programming discussion

Post by Scott »

I know but how would that help?
Image
Jedi Master
Jedi Master
Posts: 336
Joined: Sun Aug 09, 2009 9:16 am
Allegiance:: Jedi
User avatar
Jedi Master
Jedi Master
Re: C++/C programming discussion

Post by Matthew »

It would have been interesting. A program that converts itself. Also it would have been easier in Python.
Administrator
Administrator
Posts: 3307
Joined: Thu Dec 24, 2009 2:06 am
Allegiance:: Space Rome
Location: ON, Canada
User avatar
Administrator
Administrator
Re: C++/C programming discussion

Post by Scott »

Always against the low level languages eh? :lol:
Image
Jedi Master
Jedi Master
Posts: 336
Joined: Sun Aug 09, 2009 9:16 am
Allegiance:: Jedi
User avatar
Jedi Master
Jedi Master
Re: C++/C programming discussion

Post 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.
Administrator
Administrator
Posts: 3307
Joined: Thu Dec 24, 2009 2:06 am
Allegiance:: Space Rome
Location: ON, Canada
User avatar
Administrator
Administrator
Re: C++/C programming discussion

Post 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.
Image
Jedi Master
Jedi Master
Posts: 336
Joined: Sun Aug 09, 2009 9:16 am
Allegiance:: Jedi
User avatar
Jedi Master
Jedi Master
Re: C++/C programming discussion

Post 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
Administrator
Administrator
Posts: 3307
Joined: Thu Dec 24, 2009 2:06 am
Allegiance:: Space Rome
Location: ON, Canada
User avatar
Administrator
Administrator
Re: C++/C programming discussion

Post 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
Image
Jedi Master
Jedi Master
Posts: 336
Joined: Sun Aug 09, 2009 9:16 am
Allegiance:: Jedi
User avatar
Jedi Master
Jedi Master
Re: C++/C programming discussion

Post by Matthew »

I deleted the question because I was stupid. It was not the problem. There is a problem somewhere though.
Administrator
Administrator
Posts: 3307
Joined: Thu Dec 24, 2009 2:06 am
Allegiance:: Space Rome
Location: ON, Canada
User avatar
Administrator
Administrator
Re: C++/C programming discussion

Post 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.
Image
Jedi Master
Jedi Master
Posts: 336
Joined: Sun Aug 09, 2009 9:16 am
Allegiance:: Jedi
User avatar
Jedi Master
Jedi Master
Re: C++/C programming discussion

Post 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.
Administrator
Administrator
Posts: 3307
Joined: Thu Dec 24, 2009 2:06 am
Allegiance:: Space Rome
Location: ON, Canada
User avatar
Administrator
Administrator
Re: C++/C programming discussion

Post 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.
Image
Jedi Master
Jedi Master
Posts: 336
Joined: Sun Aug 09, 2009 9:16 am
Allegiance:: Jedi
User avatar
Jedi Master
Jedi Master
Re: C++/C programming discussion

Post 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.
Administrator
Administrator
Posts: 3307
Joined: Thu Dec 24, 2009 2:06 am
Allegiance:: Space Rome
Location: ON, Canada
User avatar
Administrator
Administrator
Re: C++/C programming discussion

Post 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.
Image
Jedi Master
Jedi Master
Posts: 336
Joined: Sun Aug 09, 2009 9:16 am
Allegiance:: Jedi
User avatar
Jedi Master
Jedi Master
Re: C++/C programming discussion

Post 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.
Administrator
Administrator
Posts: 3307
Joined: Thu Dec 24, 2009 2:06 am
Allegiance:: Space Rome
Location: ON, Canada
User avatar
Administrator
Administrator
Re: C++/C programming discussion

Post 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.
Image
Post Reply