What programming language do you prefer?

The place for chatting and discussing subjects unrelated to Wesnoth.

Moderator: Forum Moderators

ajf
Posts: 22
Joined: March 8th, 2006, 12:49 pm

Re: What programming language do you prefer?

Post by ajf »

MCP wrote:I always use whitespace and indentation no matter what programming language I use
Don't worry I also use identation when programming.
But:
  • I do not really know, because I never seriously used Python, but I heard that it even matters in Python whether something is a TAB or multiple spaces. I.e. an invisible difference would matter, that is just crazy to me.
  • How should a editor "auto-indent" something if indentation matters to the meaning of the program, how should my editor know where I want to end a block. (If I end a block by closing a bracket on the other hand, a clever editor can easily formate the source nicely.)
  • My experience is that in particular if you switch between systems and editors (some of them maybe even ones that you have not setup yourself) that can seriously mess up whitespaces, exactly because some editors like to "automate" such things.
Cheers,
ajf
User avatar
Elvish_Hunter
Forum Moderator
Posts: 1446
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: What programming language do you prefer?

Post by Elvish_Hunter »

ajf wrote:I do not really know, because I never seriously used Python, but I heard that it even matters in Python whether something is a TAB or multiple spaces. I.e. an invisible difference would matter, that is just crazy to me.
Almost all editors have an option to show hidden characters (like whitespaces and tabs), and almost all of them (including IDLE, that is the default Python editor) convert tabs to spaces or have menu options to "tabify region" and "untabify region" (IDLE, menu Format).
ajf wrote:How should a editor "auto-indent" something if indentation matters to the meaning of the program, how should my editor know where I want to end a block. (If I end a block by closing a bracket on the other hand, a clever editor can easily formate the source nicely.)
When pressing Enter, in IDLE the cursor goes on the next line, exactly in the same position where the line above started (automatically places whitespaces). When you want to end a block, you just use the backspace. :wink:
Current maintainer of these add-ons:
1.14: The Sojournings of Grog, A Rough Life, The White Troll (co-author), Wesnoth Lua Pack
1.12: Children of Dragons
Anonymissimus
Inactive Developer
Posts: 2460
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: What programming language do you prefer?

Post by Anonymissimus »

Elvish_Hunter wrote:
ajf wrote:How should a editor "auto-indent" something if indentation matters to the meaning of the program, how should my editor know where I want to end a block. (If I end a block by closing a bracket on the other hand, a clever editor can easily formate the source nicely.)
When pressing Enter, in IDLE the cursor goes on the next line, exactly in the same position where the line above started (automatically places whitespaces). When you want to end a block, you just use the backspace. :wink:
I tend to be confused about "auto-indent." In emacs wml mode there is a functionality which can turn things like

Code: Select all

    [tag]
[subtag]
            [/subtag]
[/tag]
into

Code: Select all

[tag]
    [subtag]
    [/subtag]
[/tag]
with a single click. ("indent buffer")
Very useful for answering wml beginner questions who are posting scenarios without

Code: Select all

 tags.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: What programming language do you prefer?

Post by Sapient »

AJF: Well, there are two ways of looking at it. If Python forces you to use consistent indentation levels then the student will find out right away if they improperly indented the code. So I would say that is a learning aid, not a learning impediment. Compare this with the class of difficult-to-spot errors that you may find in other programming languages where the scope has been accidentally obscured by a novice using an incorrect indentation level or putting an extra semicolon after a if() or for().

Regarding tabs: if they are using Notepad then, yes, there is potential for mischief with mixing tabs and spaces. But they should really not be using notepad, there's no reason to use it when IDLE comes with the package.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
ajf
Posts: 22
Joined: March 8th, 2006, 12:49 pm

Re: What programming language do you prefer?

Post by ajf »

Sapient wrote:If Python forces you to use consistent indentation levels then the student will find out right away if they improperly indented the code. So I would say that is a learning aid, not a learning impediment.
That might be true, I do not question Python being a good language to learn programming (I do not know if it is, I know it to little for judging that), I just say that as someone who learned programming before Python was around, that is one reason why I would not want to switch to Python.

Best,
ajf
MCP
Posts: 518
Joined: May 23rd, 2005, 5:23 pm
Location: California

Re: What programming language do you prefer?

Post by MCP »

ajf wrote:
  • How should a editor "auto-indent" something if indentation matters to the meaning of the program, how should my editor know where I want to end a block. (If I end a block by closing a bracket on the other hand, a clever editor can easily formate the source nicely.)
Example: A multi if statement, eg if, elseif, elseif, else.

Assume the spaces are one tab for indentation.

Code: Select all

if x < 0:
    x = 0
    print 'Negative changed to zero'
elif x == 0:
    print 'Zero'
elif x == 1:
    print 'Single'
else:
    print 'More'
When I type this out, it will auto indent after the if of course.

Code: Select all

if x < 0:
    x = 0
Now when I want to type my elif it starts indented.

Code: Select all

if x < 0:
    x = 0
    print 'Negative changed to zero'
    elif 
Now when I finish typing my elif and hit enter for next line, the elif is put in the correct spot and the cursor is indented.

Code: Select all

if x < 0:
    x = 0
    print 'Negative changed to zero'
elif x == 0:
    (cursor indented here)
It's very simple. Yes the parsing can get complicated, but in notepad++ I don't recall any problems with indentation.

If for instance I want to go back outside of the else statement at the end, I just have to hit backspace to go back one tab. Or the command I use more often, something such as shift+tab or ctrl+[ which will un-indent the current line of code by one line. If you really don't like doing that, the same problem exists when coding C and java in Eclipse often times. Add or remove a new if or for loop outside of your code and all the code inside needs to be re-indented by one, something such as ctrl+i or maybe ctrl+[format] will format the highlighted code or the entire file. Just because C doesn't require correct whitespace, doesn't mean the same problems don't exist in different ways.

Now thirdly, python requires tabs for all indentation. So go into the editor preferences and set length to 2,4,8 spaces, whatever, and it will look as the current programmer feels comfortable with. While I might prefer 4, many people prefer 8. It wouldn't change anything between different people working on the project, it's just a view setting. Now the flip side is in C, whitespaces can be tabs or spaces, what if someone mixes them up and I have a tab width of 4 but they have a tab width of 8? We get all screwed up because they have one tab and 8 spaces, so while they see 16 I see 12 whitespaces.

I learned programming before I ever heard of python. I remember people arguing 'whitespace requirements suck.' In the end, Python has become very popular and is intuitive.

ajf wrote:
  • My experience is that in particular if you switch between systems and editors (some of them maybe even ones that you have not setup yourself) that can seriously mess up whitespaces, exactly because some editors like to "automate" such things.
[/list]
I've never run into an editor where ctrl+z wouldn't undo that automated formatting. Sometimes it's even as difficult as closing and not saving, changing the editors preferences.

Also python tab indentation is consistent no matter which editor one uses, unless said editor is buggy, because if the editor re-indents things as it loads in a file, it can change the functionality of the file.
User avatar
Cloud
Art Contributor
Posts: 502
Joined: December 17th, 2008, 7:43 pm
Location: The land of pixels
Contact:

Re: What programming language do you prefer?

Post by Cloud »

I know these topics always spark some debate, however as a budding Computer Scientist I've got some views.

Java I like as a teaching language, it's got very good documentation and mostly forces you to use Object Orientated Programming. It's got it's downsides too, but I've learnt to cope with them as best I can and it's my fallback language for when I'm feeling lazy, just because I know it so gorram well nowadays. Having programmed the past week in Java way too many hours for a group project I'm not too fond of it right now, especially GUI bits.

I'm liking C more and more (and hopefully by extension C++) each day. Knowing how to manage pointers/memory is a big plus for me, as Java usually confuses me with them still (I know the theory behind Java's pointer system, but still it can easily confuse) and knowing that when you free a piece of memory the language will actually do it.

PHP* for website based stuff, although I've heard a lot of support for Ruby on Rails in that area too, which I've yet to check out. OO PHP is a bit weird though, a bit more hacked together than the rest of the language.

Perl* is nice just for doing quick little bits and I personally find it nice for file reading (I know I could probably make a BASH script instead, but I find Perl easier to think in). It's quick nice as an introduction language too.

On the subject of IDEs, I like them for Java as generally I have a large set of files in packages and on the fly compilation is nice. I've tried using them for C and I found they were holding me back. I resorted to Kate instead. I think it's a lot to do with how you've learnt, I've never had to program Java outside of an IDE so doing so makes me feel weird, just because it's what I'm used to. For some reason I'm weird and prefer NetBeans to Eclipse, I might have to change that soon though for a very good reason.

*Yes I'm aware these are technically scripting languages.
Softly/SoftlySplinter on IRC. Will be lurking around more these days
Mainline Animations|The Væringjar
Art for these mead-sodden, bearded mushroom-junkies by Girgistian!
MCP
Posts: 518
Joined: May 23rd, 2005, 5:23 pm
Location: California

Re: What programming language do you prefer?

Post by MCP »

I wasn't looking for this very well until this morning, but I found something intellectually interesting and yet accessible about software.

An article on why (possibly) Code Bloat is the worst thing to happen to a software project: (warning: take everything you read in programmers blogs with a grain of salt and always think for yourself. Also make sure to read the comments with special care to understand the ones suggesting breaking the software up into modules)
http://steve-yegge.blogspot.com/2007/12 ... enemy.html

I 100% agree, code bloat is something to always keep in mind. It's a constant struggle to fight it off.

Now for those veterans and amateurs alike, remember there is a counter point to this guy's article:
I'm all for removing duplication from my code, and keeping it as small as possible in the meantime. But there's a point where making code smaller by using macros, terse languages and the like actually harms the maintainability of the code as much as code bloat does.
What he means, I think, is a software engineer can be just as overwhelmed by the abstraction of the code as by the number of lines of code. That is it can be just as confusing to a programmer to read 10 lines of code which would represent 1000 lines of code in another language because of the mental capacity required to unravel it, where as the 1000 lines spells out each case simply, but then you have 1000 lines of cases, how do you find out which one you want? And thus the ever existing problem to all software engineers is to somehow balance code size and readability/understandability. The art of software programming.

The number one reason code bloat causes more code bloat:
1. Time. Not enough time to understand enough of the software requires an engineer simply write a new piece of code and add it in the right place. Saving code by fixing the already existing code requires more time and thus more money. Hack hack hack... leading to a bad habit of rarely doing it correctly in the first place.


:hmm:

(ps I have much more language specific examples written by other authors, but these articles are at work and so I'm not sure if I can share them with everyone for free)
User avatar
Jetrel
Posts: 7242
Joined: February 23rd, 2004, 3:36 am
Location: Midwest US

Re: What programming language do you prefer?

Post by Jetrel »

:hmm: I'm probably one of the rare guys who isn't smoking the "one true language" pipe. That said, not all languages are made equal, and pure relativism is bull; it's unquestionable that some languages out there are inferior to others. In the general sense, though, what we have out there right now is a bunch of languages who all have individual niches they're good at.

There a various snippets I like from different languages. I love C++'s container classes and iterators. I love lisp/haskell/smalltalk/objc style prefix notation. I love python's usage of indentation as syntax (because it forces all programmers to use a consistent style of indentation, which seriously matters when you're forced to work on someone else's code).

I've noticed that one of the biggest make-or-break factors in how useable a programming language is, is not just the language itself, but the editor. Many programming languages can be trivial to program in, with certain features, but can be excruciating if you're missing certain key things.

For example, when working in list-based languages like lisp, haskell, or FFL, you really need an editor feature to find and inform you of matching semicolons, which can be done any number of ways.

When working in python, you really need some support for indicating invisible characters, and for displaying indentation in the terms python understands it (esp; treating equivalent amounts of spaces and tabs as visually equivalent). Likewise, it's really helpful for your editor to, if it soft-wraps, to soft-wrap and maintain the current level of indentation.


MCP's previous post is spot-on. Abstraction is all fine and dandy, unless you need to know what's going on inside the black box, and you've got this "ultimate matroyshka doll" setup with dozens of layers of macros, abstractions, and whatnot, and this is all in code you didn't write. Abstraction is really important, it's just that abstracts are occasionally leaky. (unlike joel-on-software, I don't think they're guaranteed to leak unless you're applying the strong rule of large numbers - in a single programming project, with a decent-sized team and goals, most of your abstractions won't leak.)
Play Frogatto & Friends - a finished, open-source adventure game!
User avatar
atomicbomb
Posts: 87
Joined: January 13th, 2011, 12:10 pm
Location: Pontianak, Indonesia
Contact:

Re: What programming language do you prefer?

Post by atomicbomb »

Hmm.. Talking about Editor

Before I posted this topic, I already used a kind of High Level Programming Language called Euphoria since 2 years ago. I wrote some long codes to solve my algebra homeworks.. and yeah.. I enjoyed using the editor instead of using notepad or other text editor because it's really helps me with indentation and syntax coloring.
* shadowmaster hits atomicbomb with a watermelon
* atomicbomb hits shadowmaster with durian
(On wesbreak to take care of my 17 HS classes. Will be back in mid June.)
My Blog | Noisy Bird | My Fake FB Account | Story of Wesnoth Forums
ajf
Posts: 22
Joined: March 8th, 2006, 12:49 pm

Re: What programming language do you prefer?

Post by ajf »

Jetrel wrote:I've noticed that one of the biggest make-or-break factors in how useable a programming language is, is not just the language itself, but the editor.
That is very true, and probably the main reason why I for example say that MatLab is still worth its 100 bucks or so (for a student license), even so with Octave there is a free implementation available. It is also the reason why Wolframs Mathematica will never be an alternative to Matlab. That I was never convinced by the most widely used Java editor the Eclipse-resource-eating-monster (maybe nowadays with somewhat faster computers that problem would not occur anymore), is probably also the reason I never really fall in love with Java.

Best,
ajf
User avatar
dipseydoodle
Posts: 872
Joined: September 16th, 2008, 10:26 pm
Location: The United States of America

Re: What programming language do you prefer?

Post by dipseydoodle »

Applescript, Shellscript, HTML5/CSS and Infrom7.
- Dipsey
MCP
Posts: 518
Joined: May 23rd, 2005, 5:23 pm
Location: California

Re: What programming language do you prefer?

Post by MCP »

ajf wrote:
Jetrel wrote:I've noticed that one of the biggest make-or-break factors in how useable a programming language is, is not just the language itself, but the editor.
That is very true, and probably the main reason why I for example say that MatLab is still worth its 100 bucks or so (for a student license), even so with Octave there is a free implementation available. It is also the reason why Wolframs Mathematica will never be an alternative to Matlab.
I have been searching for a Matlab alternative for years now, seeing as Matlab in the industry is thousands of dollars.

I've tried Sage, but it leaves something to be desired by those who have use Matlab. Specifically the ability to use the gui to make debug stops easily. Although the plotting appears just as easy in Sage as it does in Matlab, my experiences point me to notice a specific lack of editing mode which I have taken for granted in Matlab, but it has made any transition to another matlab alternative a no-go. There is also some lack of simplicity that is available in Matlab, where as Python is a real programming language lacking all the 'stupid' little hacks that make life easier in Matlab, but less efficient.

I'll come back here if I ever find a decent alternative with some of the important features.
User avatar
pauxlo
Posts: 1047
Joined: September 19th, 2006, 8:54 pm

Re: What programming language do you prefer?

Post by pauxlo »

Jetrel wrote::hmm: I'm probably one of the rare guys who isn't smoking the "one true language" pipe.
Me, too - use the appropriate tool for the job.
Jetrel wrote: I love lisp/haskell/smalltalk/objc style prefix notation.
I don't really know haskell and Objective C, but the notations in smalltalk and lisp are clearly different.
Smalltalk uses infix notation for method calls, or the keyword: param notation, while Lisp uses a pure prefix notation for function calls:

Code: Select all

3 + 4
3 add: 4

Code: Select all

(+ 3 4)
Jetrel wrote:I've noticed that one of the biggest make-or-break factors in how useable a programming language is, is not just the language itself, but the editor. Many programming languages can be trivial to program in, with certain features, but can be excruciating if you're missing certain key things.
Yes.
Jetrel wrote:For example, when working in list-based languages like lisp, haskell, or FFL, you really need an editor feature to find and inform you of matching semicolons, which can be done any number of ways.
You mean matching parentheses, don't you?
User avatar
Gambit
Loose Screw
Posts: 3266
Joined: August 13th, 2008, 3:00 pm
Location: Dynamica
Contact:

Re: What programming language do you prefer?

Post by Gambit »

Perl in KATE.

And, while I don't wish to start too long of a debate on the topic, I'm wondering why it was pegged 'not good for beginners'. It's only marginally more complicated than Javascript in my opinion. Unless Javascript is also not good for beginners? :hmm: Yes, I know javascript is not a 'real programming langauge', but it's very similar, and a great way to learn the required skills.

I really don't know because I just skip from one language to the next in the order that they appeal to me. I hope to one day know them all to some degree. So it's an honest question of what makes Perl so bad for beginners? C++ is rather obvious to me, because I've been unable to teach it to myself for several years now.
Post Reply