Python Strange Syntax

Thread Starter

MrAl

Joined Jun 17, 2014
13,711
I use two-space tabs as well so the code doesn’t slide too far off the screen.

It really does require analyzing the cost-benefit tradeoff. I am not a super-fan of Python but I have to give it what it is due. It has been so widely adopted in the science/math/experimental community that knowing and using it is an instant leg up if you are doing anything related. There are excellent libraries for Python in specialist areas, including one the best big number libraries.

I don’t know what you program in now, but if you are not using a dynamic language that will take a bit of getting used to. Again, it has advantages and disadvantages. Some people insist on calling Python* programs “scripts” because they believe they aren’t “real” programs.
* and Perl, and Javascript, &c

This is just word games without content. Because of the confusion concerning the difference between what is a script and what is a program, some time ago I spent quite a bit of effort researching the question and discovered there was no real difference in the context of dynamic vs. fully* compiled programming languages. It just isn’t a thing, and even if it was, it wouldn’t confer some special goodness on the “programs” compared with the “scripts”.
*fully compiled because dynamic languages generally use a combination of intermediate compilation and interpretation of the intermediate code

In practice, I finally decided to make the word “script” somewhat useful by making the following distinction:


For me, this makes using the two different words helpful in distinguish the role of a program, and to some extent the nature of the code in it.

In any case, if dynamic languages are new, you are going to find some very useful things they can do. Make sure to take advantage of them. I tell aspiring Perl programmers who are coming from a C/C++ background, and are writing Perl as if it was C, that C is a great language for writing Perl, but a terrible way to write perl code.*
*Perl is written in C (and Perl), but using C syntax and methods in Perl code completely misses the point of Perl

If you are going to learn Python, learn it all the way. Learn to program in it as Python programmers do. Try not to smuggle in a bunch of baggage. After you‘ve learned it fairly well, you may find a place for habits, structures, and methods you have learned for other languages—but wait until you know how to program “natively”.

Good luck, and have fun.
Hi Ya'akov,

Thanks for the reply.

I think I understand what you are saying here. It would be better to learn the pro's before making any real code and any real judgements.

This is kind of interesting for me because this would be the first new language I have studied in quite a few years now. The previous was Java for Android, but I could not seem to find enough info on that for some reason. If I could find more about that I might put that first.
Do you happen to know if Python could be used for Android programming? I know this is a long shot, but if true that would be a really good "pro".
 

Thread Starter

MrAl

Joined Jun 17, 2014
13,711
It’s great that you‘ve found an editor that works for you, and cool that wrote it. Very nice.

I would do a little research before claiming that it is more capable or feature rich than others. I don’t see anything on your list at first glance that modern editors can’t do—either natively or with plugins. Editors have come a very long way, and modern ones, with IDE features, are pretty damned amazing.

I think if you did some looking around now, you’d find that there are many options that can do what you want(ed). Of course, you are “married” to the current editor and have a big investment in it, of both time and psychological attachment. ”If it ain’t broke…” is surely an apt maxim in this case, and there’s probably no reason to bother looking around.

Still, you might get some ideas to enhance your own editor—or, who knows, find something you like better(!) and port your features to it as plugins…
Hello again,

Well my experience in the past was when i use someone else's software there are always bugs, and i have no way to fix them because i don't always have the code, and when i do have the code it's rather long and takes a lot of time to study out. That's the main reason i started writing my own editor way back.
It's very frustrating to get part way through a program and find that you can't do something or something does not work, and it could be critical.
I used a web based program a long while back for writing web pages. I got pretty far, but then ran into a problem where i could not write something properly because of the way the 'language' was written. It put a big halt to the whole project. It may be better now though, that was probably 20 years ago.

I will in fact look around for other editors and see if I can find something I can live with. Hopefully there is not much of a learning curve either.
 

Thread Starter

MrAl

Joined Jun 17, 2014
13,711
I will be looking up that help again so I will see if I can find it again.
I cannot find it again and I looked around quite a bit. It may be that they were talking about a 'method' of programming and not part of the actual language. Not sure where it is now though because I closed out the page and never thought I would have to go back to it.
 

Ya’akov

Joined Jan 27, 2019
10,244
I will in fact look around for other editors and see if I can find something I can live with. Hopefully there is not much of a learning curve either.
Any sophisticated software will have a fairly substantial curve, but lately people do a good job of being consistent with UIs. So, I would recommend whatever you try to use, you start with working out the principles of the UI—it will make things much smoother.
 

ApacheKid

Joined Jan 12, 2015
1,762
Hello there,

Anyone here use that language?

From what i can tell so far, it looks like the most ridiculous language i have ever seen. That's because the syntax attempts to force the programmer to keep track of every space in the program lines. THAT seems like a discontinuity in how humans want to program because it nails down the form of the text into a overly rigid form.
For example, if you are declaring constants you can not do this in an attempt to line up the decimal points vertically:
x=___1.234 (the underscores are spaces really)
y=123.4

You MUST do it this way only:
x=1.234
y=123.4


Do i have this wrong? I only took a very short look at some of the documentation so far.
This is sadly true, Python relies on indentation to denote hierarchies/nesting. It is not something I like myself, many do. If you copy/paste the code and mess up spaces and the code either won't compile or even worse will compile but behaves differently.

There are other languages that do this, e.g. F#.

I developed a programming language grammar last year that was designed from the groundup to meet a set of very specific goals, one of these was concerned with how best to express this concept of hierarchy. I managed to design that and in the process eliminate all reserved words, eliminate semicolons and even support foreign keywords (like German or Spanish versions of every keyword) without issues.

As part of my research ahead of the work, I encountered Python and didn't like it either !

The most attractive way - IMHO - was keyword/end pairings, if you're interested in details take a look at this thread where it was actively discussed.
 
Last edited:

Thread Starter

MrAl

Joined Jun 17, 2014
13,711
This is sadly true, Python relies on indentation to denote hierarchies/nesting. It is not something I like myself, many do. If you copy/paste the code and mess up spaces and the code either won't compile or even worse will compile but behaves differently.

There are other languages that do this, e.g. F#.

I developed a programming language grammar last year that was designed from the groundup to meet a set of very specific goals, one of these was concerned with how best to express this concept of hierarchy. I managed to design that and in the process eliminate all reserved words, eliminate semicolons and even support foreign keywords (like German or Spanish versions of every keyword) without issues.

As part of my research ahead of the work, I encountered Python and didn't like it either !

The most attractive way - IMHO - was keyword/end pairings, if you're interested in details take a look at this thread where it was actively discussed.
Hi,

That's very interesting because I have thought about hierarchy a lot myself as it relates to program maintenance. This troubled me in C++ and another language that also uses classes or class-like objects.

The Pro is that a class can be derived from another class, which means quick turnaround for new classes that can use features that a lower class had all along.
The Con is that if you derive a lot of upper classes with that one lower class and that lower class had a problem you just found out about, you may have a lot of work on your hands correcting the upper classes.

I believe that classes came as a natural progression in thinking which started from a regular variable and separate functions. The fix may be to figure out some sort of versioning system that allows you to correct code in several modules automatically or at least very quickly.

I'd like to hear how you dealt with hierarchy though as to what you did with this.

What did you mean when you said you eliminated all reserved words though, how can you do that and still have key words.
 
Top