The Ur-Quan Masters Home Page Welcome, Guest. Please login or register.
Did you miss your activation email?
December 05, 2024, 04:57:53 pm
Home Help Search Login Register
News: Celebrating 30 years of Star Control 2 - The Ur-Quan Masters

+  The Ur-Quan Masters Discussion Forum
|-+  The Ur-Quan Masters Re-Release
| |-+  Starbase Café (Moderator: Death 999)
| | |-+  Programming
« previous next »
Pages: 1 2 [3] 4 Print
Author Topic: Programming  (Read 7702 times)
superbutcherx
*Many bubbles*
***
Offline Offline

Posts: 116



View Profile
Re: Programming
« Reply #30 on: August 19, 2010, 02:57:55 pm »

I have to agree with onpon4 and Novus: Python is an excellent language for its clean, intuitive syntax and ease of use (especially when learning it as your first programming language): For example you don't have to muck around so much with different variable types as in C/C++ and it's more straightforward to manipulate files and use system command line commands. Java puts me off with its unnecessarily long-winded syntax (the likes of system.out.println vs Python's print).

I've been programming stuff for network simulators for a living a while now. My main tools have been both straight C and C++. I think those are still the "bread and butter" of programming languages in the engineering world. They tried to introduce Java in place of C in the introduction classes here in the university's computer engineering studies some years back , but have since quietly returned to teaching C.

In addition Python has been a lot of use for me when programming scripts for extracting results from tens of thousands of files. That could've been done also in C/C++, but would have been a more tardy way, with all the compilations and the quirkier format for file manipulation.
Logged
Death 999
Global Moderator
Enlightened
*****
Offline Offline

Gender: Male
Posts: 3874


We did. You did. Yes we can. No.


View Profile
Re: Programming
« Reply #31 on: August 19, 2010, 04:42:01 pm »

Java's print syntax is not unnecessarily long-winded. Flexibility and clarity come at a reasonable cost in length. And if you don't want to have to type System.out every time, feel free to declare

Code:
PrintStream a = System.out;

a.println(...);
...
a.println(...);
...
a.println(...);

which is much shorter, only four characters longer than just 'print'. And if you want to use the 'print' function, go ahead. System.out has it. But you'll have to put in the line break yourself. i.e. print("blah\n"); is the same as println("blah");
How do you print a line and end it in python?

So yeah. Once per function that prints to stdout (which shouldn't be many) java takes one line and three or four characters more than python to do the same thing.

MASSIVE BLOAT!!!!!1one
« Last Edit: August 19, 2010, 04:44:30 pm by Death 999 » Logged
onpon4
Enlightened
*****
Offline Offline

Gender: Male
Posts: 709


Sharing is good.


View Profile WWW
Re: Programming
« Reply #32 on: August 19, 2010, 06:49:11 pm »

Quote
How do you print a line and end it in python?

Was this a serious question? I can't tell.

If it was, the print statement (now the print() function in Python 3.x) automatically ends the line normally. In Python 2.x, this is bypassed by adding a comma after the print statement; in Python 3.x, it is a print() function, and there is a parameter ('\n' by default) which specifies what the printed string ends with (normally, this is left alone or changed to '' or ' ').
Logged

Death 999
Global Moderator
Enlightened
*****
Offline Offline

Gender: Male
Posts: 3874


We did. You did. Yes we can. No.


View Profile
Re: Programming
« Reply #33 on: August 19, 2010, 10:16:33 pm »

It was a serious question. The original version of the question, before I edited it away by accident, followed up, "If print does that by default, how do you not have it automatically end the line?"

Looking at the answer...

Interesting that print was demoted to function from core syntax.
« Last Edit: August 19, 2010, 10:19:09 pm by Death 999 » Logged
superbutcherx
*Many bubbles*
***
Offline Offline

Posts: 116



View Profile
Re: Programming
« Reply #34 on: August 20, 2010, 10:48:12 am »

Java's print syntax is not unnecessarily long-winded. Flexibility and clarity come at a reasonable cost in length.

Well put! There's always pros and cons in every design choice and that's why no language can be claimed to be absolutely better than another one. For certain tasks and purposes, yes, one trumps the other, but not for every one of them.

What I meant to convey with my "unnecessarily" was that from learning-your-first programming-language point of view, it might be confusing to face a wide array of flexibility and options, when all you need for your specifc purposes is just one of them.

In that infamous basics of programming class we only used System.out.println for that one purpose -printing lines on screen-, and received quite a little in the way of explaining what is this System, why does the command come only after all those prefixes, or how it could be declared shorter as you showed in your example.

Now that I think of it, that's more a fault of the teaching being bad than the language being unwieldy.
I think the teacher tried to achieve both: a) Show us students the versatility of java by demonstrating long-winded commands b) make it easy to learn by not painstakingly explaining all the details of the command, just using one instance of it in practice to see what happens.

Unfortunately, from my POV he failed in both accounts:
Typing in long commands without seeing the point in the syntax just made it frustrating for a beginning programmer. This made me veer towards languages that seemed more "sensible" to me at the time. Smiley
Logged
onpon4
Enlightened
*****
Offline Offline

Gender: Male
Posts: 709


Sharing is good.


View Profile WWW
Re: Programming
« Reply #35 on: August 20, 2010, 03:11:27 pm »

In that infamous basics of programming class we only used System.out.println for that one purpose -printing lines on screen-, and received quite a little in the way of explaining what is this System, why does the command come only after all those prefixes, or how it could be declared shorter as you showed in your example.

Now that I think of it, that's more a fault of the teaching being bad than the language being unwieldy.
I think the teacher tried to achieve both: a) Show us students the versatility of java by demonstrating long-winded commands b) make it easy to learn by not painstakingly explaining all the details of the command, just using one instance of it in practice to see what happens.

Unfortunately, from my POV he failed in both accounts:
Typing in long commands without seeing the point in the syntax just made it frustrating for a beginning programmer. This made me veer towards languages that seemed more "sensible" to me at the time. Smiley

That's what I don't like about YouTube user thenewboston's ("Bucky") video tutorials. I've only seen his Python tutorials; there were a ton of things, especially in his wxPython tutorials, that he didn't explain; he just said "do it, I'll explain it later" and never explained them. This is a horrible long-term teaching strategy; it is VERY frustrating to be forced to use something you don't understand, especially because you don't understand how to properly manipulate it, yet almost every teacher seems to do this.
Logged

Death 999
Global Moderator
Enlightened
*****
Offline Offline

Gender: Male
Posts: 3874


We did. You did. Yes we can. No.


View Profile
Re: Programming
« Reply #36 on: August 20, 2010, 04:58:02 pm »

Well put! There's always pros and cons in every design choice and that's why no language can be claimed to be absolutely better than another one.

umm. Some languages, even serious ones, are just bad. I can't think of any reasonably modern programming language that is worse than fortran 77 at anything, except that java's 'hello world' is longer than fortran 77's. If you actually do anything more complicated than calculate the factorial of something, the balance shifts back.
Logged
Novus
Enlightened
*****
Offline Offline

Gender: Male
Posts: 1938


Fot or not?


View Profile
Re: Programming
« Reply #37 on: August 21, 2010, 01:09:45 pm »

umm. Some languages, even serious ones, are just bad. I can't think of any reasonably modern programming language that is worse than fortran 77 at anything, except that java's 'hello world' is longer than fortran 77's. If you actually do anything more complicated than calculate the factorial of something, the balance shifts back.
A programming language doesn't get that popular without doing something right.

I take it you've never done heavy-duty numeric processing; physics simulation people tend to swear by Fortran, even FORTRAN 77. Built-in complex arithmetic, lots of opportunities for compiler optimisations that pointers and references prevent, lots of high-performance numerical libraries; these are things that e.g. the C/Java branch of languages doesn't do or doesn't do as well as even FORTRAN 77. Admittedly, FORTRAN 77 is very annoying and limited in other ways, but that's why we have Fortran 90 (and later versions), which adds a lot of things to Fortran that users of ALGOL-like languages take for granted (e.g. recursion).
Logged

RTFM = Read the fine manual.
RTTFAQ = Read the Ur-Quan Masters Technical FAQ.
Megagun
Enlightened
*****
Offline Offline

Gender: Male
Posts: 580


Moo


View Profile
Re: Programming
« Reply #38 on: August 21, 2010, 04:59:30 pm »

The problem I have with Python is that it is dynamically typed, which makes having a browser open next to your IDE almost mandatory as there'd practically zero code completion when you need it. This makes researching stuff ("I want to do X, how do I do it") hard, even more so because what some function returns is pretty arbitrary...

Unlike Java, where there is nice static typing, and documentation standards are high. This makes understanding existing code a lot easier, even though code tends to bloat up a bit.
Logged
onpon4
Enlightened
*****
Offline Offline

Gender: Male
Posts: 709


Sharing is good.


View Profile WWW
Re: Programming
« Reply #39 on: August 21, 2010, 06:14:28 pm »

The problem I have with Python is that it is dynamically typed, which makes having a browser open next to your IDE almost mandatory as there'd practically zero code completion when you need it. This makes researching stuff ("I want to do X, how do I do it") hard, even more so because what some function returns is pretty arbitrary...

Unlike Java, where there is nice static typing, and documentation standards are high. This makes understanding existing code a lot easier, even though code tends to bloat up a bit.

You're not making much sense to me here. The big difference between static typing and dynamic typing is statically typed languages perform type checking at compile time, while dynamically typed languages perform type checking at run time. Dynamically typed languages are also much more flexible, though more resource-intensive, than statically typed languages. This has absolutely nothing to do with availability of documentation.

Ignoring that: First of all, you can easily look up information on specific topics, keywords, modules, functions, and classes by using the help() function in interactive mode. Second, Python comes with a comprehensive and easy to understand manual. Third, there is a great forum, python-forum.org, where many people are willing to answer questions, and most 3rd-party modules have a forum or mailing list you can ask questions on. Considering that Java is far more widely used than Python, it makes sense that it's easier to look up help on Java, but I personally have never had much of a problem figuring something out that I was confused about.
« Last Edit: August 21, 2010, 06:17:24 pm by onpon4 » Logged

Death 999
Global Moderator
Enlightened
*****
Offline Offline

Gender: Male
Posts: 3874


We did. You did. Yes we can. No.


View Profile
Re: Programming
« Reply #40 on: August 21, 2010, 08:45:30 pm »

A programming language doesn't get that popular without doing something right.

I take it you've never done heavy-duty numeric processing

I did a fair amount of monte carlo simulation. In Fortran 77. It was hellish.

Maybe if I had had to use complex numbers I would have found the alternatives even more hellish. But I didn't.

Lots of opportunities for compiler optimisations that pointers and references prevent, lots of high-performance numerical libraries

Interesting. I don't see that the libraries are really an intrinsic part of the language, but restricting your actions so as to permit optimization is fair enough.
Logged
Novus
Enlightened
*****
Offline Offline

Gender: Male
Posts: 1938


Fot or not?


View Profile
Re: Programming
« Reply #41 on: August 21, 2010, 09:38:48 pm »

I did a fair amount of monte carlo simulation. In Fortran 77. It was hellish.

Maybe if I had had to use complex numbers I would have found the alternatives even more hellish. But I didn't.
No one is disputing that FORTRAN 77 is a pain to use. Since you didn't mention what your Monte Carlo simulation was a simulation of (although I imagine it's something to do with nanoscale physics), it's hard to say whether Fortran was the right choice. Using an ancient version of Fortran certainly doesn't make things any better (unless, of course, you were doing this in . However, as I've been trying to point out, someone must have liked it enough to put you in the situation where you had to use it.

Quote
Interesting. I don't see that the libraries are really an intrinsic part of the language, but restricting your actions so as to permit optimization is fair enough.
They may not be part of the language, but they are indisputably an important part of the programming experience in most situations.
Logged

RTFM = Read the fine manual.
RTTFAQ = Read the Ur-Quan Masters Technical FAQ.
Megagun
Enlightened
*****
Offline Offline

Gender: Male
Posts: 580


Moo


View Profile
Re: Programming
« Reply #42 on: August 22, 2010, 12:16:34 am »

The problem I have with Python is that it is dynamically typed, which makes having a browser open next to your IDE almost mandatory as there'd practically zero code completion when you need it. This makes researching stuff ("I want to do X, how do I do it") hard, even more so because what some function returns is pretty arbitrary...

Unlike Java, where there is nice static typing, and documentation standards are high. This makes understanding existing code a lot easier, even though code tends to bloat up a bit.

You're not making much sense to me here. The big difference between static typing and dynamic typing is statically typed languages perform type checking at compile time, while dynamically typed languages perform type checking at run time. Dynamically typed languages are also much more flexible, though more resource-intensive, than statically typed languages. This has absolutely nothing to do with availability of documentation.
Since Python is dynamically typed, my IDE (Eclipse + Pydev) can't determine the type of an attribute and thus can't give me useful info when I want to do something with some value that some random function returned. Unlike my Java IDE (NetBeans, but it should be similar in Eclipse) which happily shows me information on anything I want. This is especially useful when trying to understand existing code. Place the cursor over something you don't understand, hit CONTROL+SPACE, and browse through the documentation of the class of which the selected attribute is the type.

If I get some value (integer, class instance) from a function and want to know what I can do with it in Python, I'd have to manually go through the parent function's code or documentation in order to find out what it actually returns, then go through the code for the returned class to find out what I can actually do with it. In Java, I'd just hit CONTROL-SPACE and that's it. My Python IDE sometimes gives me proper results for autocomplete (I guess whenever the codebase is tiny and it can actually determine what class a given attribute is), but mostly it doesn't.

So, indeed, typing doesn't have any direct influence on availability of documentation, but in practice I definitively noticed that documentation wasn't just on the screen whenever I wanted it quickly.
« Last Edit: August 22, 2010, 12:18:36 am by Megagun » Logged
onpon4
Enlightened
*****
Offline Offline

Gender: Male
Posts: 709


Sharing is good.


View Profile WWW
Re: Programming
« Reply #43 on: August 22, 2010, 02:27:48 am »

Since Python is dynamically typed, my IDE (Eclipse + Pydev) can't determine the type of an attribute and thus can't give me useful info when I want to do something with some value that some random function returned. Unlike my Java IDE (NetBeans, but it should be similar in Eclipse) which happily shows me information on anything I want. This is especially useful when trying to understand existing code. Place the cursor over something you don't understand, hit CONTROL+SPACE, and browse through the documentation of the class of which the selected attribute is the type.

If I get some value (integer, class instance) from a function and want to know what I can do with it in Python, I'd have to manually go through the parent function's code or documentation in order to find out what it actually returns, then go through the code for the returned class to find out what I can actually do with it. In Java, I'd just hit CONTROL-SPACE and that's it. My Python IDE sometimes gives me proper results for autocomplete (I guess whenever the codebase is tiny and it can actually determine what class a given attribute is), but mostly it doesn't.

So, indeed, typing doesn't have any direct influence on availability of documentation, but in practice I definitively noticed that documentation wasn't just on the screen whenever I wanted it quickly.

It sounds to me your problem isn't the dynamic typing, but the lack of a feature that you've become used to in your Java IDE. Honestly, I am not quite understanding the problem, though. Usually I can intuitively understand what to do with a given data type; I don't need to be told what I can do with it. For example, I already know that with a string:
- I can iterate through the individual characters (since it is an iterable data type)
- Since it is an immutable data type, I cannot append new characters to it (but I can delete the entire string).
- I can concatonate the string with another string to return a larger string (perhaps to store it in a variable)
- I can pass it as a parameter for various functions and methods (i.e. print)
- etc...

Perhaps I'm not understanding you correctly, but you seem to be suggesting that you need to constantly look up how to use different data types properly, and as a result, Python is difficult because it doesn't show you this information unless you look it up in the manual or search for it with help(). If I am misunderstanding, please correct me.
Logged

Novus
Enlightened
*****
Offline Offline

Gender: Male
Posts: 1938


Fot or not?


View Profile
Re: Programming
« Reply #44 on: August 22, 2010, 12:11:04 pm »

Perhaps I'm not understanding you correctly, but you seem to be suggesting that you need to constantly look up how to use different data types properly, and as a result, Python is difficult because it doesn't show you this information unless you look it up in the manual or search for it with help(). If I am misunderstanding, please correct me.
I think it's more a question of not being easily able to determine which type you need to look up. In a statically typed language, determining the type of a value is easy (even if not explicitly declared). In a dynamically typed language, this may be impossible. Hence, when you're working with a complex set of objects that refer to objects and return other objects from their methods, static typing can make it a lot easier to keep track of what type of value you have at a given point in your program. Not only does this allow an IDE to provide helpful features like auto-complete, it also makes a lot of bugs detectable at compile-time.
Logged

RTFM = Read the fine manual.
RTTFAQ = Read the Ur-Quan Masters Technical FAQ.
Pages: 1 2 [3] 4 Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!