6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue May 14, 2024 3:28 am

All times are UTC




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Tue Apr 26, 2022 2:29 pm 
Offline
User avatar

Joined: Mon Aug 30, 2021 11:52 am
Posts: 268
Location: South Africa
At least in C++ and Java.

Seriously.

-0x3'0B'C'2DULL is a completely valid integer (equal to -3193901) but 09 is not (being an octal value).

Rant over and thank you for coming to my TED talk.

Anyway I'm back from the wilderness and in front of a computer so I thought I'd just gently ease myself back into posting.


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 28, 2022 6:32 pm 
Offline

Joined: Wed Jan 08, 2014 3:31 pm
Posts: 575
That hex literal hurt my eyes.

I remember the first time I encountered the C programming language in 1984. I thought it was one of the uglier languages I'd seen. It was impossible to touch type because it used characters from some of the most far flung sections of the keyboard.

Of course it then took over the world and I spent the next 33 years working with C or C influenced languages.


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 29, 2022 4:02 am 
Offline

Joined: Thu Mar 12, 2020 10:04 pm
Posts: 690
Location: North Tejas
How about this one from Python?

Code:
int('0b1', 16)


It looks deceptively simple, but challenging to parse. Python allows arbitrary number bases from 2 to 36.

https://talk.dallasmakerspace.org/t/pro ... /18852/154

https://talk.dallasmakerspace.org/t/pro ... /18852/157


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 29, 2022 9:25 am 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1412
Location: Scotland
Martin_H wrote:
That hex literal hurt my eyes.

I remember the first time I encountered the C programming language in 1984. I thought it was one of the uglier languages I'd seen. It was impossible to touch type because it used characters from some of the most far flung sections of the keyboard.


I loved C the first time I saw it - c1980.

Previously I'd used a high level language called imp77 and while it was a marvel (compared to the BASIC and FORTRAN I'd been using), it was "wordy". It used what I thought were old-fashioned words like "predicate" and "routine spec" and other terms talked about by older folks like "name" variables (as in pass by name vs. pass by value) although once someone else said - "pointer" it all made sense - it's just another word preferred by old Algol programmers (I guess) another is vectors vs. arrays, and so on.

So C was simple, easy to understand and appealed to me as something almost as efficient as assembler but easier to use and think...

Quote:
Of course it then took over the world and I spent the next 33 years working with C or C influenced languages.


Indeed - probably why there are a lot of people (and I could myself here, to a degree) for whom C is the holy-grail of microcomputer programming...

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 29, 2022 11:00 am 
Offline

Joined: Fri Jul 09, 2021 10:12 pm
Posts: 741
My first "experience" of C was being handed-down an old copy of Microsoft C 5 for DOS, complete with multiple ring-bound loose leaf manuals. I played with it a bit as a novelty, but I was already using Turbo Pascal by this point, which was also able to produce compiled executables, had a better IDE, and built-in support for (rather slow) graphics. As I grew up with a BBC Micro, graphics were a fundamental part of programming for me, I couldn't imagine anything text-based being interesting. So for me, C was like Turbo Pascal with some things renamed, some words replaced by symbols, all the object-oriented features removed, and not so good runtime libraries.

It wasn't until a bit later that I discovered Linux, gcc, DJGPP (gcc for DOS), and really got into the language, and like many have used it ever since as it's pretty fundamental to my profession.


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 29, 2022 11:22 am 
Offline

Joined: Sat Oct 09, 2021 11:21 am
Posts: 704
Location: Texas
Since the topic has strayed some, I might as well keep that trend going.

I first learned C in high school, it was "Turbo Borland C++", which like George was saying, had a lot of built in features. Problem is, when I left that high school, I didn't have that fancy IDE anymore, so I was kind of in the dark for a couple of years. Then a buddy in college showed me Linux and gcc, and I never turned back. I have used C ever since, in particular with OpenGL.

As a mini-rant, I see some of my students learning C++ today. They show me their code, and I laugh. Stupid 'cout'. I'm happy for those of them, or you, that like that sort of thing, but I am a printf() only kind of guy. And... I keep wondering: Why are these programming students not actually doing their own projects on the side??? Like, they do what the class requires of them, yippie, but aren't they supposed to be doing stuff on their own, in their spare time? I took a computer class each semester, but I was CONSTANTLY programming video games and other things on the side... and I was just a math major, and I had a 39.5 hour job! Is it normal to have students now-a-days just follow the laid-out curriculum and stop there???

Rant over I guess. Thanks!

Chad


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 29, 2022 11:46 am 
Offline

Joined: Fri Jul 09, 2021 10:12 pm
Posts: 741
Times have changed I guess - there were no programming courses when I was at school, so you had to learn it off your own back or not at all. However, I started teaching one at some point, to a small group under the "Duke of Edinburgh Award" scheme. I don't think I was a good teacher, but it was nice seeing them gain some understanding and experiment.

To some extent you can get overloaded if you try to do the same thing in your free time that you do for work/school. At some point I made a conscious decision not to do the same things at home that I do for work (software development), and especially recently that's where my interest in electronics came from, and I try to keep what I do in that arena quite a long way away from what I do professionally.


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 29, 2022 11:49 am 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1412
Location: Scotland
sburrow wrote:
Since the topic has strayed some, I might as well keep that trend going.


Well...

sburrow wrote:
As a mini-rant, I see some of my students learning C++ today. They show me their code, and I laugh. Stupid 'cout'. I'm happy for those of them, or you, that like that sort of thing, but I am a printf() only kind of guy. And... I keep wondering: Why are these programming students not actually doing their own projects on the side??? Like, they do what the class requires of them, yippie, but aren't they supposed to be doing stuff on their own, in their spare time? I took a computer class each semester, but I was CONSTANTLY programming video games and other things on the side... and I was just a math major, and I had a 39.5 hour job! Is it normal to have students now-a-days just follow the laid-out curriculum and stop there???


I'm currently ploughing my way through reams of mostly un-documented code of very questionable quality to try to understand how a particular ARM development board works at the "stand-alone" level. There are a dozen or more project (including the Linux kernel) which target this system.

The code quality is shocking (to me). One project has at least 3 different ways to print text through a UART and to the screen - because - I don't know, but I'm thinking that the person who bludgeoned that particular thing together just pulled in files, etc. from various github, etc. places and hit them on the head until it worked. They even have their own version of 'malloc' when there is a perfectly good one in a standard library aimed at standalone systems ('newlib').

So I'm effectively re-writing it from scratch now that I understand some of it, but modern systems are just far too complex. Give me a nice little 6502 any day! (except when I want to port a large 32-bit application...)

Quote:
Rant over I guess. Thanks!


Cheers,

-Gordon
(and the rest of us older folks who'd grumble about their lawns, etc. ;-)

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 29, 2022 12:01 pm 
Offline

Joined: Sat Oct 09, 2021 11:21 am
Posts: 704
Location: Texas
gfoot wrote:
To some extent you can get overloaded if you try to do the same thing in your free time that you do for work/school. At some point I made a conscious decision not to do the same things at home that I do for work (software development), and especially recently that's where my interest in electronics came from, and I try to keep what I do in that arena quite a long way away from what I do professionally.


Very true! I'm happy to be a math teacher because I can come home to do computers. I like math well enough, but computers are my passion. There was a decision in my life when I was early in college: math or computers. And I decided on math because if I had chosen computers, I would have to "sit at a cubical all day". Now I stand in front of a classroom talking all day. *shrug*

Gordon, that sounds like how people have been programming for ages. Rip it from some other place, beat it over the head until it fits. I can't say I haven't done that myself once in a while.

And my lawn needs mowing, haha :)

Chad


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 29, 2022 1:36 pm 
Offline
User avatar

Joined: Mon Aug 30, 2021 11:52 am
Posts: 268
Location: South Africa
Ha :D I started writing a response at 11am my time. Got sucked into a three hour meeting, got distracted, covered the pool and had lunch and the came back to hit send at 3pm. And found I was about to post over a whole conversion. That'll teach me to have meetings :shock:

I think my first run in with C must have been Turbo C 3.0* relatively recently in 1995 whilst I was still in high school. Coming from a Turbo Pascal background it seemed really cryptic to me and took a number of years to 'get'. After that I pretty swiftly moved onto C++ and even bought both Borland C++ 4.5 and 5.0 (I've still got the disks and manuals somewhere).

But really I think the C++ standards committee have lost the plot and exist solely to make compiler writers lives miserable. I say this a lot. Template shenanigans** aside the barrier to entry just seems way to high nowadays. In Turbo C I was happy that I could start the program, type some code hit run and it just worked. Now I accept that it could to take a least a day getting a new project configured with all it's libraries, calling conventions, exception types, character sets and language version settings. And then tracking down that one unresolved linker reference that magically goes away when the entire project is recreated exactly as it was.

But enough about the high level stuff. Here's another eye hurting literal. This time a character:
Code:
   char space = '\
\
\u0\
0\
20\
\
\
';


Perfectly legit C++ code and at the end you get a ' '. Wicked!

* I think it was Turbo C 3 not Turbo C++ 3. It was long enough ago that I can't be certain and looking at Wikipedia it seems confusing...
** "but you didn't say anything about templates?!" Yeah, 'cause there's a rant that I could lose the rest of the day to.


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 29, 2022 3:22 pm 
Offline
User avatar

Joined: Mon Aug 30, 2021 11:52 am
Posts: 268
Location: South Africa
Okay, so apparently the char above is not supported by the Visual Studio compiler. That makes feel a little better. (It is considered legit by the IDE's parser which is still kinda scary.)

Code:
   char space = '\
\
\u0020\
\
\
';

This is still legit and compiles though. A char. For realz.


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 30, 2022 6:04 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1929
Location: Sacramento, CA, USA
Hey, if you're going to have fun with the C++ parser (it's just an occasional toy for me), at least try to tickle your white space into significance: :D
Code:
                          //>,_
                        //Beer Song>,_
                       #include <iostream>
                      using namespace std;
                     int main(){ for( int
                    b=-1; b<99;  cout <<
                   '\n') for ( int w=0;
                  w<3; cout << ".\n"){
                 if (w==2) cout << ((
                b--) ?"Take one dow"
               "n and pass it arou"
              "nd":"Go to the sto"
             "re and buy some mo"
            "re"); if (b<0) b=99
           ; do{ if (w) cout <<
          ", "; if (b) cout <<
          b;  else  cout << (
         (w) ? 'n' : 'N') <<
         "o more"; cout <<
         " bottle" ;  if
        (b!=1) cout <<
       's' ; cout <<
       " of beer";
      if (w!=1)
     cout  <<
    " on th"
   "e wall"
  ;} while
 (!w++);}
  return
       0
       ;
       }
      //
  // by barrym 2011-05-01
     // no bottles were harmed in the
            // making of this program!!!

_________________
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)


Top
 Profile  
Reply with quote  
PostPosted: Sun May 01, 2022 2:27 pm 
Offline

Joined: Wed Aug 21, 2019 6:10 pm
Posts: 217
drogon wrote:
... I don't know, but I'm thinking that the person who bludgeoned that particular thing together just pulled in files, etc. from various github, etc. places and hit them on the head until it worked. ...


I first ran into that approach to programming in the late 90s. It was a young lab tutor in Economics in Newcastle, NSW, patiently explaining to me (late 30s at the time, first started programming in Basic, then 6502 assembler, then fig Forth in the early 1980's on a C64) how to "program" by searching repositories for bits and pieces that do what you want and then patching them together.

I don't remember what language it was, but given the time period and the focus on web tools at Newcastle Uni, it might have been Perl 5.

"Pull in files and hit them on the head until it works" would be a quite accurate and concise description of his approach.


Top
 Profile  
Reply with quote  
PostPosted: Sun May 01, 2022 7:25 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8182
Location: Midwestern USA
drogon wrote:
...but I'm thinking that the person who bludgeoned that particular thing together just pulled in files, etc. from various github, etc. places and hit them on the head until it worked.

Sounds like how MS Windows was developed. :D

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


Top
 Profile  
Reply with quote  
PostPosted: Sun May 01, 2022 7:56 pm 
Offline

Joined: Thu Mar 03, 2011 5:56 pm
Posts: 277
barrym95838 wrote:
Hey, if you're going to have fun with the C++ parser (it's just an occasional toy for me), at least try to tickle your white space into significance: :D
Code:
                          //>,_
                        //Beer Song>,_
                       #include <iostream>
                      using namespace std;
                     int main(){ for( int
                    b=-1; b<99;  cout <<
                   '\n') for ( int w=0;
                  w<3; cout << ".\n"){
                 if (w==2) cout << ((
                b--) ?"Take one dow"
               "n and pass it arou"
              "nd":"Go to the sto"
             "re and buy some mo"
            "re"); if (b<0) b=99
           ; do{ if (w) cout <<
          ", "; if (b) cout <<
          b;  else  cout << (
         (w) ? 'n' : 'N') <<
         "o more"; cout <<
         " bottle" ;  if
        (b!=1) cout <<
       's' ; cout <<
       " of beer";
      if (w!=1)
     cout  <<
    " on th"
   "e wall"
  ;} while
 (!w++);}
  return
       0
       ;
       }
      //
  // by barrym 2011-05-01
     // no bottles were harmed in the
            // making of this program!!!


Beautiful!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 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: