PDA

View Full Version : Relative To Ubuntu?



pgar23
August 23rd, 2007, 02:51 AM
HEY ALL,

I am beginning to learn programming. I spent most of today learning PYTHON. it seems a little advanced for me (a noob), I am wondering, which language is the most relative to ubuntu. and can someone rply with a couple of good links (for a NOOB like me please). I want to start slow and work in to it.

Nekiruhs
August 23rd, 2007, 02:52 AM
Python is definitely relative to Ubuntu, some of the programs in the default install are written in it. I really can't think of a more beginner usable language than Python, can you describe what seems too advanced?

pgar23
August 23rd, 2007, 02:59 AM
Python is definitely relative to Ubuntu, some of the programs in the default install are written in it. I really can't think of a more beginner usable language than Python, can you describe what seems too advanced?

It doesnt seem "2 advanced" it just seems "different" to me i guess.(that sounds really stupid I know). I am a web designer and I am ready to become a programmer I guess. I wanted to start with a language relative to ubuntu first, so i could apply the language and skill to my system.

what is your take on C and C++? are they relative? do you have any experience in them? How complicated?

It sounds like Python is the way to go for now i guess.

pgar23
August 23rd, 2007, 03:07 AM
is this a good book to start with? http://savannah.nongnu.org/download/pgubook/ProgrammingGroundUp-1-0-booksize.pdf

Nekiruhs
August 23rd, 2007, 03:12 AM
It doesnt seem "2 advanced" it just seems "different" to me i guess.(that sounds really stupid I know). I am a web designer and I am ready to become a programmer I guess. I wanted to start with a language relative to ubuntu first, so i could apply the language and skill to my system.

what is your take on C and C++? are they relative? do you have any experience in them? How complicated?

It sounds like Python is the way to go for now i guess.
C/C++ are far more complicated than Python. The Linux Kernel is written in C. And C/C++ are really fast. But for normal apps, you won't notice a difference in speed truly. I have done some programming in C++, and while it is a truly powerful language with hardware-level access, it is impractical for most purposes where speed is not of the utmost concern. (3D High Res Games, Kernels, Drivers, etc)

Heres a comparison of languages. The program must output the classic 99 bottles of beer on the wall song.

C (http://99-bottles-of-beer.net/language-c-820.html)
C++ (http://99-bottles-of-beer.net/language-c++-108.html)
Python (http://99-bottles-of-beer.net/language-python-808.html)

pgar23
August 23rd, 2007, 03:17 AM
C/C++ are far more complicated than Python. The Linux Kernel is written in C. And C/C++ are really fast. But for normal apps, you won't notice a difference in speed truly. I have done some programming in C++, and while it is a truly powerful language with hardware-level access, it is impractical for most purposes where speed is not of the utmost concern. (3D High Res Games, Kernels, Drivers, etc)

Heres a comparison of languages. The program must output the classic 99 bottles of beer on the wall song.

C (http://99-bottles-of-beer.net/language-c-820.html)
C++ (http://99-bottles-of-beer.net/language-c++-108.html)
Python (http://99-bottles-of-beer.net/language-python-808.html)

WHOA!!
PYTHON it is! lol
C next.
C++ after that. (which seems extreme)

thanks for that comparison and your input. appreciate it.

HermanAB
August 23rd, 2007, 03:22 AM
Start with Bash, then Perl. After that, anything else will be ridiculously easy...

pgar23
August 23rd, 2007, 03:23 AM
Start with Bash, then Perl. After that, anything else will be ridiculously easy...

I was just looking at BASH. Isnt that really really relative to ubuntu?

Nekiruhs
August 23rd, 2007, 03:27 AM
Start with Bash, then Perl. After that, anything else will be ridiculously easy...
I gotta love the perl version of 99 bottles. (http://99-bottles-of-beer.net/language-perl-737.html) The entire program contains no alpha-numeric characters what so ever. Just so you know OP, thats not normal Perl, the guys is doing some crazy things with Regular Expressions (REALLY powerful search terms) that only perl can do. But Perl is notoriously hard to read.

pgar23
August 23rd, 2007, 03:29 AM
I gotta love the perl version of 99 bottles. (http://99-bottles-of-beer.net/language-perl-737.html) The entire program contains no alpha-numeric characters what so ever. Just so you know OP, thats not normal Perl, the guys is doing some crazy things with Regular Expressions (REALLY powerful search terms) that only perl can do. But Perl is notoriously hard to read.

That perl version looked pretty awesome. hahaha. I had to save that in a file. but what is your take on learning BASH? as i previously stated...isnt that really relative to ubuntu?

slavik
August 23rd, 2007, 03:31 AM
C/C++ are far more complicated than Python. The Linux Kernel is written in C. And C/C++ are really fast. But for normal apps, you won't notice a difference in speed truly. I have done some programming in C++, and while it is a truly powerful language with hardware-level access, it is impractical for most purposes where speed is not of the utmost concern. (3D High Res Games, Kernels, Drivers, etc)

Heres a comparison of languages. The program must output the classic 99 bottles of beer on the wall song.

C (http://99-bottles-of-beer.net/language-c-820.html)
C++ (http://99-bottles-of-beer.net/language-c++-108.html)
Python (http://99-bottles-of-beer.net/language-python-808.html)

C more complicated than Python? woah, dude, whoa.

you say you are a web developer ... do you use php? if so, I can recommend using perl as a stop gap between php and python.

Nekiruhs
August 23rd, 2007, 03:35 AM
That perl version looked pretty awesome. hahaha. I had to save that in a file. but what is your take on learning BASH? as i previously stated...isnt that really relative to ubuntu?
BASH isn't really a programming language. Its more of a scripting/automation language. Whenever you type something in a terminal, thats BASH, BASH scripting is just automating that process. But not to say that its not a good starting area. If thats your interest. linuxcommand.org (http://www.linuxcommand.org) is a good place to start learning.

Nekiruhs
August 23rd, 2007, 03:38 AM
C more complicated than Python? woah, dude, whoa.
Do I detect a hint of sarasm?

slavik
August 23rd, 2007, 04:08 AM
Do I detect a hint of sarasm?

Lots of it actually. :)

C as a language is very small (smallest of all the really popular languages).

The 2nd edition of the C Programming Language (written by the creators Brian Kernighan and Dennis Ritchie, reffered to as "K&R book") is 272 pages. These 272 pages is introduction, everything in the C language, a chapter on basic unix interface and the reference manual for the standard library.

My Programming Perl book (written by Larry Wall, creator of Perl) is over 1000 pages.

Java book (that describes the standard library is probably even larger).

Please note that this is not including stuff like sockets, multi-threading, etc. because these are fairly specific. C syntax is also simple and short (no operator overloading and such). and #include and such are not part of C ;), they are part of the cpp (C Pre-Processor).

This is why I think C is a better language for beginners than Python or Perl or Java, or C++.

pmasiar
August 23rd, 2007, 04:37 AM
I spent most of today learning PYTHON. it seems a little advanced for me (a noob), I am wondering, which language is the most relative to ubuntu. and can someone rply with a couple of good links (for a NOOB like me please).

Python is just fine. Your problem is, you expected it be as easy as HTML. It is not - **problem** is harder. Programming is harder that just some HTML markup, because when you program, you cannot see results immediately, you need to build mental models of data structures and operate on them, there is nothing to see or touch. **This is why** programming is hard. Welcome to the club.

Wiki in my sig has links to get you started. Learn to use Python shell: you can type 1 line command and see results, very good for learning and experimenting.

You are in for months of hard work, learning language, data structures, designing modules, refactoring code, understanding error messages, and debugging (finding semantic errors - where syntax is right, code works, but does something different than you wanted).

But it is all fun, and at the end, you can make computer to do whatever you want!

If you want to start with programming games, there is easier way: http://en.wikipedia.org/wiki/Game_Maker (windows only) is very intuitive GUI to create games. No code to write, all is done by placing icons in slots and changing properties. You will learn enough about programming than learning Python will be easier

CptPicard
August 23rd, 2007, 04:41 AM
what is your take on learning BASH? as i previously stated...isnt that really relative to ubuntu?


This "relative to Ubuntu" is an odd concept. I suppose you mean a language that somehow is most integrated and "natural" for the system... and there is nothing like that. Linux in general has compilers/interpreters for pretty much every language out there, and you can pick and choose. Most of the OS components and apps are written in C or C++, and they tend to be the lingua francas of most big OSS projects, but for a beginner you want something like Python.

You'll want to learn bash along the way to script your shell, but I wouldn't recommend it for a language you use to learn programming; the syntax is pretty ugly and basic constructs are a bit weird, it being more of a tool for gluing together other tools rather than a comprehensive programming environment...

pmasiar
August 23rd, 2007, 04:43 AM
This is why I think C is a better language for beginners than Python or Perl or Java, or C++.

Lisp or Forth are even more compact than C, but it does not mean they are good for beginners. Just the opposite: Bigger building blocks which work well together are preferable to raw power like C has. Or do you really think that Python's dictionary is harder to define and use than C version of it? Which, BTW, is not in Big Blue C, IIRC?

mgoblue
August 23rd, 2007, 04:47 AM
I'd keep trying python, it will be easier for you IMO

slavik
August 23rd, 2007, 04:58 AM
Ahh, data structures. ;)

Like I said in another thread, to me crawling is being able to bolt two useless sticks together to make something even more useless and walking is being able to take a thousand useless sticks and bolt them together to make something useless.

I remember pictures of Scooby Doo made out of Lego blocks. Large model, small blocks. Your suggestion is that the dog should come in pieces such as head, tail, body, limbs. My suggestion is that you should first learn to put lego blocks together to make a small column, then explore how they can interconnect and then build large things with bigger parts.

Similar to bottom-up design strategy.

I also think that Python/Perl have as much raw power as C does (even brain**** has as much raw power as C or Python or Perl). They are turing complete after all.

I have before written a "simple" program in C that connects to google.com and fetches the main page and I can tell you that if I had to choose the language to do it, I'd choose Perl (I haven't bothered to learn Python, since Perl does everything I need it to do).

Roughly in C:
1. create socket
2. convert address to IP address
3. set the proper port
4. connect socket
5. send the 3 line HTTP request
6. read the request

Roughly in Perl (and most likely Python):
1. Create socket to the address and port you want: new IO::Socket::INET(peeraddr => "google.com", port =>80,proto=>'tcp')
2. write the 3 line request
3. read the response

the entire perl script will be about 5 lines of decently non-cryptic Perl code (I except the same in Python). In C, the program was 30-40 lines (of good style, almost no comments).

But in one instance, I am kept ignorant of what Python or Perl interpreters/virtual machines have to do, in another, I feel their pain.

pmasiar
August 23rd, 2007, 05:27 AM
Your suggestion is that the dog should come in pieces such as head, tail, body, limbs. My suggestion is that you should first learn to put lego blocks together to make a small column, then explore how they can interconnect and then build large things with bigger parts.

No. I see my suggestion as building houses from prefabricated blocks, ready-made windows and appliances, your way (bottom-up) as to start with sand+rock+cement+water, then get axe to fell some trees... All raw power, universalmaterials, highly customizable, but with more efforts required to make things happen.

slavik
August 23rd, 2007, 05:48 AM
Yes, pretty much. Except that I am against taking raw materials and trying to build a large house right away. More like first learn how to build a panel, then go buy enough to build a house.

I was pretty sure the lego example was similar to your building example.

CptPicard
August 23rd, 2007, 05:53 AM
Lisp or Forth are even more compact than C, but it does not mean they are good for beginners. Just the opposite: Bigger building blocks which work well together are preferable to raw power like C has.

I have to take issue with this, in particular as it applies to Lisp. As you say, for example Scheme is extremely compact, and I feel that the functional paradigm is actually quite natural as a programming abstraction. It would be pretty good for a mathematically-inclined beginner without preconceptions of what programming is supposed to be like.

I have always played around with the idea of what would come of kids who were just handed a copy of SICP and a REPL and left to explore, with some guidance...

(I must confess that I just barely passed my Scheme/Prolog class as I was too busy to really put my mind into it and just have never been able to code with pencil and paper... writing symbolic programming stuff by hand sucks...)

bigboy_pdb
August 23rd, 2007, 08:15 AM
If you've already done some web design/creation then I think javascript might be a good place to start.

BASH scripting is definitely worth learning since the BASH shell is shipped with Ubuntu. I've used BASH commands (directly on the command line) to parse HTML files. You can also use bash scripts to automate tasks.

I don't recommend PERL as a starter language. It's quick, but it can be a pain to learn and use, and it isn't a language that you can easily return to after being away from it for some time (due to the amount of symbols used where function calls with English names could have been used). Objects can be difficult to understand and implement for a beginner, it has syntax that can be difficult to learn, and it can't overwrite segments of a file without erasing the rest of the file (although that could have been changed since I last used it).

I've never used Python so I can't say anything about it.

Java would be easier to learn than C or C++ because you won't have to control memory management in Java and references and pointers are simpler than in C and C++. You can always learn C and C++ after. Also, you could use Java Servlets to create web sites/pages.

Learning about programming concepts is more important than the language that you learn because many programming concepts exist in most or all languages (at least in some shape or form).

The programming concepts that I think a person should learn about are:
variables, conditional statements, loops, functions, recursion, objects/classes, reading from and writing to files, error handling, memory management, manipulating numbers, manipulating strings, regular expressions, and concurrency.

Learning a programming language isn't enough to write good programs though. A person should also learn about:
Run time complexity, proving that a program terminates, proving that a program is correct, proofs in general (of a logical, mathematical, or computer science related nature), algorithms, design patterns, debugging strategies, logic, and mathematics (subjects in algebra and discrete mathematics are closely related to computers).

pmasiar
August 23rd, 2007, 03:46 PM
I have to take issue with this, in particular as it applies to Lisp. As you say, for example Scheme is extremely compact...

Scheme's source code is compact, but with Forth, **binary code** is compact too. That's why it is used in drivers.

See source for function: add one to parameter, and print it:

: fun1 1 + . ;

Forth assumes parameters on stack, and places result to the stack.

When compiled in Forth, this definition would take about 20 bytes, including text 'fun1', which is stripped down for production binaries. No other language, **including ASM,** can beat that.

BTW 'fun1' is non-idiomatic name for this function, real name would be '1+.', because all chars except space are valid in names. It gives you chance to real nice terse names, like if you have some structure S, you can have '>S' (put top value from stack to S) and 'S>' (pop == remove value from S and place it on stack).

Then you define "peek at S"
: ?S S> dup . >S ;

which will pop S, make copy, print it, and place original back to S. See the pattern? Can you fell the power?

And space used? About 16 bytes...

ghostdog74
August 23rd, 2007, 03:56 PM
which language is the most relative to ubuntu.

the shell of course. the shell is always there....learn it

CptPicard
August 24th, 2007, 10:13 PM
Scheme's source code is compact, but with Forth, **binary code** is compact too. That's why it is used in drivers.

Umm.. ok. I wasn't really referring to binary size, but the "size" of the space of language concepts :)



which will pop S, make copy, print it, and place original back to S. See the pattern? Can you fell the power?

And space used? About 16 bytes...

Yes, I am sure all the n00bs who insist that the lower level the language is, the more powerful it is, can indeed feel the power. ;) ;)

pmasiar
August 25th, 2007, 12:20 AM
Umm.. ok. I wasn't really referring to binary size, but the "size" of the space of language concepts :)

way too abstract for me.

> Yes, I am sure all the n00bs who insist that the lower level the language is, the more powerful it is, can indeed feel the power. ;) ;)

Forth is language to design domain-specific languages, pretty good at that, and practical (Ie works). Looks like you missed that.

CptPicard
August 25th, 2007, 12:37 AM
Forth is language to design domain-specific languages, pretty good at that, and practical (Ie works). Looks like you missed that.

Yes, seems so... :worship:

(Why doesn't this board have that particular one...)

pmasiar
August 26th, 2007, 01:34 AM
Yes, I am sure all the n00bs who insist that the lower level the language is, the more powerful it is, can indeed feel the power. ;) ;)

Well, real n00b is the one who does not recognize interesting system when faces it. :-)

I am not saying you should be interested in it - but I believe you dismiss from your high horse extremely powerful language you don't took time understand or appreciate.

I am not saying that low level is always good, or high level should not access low level features directly. Of course **most** languages take side on either low-level features or high, but Forth is strange mix which takes both sides -- and cutting other corners.

So let me say little more about Forth: I don't use it anymore, but **really** care about the language, and maybe someone will get interested.

Forth is unique in couple aspects:
- it discards many language stereotypes: It allows programmer (even forces) to manipulate parameter stack: all parameters come from stack, result returns to stack, and uses postfix notation. You can even manipulate return stack, and patch already compiled binary code. No restrictions at all. Not for a coder who is used to lots of hand-holding and security ropes from IDE.
- it includes assembly, so any of the functions can be programmed is assembly, and it integrates seamlessly into system
- it includes own operating system (written in Forth, of course), if needed, so it can run on bare metal
- it is trivial to enhance language in a given direction, creating domain-specific languages. Every part can be changed, including input line parser
- It is very compact, more than any other high-level language, and also rather fast, because code is compiled (hard addresses), not much search in namespaces on runtime unless you requested it.
- It is very cross-platform - big part of Forth is written in Forth itself, and whole system is like 7 pages of Forth source code and a 3 pages of assembly. If you have macro-assembler available, and know what to do, porting Forth should be a week job.

Just to get you the idea how compact it is, Forth editor, compiler, and runtime (OS-like, running on bare metal) for PDP/11 was about 4-6K of code. We used it for testing special custom devices.

All this is result of Forth (http://en.wikipedia.org/wiki/Forth_%28programming_language%29) history: it was created as workaround, where Charles Moore (http://en.wikipedia.org/wiki/Charles_H._Moore) needed to program custom telescopes: they had enough memory to run binary code, but not enough to run development system, and because they were custom system, cross-compile was not good option either: nobody was interested to create cross-compilers for custom one-off systems.

Forth is still actively used by device drivers, I am waiting for mobile device programmers to find it again. Maybe someone should implement Python on top on Forth - that would be cool for mobile phones!