idea

print() all over yourself …

There are fancy progress bars for Python, but what if you are in a hurry or don’t want to install additional modules or libraries. if that is the case then you can use a little known option of print(), namely end=”\r”.

Here goes :

import time

for i in range(100): 
  time.sleep(0.01)
  print(f'counting : {i}   ', end="\r")                                                                                         

you would use the carriage return symbol to return the cursor to the beginning of the line after every print. Then the print will overwrite the previous string.

You may also put some spaces after the number because the number is left aligned.

Better than a Permalink

Do not do any changes to your site until you read the full Post !

Everyone is aware of the permalinks capability of WordPress, but for sites with fully or partially hierarchical structure there is an additional feature which can make your site easier to navigate and understand.

The idea is for the hierarchical part of your site to use this hierarchy in building your permalink. For example the following page “Learn Java” based on the structure of this site the permalink can be :

  • learn-java
  • learn/java
  • learn-programming/java
  • learn/programming/java

It is clear that the last one is the superior link if you know that every word in this link represents a page.

  • learn
  • learn/programming/
  • learn/programming/java

Again I’m emphasizing that you do that only for the parts of the site that exhibit hierarchy.

So if all what I said apply to your case, how do you do it ?

There is an option in the side panel in the Block editor where you specify Parent page, but if are like me and learned about this after the fact then you would use the Quick edit in the Dashboard > Pages > All Pages list (like shown below) to do the modifications.

Set all the pages in the hierarchy in the following manner :

  • learn => no parent
  • learn/programming/ => learn
  • learn/programming/java => learn/programming/

Why do you see the yellow highlights ? Because there are several things to account for that you have to take into consideration.

First you want your Title to stay descriptive, so you may keep it as it is.

Second your slug should be shorter because it is now part of the hierarchy. You don’t want to put there learn-java, because your permalink will become learn/programming/learn-java. We don’t want that.

The third thing is that if this page is a part of a menu you may have a different text there because of a space constraint.

In this site I have even deeper hierarchy : /understand/programming/languages/java/
But as you see I have many sub-hierarchies, instead of ONE, because otherwise the URL will get too long.

So you like the idea and want to jump in … A, a, a … not so fast. Changing the structure of your site means broken links. So before you start find yourself a plugin to mop up after you break some eggs.

I used “Broken Link Checker“.

Now you are good to go ….

What would you like to change in your favorite language

In this post I will keep a list of things I would like changed in languages, frameworks and formats.

Python

Use multi-method dispatch

Allow Functions not to use brackets() like in Ruby

Add proper range like in Ruby

Add do … while loop

Allow self-defaults in the method declaration, example :

def method(self,val=self.attr1) :
   .........

instead of :

def method(self,val=None) :
   if val is None : val = self.attr1
   .........

Java

Create a synonym for System.out.println(), just use say()

On some places the Parser could be more clever and allow us to skip using the dot-comma ;

Allow if()-like one-line methods. Example from good to bad :

  • public int method(int v) v * v;
  • public int method(int v) return v * v
  • public int method(int v) { v * v }
  • public int method(int v) { return v * v }
  • public int method(int v) { return v * v; }

Allow Python like optional named arguments it is the damn 21st century !! Those variadic arguments are crock.

Reclaim back single quotes for String

Invent groovy.

Allow in-scope-up declaration, code example is worth a hundred words. F.e. we add the let keyword to Java and …

try {
  let String s = "abc"; 
}

should be equivalent to this :

String s = null;
try {
  s = "abc"; 
}

JavaScript

Create synonymous of function() => fun()

console.log(), really !! why not system.out.console.log() then we can all switch to Java and rejoice the brevity.

Ruby

Hmm ….

“Perl6” aka Raku

Finish it already ….

Lisp

Use curly brackets {}, instead of () and call the language Curly Lisp ………. I’m messing with you.

Prolog

Change the rule that variables have to start with UpperCase. But I don’t know with what ??

XML

Call on Tanos to remove it from the Internet 😉

JSON

Allow the use of unquoted “key” : “value”

All languages

All languages should have a command line -flag and configuration rules to exclude and physically remove from the program or convert to nope instruction specific calls.

F.e. nope() normally acts like a print(), but when the flag -nope is used the call is not even in the program.

Add Unification, like in Prolog. All languages are in a hurry to copy functional style primitives and here is this gem waiting to be used.

Add __DATA__ and __END__ sections like in Perl

Adopt Symbols like in Ruby

All languages should immediately drop their version of switch/case in favor of Raku given/when

Standardize on a single spec for templating/formatting strings across as much languages as possible, call it say() and be done with it.

Add BEGIN, END, FIRST, LAST hook to the program and code block …. AWK here we come. Of course the obligatory break and continue should be there too.
To my knowledge only Perl/Raku and Ruby has those.


What do you want to change !!