W. H. Heydt
Posts: 11974
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Learning a New Programming Language

Sat May 21, 2016 3:40 pm

Heater wrote: Indeed it does. At least Algol did not make that mistake. A mistake that has been perpetuated ever since through the linage of C, C++, Java, C#, Javascript, etc, etc.
ALGOL made the mistake of not including an I/O capability in the language definition (at least, not in the ALGOL60 report). UC Berkeley implemented ALGOL by cobbling on FORTRAN I/O using FORMAT statements....
Not really. There are no "subroutines" in assembler or machine instructions. There may well be mechanisms to support them, using the stack, or dedicated registers as you say.
Let me put it this way... *Every* "high level" construct has to interpret/compile to machine instructions. Anything that can be put into machine language can be done in assembly language, therefore, *any* language structure *can* be implemented directly in assembly language. The result may be ugly and inefficient unless done by a real expert, but every single one can be done because if they couldn't, they couldn't exist in high level languages.

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

Re: Learning a New Programming Language

Sat May 21, 2016 4:38 pm

W. H. Heydt,
ALGOL made the mistake of not including an I/O capability in the language definition...
That is true.

But there is lies another minefield of debate. :)

I don't think any such I/O should be part of a language definition.

It's not part of the C language definition either, for example. It is however part of the C standard libray which is all mixed up in the standard.

For example: Embedded systems, like the Arduino, use the language but not the standard library. They know nothing of the "printf()" function.

Contrast with BASIC or Python where I/O was baked into the language syntax. See what issues Python 3 has when moving "print" out of the language into "print()", part of a library.

How much of the I/O of Javascript is specified in the language definition? None (Well perhaps console.log()) The rest is down to other standards, like the Document Object Model of the browser.

ALGOL may have thrived better if it had specified such an I/O library.
Let me put it this way... *Every* "high level" construct has to interpret/compile to machine instructions. Anything that can be put into machine language can be done in assembly language, therefore, *any* language structure *can* be implemented directly in assembly language....
Yes.

No argument with that. If it's a Turing complete machine it can do whatever we like.

But concider: A pile of bricks and cement is not a house. Or a multi-story building. Or an outside toilet. Or a bomb shelter. Or a garden wall. Although it does make all those things, and more, possible.

Similarly a pile of machine instructions is not a functional programming language or an object oriented language or whatever it is you want to build from it.
Memory in C++ is a leaky abstraction .

User avatar
Gavinmc42
Posts: 4363
Joined: Wed Aug 28, 2013 3:31 am

Re: Learning a New Programming Language

Sun May 22, 2016 2:04 am

These are on my list to learn/master next.
Go, multicore aware, obvious for Pi2/3
Lua + Luajit, can be used in tiny stuff like micropython.

I use Lua and micropython as faster scripting languages when bash/ash shell is not fast enough.
For Web stuff HMTL5, CSS, Javascript

Nice if the new language has native socket support, easier to do networked stuff.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
DougieLawson
Posts: 38447
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: New Programming Language

Sun May 22, 2016 7:27 am

lpsw wrote:IMHO it depends on what you want to do, but two of the more popular languages on Linux based systems are C (and it's variants) and Java (and it's variants). I prefer the former and despise the latter, but that's just my opinion.
That is so wrong. Java is C++ without all the awful crud and complexity. The only thing wrong with Java is the JVM, if they'd made it with a native compiler/linker it would be an excellent language. The thing that pulls Java down is the "write once, run anywhere" or as critics would say "write once, debug everywhere" principle which needs the JVM and is totally unnecessary.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

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

Re: Learning a New Programming Language

Sun May 22, 2016 10:05 am

yodermk,
Problem with Javascript is that it is a truly horrible language that was thrown together almost thoughtlessly over the last 20 years.
This is not true. You clearly don't know the history of Javascript. Let's skip the "horrible" part for a moment.

Javascript was standardized internationally, ECMA standard 262, in 1997. The language design has changed very little over the years and what changes there have been have always been backwards compatible. The standards committee comprises members such as Mozilla, Microsoft, Adobe and others. They put a lot of thought into proposed language changes. So much so that the proposals for version 4 of the language standard were totally dropped after a lot of work had been put in to them.

Javascript has, like C and C++ been one of the most rigorously defined and stable standards over a long period of time.
If you don't believe me that it's horrible note O'Reilly's book "Javascript: The Good Parts." It is one of the thinnest tech books I've ever seen, and most of it is an appendix describing the bad parts!
I would say the fact that "Javascript: The Good Parts." is such a "thin" book is a very good thing. Should one have to digest a 1000 page book to use a programming language? Consider "The Good Parts" as a guide to using JS sensibly. In the same way as we have
guidelines for the use of C++ and other languages.

People like to point and laugh at the bad parts of JS. That's easy to do. However in practice JS programmers hardly ever find those bad parts a problem. If you use a nice editor like Microsoft's Visual Studio Code, or Atom, or Sublime with intellisence and especially linting built in you will hardly ever run into problems with "the bad parts"

All languages have "bad parts". C++ developers have been dependant on their IDE's to save them for years now.

It's true to say that JS was designed and prototyped very quickly in 1995. However it's designer, Brendan Eich, is no dummy and had a language in mind when he was hired.

JS is far from "thrown together".

There is change coming though. The ECMA Sript 6 standard (2015) brings with it lot's of nice new features to Javascript. Again all backwards compatible.

If you really want to use a different language in the browser do so. There are many that can be "transpiled" to JS and run in browser.when I transpile C++ to JS it runs at speeds comparable to natively compiled C++.


Python is a disaster. Whoever though white space block delimiting was a good idea? The only advantage I see for it is it's support for arbitrarily big integer arithmetic.
Personally I'm increasingly a fan of modern C++.
Me too.

C++ has grown tremendously over the years and is now such a big and complicated language that I don't believe there is a single human alive that understands all it's parts and how they interact with each other. That's why any serious project that uses C++ has a thousand page guidelines document drawn up specifying what programmers on the team can and cannot do with the language.

C++ gives you enough rope to hang yourself good and proper. However one could write a book, say "C++: The Good Parts", that would be very thin and allow people to use the language sensibly. In fact that is what the Arduino documentation does.

Certainly recent C++ feature additions make it very nice to use.

Qt is fabulous.

Java is nuts. It has no reason to exist. We have C++ right? Forcing everything to be a class is nuts. When Java was introduced I could not get my head around the idea of putting main() into a class. After a decade or so I concluded it was not my problem Java is just nuts.
Memory in C++ is a leaky abstraction .

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

Re: Learning a New Programming Language

Sun May 22, 2016 10:15 am

Dougie,
That is so wrong. Java is C++ without all the awful crud and complexity.
That is so wrong. Java forces all programs to be class based. C++ does not. To my mind this makes them fundamentally different. Even before we start talking about the huge and slow JVM.

You can't even get at memory in Java.

Chalk and cheese.

I'm not sure that it's even possible to compile all Java programs to native code.

Java, the worst of both worlds, the hugeness and slugishness of interpreted languages, the compilation hassle of compiled languages.
Memory in C++ is a leaky abstraction .

Pithagoros
Posts: 580
Joined: Wed Nov 12, 2014 8:16 pm

Re: Learning a New Programming Language

Sun May 22, 2016 10:34 am

Seems language preference is subjective.

On Javascript, it is maturing as a language and its scope is growing. Apart from Node.JS it is now fundamentally in NoSQL with stuff like Mongo and Couch and nicely coupled with JSON. It seems to have come a long way from when it was used to bodge more client side functionality in browsers. A JavaScript string to your bow is no bad thing.

Despite having put a lot of time into Java when it first appeared in the 90s, I find the whole thing abhorrent, shabby and entropic. The Oracle association is the last straw and I actively drive it out of anywhere I find it, as if it were vermin (anyone worked on Oracle and used SQL Developer will know how dreadful Java can be). The consensus against it is overwhelming and if it weren't for legacy it would be dead in the water.

User avatar
Gavinmc42
Posts: 4363
Joined: Wed Aug 28, 2013 3:31 am

Re: Learning a New Programming Language

Sun May 22, 2016 10:41 am

Java is a pain, need to use Netbeans on a PC for remote development.
And yet with JavaFX you can do stuff that is hard to do otherwise.
Graphics overlay on video, not painful.
Still looking for a lower footprint replacement for it.

Learn as many languages you can.
Each time it gets easier and your toolbox of methods means you can do more stuff.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
PeterO
Posts: 5701
Joined: Sun Jul 22, 2012 4:14 pm

Re: Learning a New Programming Language

Sun May 22, 2016 10:54 am

W. H. Heydt wrote: ALGOL made the mistake of not including an I/O capability in the language definition (at least, not in the ALGOL60 report).
Algol 60 was my first high level language, on one of these machines....
https://www.youtube.com/watch?v=AIxZ1i8pvZI

I have several emulations of this machine... I really must finish this one sometime
https://www.youtube.com/watch?v=3zezUiJ8NI8

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

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

Re: Learning a New Programming Language

Sun May 22, 2016 11:57 am

PeterO,

Wonderful. You really should finish that emulator. A version for the web using webgl would allow the whole world to experience it.

My first Algol was on an ICL 1903, or 190 something I forget exactly, soon replaced with an ICL 2960. A huge big beautiful bright orange machine.
Memory in C++ is a leaky abstraction .

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

Re: Learning a New Programming Language

Sun May 22, 2016 12:51 pm

Amazingly I find there is Algol 68 available for the Pi:

Code: Select all

$ apt-cache search algol
algol68g - Implementation of Algol 68 as defined by the Revised Report
Thanks to the amazing Marcel van der Veer.

It's all up to date and well documented:

https://jmvdveer.home.xs4all.nl/algol.html
Memory in C++ is a leaky abstraction .

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Learning a New Programming Language

Sun May 22, 2016 2:27 pm

I believe Algol68 was the language that introduced the type "void" to the world. Unlike how it is used in C++, it was a complete type. You could define variables, even arrays of it, and they all took up no memory whatsoever. I'm struggling to find a use-case for that, but it's beautifully orthogonal. One could argue that the loosely typed languages such as Python make use of it, since the value None conveys no information.

There's a couple of languages I could chuck into the pool -- Forth and Lisp. Much like Algol, you're unlikely to make a living off them these days (although I was writing Forth as a day job for over ten years and into this century. I even got it to do object orientation.)

Forth is great as a way of understanding how a language can be built up with its own bootstraps without a compiler or interpreter. It is an entirely different beast from just about everything else out there.

Lisp on the other hand is a good example of just how simple and pure a language can be. It's a shame that XLisp died, because an object oriented language that could learn to handle new methods at runtime was a fascinating concept that later languages still struggle with. Say you've got a library class that is used all over and you want it to do something different. Subclassing it won't change all the places that it is already used. But with XLisp you could do it.

Neither of those is something you would want to learn for writing a large project, these days they are far to clunky. But to expand your ideas they would be perfect. Not only do they not use "=" for assignment, Forth doesn't even limit the characters you can have in variable names; if you want to call something "&%$%&^" then go ahead.

User avatar
lpsw
Posts: 207
Joined: Thu Jun 25, 2015 4:45 pm
Location: USA

Re: Learning a New Programming Language

Sun May 22, 2016 3:11 pm

Heater wrote:Dougie,
That is so wrong. Java is C++ without all the awful crud and complexity.
That is so wrong. Java forces all programs to be class based. C++ does not. To my mind this makes them fundamentally different. Even before we start talking about the huge and slow JVM.

You can't even get at memory in Java.

Chalk and cheese.

I'm not sure that it's even possible to compile all Java programs to native code.

Java, the worst of both worlds, the hugeness and slugishness of interpreted languages, the compilation hassle of compiled languages.

++1
Self-education is, I firmly believe, the only kind of education there is - Isaac Asimov

anzi2001
Posts: 2
Joined: Sat Mar 26, 2016 3:30 pm

Re: Learning a New Programming Language

Sun May 22, 2016 3:28 pm

Kratos wrote:I am looking to learn a new programming language. I have a a decent amount of python experience, and a tiny bit of HTML and CSS knowledge. Any recommendations for a heavily used, popular language?

Kratos
c++ is easier than c but still powerful and widely used...and if you learn c++ its super easy to learn c later...if youre searching for a lighter language i suggest javascript. its still has all the concepts of languages like c(unlike html and css) but easier to learn and its much easier to learn c later on :)

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

Re: Learning a New Programming Language

Sun May 22, 2016 4:31 pm

anzi2001,
c++ is easier than c but still powerful and widely used...and if you learn c++ its super easy to learn c later.
How can that be?

Almost any valid C program is also a valid C++ program.

If you know C++ you already know C.

C++ is a huge and complicated language.

Of course things like the STL and Qt GUI toolkits will probably make your life easier than trying to do the same in C.
Memory in C++ is a leaky abstraction .

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

Re: Learning a New Programming Language

Sun May 22, 2016 10:06 pm

rurwin
It's a shame that XLisp died, because an object oriented language that could learn to handle new methods at runtime was a fascinating concept that later languages still struggle with. Say you've got a library class that is used all over and you want it to do somethingdifferent. Subclassing it won't change all the places that it is already used. But with XLisp you could do it.
No worries. Javascript has been able to this for twenty years now. Javascript supports "prototypal inheritance" (or should we call it "delegation"?) all you have to do is reach back into the prototype chain and change whatever you like.

People have been using this idea to add methods to built in classes in the language and the in browser API since the beginning. For example to add functionality to strings.

You can change the behaviour of code as it runs. Which has made for some funky code editing environments where your code runs all the time and changes on the fly as you edit.

You can do things like add existing functions to classes. Or create entirely new functions out of input strings. See the code below. I have used the new ECMAScript 2015 classes and template strings to make it easier on the eyes but it's equally doable in your father's Javascript from 1995.

You can also do this kind of thing in Lua and other languages.

Code: Select all

'use strict';

class Counter {
    constructor (initialCount) {
        this.count = initialCount;
    }

    increment () {
        this.count += 1;
    }

    decrement() {
        this.count -= 1;
    }

    get value() {
        return this.count;
    }
}

let counter = new Counter(0);

counter.increment();
counter.increment();
counter.decrement();
counter.increment();

console.log(counter.value);

// Add a clear() method to all instances of Counter
Counter.prototype.clear = function () {
    this.count = 0;
};

counter.clear();

console.log(counter.value);

// Replace the decrement() method to all instances of Counter
// N.B. This function is created from a string
Counter.prototype.decrement = new Function (`
    if (this.count > 0) {
        this.count -= 1;
    }
`);

counter.decrement();

console.log(counter.value);
Memory in C++ is a leaky abstraction .

Return to “General discussion”