Brainstorming is good. Getting stuff done in the problem, my boss is always pushing me to do "reality storming":)
No probs emulating a 32 processor on an 8 it. Just very slow and you soon run out of memory address space.
The single instruction set comupter makes my brain itch as well. The Single Instruction Cet Komputer (SICK) may well be the next emulator on the Propeller for me. Especially attractive as there is a compiler for it. Interesting how that guy built 28 32Bit processors with 2K memory each on a $30 FPGA running at 150MHz. Sounds like a Prop no?
Back in the day when C first started, memory was expensive. So you declared variables at the beginning of a function and threw them away at the end. But it takes time to create them and throw them away.
It does not take time on most processors, or at least very little. Want 10 local variables in a function? Just bunp the stack pointer by 10 places. Accessing them via stack + offest instructions takes the same time as accessing fixed global RAM.
Anyway that is not why they did that:
1) Limiting scope of variables to your function makes your program easier to comprehend. You never end up reusing a variable that some other function is using. That's the general, "globals are bad" rule in software construction.
2) Having local variables on stack in functions means you can make those functions recursive. Which makes solving a whole l ot of problems much easier. Writing a recursive decent parser for a compiler for examlple.
Anyway, could it be more deterministic to create variables but never throw them away? Maybe they are global variables, but for code neatness only the function that created them can use them?
You can already do this in C. Just put the "static" keyword on your variable declarations within functions and they are no longer on stack. When a fuction is called a second time the variables will have whatever values wre there the last time it was called.
Static variables might speed up C on the Prop a bit as the Prop has no stack relative addressing instructions.
So if you are thinking of another emulator, how about a hybrid stack and register system?
Given that such a proposed machine architecture does not exist and so there is nothing to emulate it would be better if we called it a virtual machine. Anyway I'm not really up for doing such a thing as we then end up with a VM for which we have no language compilers.
It seems there are a number of languages that serve as simplified front ends to complicated languages like Java or C++. I like the way these programs are sold as suitable for "artists"...
I wonder, as an abstract idea, whether it is possible to simplify C by never using pointers? For a function that returns a value, you don't need pointers. Pass the values, and return a value. If you want to modify the values, well in a way, that introduces the bad aspects of having global variables, where another function miles away in another part of the code modifies something. So, the only exception to pointers is when you pass the pointer to an array, and that seems simpler in C anyway, and it also makes sense to pass one variable rather than copying arrays every time a function is called. So - "no pointer C". That could make C and C++ more manageable...
Going off on a tangent, I just got myself a 4 channel helicopter (the F45) and it is by far the best helicopter I have ever bought. Easy to fly for beginners plus it can do some simple tricks if the flyer is up to it. Great price, but the catch is that all the instructions were in Chinese. I got it flying anyway. I ran this past my dad and he said that he never read the instructions in life anyway, and now that so many things come with instructions only in Chinese, he is now ahead of the average punter.
So this could be a design challenge for a new language. No instructions at all!
How about it starts off with a long list of all the library functions, like the OBJ of a Spin program, but virtually all of these are commented out. So you have
which a C programmer and other language programmer should be able to work out.
Now later, if you use this, you type stdio. and as soon as you hit the period button, up comes a drop down menu with all the methods. One of the methods would be printf for the C programmers, and for the basic programmers it could be duplicated as print, and the C flavour one has \n and the basic one might have crlf. The only thing slightly strange is that you use this as "stdio.printf("Hello World")
Then you don't need any help menu. You can quickly scroll through all the methods in a class just by uncommenting it and typing its name.
Add in autocompletion of braces. Maybe each object contains the rules about color highlighting and the IDE and compiler start to be very easy projects (popping up a dropdown menu at the mouse location in a richtextbox is pretty easy in C# and ought to be easy in other languages). I guess the IDE has to be written in C++ if we take the vibe of where this thread is going.
He he. If Wiring and Processing are so simple that they can even be used by artists, maybe 'dogs breakfast' can be so simple it can even be used by politicians? Donning flame proof suit now
Addit
Given that such a proposed machine architecture does not exist and so there is nothing to emulate it would be better if we called it a virtual machine. Anyway I'm not really up for doing such a thing as we then end up with a VM for which we have no language compilers.
Good point. Everything probably best to compile to LMM or to cached LMM for the propeller.
I agree re global variables. Yes good point re moving the stack pointer. Is that how zog works? Hmm - maybe time to revisit Zog. Can Zog do caching?
I wonder, as an abstract idea, whether it is possible to simplify C by never using pointers?
Sure it is. In fact Go, XC and other languages have done so. In Go for example you can have pointers but you cannot do any pointer arithmetic so you have to access into arrays via normal array indexing. Effectively pointers become references so that you can pass parameters by reference rather pass by value which would require them to be copied.
Yes, Zog, or rather the ZPU compiler does that move the stack pointer thing to make space for local variables, it has been common in compilers for ages.
Zog does have cached access to external memory for speed.
Zog is a bit of a curio, only of academic and historical interest (It was the first time GCC compiled 32 bit code from C to run on the Propeller). It may have had a real world use due to it's smaller byte codes but now we have Catalina and GCC are using CMM that is a better option.
My kids learned Taekwondo when they were young. I was with them through it all to help them learn the steps in the different "forms" or exercise sequences they had to master to advance. Wish I had practiced with them instead of just looking at the notes.
A "form" is essentially a program of steps. Using a language to is sort of like doing forms. There are several forms for beginners and beyond. Each form teaches new techniques and exercises key muscle groups. Programming involves techniques too. Blinking an LED is is like a white-belt form. Writing a serial port driver is like a blue-belt form. There are many levels that can be analogies.
Bottom line IMHO is that people should at least become a black-belt in one language before moving on to another. Going through the motions to learn all the "forms" is really important. Some forms won't be available in all languages though, so learning more than one language eventually is very valuable in that it offers perspectives and raises the bar.
Where to start is an interesting subject of course. I started seriously with a language that made it easier to spread my wings thanks to various reasons.
I learned basic in the early years of the PC, then Pascal, then C and derivatives. I hated Dartmouth BASIC, but didn't have much choice in early computers. PBASIC is very different of course and my opinion of it is much better. I grimaced at COBAL and those punch-cards. Pascal was the first language I actually liked. Once I learned C though, I never looked back.
Spin has some organizational advantages over C, but generally it's not good for enterprise class systems because of it's limits and lack of pre-compiled library support. That being said, I think Spin really is a great learner's language. Many people want to go further than Spin's training wheels will allow though.
I guess every new language that has been invented has been done by people frustrated with existing languages. C and Spin are both great, the contents of the objects seem to be deliberately hidden from the user. In Spin for instance, a better way for all obex code to be organised would be for all PUB methods to be listed ahead of all PRI methods, as the user of the object doesn't need to know about the PRI methods. Some conform to this standard, but some are alphabetical, and some are just the order the methods were written. An IDE could reorder the methods as an option. Even better would be autocompletion of PUB methods. Maybe code::blocks or Eclipse or one of those programs could do this?
As for C, I've found it hard to articulate the problem, but someone here http://forums.codeguru.com/showthread.php?474119-C-IDE-and-Intellisense asks the same question. C libraries could be treated as classes but they don't seem to work that way, and maybe this was why C++ was invented?
For the Propeller, an ideal language also needs to integrate pasm better. When the prop first came out SD drivers didn't exist, so pasm has ended up sitting in hub, and it still irks me that a typical Spin program wastes nearly half the hub ram to hold pasm programs. There are many other ways to do this as the pasm code could be precompiled and loaded to either an SD card or to a larger eeprom, and immediately give the user another 14k of code space. So an IDE ought to have that as an option. Or it could be new keywords added to the language.
C could do this too but many of the drivers keep things hidden from the user, and if you want to become a black belt you really need to be hacking into any and all of the objects in the obex at the assembly level and tweaking them and making them run better.
I guess there is also the issue of how you set compile options - eg like where pasm code should be compiled to. There are at least three ways - as drop down menus in an IDE, as command line options, or as text in the program. Each has its merits. I kind of prefer the last one with text in the program, as you can add comments to explain what is going on (cf command line options where often the options are a single letter and you have to read the help file to find out what it means). I don't know all the answers to this.
I'm intrigued by all the languages that have been mentioned here. So many to choose from!
Bottom line IMHO is that people should at least become a black-belt in one language before moving on to another.
Well that is one perspective, however that perspective does not fit into my grand scheme. After dabbling in HTML, JavaScript, and PERL for quite some time, I had a serious project that I wanted to undertake, and I initially chose J++ for this task, because I thought it was the tool for the job. After messing with the ide a while and checking out all the various documentation, I soon discovered that this was not the language that I should be learning, so I dropped it like a hot potato and started learning C++ instead. If I ever come to the conclusion that I have been wasting my time in a specific subject, I certainly don't waste anymore time becoming an expert at it.
Bruce
EDIT: My philosphy is to learn specific areas of interest that benefit you the most. So mix it up: http://www.jukadousa.com/
Even better would be autocompletion of PUB methods. ...
I added this to SimpleIDE version 0-8-5 but the white-belts had a fit. Guess it doesn't matter since the next SimpleIDE's release will temporarily remove SPIN support.
wxSmith for buttons, pull in the spin/pasm drivers for the touchscreen and it might be possible to run GUI programs on a PC and run the same program on the propeller. Reduced color/more pixels should also be able to do VGA and TV. Maybe grayscale VGA to start as doesn't need any special hardware. Bursting with ideas at the moment. Thanks SRLM.
Ha, you just remeinded me that I once had a book teaching how to create Win32 GUI apps in assembler!
I worked through some of the examples and found it easier to understand than the same stuff in C++:)
Shame I can't recall the author or title now.
I learned C, then hit a wall trying to learn C++. I read through a BUNCH of books, but nothing really clicked for me. Then I found a book explaining how to do Windows GUI in C++ ("Windows++") and that finally made everything clear. I think it was the fact that the author was building something constructive through the book, rather than showing isolated examples.
Ha! You and a billion other people. That's why we have Java and C# and Python and anything else to get out of that C++ mess.
As an example from my own code using C++ and the Qt GUI toolkit. Lets say I have a hash map of keys and values, both strings, and I want to iterate over all the items in it, it goes like this:
for (QMap<QString, QString>::const_iterator item = myMap->constBegin(); item != myMap->constEnd(); ) {
QString key = item.key();
QString value = item.value()
// Do something with item
}
In JavaScript that might look like this:
for (var key in myMap) {
var value = myMap[key];
// Do something with item
}
In Python we might only have:
for key, value in myMap
# Do something with item
OK they are not type safe so how about the Go language:
for key, value := range myMap {
// Do something with item
}
Jazzed or any C++/Qt gurus out there, what can I do about that C++ nonsense?
As it happens that code is out of a server process I wrote. I just created a JavaScript implementation of the same thing using node.js and it runs as fast as the C++ version!!
BASIC has always served me well and has never left me wanting. In the DOS days it was QuickBASIC (well, PDS 7.1). I soon learned how to write and link .asm routines to the BASIC .obj's and achieved great results.
I have always been writing machine-control software and I wasn't happy when a floppy disk access would bring everything to a grinding halt. I discovered some print-spooler asm code where the clock interrupt had been sped-up (compensated for to maintain time-keeping) and intercepted to point at other code. I created my own routines for the time-critical stuff and set the interrupt for as near to 1KHz as possible. Furthermore, I shared variables with the top-level BASIC code so I didn't need to call any routines to pass values. So I ended-up with QuickBASIC running on a system that was essentially hard real-time. I could set a BASIC variable to a value and the low-level timer-interrupt code would be updated and vice-versa (is this inheritance?). Even the threaded P-code stuff worked (using the IDE)...Talk about rapid development!
When Windows came along, I took an instant disliking to VB so I switched to PowerBASIC as it doesn't have any runtime dependencies, has inline .asm and supports code-pointers.
Today we are developing for Android and 90% of what we do is in BASIC4Android (some Java).
Propeller: Attempting to use nothing but PropBASIC
I have tried to learn java many times along with get even a "blie belt" in cpp, im not sure why i have never accomplished either. iv been trying to get through a full java book since jdk 1.2... maybe 1998/1998 it first started with chat room applets and now android. the only book i have now is bruce eckels thinking in java ive always heard it so great but it puts me to sleep. i think my biggest issue with java is that i always have specific programs in mind which only java can do and i just get add becuase i dont care about polyymorphism or garbage collection i just want to know it and master oop so i can learn the stuff im into. now that im getting a tablet i may acually read an ebook on it, i hate my eink nook.
as far as gui then code this is exactly how i write vb programs, or c win32 code. i sit down draw all the windows on paper then code or drag and drop a gui. after thats gone i do code for each window and windows linked to it. im hoping thiz new intfest in processing will ease me in to some real java. lately ive just been worried about the future of java i dont trust oracle much
I think part of my problem is OOP im just not a fan. I like objects as they are implemented in spin/vb and even setting up type defs in C kind of like the quake2 source code for wanna be oop. I started programming in GW Basic then C then VB,VC then a bit of Assembly and more recently python which is oop. I did take the C++ courses at gameinstitue.org when it use to be more like a school. I just hate how CPP and especially Java material want to drone on for days about the OOP paradigm its such a fanboy perspective I guess. Like I said I like simple objects I think they help alot when VB got class modules I was all over it but haveing to figure out all this hard core oop stuff just puts me right to sleep... Im hoping processing will maybe shift my thinking from such a procedural paradigm but who know. Give me C and a command line or Give me death . This is why I never made it as a coder.... Im intrested in learning things near the hardware level and its an aging art on a PC, I spent two years in high school doing work in VB, right before .net came out and I wanted to rip my eyes out at work doing all this boring SQL data processing and ASP web page stuff.. I have a web page http://www.lowlevel-logicdesign.com I just cant seem to get past where its at now becuase I cant motivate myself, every time I work on it I feel bad im not soldering a board togather or learning a new micro. Im hoping this new found world of micros and hardware may some day lead into professional development I can stand... I never applied for another coding job again except with game company's after that "corporate world" type codeing job, simply becuase it took the joy out of using my computer and I had to learn stuff in my off time I really would have rather used learning assembly language. Im an electrician by trade, and im hoping maybe in a few years I can intergrate electronics with my job and to do some really cool things around the house. For me processing seems like a godsend it will allow me to focus on the things I want to do and quickly whip up a nice front end for windows/linux/android without snoozing through another inheritance chapter
I've spent a few more days downloading lots of programs and testing them. Lots of dead ends. I've got spoiled with the intellisense of C# and VB.Net. C++ is not so intuitive as I find I have to keep going back to the books. There seem to be very few IDEs where an object's public methods come up automatically when one types the objects name (the Spin tool falls over here too). Wxwidgets are messy - draw a button on the screen and it goes purple and nothing displays till you add the second widget. Half the autocompletion works and half doesn't. The BCX to C++ converter which has worked so well for text based programs has fallen over when translating GUI programs with huge numbers of errors in the C code.
In an ideal world, I'd like to include the stdio library, and I'd like to type 'stdio.' and all the public methods in that library would appear. Maybe the .net IDE is the only one that really gets this right, and if so, perhaps a GUI for the propeller has to be built within the .net framework?
I haven't tried Qt yet. It is a big program. Does it have 'drag and drop' for buttons and intellisense autocompletion for objects?
I'm starting work on an IDE with a custom form of intellisense. Create a rich text box, put a drop down menu on that text box, hide it, then monitor keypresses and if it matches a series of strings, check the cursor position and unhide the drop down menu and fill it up with suggestions. This is the sort of thing .net does well.
The holy grail of running on multiple platforms might have to go, unless I can find something as good as the .net IDE.
So - languages. I have a lot of trouble understanding C++, especially when talking to a GUI like windows. Half of what wxwidgets autowrites seems confusing to me. C makes a lot more sense to me but there do not seem to be IDEs that make writing code easier. I guess when C was around it was being written in text editors and not in drag-and-drop IDEs. Basic is simpler to understand but there are still a lot of keywords. I grew up with MID$ and LEFT$ etc but I have grown to like the .net way even more where, you include a strings object, and use strings.mid() strings.left() etc and it tells you how many parameters to pass etc. Spin is hamstrung by the 32k hub ram limit. I checked out javascript and vbscript but there are a lot of commands missing, eg file access and I guess that is deliberate to stop script kiddies hacking computers. html has some interesting possibilities. Python might be possible.
What many of these languages need (apart from C and C++ which are already done) is a compiler. So that has taken me down the road of looking at a new RISC language for the propeller. Brainstorming here...
Programs are compiled to assembly and run from a cog. If a cache access is needed from hub, or from external ram, that is handled by spin or another cog. It is a hybrid stack/register machine, so that can tap into the Forth work. There are 16 registers r0 to r15 for longs, and b0-b7 byte registers. These exist in a cog. There is a 32 bit stack pointer also in the cog, and the stack itself exists in hub ram. There is a pseudo PC program counter which does not get incremented each instruction, but it does get updated every jump/call/ret.
The compiler has a complex job. It needs to chop a program up into 2k chunks (a bit less than 2k, as the registers need to stay static).
All instructions that exist in pasm and which are not jumps/calls etc are simple to code. If the compiler comes across a jump, it stores the jump location in a jump register, and then goes to a little routine included in every 2k code fragment. Put the PC jump location in a hub variable.Set a flag to spin/another cog that a jump is requested. The 'cache' cog process this and loads in new blocks of code if needed (and jumps to the correct location, and I don't know how to do that bit. In 8080 you could cheat and push a new PC onto the stack, and then do a RET popped it back off the stack and wen to that location).
Local jumps stay within the 2k fragment. If the code gets to the end of the 2k block it also notifies the cache driver.
There is a little more work for the compiler. Make sure no subroutines are split. Keep a list of 'local' constants that are more than 9 bits and put these in the DAT section.
The point of all this is to try to build a system that can run faster than LMM as most of the time, it is running standard pasm code, not pasm code being loaded every instruction from hub.
I'm not sure how to reload new chunks of code. A cognew, (but that overwrites the registers), or a little routine that just does a loop with around 400 rdlongs.
The aim is to emulate a flat memory space of 32 bits. Maybe fix a few pasm limitations along the way like the problem of constants being limited to 9 bits.
With such a program, compilers for multiple languages should be possible.
QtCreator is the Qt development IDE. It has auto-complete and many other great and helpful features.
Qt supports GNU C/C++ (Linux, Mac, or MinGW ) and VisualC++.
Qt makes C++ fun. Limiting oneself to C++ STL (or other old junk) is really silly.
Qt provides lots of wonderful libraries that makes STL look totally stupid.
Qt class help is context sensitive in Qt creator and very helpful (both local and on-line).
There may be a brief learning curve with Qt and QtCreator, but if you've used VisualStudio or Netbeans it's easy to learn.
Looks like Qt is also going to be officially supported on Android soon as well.
It's also the basis of the new Sailfish OS for mobile phones from Jolla and today I hear it's used on the new Blackberry 10 phone.
Did I mention it works on that Raspberry Pi and other ARM boards.
I was worried about what might happen to Qt given that it was owned by Nokia which has now been screwed over my MS and forced not to use it.
However it looks like Qt's future development is secure.
Thanks guys. Invaluable advice as always. I avoided Qt previously as it was a 500mb download but my ISP recently increased my download to 30G a month at no extra cost, so I'm downloading Qt right now.
Amazing, I'm sure I remember downloading the first version of the K Desktop Environment (KDE) for Linux, based on Qt, at work and taking it home on a bunch of floppy disks. Still that was last century, you could still take Windows home on a bunch of floppies as well.
This thread has got me psyched up to try PerlQt now. Although I'm happy, for the most part, with Perl/Tk, it does have its quirks; and some of its GUI themes still look like last century's X-Windows.
In an ideal world, I'd like to include the stdio library, and I'd like to type 'stdio.' and all the public methods in that library would appear. Maybe the .net IDE is the only one that really gets this right,
When ever you are dealing with a class object in C++, the class members do appear. An example screen shot is shown below. But I do understand your pain... C++ is difficult to get a grasp on, but when you do.... Look out baby....
Ok, downloaded Qt. I ran through the tutorials and tried a demo program but ran into a small problem. It says I don't have a compiler. Well I guess that makes sense as I had a big cleanout of the hard drive yesterday and removed all those other compilers that *didn't* have intellisense. Maybe I got a bit too keen there!
So, Qt gives you three choices of compiler in the dropdown menu, so I picked the first one which is MinGW. I downloaded that (which, heater, no doubt would not fit on a floppy disk any more) and that is happily sitting in the c:\mingw folder.
Now the next step - tying them together. Qt says it will auto find compilers but it didn't work so I rebooted windows but it still can't find it. I followed the Qt tutorial here http://doc.qt.digia.com/qtcreator-2.4/creator-tool-chains.html and in the last screenshot I tried to point it to c:\mingw\bin\gcc.exe but it still says there is no compiler. The first screenshot shows the error at the bottom saying it hasn't got a compiler.
I've tried a few other things, like copying that tutorial link exactly to see if MinGW happened to be included in the Qt package I downloaded but I can't find it in any subdirectories.
I then went to the internet and there is some poor sod on a discussion forum that says he spent two days trying to do this
There also are some older discussion posts that talk about changing the path settings in windows but I wonder if that is still the way things are done, given there is that menu in Qt to set the compiler.
I'm quite happy to uninstall mingw and Qt and reinstall the lot if there is a package out there that can make this easier. Or download another compiler (GCC is the second one on the list that Qt suggests).
Qt has a gorgeous looking front end, so I'm sure it must be just as easy to work with once it has a suitable compiler.
Any help here would be most appreciated.
Addit
@idbruce
C++ is difficult to get a grasp on, but when you do.... Look out baby
Yea, I'm still at the newbie stage. The printf("hello world"); part of C is easy. The hard part is the myriad of files and libraries and subdirectories and path changes and working out (real world example here) whether the compiler is in c:\mingw\bin or in c:\mingw\mingw32\bin and working out whether it is not compiling because of an error in the code or because it can't find a component somewhere in a subdirectory. I've stripped a number of C programs back to just a one line main() with no #includes at all and still had them not compile.
I think C was written by nerds. I'm a nerd too, but C was written by *hardcore* nerds!
Qt looks good and I'm looking forward to getting it going.
Wait a minute, which package did you download?
I have installed Qt on Windows a bunch of times and it always came with the compiler and everything ready to rock.
Ah, that might explain things. I got the download by searching for "Qt download" which took me to this page http://qt-project.org/downloads
But rereading that page again, it seems that is not the whole package. And beta version 5 like you say. Beta installers probably have a compiler so won't have flagged that as an error yet?
Ok, uninstalling Mingw and Qt and re-downloading now...
Addit - no that package doesn't have Mingw either. See screenshot. The hyperlink redirects to the Qt home page rather than to the download page, and so maybe I'll have to get Mingw from elsewhere. Hopefully it will play nice with Qt.
Comments
Brainstorming is good. Getting stuff done in the problem, my boss is always pushing me to do "reality storming":)
No probs emulating a 32 processor on an 8 it. Just very slow and you soon run out of memory address space.
The single instruction set comupter makes my brain itch as well. The Single Instruction Cet Komputer (SICK) may well be the next emulator on the Propeller for me. Especially attractive as there is a compiler for it. Interesting how that guy built 28 32Bit processors with 2K memory each on a $30 FPGA running at 150MHz. Sounds like a Prop no? It does not take time on most processors, or at least very little. Want 10 local variables in a function? Just bunp the stack pointer by 10 places. Accessing them via stack + offest instructions takes the same time as accessing fixed global RAM.
Anyway that is not why they did that:
1) Limiting scope of variables to your function makes your program easier to comprehend. You never end up reusing a variable that some other function is using. That's the general, "globals are bad" rule in software construction.
2) Having local variables on stack in functions means you can make those functions recursive. Which makes solving a whole l ot of problems much easier. Writing a recursive decent parser for a compiler for examlple. You can already do this in C. Just put the "static" keyword on your variable declarations within functions and they are no longer on stack. When a fuction is called a second time the variables will have whatever values wre there the last time it was called.
Static variables might speed up C on the Prop a bit as the Prop has no stack relative addressing instructions. Given that such a proposed machine architecture does not exist and so there is nothing to emulate it would be better if we called it a virtual machine. Anyway I'm not really up for doing such a thing as we then end up with a VM for which we have no language compilers.
It seems there are a number of languages that serve as simplified front ends to complicated languages like Java or C++. I like the way these programs are sold as suitable for "artists"...
I wonder, as an abstract idea, whether it is possible to simplify C by never using pointers? For a function that returns a value, you don't need pointers. Pass the values, and return a value. If you want to modify the values, well in a way, that introduces the bad aspects of having global variables, where another function miles away in another part of the code modifies something. So, the only exception to pointers is when you pass the pointer to an array, and that seems simpler in C anyway, and it also makes sense to pass one variable rather than copying arrays every time a function is called. So - "no pointer C". That could make C and C++ more manageable...
Going off on a tangent, I just got myself a 4 channel helicopter (the F45) and it is by far the best helicopter I have ever bought. Easy to fly for beginners plus it can do some simple tricks if the flyer is up to it. Great price, but the catch is that all the instructions were in Chinese. I got it flying anyway. I ran this past my dad and he said that he never read the instructions in life anyway, and now that so many things come with instructions only in Chinese, he is now ahead of the average punter.
So this could be a design challenge for a new language. No instructions at all!
How about it starts off with a long list of all the library functions, like the OBJ of a Spin program, but virtually all of these are commented out. So you have
which a C programmer and other language programmer should be able to work out.
Now later, if you use this, you type stdio. and as soon as you hit the period button, up comes a drop down menu with all the methods. One of the methods would be printf for the C programmers, and for the basic programmers it could be duplicated as print, and the C flavour one has \n and the basic one might have crlf. The only thing slightly strange is that you use this as "stdio.printf("Hello World")
Then you don't need any help menu. You can quickly scroll through all the methods in a class just by uncommenting it and typing its name.
Add in autocompletion of braces. Maybe each object contains the rules about color highlighting and the IDE and compiler start to be very easy projects (popping up a dropdown menu at the mouse location in a richtextbox is pretty easy in C# and ought to be easy in other languages). I guess the IDE has to be written in C++ if we take the vibe of where this thread is going.
He he. If Wiring and Processing are so simple that they can even be used by artists, maybe 'dogs breakfast' can be so simple it can even be used by politicians? Donning flame proof suit now
Addit
Good point. Everything probably best to compile to LMM or to cached LMM for the propeller.
I agree re global variables. Yes good point re moving the stack pointer. Is that how zog works? Hmm - maybe time to revisit Zog. Can Zog do caching?
Yes, Zog, or rather the ZPU compiler does that move the stack pointer thing to make space for local variables, it has been common in compilers for ages.
Zog does have cached access to external memory for speed.
Zog is a bit of a curio, only of academic and historical interest (It was the first time GCC compiled 32 bit code from C to run on the Propeller). It may have had a real world use due to it's smaller byte codes but now we have Catalina and GCC are using CMM that is a better option.
A "form" is essentially a program of steps. Using a language to is sort of like doing forms. There are several forms for beginners and beyond. Each form teaches new techniques and exercises key muscle groups. Programming involves techniques too. Blinking an LED is is like a white-belt form. Writing a serial port driver is like a blue-belt form. There are many levels that can be analogies.
Bottom line IMHO is that people should at least become a black-belt in one language before moving on to another. Going through the motions to learn all the "forms" is really important. Some forms won't be available in all languages though, so learning more than one language eventually is very valuable in that it offers perspectives and raises the bar.
Where to start is an interesting subject of course. I started seriously with a language that made it easier to spread my wings thanks to various reasons.
I learned basic in the early years of the PC, then Pascal, then C and derivatives. I hated Dartmouth BASIC, but didn't have much choice in early computers. PBASIC is very different of course and my opinion of it is much better. I grimaced at COBAL and those punch-cards. Pascal was the first language I actually liked. Once I learned C though, I never looked back.
Spin has some organizational advantages over C, but generally it's not good for enterprise class systems because of it's limits and lack of pre-compiled library support. That being said, I think Spin really is a great learner's language. Many people want to go further than Spin's training wheels will allow though.
My $0.02
I guess every new language that has been invented has been done by people frustrated with existing languages. C and Spin are both great, the contents of the objects seem to be deliberately hidden from the user. In Spin for instance, a better way for all obex code to be organised would be for all PUB methods to be listed ahead of all PRI methods, as the user of the object doesn't need to know about the PRI methods. Some conform to this standard, but some are alphabetical, and some are just the order the methods were written. An IDE could reorder the methods as an option. Even better would be autocompletion of PUB methods. Maybe code::blocks or Eclipse or one of those programs could do this?
As for C, I've found it hard to articulate the problem, but someone here http://forums.codeguru.com/showthread.php?474119-C-IDE-and-Intellisense asks the same question. C libraries could be treated as classes but they don't seem to work that way, and maybe this was why C++ was invented?
For the Propeller, an ideal language also needs to integrate pasm better. When the prop first came out SD drivers didn't exist, so pasm has ended up sitting in hub, and it still irks me that a typical Spin program wastes nearly half the hub ram to hold pasm programs. There are many other ways to do this as the pasm code could be precompiled and loaded to either an SD card or to a larger eeprom, and immediately give the user another 14k of code space. So an IDE ought to have that as an option. Or it could be new keywords added to the language.
C could do this too but many of the drivers keep things hidden from the user, and if you want to become a black belt you really need to be hacking into any and all of the objects in the obex at the assembly level and tweaking them and making them run better.
I guess there is also the issue of how you set compile options - eg like where pasm code should be compiled to. There are at least three ways - as drop down menus in an IDE, as command line options, or as text in the program. Each has its merits. I kind of prefer the last one with text in the program, as you can add comments to explain what is going on (cf command line options where often the options are a single letter and you have to read the help file to find out what it means). I don't know all the answers to this.
I'm intrigued by all the languages that have been mentioned here. So many to choose from!
Well that is one perspective, however that perspective does not fit into my grand scheme. After dabbling in HTML, JavaScript, and PERL for quite some time, I had a serious project that I wanted to undertake, and I initially chose J++ for this task, because I thought it was the tool for the job. After messing with the ide a while and checking out all the various documentation, I soon discovered that this was not the language that I should be learning, so I dropped it like a hot potato and started learning C++ instead. If I ever come to the conclusion that I have been wasting my time in a specific subject, I certainly don't waste anymore time becoming an expert at it.
Bruce
EDIT: My philosphy is to learn specific areas of interest that benefit you the most. So mix it up: http://www.jukadousa.com/
I added this to SimpleIDE version 0-8-5 but the white-belts had a fit. Guess it doesn't matter since the next SimpleIDE's release will temporarily remove SPIN support.
I missed that. "White belts" as in, newbies?
Copyright condenaststore.com
A link to remind me later to this thread http://forums.parallax.com/showthread.php?143950-solved-PropGCC-and-Code-Blocks-Tutorial
wxSmith for buttons, pull in the spin/pasm drivers for the touchscreen and it might be possible to run GUI programs on a PC and run the same program on the propeller. Reduced color/more pixels should also be able to do VGA and TV. Maybe grayscale VGA to start as doesn't need any special hardware. Bursting with ideas at the moment. Thanks SRLM.
Perhaps you can elaborate on that. Why? For example. Hope there will be a build option to include Spin support.
It's purely for planning purposes. SPIN functionality will be available with DEFINES+=SPIN.
The next binary release will be for a set of customers who won't use SPIN.
Wow, just noticed that the book is 20 years old!
As an example from my own code using C++ and the Qt GUI toolkit. Lets say I have a hash map of keys and values, both strings, and I want to iterate over all the items in it, it goes like this: In JavaScript that might look like this: In Python we might only have: OK they are not type safe so how about the Go language: Jazzed or any C++/Qt gurus out there, what can I do about that C++ nonsense?
As it happens that code is out of a server process I wrote. I just created a JavaScript implementation of the same thing using node.js and it runs as fast as the C++ version!!
I have always been writing machine-control software and I wasn't happy when a floppy disk access would bring everything to a grinding halt. I discovered some print-spooler asm code where the clock interrupt had been sped-up (compensated for to maintain time-keeping) and intercepted to point at other code. I created my own routines for the time-critical stuff and set the interrupt for as near to 1KHz as possible. Furthermore, I shared variables with the top-level BASIC code so I didn't need to call any routines to pass values. So I ended-up with QuickBASIC running on a system that was essentially hard real-time. I could set a BASIC variable to a value and the low-level timer-interrupt code would be updated and vice-versa (is this inheritance?). Even the threaded P-code stuff worked (using the IDE)...Talk about rapid development!
When Windows came along, I took an instant disliking to VB so I switched to PowerBASIC as it doesn't have any runtime dependencies, has inline .asm and supports code-pointers.
Today we are developing for Android and 90% of what we do is in BASIC4Android (some Java).
Propeller: Attempting to use nothing but PropBASIC
It's all very BASIC
Mickster
as far as gui then code this is exactly how i write vb programs, or c win32 code. i sit down draw all the windows on paper then code or drag and drop a gui. after thats gone i do code for each window and windows linked to it. im hoping thiz new intfest in processing will ease me in to some real java. lately ive just been worried about the future of java i dont trust oracle much
Do this in Qt:
There are equivalents in Java, C#, php, and other languages.
Here's another way in Qt:
In an ideal world, I'd like to include the stdio library, and I'd like to type 'stdio.' and all the public methods in that library would appear. Maybe the .net IDE is the only one that really gets this right, and if so, perhaps a GUI for the propeller has to be built within the .net framework?
I haven't tried Qt yet. It is a big program. Does it have 'drag and drop' for buttons and intellisense autocompletion for objects?
I'm starting work on an IDE with a custom form of intellisense. Create a rich text box, put a drop down menu on that text box, hide it, then monitor keypresses and if it matches a series of strings, check the cursor position and unhide the drop down menu and fill it up with suggestions. This is the sort of thing .net does well.
The holy grail of running on multiple platforms might have to go, unless I can find something as good as the .net IDE.
So - languages. I have a lot of trouble understanding C++, especially when talking to a GUI like windows. Half of what wxwidgets autowrites seems confusing to me. C makes a lot more sense to me but there do not seem to be IDEs that make writing code easier. I guess when C was around it was being written in text editors and not in drag-and-drop IDEs. Basic is simpler to understand but there are still a lot of keywords. I grew up with MID$ and LEFT$ etc but I have grown to like the .net way even more where, you include a strings object, and use strings.mid() strings.left() etc and it tells you how many parameters to pass etc. Spin is hamstrung by the 32k hub ram limit. I checked out javascript and vbscript but there are a lot of commands missing, eg file access and I guess that is deliberate to stop script kiddies hacking computers. html has some interesting possibilities. Python might be possible.
What many of these languages need (apart from C and C++ which are already done) is a compiler. So that has taken me down the road of looking at a new RISC language for the propeller. Brainstorming here...
Programs are compiled to assembly and run from a cog. If a cache access is needed from hub, or from external ram, that is handled by spin or another cog. It is a hybrid stack/register machine, so that can tap into the Forth work. There are 16 registers r0 to r15 for longs, and b0-b7 byte registers. These exist in a cog. There is a 32 bit stack pointer also in the cog, and the stack itself exists in hub ram. There is a pseudo PC program counter which does not get incremented each instruction, but it does get updated every jump/call/ret.
The compiler has a complex job. It needs to chop a program up into 2k chunks (a bit less than 2k, as the registers need to stay static).
All instructions that exist in pasm and which are not jumps/calls etc are simple to code. If the compiler comes across a jump, it stores the jump location in a jump register, and then goes to a little routine included in every 2k code fragment. Put the PC jump location in a hub variable.Set a flag to spin/another cog that a jump is requested. The 'cache' cog process this and loads in new blocks of code if needed (and jumps to the correct location, and I don't know how to do that bit. In 8080 you could cheat and push a new PC onto the stack, and then do a RET popped it back off the stack and wen to that location).
Local jumps stay within the 2k fragment. If the code gets to the end of the 2k block it also notifies the cache driver.
There is a little more work for the compiler. Make sure no subroutines are split. Keep a list of 'local' constants that are more than 9 bits and put these in the DAT section.
The point of all this is to try to build a system that can run faster than LMM as most of the time, it is running standard pasm code, not pasm code being loaded every instruction from hub.
I'm not sure how to reload new chunks of code. A cognew, (but that overwrites the registers), or a little routine that just does a loop with around 400 rdlongs.
The aim is to emulate a flat memory space of 32 bits. Maybe fix a few pasm limitations along the way like the problem of constants being limited to 9 bits.
With such a program, compilers for multiple languages should be possible.
Qt supports GNU C/C++ (Linux, Mac, or MinGW ) and VisualC++.
Qt makes C++ fun. Limiting oneself to C++ STL (or other old junk) is really silly.
Qt provides lots of wonderful libraries that makes STL look totally stupid.
Qt class help is context sensitive in Qt creator and very helpful (both local and on-line).
There may be a brief learning curve with Qt and QtCreator, but if you've used VisualStudio or Netbeans it's easy to learn.
It's also the basis of the new Sailfish OS for mobile phones from Jolla and today I hear it's used on the new Blackberry 10 phone.
Did I mention it works on that Raspberry Pi and other ARM boards.
I was worried about what might happen to Qt given that it was owned by Nokia which has now been screwed over my MS and forced not to use it.
However it looks like Qt's future development is secure.
-Phil
When ever you are dealing with a class object in C++, the class members do appear. An example screen shot is shown below. But I do understand your pain... C++ is difficult to get a grasp on, but when you do.... Look out baby....
Ok, downloaded Qt. I ran through the tutorials and tried a demo program but ran into a small problem. It says I don't have a compiler. Well I guess that makes sense as I had a big cleanout of the hard drive yesterday and removed all those other compilers that *didn't* have intellisense. Maybe I got a bit too keen there!
So, Qt gives you three choices of compiler in the dropdown menu, so I picked the first one which is MinGW. I downloaded that (which, heater, no doubt would not fit on a floppy disk any more) and that is happily sitting in the c:\mingw folder.
Now the next step - tying them together. Qt says it will auto find compilers but it didn't work so I rebooted windows but it still can't find it. I followed the Qt tutorial here http://doc.qt.digia.com/qtcreator-2.4/creator-tool-chains.html and in the last screenshot I tried to point it to c:\mingw\bin\gcc.exe but it still says there is no compiler. The first screenshot shows the error at the bottom saying it hasn't got a compiler.
I've tried a few other things, like copying that tutorial link exactly to see if MinGW happened to be included in the Qt package I downloaded but I can't find it in any subdirectories.
I then went to the internet and there is some poor sod on a discussion forum that says he spent two days trying to do this
There also are some older discussion posts that talk about changing the path settings in windows but I wonder if that is still the way things are done, given there is that menu in Qt to set the compiler.
I'm quite happy to uninstall mingw and Qt and reinstall the lot if there is a package out there that can make this easier. Or download another compiler (GCC is the second one on the list that Qt suggests).
Qt has a gorgeous looking front end, so I'm sure it must be just as easy to work with once it has a suitable compiler.
Any help here would be most appreciated.
Addit
@idbruce
Yea, I'm still at the newbie stage. The printf("hello world"); part of C is easy. The hard part is the myriad of files and libraries and subdirectories and path changes and working out (real world example here) whether the compiler is in c:\mingw\bin or in c:\mingw\mingw32\bin and working out whether it is not compiling because of an error in the code or because it can't find a component somewhere in a subdirectory. I've stripped a number of C programs back to just a one line main() with no #includes at all and still had them not compile.
I think C was written by nerds. I'm a nerd too, but C was written by *hardcore* nerds!
Qt looks good and I'm looking forward to getting it going.
I have installed Qt on Windows a bunch of times and it always came with the compiler and everything ready to rock.
I'm just checking the download page looks like they have
http://releases.qt-project.org/qt5.0/beta2/qt-windows-opensource-5.0.0-beta2-msvc2010_32-x86-offline.exe
The name of which implies it expects you to have Microsoft Visual C (msvc2010) installed.
I would not take that as it is a beta of the new Qt version 5.
A bit further down they have:
http://releases.qt-project.org/qt4/source/qt-win-opensource-4.8.3-mingw.exe
Which looks more like it. The latest stable Qt version and for use with mingqw.
Seems their download options have changed recently, there used to be a thing called QtSDK something which jad everything you need.
But rereading that page again, it seems that is not the whole package. And beta version 5 like you say. Beta installers probably have a compiler so won't have flagged that as an error yet?
Ok, uninstalling Mingw and Qt and re-downloading now...
Addit - no that package doesn't have Mingw either. See screenshot. The hyperlink redirects to the Qt home page rather than to the download page, and so maybe I'll have to get Mingw from elsewhere. Hopefully it will play nice with Qt.