![]() |
Forum Index : Microcontroller and PC projects : CMM2: Standalone C Programs?
Page 1 of 2 ![]() ![]() |
|||||
Author | Message | ||||
chris Regular Member ![]() Joined: 24/08/2020 Location: United KingdomPosts: 56 |
Hello, I'm really intrigued by the CFunction functionality. I wonder if it would be possible in a future update for the CMM2 to run C programs without them having to be wrapped in a .BAS file? Are there ideological objections to such an addition? Chris. |
||||
RetroJoe![]() Senior Member ![]() Joined: 06/08/2020 Location: CanadaPosts: 290 |
My first reaction is why would you want to do that on a CMM2 versus, say, a Raspberry Pi? I think the essential characteristics of the Maximite Platform are “immediacy” & “accessibility”, and it’s instant-on MMBasic as its lingua franca is the manifestation of those design goals. Even if you don’t know BASIC (unlike us old farts who grew up with it...), it’s not at all hard to learn, especially if you already know C. Despite the CMM2’s blazing-fast BASIC interpreter, there are clearly some computational use cases where inline ARM code is a nice option to have, but surely there are much better SOC options if C is your main () thing? :) While we are on the topic of alternative languages, I would love to see a “MMPython” version of the firmware. Like BASIC was in my day, Python is the first language many kids learn today, but it’s always buried under a heavy stack, even on the Raspberry Pi. The CMM2’s minimalist approach would be a great fit with the Python language and ethos, IMHO. Edited 2020-09-03 07:14 by jpusztai Enjoy Every Sandwich / Joe P. |
||||
chris Regular Member ![]() Joined: 24/08/2020 Location: United KingdomPosts: 56 |
For me there is a huge difference to coding C for CMM2 versus rpi. It's still instant-on, and it's a fixed platform with excellent system libraries. Imagine the overhead of coding a simple program in C for rpi. Also the Pi graphics operations has to go through a heavy driver and picks up latency and overhead. The Pi is also too powerful to be fun. I'm not disputing at all that it's going to be fun to write BASIC code on CMM2, but a lot of that fun comes from the superb system libraries, and it would be just as much fun to exploit the libraries and fixed platform in C, where more intensive projects would be available. MMBasic is awesome, and I have some cool projects planned for it, but I also have a hankering to write an emulator, just so I can say that I can. That kind of project is more fun in C, and 100x more fun on a fixed platform that is close to the metal. |
||||
Pilot352 Newbie ![]() Joined: 12/08/2020 Location: United StatesPosts: 34 |
I'm confused about the request. MMBasic is written in C. So are the other parts of the Maximite. So what you are suggesting is a second layer of C programs on top of the original core? |
||||
capsikin Guru ![]() Joined: 30/06/2020 Location: AustraliaPosts: 341 |
Your emulator idea sounds cool. I've got maybe one and a half. One is that it's extra complexity that doesn't seem within the spirit of the system. The half is that I kind of like that it's encouraged for people to mostly use a common language. I'm not sure that a few lines of wrapper in basic makes much difference there though, they'd still need to be compiled. Are you talking about "CSUB" line, the "END CSUB" line, and the call to the CSUB? |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
It is probably possible now but someone would need to do the spadework to develop and test an approach. Enabling tasks Write a Basic program to load a STM32 library file (filename.a) into RAM write a trivial CSUB to jump to a specific location RAM Then write your application and compile it as a position independent library with a single entry point. You will needd to use the CSUB header file to access CMM2 internal functions. You are going to have to understand the library file format to make this work but it should be do-able - just not by me!!! Re Python IMHO python is an abomination of a language. Any language that uses whitespace as a syntactical element shouldn't have been conceived and shouldn't be promoted. There is zero chance I will ever develop anything for python but if you want to port micropython to the CMM2 H/W feel free. Just don't expect any support coming from this direction ![]() |
||||
Nimue![]() Guru ![]() Joined: 06/08/2020 Location: United KingdomPosts: 420 |
Can I second that. In education circles, the progression (in the UK) is Scratch >> Python (or JavaScript or VB!!). Currently trying to break the CMM2 into curriculum areas in Wales and whilst BASIC is easy enough and meets to goal of moving from pictorial / block coding in Scratch to a "text" based language, when learners move to assessment at 16 (GCSES), Python is the default goto (pun intended) language. MMPython (with library support) would be a huge bonus. That said, CMM2 and MMBasic is more than suitable as long as I enter the "BASIC is a 1980's language" argument -- which is winnable easily enough as the CMM2 is so capable. Entropy is not what it used to be |
||||
Nimue![]() Guru ![]() Joined: 06/08/2020 Location: United KingdomPosts: 420 |
|
||||
chris Regular Member ![]() Joined: 24/08/2020 Location: United KingdomPosts: 56 |
It is probably possible now but someone would need to do the spadework to develop and test an approach. Enabling tasks Write a Basic program to load a STM32 library file (filename.a) into RAM write a trivial CSUB to jump to a specific location RAM Then write your application and compile it as a position independent library with a single entry point. You will needd to use the CSUB header file to access CMM2 internal functions. You are going to have to understand the library file format to make this work but it should be do-able - just not by me!!! Re Python IMHO python is an abomination of a language. Any language that uses whitespace as a syntactical element shouldn't have been conceived and shouldn't be promoted. There is zero chance I will ever develop anything for python but if you want to port micropython to the CMM2 H/W feel free. Just don't expect any support coming from this direction ![]() I was thinking more of something that would be supported by the firmware and the file browser. Something like just running a .EXE, .COM. I think that it wouldn't take away anything from BASIC tinkerers for the machine to also appeal to C tinkerers, given that 99% of the work is done (the headers exist). That said, I'm very grateful for the support that is already in the firmware for loading native code, and the superlative libraries and documentation. Just raising a 'feature request' for being able to load binaries from the file browser directly without an explicit wrapper. Not a priority. |
||||
RetroJoe![]() Senior Member ![]() Joined: 06/08/2020 Location: CanadaPosts: 290 |
Peter, if it wasn’t for the whitespace, would you still consider Python an abomination? Maybe I’m missing something (along with millions of other people...), but Python strikes me as a very elegant and well-conceived language, and not unlike Pascal in its explicit goal of promoting structured / modular programming and good coding habits. That being said, I’ve heard the “whitespace == bad” argument many times from colleagues, but as far as I know, syntactically meaningful whitespace is the only way to make indenting mandatory. I believe everyone agrees that consistently indenting code is a Good Thing, so I’m confused why a language that actually enforces it is so controversial. From what I can gather, where Python screwed up slightly was by allowing a mix of tabs and spaces to represent indentation levels, making it more difficult to parse accurately. Here’s an excellent blog on the topic. To wrap up, assuming the Maximite appeals primarily to “mere mortal” computing enthusiasts (versus professional coders), BASIC was an excellent general-purpose, interpreted language to base it on... but IMHO Python could also have been a contender, and in theory it’s availability could open it up to a much wider educational market (the market that Eben Upton envisioned for the Raspberry Pi, but teaching Linux syntax to elementary school kids just seems cruel :) Edited 2020-09-03 23:14 by jpusztai Enjoy Every Sandwich / Joe P. |
||||
Paul_L Guru ![]() Joined: 03/03/2016 Location: United StatesPosts: 769 |
Hmmmmmmmmmm ... mandatory whitespace. Egads! It's deja vu all over again. I distinctly remember have to insert a line number at the beginning of the line and then begin code in a certain column on Hollerith cards. The card reader hardware routines just wouldn't tolerate anything else. I think standardized indentation makes program structure highly visible and is a valuable debugging aide .... but I disagree vehemently with making the whitespace syntactically important. That would be a regression all the way back to the IBM 701! Paul in NY |
||||
Raul Newbie ![]() Joined: 06/05/2020 Location: United KingdomPosts: 11 |
Micropython https://micropython.org/ Runs instantly and interactively on bare metal. Python script is compiled instantly on board to bytecodes, very efficient and fast. Runs on ESP8266 - $1 wifi module, and larger ESP32 dual core with 4MB+ flash and Ram on Real time operating system. Large range of STM32F4 and F7 series microcontrollers. Totally open source. As easy if not easier than basic, but much more powerful if you want to explore all the features including OOP Classes etc. STM32 version supports inclusion of simple text based inline ARM assembly code inside the python script. Everything gets instantly compiled to bytecodes on board when you press upload/run. Lots more. https://www.google.com/search?q=%27micropython&oq=%27micropython&aqs=chrome..69i57j69i65l2.5607j0j4&sourceid=chrome&ie=UTF-8 https://www.youtube.com/watch?v=5W3WvXAmDJc https://www.youtube.com/watch?v=DFp_T-H3eRc https://randomnerdtutorials.com/projects-esp32-esp8266-micropython/ Edited 2020-09-04 00:29 by Raul |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
put micropython on a NucleoH743. Then connect a keyboard - oops you can't. Then connect a screen - oops you can't. OK then connect a terminal emulator. That works, I get a >>> prompt. Now how do I edit and run a program? Google "Micropython getting started". All the examples seem to suggest I need to edit the program on a PC and then download. Apparently I should see a disk drive on my PC to download to but I don't. Look for a user manual - lots of complex documentation but nothing remotely like a getting started manual. GIVE UP and reflash ArmmiteH7 code |
||||
RetroJoe![]() Senior Member ![]() Joined: 06/08/2020 Location: CanadaPosts: 290 |
I distinctly remember have to insert a line number at the beginning of the line and then begin code in a certain column on Hollerith cards. The card reader hardware routines just wouldn't tolerate anything else. I think standardized indentation makes program structure highly visible and is a valuable debugging aide .... but I disagree vehemently with making the whitespace syntactically important. That would be a regression all the way back to the IBM 701! Paul in NY If you’re talking about mandatory whitespace to pad out fixed field / record lengths, no argument there. That is Indeed a horrible legacy of the early days of limited compute power and storage. As any artist will tell you, though, the “negative space” is as important as the “positive space”, and code indenting fulfills that function. As Donald Knuth said, “If you love something, you can put beauty in it”. I think he also said reading good code should be like reading a good book. Another argument to be made for “structural whitespace” comes from the book “Thinking Fast and Slow” by Daniel Kahneman. In it, he posits two very distinct modes of thinking: “Type 1” (intuitive and fast, sometimes wrong) and “Type 2” (analytical and slow, usually correct). Picking up the logical structure of code blocks from its indenting uses Type 1, whereas working out a bunch of nested parentheses uses Type 2. Most “geeks” are heavily biased toward Type 2, which is why they are OK with symbolic / textual (versus visual...) methods to delimit code blocks and logical structure, and why the vast majority of computer languages are “indenting optional”. I guess Guido van Rossum was attempting to engage both “Type 1” and “Type 2” modes in Python... while he was in Mode 1 :) Edited 2020-09-04 01:34 by jpusztai Enjoy Every Sandwich / Joe P. |
||||
RetroJoe![]() Senior Member ![]() Joined: 06/08/2020 Location: CanadaPosts: 290 |
Then connect a keyboard - oops you can't. Then connect a screen - oops you can't. OK then connect a terminal emulator. That works, I get a >>> prompt. Now how do I edit and run a program? Google "Micropython getting started". All the examples seem to suggest I need to edit the program on a PC and then download. Apparently I should see a disk drive on my PC to download to but I don't. Look for a user manual - lots of complex documentation but nothing remotely like a getting started manual. GIVE UP and reflash ArmmiteH7 code LOL :) That PyBoard looks cool, but the fact that it is “headless” is a showstopper. The beauty of the CMM2 is in it’s simple / self-contained / standalone operation. Related, unlike traditional BASIC dialects, Python has no interactive graphics commands; these would have to be invented (or “adopted” from MMBasic syntax...) for a notional “MMPython” implementation. But, BASIC started life in the 1960’s on a time-sharing mainframe, so I‘m guessing that “tradition” only began with the 8-bit personal computer era in the 1970’s. P.S. I follow the “Commander X16” project, which is an attempt to create a contemporary Commodore64 as close as possible to the original hardware e.g. using a physical 6502. This “Can you port Python to it?” request came up over there, too (not by me :), but it was deemed impossible given the limitations of the 8-bit HW. Unlike MicroPython on the STM32H7, which seems technically feasible. P.P.S. I sense I may have violated TBS’s “no politics” policy by triggering this Python flame war :) Edited 2020-09-04 02:25 by jpusztai Enjoy Every Sandwich / Joe P. |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
The Python debate will rage until a new language is the rage. I've earned money programming in Python but I still have a problem with something that you can't see controlling how a program works - whitespace. Especially since it is (or ought to be) something at the editing level that has no need to exist at the execution level. But it is what it is. I'll stick with C, assembly and MMBasic. And ladder logic. Visit Vegipete's *Mite Library for cool programs. |
||||
RetroJoe![]() Senior Member ![]() Joined: 06/08/2020 Location: CanadaPosts: 290 |
I've earned money programming in Python but I still have a problem with something that you can't see controlling how a program works - whitespace. Especially since it is (or ought to be) something at the editing level that has no need to exist at the execution level. But it is what it is. I'll stick with C, assembly and MMBasic. And ladder logic. It’s interesting that despite decades of computer science as an academic discipline, and the invention of hundreds of “better” languages and frameworks, professional programmers invariably converge on tried-and-true tools and methods that are as close to the bare metal as possible. I personally find the syntax and organizing principles of Python appealing, and it is definitely enjoying a burst of popularity (primarily as the glue code for data science applications), but indeed, it will be eclipsed by the “new new thing” soon enough. From that perspective, BASIC’s longevity is remarkable - it’s like the B-52 of 3GLs. Here’s an apropos nerdy riddle to “prove” my point: Q: If “The Matrix” was real, what language would it be written in? A: Machine language, of course :) Enjoy Every Sandwich / Joe P. |
||||
chris Regular Member ![]() Joined: 24/08/2020 Location: United KingdomPosts: 56 |
You only really need something to control flow, arrays, memory access, subroutines, and functions. BASIC is really good at those things. It tends to fall apart at scale but beginners don't code at scale. Languages struggle to out-BASIC BASIC. |
||||
HellbentHorse Regular Member ![]() Joined: 08/07/2020 Location: AustraliaPosts: 55 |
Almost like the intent is in the name.. BASIC.. ![]() |
||||
berighteous Senior Member ![]() Joined: 18/07/2020 Location: United StatesPosts: 110 |
Indenting code is stupid. Learn to read code. Untangling spaghetti is part of the experience. I have spoken. The CMM2 is freaking awesome as-is. It programs in basic. Learn basic. (if there were an assembler that would be awesome too) But we don't need any other languages. The built in basic is all we need. |
||||
Page 1 of 2 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |