Page 3 of 5 [ 72 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

Dussel
Veteran
Veteran

User avatar

Joined: 19 Jan 2009
Age: 61
Gender: Male
Posts: 1,788
Location: London (UK)

17 Jun 2009, 7:31 pm

ikorack wrote:
What was your guys first language and where did you learn it.(wants to learn C/C++)


Also giving away my age: ANSI-Pascal on a HP-UX V machine (we had a central server with an external "mass storage" of 4 GB in the size of a fridge).



Dussel
Veteran
Veteran

User avatar

Joined: 19 Jan 2009
Age: 61
Gender: Male
Posts: 1,788
Location: London (UK)

17 Jun 2009, 7:36 pm

lau wrote:
EarlPurple wrote:
C++ has to offer 4 things that C doesn't that make it easier to use:
    EarlPurple wrote:
    - Automatic destructors
    At a memory/speed cost.
    EarlPurple wrote:
    - Exceptions
    At a memory/speed cost.
    EarlPurple wrote:
    - Polymorphism i.e. virtual functions.
    At a memory/speed cost.
    EarlPurple wrote:
    - templates, in particular for collections
    At a memory/speed cost.


I've run into this once extremely: I wrote a program which dealing with a vast amount of very small data sets (10^7 of a few kB each). Replacing the std-lib, virtual methods and templates with C-Style pointer increased the speed drastically (factor 10 and more).

Most speed consuming are virtual methods of classes which are only determinate during runtime.



LostInEmulation
Veteran
Veteran

User avatar

Joined: 10 Feb 2008
Age: 42
Gender: Female
Posts: 2,047
Location: Ireland, dreaming of Germany

18 Jun 2009, 5:03 am

Pobodys_Nerfect wrote:
I use block style, K & R style gets on my nerves. My first was Pascal. My favourite is Java.


My first was Pascal as well, I like Allman style, K&R is a crime against humanity! :wink:

I like Forth and C best.


_________________
I am not a native speaker. Please contact me if I made grammatical mistakes in the posting above.

Penguins cannot fly because what cannot fly cannot crash!


lau
Veteran
Veteran

User avatar

Joined: 17 Jun 2006
Age: 76
Gender: Male
Posts: 9,798
Location: Somerset UK

18 Jun 2009, 8:56 am

Code:
: xx cr 3 0 do 2 0 do ." Hip, " loop ." Hurray!" cr loop ; xx


_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer


immersive
Hummingbird
Hummingbird

User avatar

Joined: 7 Jun 2009
Age: 42
Gender: Male
Posts: 18

18 Jun 2009, 9:04 am

Sure, if you need optimize your code to run as fast as possible to run a real-time system or process a huge amount of data, C has less overhead than C++. But for most commercial software, what's far more important is development time (that's what costs companies tons of $$), not speed of execution. All the advantages of C++ make sharing code among teams faster and easier and results in better designed software (in general), because it allows you to hide the low-level implementation behind high-level abstractions. Sure, this has some overhead at run-time, but if you're part of a large development team writing a complicated piece of commercial software, the advantages of C++/C#/Java often justify the speed tradeoffs.

Besides, CPU speeds are so fast these days, unless you're dealing with large amounts of data (visualization, databases, etc) most of the time you wouldn't notice a difference at runtime (unless you're programming for a cell phone or other mobile device with limited processing power). I'm a virtual reality researcher, and we need to optimize our applications to run in real-time (at least 60 frames per second or users will experience simulator sickness). I use C++ and high-level API's like OpenSceneGraph. The bottleneck in our applications is never the CPU - it's the graphics processing on the GPU. And given that I'm often having new students working on these applications from year-to-year, the advantages of using high-level languages is well worth it - if we used just C and OpenGL, the learning curve would be too high for new students, and nothing would get done.



0_equals_true
Veteran
Veteran

User avatar

Joined: 5 Apr 2007
Age: 43
Gender: Male
Posts: 11,038
Location: London

18 Jun 2009, 9:04 am

Does anyone hate it when braces are bellow the control statement rather then the same line. It drives me nuts.



immersive
Hummingbird
Hummingbird

User avatar

Joined: 7 Jun 2009
Age: 42
Gender: Male
Posts: 18

18 Jun 2009, 9:05 am

Oh, and to answer the original question: taught myself QBASIC from a textbook my dad bought me when I was about 10-12 years old.



Dussel
Veteran
Veteran

User avatar

Joined: 19 Jan 2009
Age: 61
Gender: Male
Posts: 1,788
Location: London (UK)

18 Jun 2009, 6:12 pm

0_equals_true wrote:
Does anyone hate it when braces are bellow the control statement rather then the same line. It drives me nuts.


Not if you come from Pascal:

Code:
for Loop:=1 to 100 do
begin
      Remainder := DoSomething (Loop);
      if Remainder mod 6 = 2 than
             begin
                  RunSpecailTwo (Loop);
             end
      else
             begin
                   RunOther (Loop);
                   DoSomething (Loop);
             end;
end;



UrchinStar47
Sea Gull
Sea Gull

User avatar

Joined: 23 Feb 2009
Age: 38
Gender: Male
Posts: 216

19 Jun 2009, 12:32 pm

I started programing in QBasic, moved on to C and Fortran.



ikorack
Veteran
Veteran

Joined: 15 Mar 2009
Age: 33
Gender: Male
Posts: 1,870

19 Jun 2009, 8:58 pm

Some of you are not anwsering the second and most important part of my question. how?



lau
Veteran
Veteran

User avatar

Joined: 17 Jun 2006
Age: 76
Gender: Male
Posts: 9,798
Location: Somerset UK

20 Jun 2009, 4:31 pm

ikorack wrote:
Some of you are not anwsering the second and most important part of my question. how?

Erm. The second part of your question was "where", not "how".

Where... I learned Fortran in school, maybe.

How... from the Fortran manual, I think.


_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer


peterd
Veteran
Veteran

User avatar

Joined: 25 Dec 2006
Age: 72
Gender: Male
Posts: 1,353

21 Jun 2009, 6:35 am

The only "how" that's ever worked for learning a computer language is to solve a problem that I care about using the language.



lau
Veteran
Veteran

User avatar

Joined: 17 Jun 2006
Age: 76
Gender: Male
Posts: 9,798
Location: Somerset UK

21 Jun 2009, 6:48 am

peterd wrote:
The only "how" that's ever worked for learning a computer language is to solve a problem that I care about using the language.

Very true.

As to what materials, etc., I've used while learning a language: most times it would just be the "Programmer Reference Manual".

I don't have much patience for the "A Primer in Language X" books (though I might flip through them), or classroom settings.

In some cases, I've learnt a language while debugging/rewriting/translating programs written in it. That especially applies when learning an assembler - as it helps enormously to see the machine code "tricks" you'll need to know about. Hopefully, the code will also contain comments that are illuminating. :idea:


_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer


charliec
Butterfly
Butterfly

User avatar

Joined: 25 Apr 2009
Age: 44
Gender: Male
Posts: 12

23 Jun 2009, 4:25 pm

I also started from QBasic and then moved to Pascal.



EtotheC
Blue Jay
Blue Jay

User avatar

Joined: 23 Jun 2009
Gender: Male
Posts: 89

24 Jun 2009, 2:09 pm

ikorack wrote:
What was your guys first language and where did you learn it.(wants to learn C/C++)


I learned Basic on an Amstrad CPC, but I started to learn C shortly after I started that



EarlPurple
Snowy Owl
Snowy Owl

User avatar

Joined: 4 Jun 2009
Age: 60
Gender: Male
Posts: 162
Location: London, UK

24 Jun 2009, 2:24 pm

Dussel wrote:
lau wrote:
EarlPurple wrote:
C++ has to offer 4 things that C doesn't that make it easier to use:
    EarlPurple wrote:
    - Automatic destructors
    At a memory/speed cost.
    EarlPurple wrote:
    - Exceptions
    At a memory/speed cost.
    EarlPurple wrote:
    - Polymorphism i.e. virtual functions.
    At a memory/speed cost.
    EarlPurple wrote:
    - templates, in particular for collections
    At a memory/speed cost.


I've run into this once extremely: I wrote a program which dealing with a vast amount of very small data sets (10^7 of a few kB each). Replacing the std-lib, virtual methods and templates with C-Style pointer increased the speed drastically (factor 10 and more).

Most speed consuming are virtual methods of classes which are only determinate during runtime.


I'd be interested to see your C++ code that performed so badly. No doubt it performed badly because it was badly written, not because it was in C++.

std::vector can be slower than straight arrays because of its initialisation. It is not the best to use for large sets of data if it needs to be grown because reallocating is O(N) and also because it requires a contiguous buffer. std::deque should be used instead.

Read Modern C++ Design by Andrei Alexandrescu and he might give you some useful hints.

I do agree that exceptions would be better implemented if there were no class hierarchy. One exception type would suffice.