Programming


Wonderful! -- a chance for me to advance my agenda!

If you want something done in a quick and dirty fashion, and you simply do not care how things work, try Python. A lot of stuff is simply done for you, whether through syntax or libraries. It may be unsatisfying. Comes with an interactive interpreter.

If you want something done in a quick and dirty fashion, but do not want to install too many new programs on your clean UNIX system, try sh/bash/zsh. Embrace the pipe! Also, you may know some already. As a shell, is interactive, of course.

If you do not really care how things work in reality, but do want to actually learn something, try Scheme (perhaps with the SICP). Especially good for those who like (superficial) simplicity. For more industrial/less pure an environment, try Common Lisp or Clojure. You shall learn the value of everything and the cost of nothing. There are also other LISP-type languages out there, do you really want to spend months reading about them all? Most LISPS give the ability to generate more LISP code with other LISP code, called macros -- the saying is code is data. This allows the production of little domain-specific languages (DSLs) to be produced for the problem, though usually the DSLs must (be (composed of (parentheses just as (LISP is)))). Detractors say that LISP stands for Lots of Irritating Superfluous Parentheses (it actually stands for LISt Processing, as it built from a datastructure known as a list). Comes with an interactive interpreter (Read-Eval-Print-Loop, REPL).

If you want to understand how your UNIX system (you have a Pandora or Pyra, at least, right?) works on a lower level, try C. It is very much a mainstream language, with little in the way of exotic/interesting features, but it does allow you the sensation of touching a real computer, with pointers, manual memory management (all of the above are (effectively) garbage collected) and so on. It is also relatively simple, describing a lowest-common-denominator-type virtual computer. Unlike with (most of, the LISPs may be an exception) the other languages above, if you can demonstrate decent knowledge of C, then people will generally assume that you know something about computers as one must learn quite a few other things to make anything serious (make, gcc flags, static vs. dynamic linking etc.). This can be both good and bad. Usually no interactive interpreter, compiler only.

If you really want to understand what you are doing (kudos!), rather than to get the right answer (Tom Lehrer  ;)  -- search for New Math) then try the Assembly language for your computer. It can be a very educational experience -- I regret that I delayed for so long before I taught it to myself (on x86_64) -- as it strips away most of the abstractions in use elsewhere: there are no built-in loops or if-statements (at least, on x86, none you are expected to use), no variables, no built-in memory manager (C provides malloc and free) and no functions (at least, not in the way you may know). Your assembler will provide you with some registers (very small, fast memory locations -- most operations use at least one register), mnemonics (short names that translate into machine-code instructions) and probably a text-substitution-macro language (which is so useful that you will probably find yourself using it). The mnemonics are the statements (better: orders or imperatives as in imperative programming) given to the machine to direct its behaviour, such as GOTO/JMP, CMP, AND, NOT etc. (you can do pretty much anything given those mnemonics and enough effort -- I believe only those, or fewer, are required for Turing completeness; of course, most computers will give you more instructions for the sake of both speed and ease-of-use). You will also, likely, learn how most programs depend on the operating system (you do want an operating system, don't you? Or would you rather write your own I/O routines?) and learn what a stack (there are probably built-in instructions for working with at least one). Also, remember, one man's constant is another man's variable -- there is very little you cannot do with just assembly language, including unwise things, and what little you cannot do (self-modifying code, for example) can be done with a smattering of machine-code knowledge, in addition. (If someone knows of something that can only be done with pure machine-code -- operating on the numerical values of the instructions to do... what? -- please tell me what it is. I only really have x86 in mind, and perhaps also ARM). Assembly usually has no interactive interpreter, though assembly (the process) is usually quite quick, so it can approach the effects of having one; machine-code DOES have an interpreter: the machine! In theory one could input machine-code directly as hexadecimal numbers using tools such as xxd, but it is usually not practical.

You may have heard of Object-Oriented Programming. For most of the last 30 years it has been the prime programming fad (there are uses for it, but it has been promoted as the solution to everything, inappropriately -- also, there is no agreement on what it really means), fading a bit now though (in favour of functional programming). Two OOP languages you may have heard of are C++ and Java. I recommend leaving C++ for later: it may be good if you are already knowledgeable, but for now it is very large, (almost) as unsafe as C (in terms of crashing and unexpected behaviour from manual memory manipulation, with assembly more so) but more complex (both the language itself and the code, written by other people, that you may want to use, though that may just be my own experience; if you want to learn about lower level programming, C is probably a better place to start). Notwithstanding that it is considered rather uncool at the moment, Java does, mostly (I hear there is NullPointerException), save you from C++'s troubles regarding manual memory management and "safety", though less when it comes to complex code libraries. Java also, supposedly, works on multiple platforms without requiring you to change your code -- write once, run anywhere -- and is (sort of) the standard language for programming on Android (assuming that interests you). There are other OOP languages, but I do not have experience with them. Neither C++ nor Java are designed with interactive interpreters in mind; I have never seen one.

Increasingly popular now are the functional languages (also known as applicative languages, as opposed to concatenative languages), which have a reputation as being academic and mathematical -- few more so than Haskell (named after a mathematician!). I have cheated a bit: most LISPs are designed to make functional programming easy, classically Scheme, and in many imperative or procedural languages it is possible to program in a somewhat functional style -- i.e. without changing many global (or static) variables in most of the functions/procedures, so that they always return the same result with the same inputs. Haskell, though, enforces functional programming. Functional programming is generally regarded as good for reasoning about (and testing) small procedures and, particularly, for concurrent programs, though I doubt that you should worry too much about that, right now. I know little about Haskell, though, so here some other functional languages that I have on my TODO list: MLErlangI do not know about interactivity for Haskell, but I believe it is mainly used with the Glasgow Haskell Compiler, which suggests to me that it is not normally used interactively.

Finally, I am currently playing with a concatenative language called Forth or FORTH(by the way, if something is spelt in ALL-CAPS, that frequently means that the language is old-enough that it existed before systems with lower-case letters were common/universal: some of the oldest systems had only UPPER-CASE -- after all, if the input is a punch-card, why care what the text (you cannot see) looks like? -- and, as a result, both Forth and Common Lisp are case insensitive, while most more modern languages are the opposite). Concatenative means that any program can be placed before or after another program and it will run, even if only to crash. Forth is quite an odd language: while Python and C mostly use prefix notation (for functions, f(a,b,c)) with some infix (x+y) and LISP only prefix ((+ x y)), Forth uses (mostly) postfix (x y +), like some old calculators. As a result, it kind-of reflects how the computer really works, as the computer needs to be given the values before they can be added together; also, postfix allows Forth to be concatenative, with the addition of an implicit stack, so the program x y +, which leaves x+y on the stack, can prepended to the program z *, which accepts a value on the stack and multiplies it by z, to give a new program x y + z *, which leaves z*(x+y) on the stack. This new program can also be prepended or appended to any other valid program to give a valid program, which is important as function calling in Forth is dependent on this behaviour. Forth also has some other fun features: direct return-stack (yes, there are two stacks built-in!) manipulation (allowing tricks like copying the return address of a calling function multiple times so that the latter part of that function will return to itself multiple times  B)  ), compile-time functions (which are a bit like LISP macros, allowing the creation of DSLs in a similar way, but without the parentheses of LISP; here the saying is data is code) and use of the Forth interpreter in one's own programs (I wrote a simple stack-based virtual machine language translator by just treating every instruction in that language as a Forth function and getting the Forth interpreter to read in the non-Forth source code  B)  ). As such, using Forth is a bit like coding the inside of a very simple compiler, especially as it also starts at a very low level (like C) with access to memory address, bitwise operations and manual memory management; but since, in Forth, everything is just a function (or word) except for numbers, one can quickly build up one's own high level language inside the program. I should also note that Forth is a very simple language, in terms of implementation (not so much in terms of use, as, eventually, one needs to have some idea of how the compiler works to do the most interesting things), and has been used as the machine-code/assembler for some processors with two built-in stacks (Intel and AMD x86 processors have only one). Also, in Forth it is general practice for functions to be very small, as that reduces the need to remember stack state mid-function, which has the effect of greatly encouraging code reuse on a very fine scale (very important!). TL;DR: Forth is great fun. At least, it is at the moment, as I play with it. Almost always comes with an interpreter, usually a very simple one -- this allows the interpreter to be used on very small embedded systems, allowing interactive debugging on them, including hardware debugging, so Forth has a niche there.

Some possible paths:

1. Quick-results: Python/bash --> Java --> C/C++

2. Bottom-up (why does all this work?): Assembly --> Forth/C --> Scheme/Common Lisp/Clojure --> Haskell

3. Software Engineering undergraduate: Python/Java --> C++

4. UNIX-hacker: sh/bash/zsh --> (Python, optional) --> C --> Assembly

5. Little-computers: Arduino C (or is it C++?) --> Forth/Assembly

6. I don't care how real computers work!: Scheme/Haskell --> Haskell/Clojure/Common Lisp

7. I want to build a computer: VHDL/Verilog (I assume this does not apply to you, so I shall not expand)

8. My path: a little Pascal --> Java (university) --> C++ --> Python (work) --> C --> sh/bash/zsh (a smattering earlier, but got serious here) --> Assembly --> Forth --> ? (I have read a lot about the LISPs, and plan to do them next. The question is, Scheme (which one?), Common Lisp (which one?) or Clojure? Help!)

I like paths 2 and 4 the most. A little bit of path 7 can be explored by using the material at nand2tetris.org, which, in itself, is quite educational.
 
Nice rant :)

I went from BASIC to Asm on the z80, then BASIC, followed by C, E and Asm on the Amiga (68k) then Delphi to Asm on the PC. Didn't dip back into C/C++ until I got the Pandora, only to realise (embarrassingly) that I'd forgotten how to create a makefile.

Now I code almost exclusively in BASIC - it's my Python.

D.
 
8. My path: a little Pascal --> Java (university) --> C++ --> Python (work) --> C --> sh/bash/zsh (a smattering earlier, but got serious here) --> Assembly --> Forth --> ? (I have read a lot about the LISPs, and plan to do them next. The question is, Scheme (which one?), Common Lisp (which one?) or Clojure? Help!)
I did the last part by doing some Clojure for work stuff, then going the SICP/Scheme detour that I recommend for anyone, then using GNU Guile as a part of a C project. I may look into common lisp at some point (currently looking into Rust).
 
I´m not sure if it has been said before on this thread but GLBasic compiles for the Pandora and it is pretty powerfull.

Check here: http://www.glbasic.com/

It is what I use for the Pandora and Caanoo, works like a charm.

Hopefully I can release the game before Pyra is around. ;)

EDIT: yeah, it has been mentioned before... Now the best language to use with it, is the one you prefer and is comfortable with, the one that gets you there. 
 
Last edited by a moderator:
Well, I decided on Python.


I like path 1 the most, but why should I go to Java after Python?


My intention is put all my energies (that I can spare) into Python, and worry about speed after I can actually produce stuff... Then when producing stuff is 'relatively' easy, look at C/C++


And tackle it one module at a time.


Installed Python 3.5 last night as well as Pycharm. Fiddled around a bit learning about the different variables and math functions.


Disclaimer: still using windows.


So far it seems fairly easy...


But I'm sure the most difficult part won't be learning the language, it will be learning to think like a programmer...


Question: I see lots of people opting for Python 2.x over 3.x


As a complete beginner I decided 3.x would be best.


Thoughts?


Also, what IDE is likely to be available on Pyra for Python?


Pycharm seems nice so far, but I doubt it will ever appear on the Pyra.


Would like to get use to a dependable cross-platform IDE.


Suggestions?
 
I basically did python and then C/C++, though in ancient history I (barely) learned Visual Basic. It's not a bad route to go.

You're probably safe going with Python 3.X. You can yell at old timers (like myself) who prefer 2.X, but for no real substantial reasoning. (I actually prefer my integer arithmetic 3/4 = 0 to Python 3.X's 0.75.)

Good luck with an IDE; I just use my handy-dandy text editor vim.
 
i used pycharm for quite a while. even bought a license. geany, look it up on the repo, works very well on the pandora. nowadays i really like sublime text.


if you were used to 2.x, python 3.x was kind of weird because it changed everyday things quite a bit. the usage of print, for example.


if you are starting just now 3.x is fine, of course.


dont worry: with python thinking like a programmer is not a prerequisite. your skills and understanding of how software works will grow naturally over time. this goes for all the languages available, but you will grow faster with python :)


make sure to actually use the tiny bits you already know. dont just read about it. soon enough you will figure out that what you did all the time was working, yes, but theres better/more efficient ways to achieve the same and even more. that will make you better.


java shares many ideas/idioms with python but is a lot more like c codewise. if you really need to/want to go down the c road, java may work as a smooth transition.


EDIT: i would like to recommend the following book: Headfirst Python.


yeah its cheesy, not entirely accurate and probably does not cover 3.x specificaly (tho there may be an updates version out).


it will get you going in no time. and in the beginning, you should not bother about the rest.
 
Last edited by a moderator:
There's a small common trunk to learn no matter what language you use, mainly thinking about functionality as a sum of its parts, abstraction, data structures and algorithms. Then the tree of knowledge splits into a few branches (at least imperative, functional, logic and declarative programming) which share some concepts but are basically different ways of thinking about problems and expressing their solutions. Those branches then further branch into language families, later languages, then dialects.

Starting in python teaches you in the ways of imperative, procedural, object-oriented, dynamically typed, strongly typed, interpreted languages. This gives you benefits for learning any other language sharing some of those traits, including but not limited to C, C++, Java, Ruby, Lua, JavaScript and Rust. Learning and using any programming language also strengthens your base skills.

At least, this is one way of looking at how the synergy boosts work in learning multiple programming languages :)
 
Last edited by a moderator:
This thread got me excited; I've written lots of little stupid programs in Commodore BASIC, I've used applescript and written bash scripts, and I'm done some arduino sketches and some PBASIC stuff... so naturally with all this talk of Python I got the notion to try it on my Pandora.

So I booted up CodeBlocks today intending to get my beginner python on. Wow. That's a lot of tabs and items for what I need. Is there an IDE that is a little simpler... maybe something like notepad++? I just need syntax highlighting really. Any advice there?
 
geany all the way, mate


EDIT:


also midnight commander. its awesome in general and the editor features syntax highlighting. iirc _wb_ is a big fan.
 
Last edited by a moderator:
I like PandaBAS's IDE, myself :p

I don't think anyone will really enjoy coding in it though - but it might be faster than Python :)

D.
 
If I ever get my Pandora working again, I'll need to look and see if it's possible to get jedi-vim installed.  If you can use vim, jedi on top just makes working in python a dream.
 
Well, I decided on Python.

I like path 1 the most, but why should I go to Java after Python?
Like Python, Java has many libraries for many uses readily available, with somewhat standard ways to find them. C and C++ are a little less organized, and generally require more work.

Like Python, Java has automatic memory management, also known as garbage collection, whereas in C and C++ one is expected to manage memory oneself.

Like Python, one can write Java code on one machine/operating system and generally assume it will run on any other that has Java (or Python) installed; for C and C++ this less often applies to source code (it may depend on endianness, word size, operating-system-specific system calls etc.) and almost never to machine code for different machine types or different operating systems.

Like Python, Java provides no syntax for using pointers (if I remember correctly), whereas in C++ and, especially, C, the use of pointers is extremely common.

Unlike Python, but like C++ and C, Java is a statically (and non-inferentially) typed language; in Java, C and C++ one generally has to declare the type of a memory store, like "int x", "float y" or "Foo bar" -- this can be restrictive, but it can also prevent certain errors.

Unlike Python (most of the time), Java code requires a separate compilation step, to translate the source code to byte code for the Java Virtual Machine; for C and C++, source code is translated into machine code, to run directly on your computer's CPU.

So, in many ways, Java is intermediate for Python and C++ (C does not have built-in classes). I should note, though, that I did not mean that you should do Java after Python (I think of them both as not being very interesting in themselves), rather that path 1 is for if you really want "quick results" -- as, with all the easily available libraries, both Python and Java can allow you to get stuff done (or, at least, started) quite quickly -- more than deeper understanding of computing etc.. Path 4, "UNIX-hacker", jumps directly from (optional) Python to C, after some work with the shell. I have my biases, as you can see.
 
Last edited by a moderator:
For anyone jumping from Python to Java, may I point out Ceylon.  It's an approach to static typing that feels a lot more like Python's duck typing, written by Java devs, so it still feels quite Javaish, and will compile to the JVM like pure Java does.  Even if your goal ultimately is to learn Java, I think it's an easier introduction to the ecosystem (especially for Python devs), as you get access to all the standard Java classes from within Ceylon (provided you build for JVM and not anything else).
 
Last edited by a moderator:
Ok, so I can see how Java would be good to learn after Python, before C++


If one wanted to be thorough...


But what will Java do for me that Python can't?


Remember, I don't work in IT... I'm a crafter, I studied fine arts.


I needed something quick and easy to pick up, easy to read, and can do pretty much anything except AAA titles, albeit at slower speeds.


Also something that I can write the whole program in, but replace parts of *if* it really is too slow and I can get help / struggle through rewriting in a faster language like C++


So I intended Python to be my bread and butter... learn it as thoroughly as possible... and only wrap my head around some C++ when it looks like I have no other option.


But as soon as that problem would be solved I would go right back to Python... until I hit another hurdle.


I'm doing this so I can greater use computers as a 'creative medium'... I.e. I would like to one day realize my ideas (interactive artforms) digitally.


I'm not doing this to get work in the industry, it is entirely personal... and so needs to be as simple and streamlined as possible.


Once upon a time, when I was more idealistic... I only wanted to learn 1 language that both did everything I could want to and be fast. So back then I decided on C++


But guess what. C++ is too hard for me to pick up, and it requires too much time and effort for me to even get a foot in the door. So I gave up and didn't learn anything.


Back then I turned my nose up at languages like Java.


Now I am more realistic.


I may never even *get* to improve my Python code with modules done in C++


It may forever remain beyond my capabilities (due to circumstances).


But with Python, at least there is a chance... There is hope, that I could learn enough to actually do something with it. One day.
 
Ok, so I can see how Java would be good to learn after Python, before C++

If one wanted to be thorough...

But what will Java do for me that Python can't?
It is generally faster (probably fast enough for anything you would want -- though so is Python), less UNIX-focused, default on Android (note: I have never used Android). It is a much more bureaucratic language, though; there is quite a bit of faffing around: to print "hello world" to the screen, in Python, takes one line, in Java 5-6. Java may be more maintainable for larger projects (>200000 lines).

Remember, I don't work in IT... I'm a crafter, I studied fine arts.

I needed something quick and easy to pick up, easy to read, and can do pretty much anything except AAA titles, albeit at slower speeds.
Python should be fine.

Also something that I can write the whole program in, but replace parts of *if* it really is too slow and I can get help / struggle through rewriting in a faster language like C++
The main python interpreter is written in C, with a C-based interface to non-Python code, so I would suggest that you use C for that rather than C++ -- it is much smaller and simpler, and C++ will not provide many features that are useful to you unless you intend to write a lot of code in it. You may also find C compilers easier to deal with than C++ compilers: the error messages, in particular, when using C++ code dependent on C++ templates can be highly obscure, in a forest versus trees kind of way. C also has fewer special cases to remember.

Or if you do not care about maximum speed (and if using Python, you probably do not), you could use Java as your one, single language, though it will likely be slower going for development, at least at the beginning.

So I intended Python to be my bread and butter... learn it as thoroughly as possible... and only wrap my head around some C++ when it looks like I have no other option.
C. Seriously, there is less of it for your head to wrap around. I dare say that there are quite a few Python features you shall not need, too.

EDIT: Oh, by the way, here is a quote by Bjarne Stroustrup, the creator of C++: "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off."
 
Last edited by a moderator:
Great, thanks for the tip... C++ is out, C is in.


... Buuuut again, why recommend Java as my 'one language' instead of Python?


Because of Android?


Because it is much faster? How much faster?


I thought they were much of a muchness. (In terms of end results) , but Python is easier to learn and read.


???


Can one not write Python programs and publish them as apps on the Google store?


I.e. bundle the interpreter with the program?
 
... Buuuut again, why recommend Java as my 'one language' instead of Python?
I didn't. I doubt that you will need any features missing from Python unless you spend years on a very large piece of code and/or work with large group of other people. Or unless you need speed (which I also doubt, but only you can know).

Because of Android?

Because it is much faster? How much faster?
Android, I have never used. I only know that Java (specifically, a dialect of Java used on the Dalvik virtual machine and/or the Android RunTime) is the native language of Android, the one much of its software is written in, like C is for UNIX. As such, the most important interfaces for Android are likely to be Java-based, so Java should be considered if you want a fast Android program with few dependencies.

Speed: on a modern PC, Java is about half the speed of C, while Python is 2% the speed of C -- i.e. Java is 25 times faster, though, I repeat, this probably does not matter for you and, at worst, some inner-loops can be replaced with C. For more info, see here: http://benchmarksgame.alioth.debian.org/u64q/which-programs-are-fastest.html

I thought they were much of a muchness. (In terms of end results) , but Python is easier to learn and read.
Probably.

???

Can one not write Python programs and publish them as apps on the Google store?

I.e. bundle the interpreter with the program?
Probably. I do not do Android, and likely never shall. On UNIX, Python programs can start with "#!/usr/bin/python" and then the operating system will run "/usr/bin/python" on the rest of the contents of the file. Android may have that facility, or it may have a built-in scripting language (Java?) allowing you to tell it to run "python my_program.py".
 
Back
Top