![]() |
What program to program with?
This is probably a dumb question but i would rather flamed than run around in circles for days. I have been doing some research on here on what languages to learn and i'm going to find some books on Java and C programming. My question is what do i use to run and compile the programs? I have been playing with xcode but i'm not sure if it is specific to one or the other. I am running on a mac. thanks for any help.
|
You can use Xcode to compile C (and C++) programs. You can also use it to compile Java programs, but for Java programming I much prefer Eclipse.
|
thanks! the only programming (if you can call it that) has been with matlab, So i'm relatively new to the area.
|
Hi Coletrain
Don't worry about being flamed on this forum. Everybody's well behaved here and will help you willingly. And I agree with Dr Hayne about Eclipse and XCode. Robin |
Quote:
oh i went there |
I guess i'm use to my off road forum where everyone seems to get less patient everyday :rolleyes:. I will still use the search button cause i know how it can be when the same question gets answered all the time
Quote:
|
I like php. It's easy, yet powerful, and it's cross platform so something I write for a Mac server will run on a Linux server, or some other platform.
|
Quote:
|
I'm not saying php doesn't have limitations, but at least some of its problems rise from that fact that lots of newbies code in it. Many of them have never heard of OOP, and their code shows it clearly.
|
Quote:
|
Yes, I have. I think that complaining about how php coerces type shows a bit of bias, and putting an image of training wheels up shows that the derision is aimed more at the people who use the language than the language itself.
Edit: This is understandable. Newbies often want to be spoon fed, and it can be annoying. |
Blaming "newbies" for the problems with the language means you either didn't read the articles or don't understand them.
All languages have newbies. Not all languages are awful. PHP happens to qualify for both. |
Sigh. I'm not blaming newbies for problems with the language. I'm blaming elitist programmers for nitpicking* the language because it gets used by so many newbies. I believe that if there were no php, then some other language — maybe Perl or Ruby —would end up with the lion's share of newbies and hence derision by 'real' programmers.
* ie, Complaints about underscores, and the use or nonuse of 'i' for case sensitivity. |
Well, there are four articles (that might not have been visually apparent, sorry) in my post that outline, quite explicitly, why PHP is a terrible abortion of a language. Everything from the Alzheimer's-inducing standard library to its broken Unicode support to WTF which string escaping do I need for this situation oh god just kill me now this is ridiculous. Documentation? Terrible, too.
And if you really think PHP is "portable", enjoy this one: http://www.mysqlperformanceblog.com/...d-portability/ |
Quote:
Here's a few denigrating other languages: http://pythonguy.wordpress.com/2008/...ks-perl-sucks/ http://rs79.vrx.net/opinions/computers/languages/PerlC/ http://www.onlamp.com/pub/a/onlamp/2...hilosophy.html http://advice.cio.com/esther_schindl...ds_why_c_sucks I'm not saying anything about any of these opinions. My only purpose in posting them is to show that no language is perfect. All have their detractors, and the one with the most newbies will inevitably have the most detractors. In any case, I think we can all agree that it isn't the weapon that matters. It's the person using it that counts. If you think a class is something you go to, it doesn't matter what language you're using. |
A good carpenter can't make a crappy hammer screw bolts any better that it's capable of.
|
Quote:
just clarifying. ;) |
Quote:
|
Since we're talking about language quirks, I'd say that any language that uses "void()" is a little strange. Sure, I'm nit picking, but let's face it: this site, as well as the Wordpress site and many others, is done in php, and they don't suffer because of the language. Are there problems with the language? Sure, but what language doesn't have issues?
|
Quote:
|
Quote:
* PHPv3 did indeed suck by current standards, but it did what it was designed to do. V4 was like a teenager learning to drive. Lots of functions are not a bad thing and minor inconsistencies like hyphens and underscores in function names are typical of community-developed anything. |
Quote:
|
Quote:
PHP is perfectly fine once you get used to its oddities, and in some ways its easier to use than a more sophisticated language like Ruby or Perl (both of which are brilliant at making clean, concise code, but which require a lot more mental effort to create or understand). |
Quote:
Quote:
Code:
class StuffPHP Code:
|
Quote:
sorry, that should be Human==Weird. logical equivalence, not assignment... :D |
Quote:
Human === Weird Logical equivalence, both value AND type. :p |
Quote:
For the Ruby version, how about: Code:
class Stuff |
well, the PHP version could be reduced to
PHP Code:
|
Quote:
|
Quote:
But it's not bad enough to make me want to learn Perl :rolleyes: |
Quote:
You're also using indexing in the PHP version (as you did in the C version), so the coefficients have to be an array. The Ruby version only requires the coefficients to be enumerable. (In C++ terminology, you're requiring a random access iterator where an input iterator would have sufficed.) This example is so tiny that it's hard to appreciate the significance of these distinctions. The thing is, the C/PHP version is constructed from smaller mental "chunks" than the Ruby version, so you need more of them. That means it takes more mental effort when reading the program to figure out what it does. It's like the difference between a 1000-piece jigsaw puzzle and a 500-piece jigsaw puzzle. The number of pieces makes a huge difference in the time it takes to assemble the puzzle. |
Quote:
|
Or in other words: yes, you can evaluate a polynomial with only addition/multiplication, but exponents are faster, even if the code looks slicker without them.
|
Quote:
|
On the positive side the giant perl-coded bomb would destroy perl too.
|
Quote:
|
Quote:
|
I was trying not to. :D
In the interest of accuracy, I need to correct myself and point out that php doesn't do exponents as: $a^$b It does them this way: pow($a,$b); One more thing for its detractors to gripe about. :eek: |
Quote:
If you have the sequence a, b, c, d, you can form the sum by injecting addition: a + b + c + d you can form the product by injecting multiplication: a * b * c * d you can form the longitudinal checksum by injecting xor: a ^ b ^ c ^ d or in general, inject an arbitrary binary operator op to get a op b op c op d In each case, these operators associate left-to-right, so the expressions are really evaluated as (((a + b) + c) + d) (((a * b) * c) * d) (((a | b) | c) | d) (((a op b) op c) op d) All you have to do in ruby is tell it which binary operation to inject. The polynomial ax^3+bx^2+cx+d can be more efficiently written as (((ax + b)x + c)x + d) which we get by injecting the operator op defined by v op c == v*x+c. And that's exactly how it's written in ruby: coefficients.inject {|v,c| v*x+c} or in words "given the sequence of coefficients, inject the operator which, on arguments v and c, computes v*x+c. Return the value of that expression." Notice that there's no need to create a loop. We're just building an expression. (Sure, there's a loop going on under the hood, but we don't need to think about that, any more than we need to think about all the dictionary lookups and memory management and subroutine calls that are also going on under the hood, in both languages.) Since we don't introduce a loop, we don't need to grok C's baroque for loop syntax, nor do we need to introduce the auxiliary variable $i whose sole purpose is to keep track of our progress through the loop. No need to count how many coefficients there are. No need to treat the coefficients as an indexable array (as in the expression $coefficient[$i]). In ruby, it's just a sequence, and we're just injecting an operator into it to form an expression. One simple (albeit powerful) concept. Well, OK, two concepts. We're using the fact that lambda expressions are easy to write and easy to use. In ruby they're called blocks; {|v,c| v*x+c} is an example of one. You don't write much ruby without using lots of blocks. Oh, and BTW, multiplication is a LOT faster than exponentiation. |
Sure, one multiplication is faster than exponentiation, but that's not what you have:
a0 + a1x + a2x^2 + a3x^3 + ... + anx^n can be written in your (((ax + b)x + c)x + d) form, but only by using a loop, which is exactly what inject does. The result is many multiplications and many additions. Remember, we don't know how many items exist in the array: coefficient. |
Quote:
|
Quote:
Let me repeat that. I don't see any loops. I am always cognizant of what's "really happening" under the hood. I know that in executing the program there's a lot happening down under. Symbols are being looked up in dictionaries. Memory is being allocated to hold values. Method dispatch tables are being consulted to locate the correct code to execute next. And yes, there are some loops down there, too. But I don't need to look at any of that to understand what the program does. The code I look at and have to understand doesn't have any loops in it. ax^3 + bx^2 + cx^1 + dx^0 takes 4 exponentiations, 4 multiplications, and 3 additions. (((ax + b)x + c)x + d) takes 3 multiplications and 3 additions. But we're drifting away from the point I wanted to make. The PHP version could easily be rewritten to evaluate the polynomial using multiply-add. Any competent programmer would do that as a matter of course. Let's consider it done and move on. My main point was this: if you're comparing two languages by looking at sample code to perform a given task, write each sample the way a reasonably competent user of that language would have written it. It's pointless to write the program in yet a third language (C in this case) and then translate that clumsily into the languages being compared. That doesn't give you a useful comparison. Besides the obvious perils of non-idiomatic translation, it rules out beforehand any features of the target languages that aren't present in the source language. In this case, Ruby has a slew of operators that operate on entire sequences (of which arrays are only one flavor) as fundamental objects. While you can loop across the elements of a sequence, it is much more common in Ruby to operate on entire sequences with a single operation. To someone not used to this, operations like inject, collect, reverse, sort, detect, any?, all?, and grep may seem exotic, but they're the bread and butter of Ruby programming. A Ruby programmer would no sooner replace any of these with an explicit loop than would a C programmer replace for(...) with the equivalent if() and goto statements. You could do it, but why? It takes more code to write, and it's harder to read, as well as being more error-prone. If you try to explain that "for" is easier to understand than "if/goto", and they reply "But 'for' just uses 'if/goto' under the hood, so they're still there," you know they're just not getting it. This fancy-schmancy "for" construct isn't just some exotic hard-to-understand thing you're doing to show off. It really does make the program easier to read and easier to get right. All it takes is the initial effort to learn what "for" does. Likewise when you explain that we have all these operators that work on entire sequences so you don't have to write out the explicit loops, and they say "But 'inject', 'collect', 'grep' et al. really do still run loops underneath," you know they're still not getting it. These aren't fancy-schmancy constructs that get thrown in just to show off. They really do make the program easier to read and easier to get right. All it takes is the initial effort to acquaint yourself with them. I feel that I'm being sucked into acting like a Ruby fanboy here. I do kinda like some features of Ruby, but it's not my favorite language. (Trying to debug Rails code cured me of that.) I just thought this particular example was maligning it unfairly. |
who's maligning anything? everybody chill a bit. all code gets executed in machine language - everything higher level is just a metaphor. what metaphor you use depends on what you know, what you're trying to do, and how your brain works. beyond that... whatever.
|
| All times are GMT -5. The time now is 05:34 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.