The online racing simulator
Learning To Program.
(91 posts, started )
Quote from Shotglass :True but how are you going to teach those without establishing at least some kind of pseudo code?

I don't think there's a problem with learning the concepts of conditionals, iteration, inheritance, polymorphism, encapsulation, etc. without code.

Quote from Shotglass :(btw on a side note I don´t think data representation is something you should put that much emphasis on when you begin to learn about coding).

I think this statement illustrates our differences in approach and our respective stance on OO. After all, the essence of Object oriented programming is that you are defining a model in which data is grouped and has data domain specific functionality attached to it. I.e. data representation precedes function in design.
OT:
Quote from StuntCarRacer :Already "golfed" to get into the mood . One char can be saved by replacing print with warn, provided that printing to STDERR is not against the rules

Please don't introduce this lot to codegolf I've barely managed to avoid it to date! One more group might push me over the edge and then I'll loose all productivity
Quote from Dygear :the FizzBuzz test

Here's my non-enterprise design:

<?php 
php
    
for($i=1;$i<101;++$i){echo
    (!(
$i%15))?'FizzBuzz':((!(
    
$i%3)||!($i%5))?((!($i%3))
    ?
'Fizz':'Buzz'):$i),"\n";}
?>

is it just me or are both fizzbuzz loops posted here a little dodgy ?
Didn't look at any code examples except the two posted, but here's the obvious way of doing it. There's probably a more elegant way, but this took me less than five minutes.

using C = System.Console;

class Program
{
static void Main()
{
for (int i = 1; i <= 100; i++)
{
if ((i % 3 == 0) && (i % 5 == 0))
C.WriteLine("FizzBuzz");
else if (i % 3 == 0)
C.WriteLine("Fizz");
else if (i % 5 == 0)
C.WriteLine("Buzz");
else
C.WriteLine(i);
}
}
}

#56 - Woz
Quote from DarkTimes :Incidentally C++ supports both imperative and object-orientated programming, although C doesn't.

While it is true that C is not an OO language it is perfectly possible to implement OO based design techniques within C, it just takes far more work to implement.

Most of the original moves in Object C (The language that evolved into C++) were just C pre-processor directives.

When all boils down a method inside a class is the same as a static function that takes a structure pointer to the data for the class..

objectInstance->DoWork();

is the same as

DoWork(objectInstance);

If objectInstance is a struct pointer. The second call is actually closer to the reality produced by the compiler as "this" in C++ is the object instance that is passed into the function as a hidden param.
Yeah, but in my view you should play to the strengths of whatever language you're working with, and OOP is not one of those for C.
Quote from DarkTimes :Yeah, but in my view you should play to the strengths of whatever language you're working with, and OOP is not one of those for C.

Totally. I spent several years doing OOP in perl. Perl is amazingly versatile and OO was grafted onto it via some clever tricks, but at the end I was trying to write perl as if it was java and it was just getting too painful. You just gotta write code in the way most natural to your language of choice.

Now I do mostly procedural stuff in perl with limited OO here and there, and leave the heavy OOP to other languages. If I had to venture back into dynamic language land for something more than admin scripting, I'd probably go for php5. It's the object model most closely resembling what I'm used to. I know lots of people swear by python but I've never been able to get over the "white space is significant" barrier.
Quote from sdether :I know lots of people swear by python but I've never been able to get over the "white space is significant" barrier.

maybe you should try this then
Quote from the_angry_angel :OT:
Please don't introduce this lot to codegolf

I can't introduce Perl without golf, these things are unseparable
Quote from filur :Here's my non-enterprise design:

<?php 
php
    
for($i=1;$i<101;++$i){echo
    (!(
$i%15))?'FizzBuzz':((!(
    
$i%3)||!($i%5))?((!($i%3))
    ?
'Fizz':'Buzz'):$i),"\n";}
?>


You can get rid of "not" operators by changing expression order in the ternary operator. Separate path for "FizzBuzz" is not needed, you can make it by joining "Fizz" and "Buzz". Loop variable initialization is not needed (PHP will complain in server logs but I don't care :razz, and loop variable incrementing can be stuffed into the main expression. After all these changes and getting rid of unneeded parentheses it will look like this:

<?php 
php
for(;$i<100;)echo++$i%3?"":"Fizz",$i%5?$i%3?$i:"":"Buzz","\n"

?>

I'm really sorry, I couldn't resist
Quote from StuntCarRacer :

<?php 
php
for(;$i<100;)echo++$i%3?"":"Fizz",$i%5?$i%3?$i:"":"Buzz","\n"

?>

I'm really sorry, I couldn't resist

Very nice.
funny that the first loop which will actually run from 1 to 100 is a butchered one

<?php 
 
while($i<100)echo++$i%3?"":"Fizz",$i%5?$i%3?$i:"":"Buzz","\n" 
  
?>

Would it not make more sense to use a while?
Quote from DarkTimes :

<?php 
 
while($i<100)echo++$i%3?"":"Fizz",$i%5?$i%3?$i:"":"Buzz","\n" 
  
?>

Would it not make more sense to use a while?

i guess it depends on what php makes of omitted init values in while loops ... either way though you dont save an chars that way
Quote from DarkTimes :Would it not make more sense to use a while?

It doesn't make sense to write code like this at all.
Quote from filur :It doesn't make sense to write code like this at all.

The point of codegolf is to create code which passes a specific test, in the fewest number of characters (including newlines).

Personally I blame perl for making it "popular".
Quote from the_angry_angel :Personally I blame perl for making it "popular".

Tim Toady is both perl's greatest asset and the reason many consider it a "write only" language. Before people accuse me of flaming perl, I should say I am a perl code and, ahem, some of my best friends are perl coders.
C++
Im starting out with C++ intrestingly . I dont think its bad atall, just requires a little brain work but then what language doesnt? I will be sticking with C++ as it seems to be pushing all the right buttons for me,and doing what i need it 2.Ive been making a few codes that where in a book i found online and im getting the hang of the programming idea. for example :

// Guess my number
// The classic number guessing game
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
srand(time(0)); // seed random number generator

int theNumber = rand() % 1000 + 1; //random number between 1 and 1000
int tries = 0, guess;

cout << "\tWelcome to Guess My Number\n\n";

do
{
cout << "Enter a Guess: ";
cin >> guess;
++tries;

if (guess > theNumber)
cout << "Too High!\n\n";

if (guess < theNumber)
cout << "Too Low!\n\n";

} while (guess != theNumber);
cout << "\nThat's it! You Got It In " << tries << "guesses!\n";
system ("PAUSE");
return 0;
}

That bunch of lettes and characters there is a game but 2 weeks ago id look at that and think WTF does it all mean...

tbh its still personal choice but if your going for insim applactions my own opinion would say go for C/C++
Yeah, that's cool. C/C++ is absolutely fine, you can obviously do a whole lot of cool stuff with it. However I would still argue that for building medium to large programs, especially Windows GUI applications, then there are better choices. It comes down to whatever floats your boat, really. There is a reason why so many programs are written in a managed language like Visual C# these days, it's just less painful overall. But if you're finding C/C++ is doing it for you, then that's great!
Yeah, my c++ text book has that one in it. We're running through it quickly, then doing open gl.

for C#, I prefer to have the good old using statement for future use.

using System;
namespace NotAnEnterprise
{

class Program
{
static void
Main(string[] args)
{
Console.WriteLine("Not an enterprise application.");
}
}
}

or in Java (not advised for making a game though)

public Class HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello world");


}
}
#72 - col
[quote=Shotglass;495284]...
theres a reason mist unis start with scheme
...

Sometimes I wish I had started with some LISP variant. I have dabbled on and off with it, but never had the time to actually *really* learn it.

I would add my vote to the folks recommending to learn about computer systems and programming in general rather than some specific language. When you have a solid foundation, you can choose a language based on what's best for your next project rather than mashing the project to fit the language you know.

In the end, you probably want to have some fluency in at least one multi-paradigm language, and as has been said, knowledge of assembly will also help a lot (even if you never do any assembly programming other than to learn how)

If I were starting now, I would be taking a very serious look at Ruby and at Python (but then I mostly use C++ and Java, and you know what they say about the grass on the other side).

Good luck and have fun
-
(wheel4hummer) DELETED by wheel4hummer
Quote from agm_ultimatex :
using System;
namespace NotAnEnterprise
{

class Program
{
static void
Main(string[] args)
{
Console.WriteLine("Not an enterprise application.");
}
}
}

Can't you simplify that alot?


#import <stdio.h>
int main()
{
printf("Not an enterprise application.");
return(0);
}

Wheel, read, what he posted is C# not C++
hi guys didnt want to make another thread so ill post here,

ive just started to learn C,C++ and C# im starting to get more confident in programing now, and starting to understand where ive made mistakes altho im not to the advanced stages yet, i feel like a challenge so i thought idd try somthing a little differant to what the books teach you, i was wondering if there was anything in lfs i could try that was just small and would give me an understanding in how apps work with insim 4.

as i said just started out and loving it but need a challange, nothing too hard just somthing easy, thanks for any help and thanks for getting me into programing as ive been following some of the topics arround here and thought idd try some of you are really good but i spose it all comes with time i cant wait till i write me first programe for lfs just dont know what to write ?

so any ideas, and no i dont want to make a cruise server type of app lol,

thanks from racemania future programer (i hope)

Learning To Program.
(91 posts, started )
FGED GREDG RDFGDR GSFDG