6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun May 05, 2024 3:43 pm

All times are UTC




Post new topic Reply to topic  [ 78 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
PostPosted: Fri Apr 23, 2021 6:57 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 899
sark02 wrote:
C++ keeps evolving into a better language, in my opinion.

I am happy that you like it. I've used it a lot, and at one embarrassing moment, found myself at an ANSI X3J16 standardization committee meeting. So as a language geek I am not talking out of my butt when I say that C++ is a horrible abomination. If you want details, my buddy yousefk is much more eloquent in his C++ Frequently Questioned Answers https://www.yosefk.com/c++fqa/. C++ looks like an extension of C, but it is not. It is full of booby-traps, ambiguities, and ways to screw yourself or whomever has to maintain your C++ code in the future. I simply cannot express my disgust with it.

In the end, the only good languages I am aware of are Forth, Lisp, and Smalltalk, covering the good part of the linguistic space with a triangle (each with its own advantages and disadvantages). The rest is just a pileup of syntax without much rhyme or reason, vomited up to solve some specific issues, and promoted past its usefulness. BLUB, as we smug lispers say. Many are useful, and some are even enjoyable, on occasions. And of course, assembly language will always be there when all else fails (I've been doing a lot of x86 assembly, which is pretty pleasant now that we have 64 bits and lots of registers).

There is a place for everything, including historical value, ignorance and masochism, of course.

sark02 wrote:
Why would you ever choose to stop?

Because it works, and needs no fixing? Because there is no need to 'upgrade' constantly? Because you care about the environment (while buying a new iphone every year)? Because 'newer' does not mean 'better' (quite the opposite, generally...) I could go on for a long time like this.

Of course there is a balance. Learning and pushing your brain is always a good thing, even when learning dumb-ass things.

Or not...

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 23, 2021 11:22 pm 
Offline

Joined: Tue Nov 10, 2015 5:46 am
Posts: 215
Location: Kent, UK
enso wrote:
[...] embarrassing [...] horrible abomination [...] booby-traps [...] disgust [...] vomited [...] ignorance [...] dumb-ass
That was a fun read, enso. I think it'd be interesting to have a drink with you on this topic. Loosen you up a bit. Hear your unfiltered thoughts.

As a summary, though, I get the feeling that C++ isn't your cup of tea. Fair enough.


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 23, 2021 11:51 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 899
:D

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 24, 2021 12:15 am 
Offline

Joined: Mon Sep 17, 2018 2:39 am
Posts: 133
Hi!

sark02 wrote:
I know we skew old here, but I think it's a shame that old school engineers seem so dismissive of modern computing. The past is where the nostalgia is, and where I guess we all developed a fondness for the little 6502.


I think you are reading the room incorrectly.

This is a 6502 forum, so obviously there are a lot of nostalgic people here that will dismiss new technologies, and those tend to be vocal about it, but not every "old school engineer" thinks this.

For an example, look at the "Go" language, designed by two old school engineers, using modern techniques for concurrency, garbage collection and fast compilation.

I personally like the Zig language, and use Python for a lot of prototyping. Each tool has it uses.

Have Fun!


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 24, 2021 2:26 am 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 899
There is a difference between being dismissive of modern computing, and refusing to 'keep up' with idiotic new/cool technologies pushed by corporations or self-promoting jackasses.

But some of us are here to take a deserved break from our dayjobs which involve idiotic tools and complexities (because idiots with money, i.e. employers and clients, love to pay for the stupidest and most painful way of doing things).

So forgive me for getting my hackles up when I see people come here and blab about how we are in the dark ages and should upgrade to the idiocies of 'modern computing', such as languages that waste 95% of the CPU and take up megabytes of code, or 'professional' build systems that require a support team. It makes sense for wintel, as this kind of bullshit sells chips and forces software upgrades. It is a disease, not something to aspire to just because it's 'modern'. When something works, it is not in your best interest to trade up to something that does not work just because it is more 'modern' -- or some guy on googletube made a video saying so and has a million followers.

Want to see something modern? Check out BalenaEtcher:https://www.balena.io/etcher/ This amazing application is 89 Megabytes (!) of code that does one thing: copies a binary image file to an SD card for your Raspberry Pi. Or you can just type 'dd' on the linux command line to do the same thing. Apparently, BalenaEtcher is such a success that they are hiring people. Enjoy your modern technology. We actually live on Bizarro.

P.S. Here is the Wikipedia entry for Etcher: https://en.wikipedia.org/wiki/BalenaEtcher
Apparently it is one of the best of Electron applications.
For those who find clicking the 'download' button challenging, there is a whole infrastructure of tutorials to help you install it, such as this one: https://www.omgubuntu.co.uk/2017/05/how-to-install-etcher-on-ubuntu
Here is a video showing how to install it: https://www.youtube.com/watch?v=EAHpTxy6twY, and don't forget to subscribe!

P.P.S. You can't make this s**t up! Apparently, they are working on a command line version of BalenaEtcher. It must be really hard work!

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 24, 2021 2:31 pm 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 690
Location: North Tejas
I do not know MicroPython at all, but I know Python moderately well and some aspects of the language very well.

Python is slower than traditional programming languages for several reasons.

The primary one is its use of dynamic typing. What that means is that variables are references (pointers) to objects. The type of the object(s) in question is determined at run time instead of by static processing of the source code.

So to "add" two variables,

a = b + c

something like the following must be done:

Code:
if b is not defined:
    raise exception
if c is not defined:
    raise exception
if b and c are not "+" compatible:
    raise exception
"+" b and c
if a currently references an object:
    delete the reference in systems implementing reference counting
store reference to the result of b + c in a

"+" can be addition of numbers, concatenation of strings, union of tuples, lists, etc

Note than in general, the result of b + c must be allocated from a pool of free memory.

The second factor is that integers vary in size; there is no hard size limit other than the amount of available free memory in the system. Since version 3, there are no fixed sizes of integers, meaning even simple arithmetic calculations bear the cost of dealing with variable precision and memory allocation.

The third reason is there is no character type. A character may be extracted from a string by slicing it into a new string containing a single character. And comparing two characters requires comparing two strings. Strings are immutable; replacing a character within a string requires creating a new string with the modification. All of this makes character processing such as parsing slower in Python than in more traditional languages.

The fourth factor is that functions in Python are overgeneralized. You can do something perverse like this:

Code:
def sum(a, b):
    return a + b

def difference(a, b):
    return a - b

print(sum(1, 2))
# yielding 3

sum = difference

print(sum(1, 2))
# yielding -1

Note that the two functions need not have the same number or types of arguments. Arguments may also be passed by name(keyword.)

For example, you can write:

Code:
one=1
print(one, 2, '3', sep=', ', end="...\n")

to get:

1, 2, 3...

What this means is that in order to call a function, a tuple is created with the positional arguments, a dictionary is created with the keyword arguments and the function name variable is confirmed as a reference to an actual function. Then and only then is control passed to the called function which has to varify the validity of data passed in via the tuple and the dictionary, raising an exception in case of a problem, before doing its work.

In light of all of this overhead, the fact that a Python program is converted into bytecode and interpreted is not really significant.

---

In the summer of 2015, I joined a couple of makerspaces.

Prior to that, I was learning the Atmel AVR using a development kit from XGameStation (Andre Lamoth's company.)

The makerspace experience showed me that both Python and the Arduino are hugely popular.

I had been avoiding the Arduino platform because I thought it was dumbed down. It used a simplified version of C/C++ as its programming language and did not offer assembly language as an option. Somehow, I had a mistaken impression it was a drag-and-drop environment not unlike the Lego Mindstorms robotics system. I found out that the Arduino was a very good platform for prototyping a project concept quickly. I became a fan, quit using the XGS set and even began teaching classes on applying the Arduino.

Likewise, Python was not only a scripting language, but it is good for rapidly trying an idea before implementing it with a more efficient traditional language. With the availability of many high quality libraries, it is sometimes even a suitable implementation language.

My thought was: Arduino is popular and Python is popular, so why can I not program an Arduino in Python? I set out to remedy that.
But the mainstream Arduino, the Uno, is based on the Atmel 328P microcontroller. With 16K words of flash program memory and 2K bytes of static RAM, it is half of the size of the 644P in my XGS development board. I had doubts that much of Python could be implemented in such a limited space.

Because the makerspace had a working Commodore C128 on display at the time, I decided to initially target the 6502 with a Python cross compiler. It is a slower processor, but with much more writeable memory.

The compiler converted a Python program into 6502 assembly language. The run-time library is responsible for implementing Pythonic behavior like variable precision integers and memory management.

The compiler is currently still very incomplete. Dynamic typing and memory management works. Most of the arithmetic operators for integers have been implemented. Functions like print are done. The ability to define a function is the next tough nut to crack.

---

I will not be implementing MicroPython. But I can offer assistance in the form of the code in the run-time library.


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 24, 2021 3:46 pm 
Offline

Joined: Thu Mar 03, 2011 5:56 pm
Posts: 277
Dynamic typing and generality is not the reason that Python is slow. Common Lisp is dynamically typed and is arguably both more general and more powerful than Python, yet Common Lisp implementations are easily 10 times as fast as Python.

I really don't understand why Python is so popular.


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 24, 2021 3:57 pm 
Offline

Joined: Thu Jan 21, 2016 7:33 pm
Posts: 269
Location: Placerville, CA
rwiker wrote:
I really don't understand why Python is so popular.

One very real reason: dead simplicity to get into. When I was doing backend order processing at a call center and we had a client who for...reasons...? demanded that orders be submitted as HTTP requests, all it took me to go from "no knowledge of network programming whatsoever" to "functional order processor for these weirdos" was a tip from a coworker and about two hours of work, half of which was in installing Python and getting the basics of the syntax and libraries down.

It's definitely not my favorite programming language (literal whitespace!? What is this, JCL?) but I will give them this: they make it very, very easy to get past the nitty-gritty of a lot of tasks and focus on the actual application for them.


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 24, 2021 4:03 pm 
Offline

Joined: Thu Mar 03, 2011 5:56 pm
Posts: 277
It may be simple, but only for simple problems or small systems. The amount of additional tooling that people add into their (large) Python projects in order to gain control of their code is impressive (and by itself an indication that the design principles behind Python are not well chosen).


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 24, 2021 4:48 pm 
Offline

Joined: Thu Jan 21, 2016 7:33 pm
Posts: 269
Location: Placerville, CA
I don't disagree, but it depends on what your goals and constraints are. For a one-off processing application that my employer needed on short notice, and where performance wasn't really a consideration, it was definitely better that I went the easy route and got something working promptly than spend weeks properly wrapping my head around Windows socket programming in C (which was what I'd been trying to do, before my coworker suggested Python as an alternative.) For a teaching language, it's nice when you can get students down to brass tacks quickly and easily and leave the less critical complexities for later.

There are all kinds of programming languages out there. Python is, as I said, not my favorite, but it does have its merits.


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 24, 2021 6:29 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 899
rwiker wrote:
Dynamic typing and generality is not the reason that Python is slow. Common Lisp is dynamically typed and is arguably both more general and more powerful than Python, yet Common Lisp implementations are easily 10 times as fast as Python.


Indeed! Common Lisp implementations handle typing in a wonderful way. No static type declarations are necessary, and it just works. Behind the scenes, modern compilers infer the possible types (or more often one type) of references, and are free to optimize code. You can assist by providing hints to the compiler (and it knows if your hints make no sense), and if you hint enough, it can generate code that runs faster than C.

Python has endless foolishness. Bloat, poor syntax, weird capitalization, no tail recursion, forced indentation (which breaks code if not followed to the letter), incompatible version problems, cross-compatibility issues (which a bytecode interpreter should not), a package system that breaks your code or requires you to figure out exactly which libraries you don't want updated later. I hardly ever used it, but experienced awfulness many times. For instance: a little python program I used to fetch newsgroup binaries started crashing. Turned out some library used another library that became incompatible with no warning, after an update I didn't want. Yuck. It does not bring me joy, so out it goes.

From Forth we know that we do not need typing or syntax. From Smalltalk we know how to encapsulate objects (with all the attendant problems) and interpret bytecodes, with a syntax that fits on a business card. From Lisp we know that we can have our cake and eat it too. What exactly do we need Python for? May as well use BASIC for throwaway code - at least it won't break by itself. BCPL looks interesting (I respect languages that can compile themselves). VTL2 is cool and takes no space. If you can stand strong typing, C is at least what it is.

The emergent mantra that programmer time is more important than CPU time is OK for big iron, and great for startups and those who want to make another billion (even then it's the end user time that is actually meaningful). We are not generally building 6502 or even 65816 machines to save time. I suggest we leave MicroPython where it belongs, with the Raspbery-Pi-LED-blinkers, or the Internet-of-things nonsense-peddling-brainwashers on google-tube. Or not.

My vote is for a PicoLisp port instead (https://picolisp.com/wiki/?home)

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Sun Apr 25, 2021 7:04 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8173
Location: Midwestern USA
BigEd wrote:
Thanks for another excellent contribution to the thread, BDD.

You're welcome. Look at the discussion that has ensued. :D

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Sun Apr 25, 2021 7:27 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10797
Location: England
BillG wrote:
I do not know MicroPython at all, but I know Python moderately well and some aspects of the language very well.

...

I will not be implementing MicroPython. But I can offer assistance in the form of the code in the run-time library.


Thanks Bill! It's nice to see someone still has their eye on the purpose of this thread.

If only it were easy for those who would rather vent their spleen than contribute (or just move on when a thread isn't their cup of tea.)

But no, it's terribly difficult to start a new thread.

I think this is the second recent thread with a promising start which turned into a torrent of vinegar.


Top
 Profile  
Reply with quote  
PostPosted: Sun Apr 25, 2021 2:26 pm 
Offline
User avatar

Joined: Mon May 12, 2014 6:18 pm
Posts: 365
BigEd wrote:
I think this is the second recent thread with a promising start which turned into a torrent of vinegar.
I think enso is quite wrong about a lot of what he's posted here, but I still like hearing where people like him and BDD disagree with the rest of us. It's interesting to hear the disadvantages with the advantages. No need to hold back as far as I'm concerned :)


Top
 Profile  
Reply with quote  
PostPosted: Sun Apr 25, 2021 3:34 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10797
Location: England
Yes, some like a heated debate (and some, I feel, like to stir one up) - for me, the place for that is a thread about the subject in hand.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 78 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: