Heater
Posts: 12072
Joined: Tue Jul 17, 2012 3:02 pm

Re: General language discussion.

Thu May 16, 2019 1:58 pm

hippy,
...doesn't mean it couldn't be done if the Python standard provided a means for it to be done.

When, and if, that happens it won't then be possible to say it cannot be done with Python.
All programming languages will be able do anything and everything once they can do anything and everything.
[/quote]
Perhaps there is something about Python I do not know.

What is it about the current specification of Python's syntax and semantics that prevents it from accessing machine memory and registers?
But whose problem is that, where is the cause, and what is the solution ?

It's no different to a DJ working for a station playing music they don't like, exactly like a musician...
Good question. No idea.

My take on it is that, for most, a career in programming is more like any other work. One works in whatever factory or office one can. One does not get to make the big decisions, one puts up with it and takes the pay check.

Then it's off to the pub with your work mates to complain about it all. Which in this case includes a moan about the tools one is forced to use, languages, operating systems, version management systems, etc, etc.

User avatar
ScriptBasic
Posts: 879
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Thu May 16, 2019 3:21 pm

Great discussion!

Having worked for myself for so long, I didn't consider the 'forced to use' scenario. It would be like telling me what to wear. Been there, done that in the military.
Last edited by ScriptBasic on Thu May 16, 2019 3:23 pm, edited 1 time in total.

hippy
Posts: 5091
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: General language discussion.

Thu May 16, 2019 3:22 pm

Heater wrote:
Thu May 16, 2019 1:58 pm
What is it about the current specification of Python's syntax and semantics that prevents it from accessing machine memory and registers?
No idea. I would guess the argument against it being provided for in official Python would not be so much that it couldn't be done, but that it shouldn't.

It would probably attract the same opposition as suggesting Python or C should have a built-in graphics and/or GUI framework. They both could, but neither do.

It seems reasonable to me that those controlling the official specification should get to decide what's in the official language specification or not.

jahboater
Posts: 4170
Joined: Wed Feb 04, 2015 6:38 pm

Re: General language discussion.

Thu May 16, 2019 3:27 pm

Heater wrote:
Thu May 16, 2019 1:58 pm
What is it about the current specification of Python's syntax and semantics that prevents it from accessing machine memory and registers?
Python doesn't have pointers which might make it a little difficult.

User avatar
ScriptBasic
Posts: 879
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Thu May 16, 2019 3:30 pm

Heads up, ScriptBasc isn't my "pet project'. It a commitment I made 15 years ago and I have no regrets.

Andyroo
Posts: 2823
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: General language discussion.

Thu May 16, 2019 3:35 pm

jahboater wrote:
Thu May 16, 2019 3:27 pm
Heater wrote:
Thu May 16, 2019 1:58 pm
What is it about the current specification of Python's syntax and semantics that prevents it from accessing machine memory and registers?
Python doesn't have pointers which might make it a little difficult.
Well - yes and no. Technically variables are passed as pointers (lets not go there) :lol:

You can get to memory via a byte array using the ctypes.string_at but I would use C to do it if I had to (and I plan never to).
Need Pi spray - these things are breeding in my house...

User avatar
ScriptBasic
Posts: 879
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Thu May 16, 2019 3:55 pm

The Fibonacci challenge is a good example how well the language you use is adaptable. Turning a buffer created by a library function into a native 1 meg string without declaring anything is where ScriptBasic shines for me.

User avatar
ScriptBasic
Posts: 879
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Thu May 16, 2019 4:08 pm

A tweet I just read in a thread asking how old were you when you started programming? I love this response.
.I started writing code in BASIC when I was 5 years old. Does that count?

Heater
Posts: 12072
Joined: Tue Jul 17, 2012 3:02 pm

Re: General language discussion.

Thu May 16, 2019 5:39 pm

ScriptBasic,
I started writing code in BASIC when I was 5 years old. Does that count?
Careful there. I read "Does that count" that as meaning the writer suspected using BASIC did not count.

Anyway, I'm envious, when I was 5 a computer might not have fit in the house, the first commercial IC's became available, the inventor of the vacuum tube died, FORTRAN IV was created, ECMA was established (Yay, Javascript!).

I suspect in the early 1980's there were a lot of 5 years olds that bashed out some BASIC. What with all those kids with BBC Micros, C64's, Sinclair Spectrums, etc in their bedrooms.

However, instead, I built my first electric circuits when I was 5. Does that count?

Quizz: What year was I 5 years old?

Andyroo
Posts: 2823
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: General language discussion.

Thu May 16, 2019 5:57 pm

Heater wrote:
Thu May 16, 2019 5:39 pm
ScriptBasic,
I started writing code in BASIC when I was 5 years old. Does that count?
Careful there. I read "Does that count" that as meaning the writer suspected using BASIC did not count.

Anyway, I'm envious, when I was 5 a computer might not have fit in the house, the first commercial IC's became available, the inventor of the vacuum tube died, FORTRAN IV was created, ECMA was established (Yay, Javascript!).

I suspect in the early 1980's there were a lot of 5 years olds that bashed out some BASIC. What with all those kids with BBC Micros, C64's, Sinclair Spectrums, etc in their bedrooms.

However, instead, I built my first electric circuits when I was 5. Does that count?

Quizz: What year was I 5 years old?
1886 :shock: :o :shock:

That’s when Prof Frederick Guthrie died :lol: Technically he created the thermionic diode but I’m not going to split hairs (though you may).
Need Pi spray - these things are breeding in my house...

jahboater
Posts: 4170
Joined: Wed Feb 04, 2015 6:38 pm

Re: General language discussion.

Thu May 16, 2019 5:58 pm

Andyroo wrote:
Thu May 16, 2019 5:57 pm
Heater wrote:
Thu May 16, 2019 5:39 pm
ScriptBasic,
I started writing code in BASIC when I was 5 years old. Does that count?
Careful there. I read "Does that count" that as meaning the writer suspected using BASIC did not count.

Anyway, I'm envious, when I was 5 a computer might not have fit in the house, the first commercial IC's became available, the inventor of the vacuum tube died, FORTRAN IV was created, ECMA was established (Yay, Javascript!).

I suspect in the early 1980's there were a lot of 5 years olds that bashed out some BASIC. What with all those kids with BBC Micros, C64's, Sinclair Spectrums, etc in their bedrooms.

However, instead, I built my first electric circuits when I was 5. Does that count?

Quizz: What year was I 5 years old?
1886 :shock: :o :shock:

That’s when Prof Frederick Guthrie died :lol: Technically he created the thermionic diode but I’m not going to split hairs (though you may).
Fortran IV was created in 1961 and released in 1962 .....

hippy
Posts: 5091
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: General language discussion.

Thu May 16, 2019 5:59 pm

Andyroo wrote:
Thu May 16, 2019 3:35 pm
You can get to memory via a byte array using the ctypes.string_at but I would use C to do it if I had to (and I plan never to).
But isn't 'ctypes' an extension module written in C ?

My own extension module allows GPIO0 to be set then cleared as simply as -

Code: Select all

import GPIO
GPIO.GPSET0 = 1
GPIO.GPCLR0 = 1
That's entirely Pythonic but isn't a part of the Python language.

User avatar
Burngate
Posts: 5863
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: General language discussion.

Thu May 16, 2019 6:03 pm

Heater wrote:
Thu May 16, 2019 5:39 pm
Anyway, I'm envious, when I was 5 a computer might not have fit in the house, the first commercial IC's became available, the inventor of the vacuum tube died, FORTRAN IV was created, ECMA was established (Yay, Javascript!).

Quizz: What year was I 5 years old?
Not gonna answer that, but you're just a kiddy-wink - totally missed out on the Vietnam war, building the Berlin Wall, Yuri Gagarin in space, ...

User avatar
rpdom
Posts: 14063
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: General language discussion.

Thu May 16, 2019 6:20 pm

Heater wrote:
Thu May 16, 2019 5:39 pm
However, instead, I built my first electric circuits when I was 5. Does that count?
I was building electrical circuits aged 4 with the help of the Ladybird Book "Magnets, Bulbs and Batteries" :)

I learnt how to wire a mains plug and lights a year or two later.
Signature is on holiday.

User avatar
ScriptBasic
Posts: 879
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Thu May 16, 2019 7:36 pm

My electronic life started at 7 as a ham radio fan.

User avatar
ScriptBasic
Posts: 879
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Thu May 16, 2019 8:12 pm

hippy wrote:
Thu May 16, 2019 5:59 pm
Andyroo wrote:
Thu May 16, 2019 3:35 pm
You can get to memory via a byte array using the ctypes.string_at but I would use C to do it if I had to (and I plan never to).
But isn't 'ctypes' an extension module written in C ?

My own extension module allows GPIO0 to be set then cleared as simply as -

Code: Select all

import GPIO
GPIO.GPSET0 = 1
GPIO.GPCLR0 = 1
That's entirely Pythonic but isn't a part of the Python language.
Any chance you can share some of that magic getting the ScriptBasic GPIO extension module going?

User avatar
ScriptBasic
Posts: 879
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Thu May 16, 2019 9:54 pm

Is Python's extension library as extensive as Perl?

I would be interested in why you think Python is better than Perl.

Python vs. Perl
Last edited by ScriptBasic on Fri May 17, 2019 12:21 am, edited 1 time in total.

User avatar
ScriptBasic
Posts: 879
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Thu May 16, 2019 10:02 pm

To clear up any misunderstandings, my focus with ScriptBasic is not to try to unseat main stream scripting solutions. Think of ScriptBasic as a high level wrapper for ANSI C. ScriptBasic by design is an API. (core scripting, embed and extend API)

In less than 10 lines of C code you could create an embeddable version of ScriptBasic in your application with the interpreter running as a shared object.

I should embed ScriptBasic in Python and reduce the pain factor. All of SciptBasic's extention modules would be available to Python. You could experiance true threading for the first time in Python. :lol:

All I would have to do is convert the SBT extension module to a Python extension module and Python would have full use of ScriptBasic. (threaded model)

SBT is an example of ScriptBasic being embedded in itself.

It seems that creating a Python extension module is a lot more complex than building a ScriptBasic extension module.
PeterO wrote: Just take a few minutes off from pushing your pet project at every opportunity and have a look around in some of the other parts of these forums to see what the rest of us are doing.
I wonder what tricks PeterO's pet projects can do?

Show me the code!

Maybe there is a ScriptO I'm unaware of.

hippy
Posts: 5091
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: General language discussion.

Fri May 17, 2019 9:43 am

ScriptBasic wrote:
Thu May 16, 2019 8:12 pm
Any chance you can share some of that magic getting the ScriptBasic GPIO extension module going?
Very probably. Best to do that in the ScriptBasic thread or start a new thread for that. I am no expert and I'm not sure how useful what I am doing for Python will be for ScriptBasic but I'm certainly willing to share what I know or think I know.

I got what I wrote slightly wrong through typing from memory, but only a little different in reality. That relies on @property features of Python to invisibly turn what looks like "<var>=<expr>" into "SetVar(<expr>)" calls so may not be applicable to ScriptBasic at the higher level.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 22044
Joined: Sat Jul 30, 2011 7:41 pm

Re: General language discussion.

Fri May 17, 2019 10:05 am

ScriptBasic wrote:
Thu May 16, 2019 9:54 pm
Is Python's extension library as extensive as Perl?

I would be interested in why you think Python is better than Perl.

Python vs. Perl
perl is fairly awful, so its not difficult for Python to be better. Perl syntax is rather obtuse, at least Python is better in that respect.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

hippy
Posts: 5091
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: General language discussion.

Fri May 17, 2019 12:56 pm

jamesh wrote:
Fri May 17, 2019 10:05 am
perl is fairly awful, so its not difficult for Python to be better. Perl syntax is rather obtuse, at least Python is better in that respect.
I wrote a full-blown comments system for a public web site in Perl. Mostly because that's all the hosted server allowed. I didn't find that too bad to do and it's fairly easy to craft Perl in such a way it looks pretty much like any other block structured language and is by no means any worse.

Prompted to look back at that; what I produced looks like Javascript, and I don't think it would be that offensive or incomprehnsible to anyone who hasn't ever used Perl.

I must have found it easy going because I rediscovered I had written a complete compiler and GUI IDE in Perl which I'd totally forgotten about !

The syntactical decoration ( $ prefixes for variables, & for subroutines, etc ) takes a little getting used to but it's not too bad. The real problem is that Perl allows a variety of ways of doing things and there seemed a 'Perl culture' of doing things in the most obscure or compact way possible which was often impenetrable to all but experts or the original author.

Perl has to carry the can for allowing that, but IMO it was mostly a problem of 'Perl culture' and Perl programmers choosing to write code in the way they did. I got the impression a good part of that was 'elitism', the smug satisfaction of writing code which only a select few would understand or could penetrate.

I took quite a battering from some quarters at the time for writing Perl in the style I was using. If I'd turned my readily understandable 10 line subroutines into obfuscated one-liners of nested RegEx's they would have been happier.

Perl invited writing impenetrable code, but it didn't have to be done that way.

User avatar
ScriptBasic
Posts: 879
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Fri May 17, 2019 3:20 pm

hippy wrote:
Fri May 17, 2019 9:43 am
ScriptBasic wrote:
Thu May 16, 2019 8:12 pm
Any chance you can share some of that magic getting the ScriptBasic GPIO extension module going?
Very probably. Best to do that in the ScriptBasic thread or start a new thread for that. I am no expert and I'm not sure how useful what I am doing for Python will be for ScriptBasic but I'm certainly willing to share what I know or think I know.

I got what I wrote slightly wrong through typing from memory, but only a little different in reality. That relies on @property features of Python to invisibly turn what looks like "<var>=<expr>" into "SetVar(<expr>)" calls so may not be applicable to ScriptBasic at the higher level.
Where we left off was you wanted the source to the GPIO extension module which I posted on RasperryBASIC.org due to a 1 week ban.

User avatar
ScriptBasic
Posts: 879
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Fri May 17, 2019 4:29 pm

Perl invited writing impenetrable code, but it didn't have to be done that way
ScriptBasic's build system is written Perl. Peter Verhas seemed rather proficient using the language. The SciptBasic MODULE / namespace was modelled after Perl.

User avatar
ScriptBasic
Posts: 879
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: General language discussion.

Fri May 17, 2019 5:01 pm

I had a one line wonder forum member bragging his Ruby code was the most efficient.

Ruby vs. ScriptBasic

When you meet someone that is rude.
Last edited by ScriptBasic on Fri May 17, 2019 7:52 pm, edited 1 time in total.

Heater
Posts: 12072
Joined: Tue Jul 17, 2012 3:02 pm

Re: General language discussion.

Fri May 17, 2019 7:36 pm

Seems a bit wordy and confusing to me. How about:

Code: Select all

let n = l = i = 1
while (n < 106) {
  process.stdout.write(('' + n + ' ').padStart(3, ' '))
  if (n++ == l) {
    process.stdout.write('\n')
    l += ++i
  }
}

Code: Select all

$ time node floyd.js
 1
 2  3
 4  5  6
 7  8  9 10
11 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35 36
37 38 39 40 41 42 43 44 45
46 47 48 49 50 51 52 53 54 55
56 57 58 59 60 61 62 63 64 65 66
67 68 69 70 71 72 73 74 75 76 77 78
79 80 81 82 83 84 85 86 87 88 89 90 91
92 93 94 95 96 97 98 99 100 101 102 103 104 105

real    0m0.205s
user    0m0.031s
sys     0m0.172s

Return to “Other programming languages”