Quantcast
[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr / vt ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Due to resource constraints, /g/ and /tg/ will no longer be archived or available. Other archivers continue to archive these boards.Become a Patron!

/g/ - Technology


View post   

[ Toggle deleted replies ]
File: 26 KB, 800x415, Clipboard02.jpg [View same] [iqdb] [saucenao] [google] [report]
35432314 No.35432314 [Reply] [Original] [archived.moe] [rbt]

Ask a C++ programmer anything

>> No.35432345

>>35432314
does it hurt?

>> No.35432362

>>35432345
Only at times, but boy is it bad

>> No.35432383

>>35432314
Doesn't the auto keyword have an impact on performance, or is the type determined at compile-time?

I don't know C++.

>> No.35432390

If you are a programmer, why are you using Windows?

>> No.35432407

C++ == C because it's a post-increment.

Clearly you should be using C.

>> No.35432408

>>35432383

Compile-time.

>> No.35432413

>>35432390
because it works

>> No.35432430

are you a code monkey for an ENTERPRISE QUALITY corporation?

do you hate your life?

>> No.35432437

>>35432383
auto is classic compile-time type inferrence. No impact on performance whatsoever. However, along with decltype, it does help in cleaning literaly thousands of lines of code in complex systems with lots of metaprogramming, that used to have awful convoluted pieces of code trying to get the right type.

So if anything it usually makes compilations faster

>> No.35432453

>>35432390

This:
>>35432413

And I'ma let you finish but Visual Studio has one of the best debuggers of al time!

>> No.35432470

>>35432453
>actually using a debugger
printf is best debugger.

>> No.35432476

>>35432407
I'm using it on the next line so it doesn't matter

>> No.35432487

>>35432470
lel this

>> No.35432498

>>35432430

stop watching The Matrix 20 times a day, kid

>> No.35432499

>>35432430
I'm a senior game developer and technical decision maker at a relatively small company. I'm pretty satisfied with my life, thanks

>> No.35432516

>>35432408
Thanks

>>35432437
Compilation time is certainly an argument when it comes to C++ I've heard.

>> No.35432517

>>35432487

lel you're an uneducated unemployed skiddie

>> No.35432519

>>35432470
no.jpeg

>> No.35432542

>>35432517
lel true, except the skiddie part though

>> No.35432566

>>35432516
yes and sometimes it can really really hit you hard.

I've worked on projects for which a full rebuild took literally an hour (there certainly are bigger ones out there, but that's a pretty long time). Even with incremental linking enabled, not using a distributed compilation tool makes this a nightmare

>> No.35432574

Well hi there sir.
How's your metadata programming going? I thought you didn't post like this on /g/.
>inb4 C++ isn't metadata programming
>mfw I saw OP posting this about 8-10 hours ago
>mfw I have no face

>> No.35432601

>>35432574
>metaprogramming*
Now I will leave after that.

>> No.35432607

>>35432574
Yeah I posted this on /b/ and since I'm still bored on a Sunday evening decided to try this on /g/.

After your question before, I decided to try it.

And it's metaprogramming. No data

>> No.35432619

>>35432314
Why isn't IsPrime a class method?

>> No.35432631

Why is libstdc++ so shitty?

>> No.35432633
File: 448 KB, 455x395, 1374351043728.png [View same] [iqdb] [saucenao] [google] [report]
35432633

>>35432517
>he doesn't use visual studio

>> No.35432641

>>35432566
Well, yeah. I guess rebuild in general takes a lot of time (at my job it takes ~20 minutes on a up-to-date box).

(Oh, yeah, I'm in the process of learning C++ and I'm hired as a back-end dev [doing Python and hopefully more C++ after I get a better hang of it]).

As a guy that comes from C, I must say that there really are quite a few gotchas in C++. But I really like it.

>> No.35432642
File: 314 KB, 1313x1200, 1291929716645.jpg [View same] [iqdb] [saucenao] [google] [report]
35432642

>>35432345
it's not java coding

>> No.35432649

>>35432619
It doesn't need to be. Especially for this small application - a solution for a Project Euler program.

If it had been a part from a bigger number theory system, I guess it would have been a static method in a class named "Integer" or something.

>> No.35432650

>>35432314
same thread on /b/ lastnight.

>> No.35432666

>>35432631
Well, unless you specify what you mean by that, I can't answer it.

It's been called shitty for a great number of reasons (most of the times for stupid ones, too)

>> No.35432673

>>35432649
>It doesn't need to be.
That's what you say.

Why use C++ if you're not using objects?

>> No.35432675

>>35432383
The old auto keyword didn't do anything. The new C++11 auto is for setting the type to be that of the result of the expression.

>> No.35432684

>>35432407
>>35432476
I'm a C programmer, so I know that C++ == C is undefined.

>> No.35432690

>>35432641
It's a very powerful language and... you know... spiderman.. so yea...

Anyway. I used to like it too. But now I'm constantly looking for something better. C++ doesn't cut it for me anymore

>> No.35432693

>>35432675
>The old auto keyword didn't do anything.
Well, as I said, I'm don't really know C++ properly yet. But I'm guessing that before C++11 auto was the same modifier it was in C, alongside register etc.

>> No.35432724

>>35432690
>C++ doesn't cut it for me anymore
Oh, why?

Have you tried D?

>> No.35432725

>>35432314
>for(auto prime : Primes)

the fuck am I reading?

>> No.35432728

>>35432673
For Project Euler or other small programs, I only use it because it's let's me write a fast program relatively easily. And also and C++ instead of C because it has a library with containers, and it's generally easy to write something small - fast.

I don't usually use C++ for small programs, though. I prefer ruby

>> No.35432802

>>35432724
Oh yes. And C#, and many many more. You can say that programming languages are a hobby of mine. I can safely say that I'm fairly proficient in at least six (D and C# included).

Still both D and C# allow you to have somewhat better metaprogramming code, they all stuffer from their old timey C roots.

A truly modern language needs to emerge. One that is really suited for metaprogramming. So far I've looked into many many languages and from the emergin ones, only Nimrod seems to be on the right track. Alas it's still in its infancy. I'm hoping that in 10 or so years a language like Nimrod (or Nimrod itself) will replace C++ in 99% of its current uses.

>> No.35432804

>>35432314
how feels the bloated shit? have nice taste?

>> No.35432806

>>35432725
It's a for each loop for an algorithm called Sieve of Erastothenes. It generates prime numers.

>> No.35432821

>>35432725
C++11

>> No.35432833

do you wake every morning and shout "I'm a C++ programmer!" ?

>> No.35432851

>>35432806
Actually the sieve of Eratosthenes is in the previous function (the cropped one).

IsPrime just test whether a number is prime, making use of the sieve results.

>> No.35432855

>>35432802
Rust has syntax-aware macros.

>> No.35432860

>>35432314
What do you think of Java?

>> No.35432866

>>35432804
What do you mean? Executable size?

>> No.35432872

>>35432693
>But I'm guessing that before C++11 auto was the same modifier it was in C
In C auto is a storage-class specifier, not a modifier.

Happy hacking.

>> No.35432892

>>35432833
Yes.
It's an important exercise in confidence.
Do you not shout something when you wake up?

>> No.35432898

>>35432470
and then there are those days when you just cant bring yourself to compile SDL with no output stream modifications to use with GCC, and have to lern2debug because you're a lazy faggot...

I guess it was good in the long run.

>> No.35432929

>>35432314
#include <iostream>
class Doe
{
public:
bool alive;
Doe() { alive = true; }
~Doe(){ alive = false; }
};
int main(int argc,char *argv[])
{
Doe *obj = new Doe();
delete obj;
std::cout << ((obj && obj->alive)?"alive":"dead") << std::endl;
return 0;
}


prints "alive". What the fuck?

also,
How do you manage keeping track of the state of your objects?

If i have pointer to an object that have been deleted, how can i verify the state of that object and prevent acessing that part of the memory?

So far I create an static dynamic vector for each class where i'll push the instances of created objects and remove them from the vector when they're deleted.

Then each time i want to be sure if an object i have a pointer to is still alive i search it on said vector. But doing it often makes my program too slow.

There's any good alternatives besides shared pointers?

>> No.35432934

>>35432804
this.
how is that OP?

>> No.35432938

>>35432855
I know. And also return type overload resolution like Haskell which is also nice. But that's still doesn't cut it. A language needs to have almost all of its features available compile time, to be really poweful.

Imagine the following imaginary compile-time code:

void foo::on_nomethod(const char* methodName, ...args)
{
}

A function called in compile time when calling a non-existing method for a class. I'm talking about stuff preciesly like that. Real power of the code that's been handled compile-time only. True code generation.

>> No.35432960

>>35432929
>prints "alive". What the fuck?
Because
delete

doesn't set the reference to NULL, and while you're accessing garbage, it is the garbage of obj that used to be there, therefore alive is also true (the alive=false is simply removed due to compiler optimization).

>> No.35432965

>>35432860
Hate it. One of the worst things to happen in the software industry.

It's just a bad language. If you want jvm, fucking use Scala. Or even clojure. Or even JRuby. Java is just ... ew...

>> No.35432987

>>35432960
Okay,
> (obj && obj->alive)
The part "obj" will be true, but about "obj->alive"?

>> No.35432993

What do you think of boost?

>> No.35432998

>>35432929

this:
>>35432960

>> No.35433009

>>35432314
c++ or lisp
what should i leanr first?

>> No.35433016

>>35432821
>>35432806

What is that syntax called? List/array comprehension?

>> No.35433021

>>35432987
nevermind

>> No.35433027

>>35432987
Run it in a disassembler. My bets is that alive = false; isn't there because of compiler optimizations (as I said in the latter part of >>35432960).

Or try to compile it and disabling all compiler optimizations.

>> No.35433037

>>35433009
c++

>> No.35433047
File: 13 KB, 324x311, ms.png [View same] [iqdb] [saucenao] [google] [report]
35433047

>>35432633
Not him, but I used visual studio for two years, and I ended up going back to GCC and codeblocks.

Codeblocks is A LOT cleaner as an IDE (mainly because it doesnt have as many features and its more akin to notepad++ with auto makefiles and a compile button), and can be a lot more transparent with less work.

That being said, visual C++ is pretty good.

Visual Studio 2013 was a pain for me tho, while it was cool, you HAVE to install the studio (meaning about 5 compilers or so), and cant (AFAIK) install only one compiler. Add a million billion SQL database related bullshit and when I went to uninstall it I had to unistal them one at a time by hand because LEL MICROSORFT cant even handle their own OS. Pic related.

>> No.35433049

What do you think of C?

>> No.35433059

>>35433009
Learn C++ first, then learn Lisp by implementing a Lisp interpreter in C++.

>> No.35433062

>>35432993
I use it a lot. I do think that some of the libraries in it are jokes, though. Written to just prove a concept. "Hey look what kind of perversion could be made with some clever metaprogramming" Spirit is the main contender for such a prize. But still the boost libraries have some real jems inside. Let's not forget that a lot of the new standard library additions are based on boost libraries.

And spirit could've been good if C++ had good - readable and debuggable - metaprogramming features.

>> No.35433075

>>35433016
Nevermind I found it, it's called "Range-based for loop"

>> No.35433084

>>35433009
neither... If you're new to programming start with something like Ruby. Or if you're bound to try functional programming start with something easier like Scala. And if you NEED to learn lisp, just use clojure

>> No.35433086

>>35433059
>>35433037
shouild i discard C (no ++) ?

>> No.35433120

>>35433027
Then it might depend on the compiler. MSVC's debugger reassigns pointers that have been deleted to feeefeee so this will most likely just crash

>> No.35433131

>>35433086
C is outdated

>> No.35433133

>>35433086
It depends on what you want to do, but most likely... yes

>> No.35433142

Isn't it nice that C++ is English based? It would suck programming in a language with keywords and variables and functions that are English idioms.

>> No.35433150

>>35433047
I'm fairly sure you can choose to not include all that SQL bullshit during the initial installation.

>> No.35433154

Do c influenced languages become obsolete?

>> No.35433174

>>35433154
I hope they will, but it doesn't look that will happen any time soon

>> No.35433184

>>35433150
What are those anyway?

>> No.35433188

>>35432314
What was your first C++ project? How long did it take to become good?

>> No.35433237

How do you feel about using the most hated language? Everyone shits on it.

>> No.35433252

>>35433188
Well I guess a snake-like game, back when I was 14.

I don't know. I guess about 8-10 years to call myself good at C++, but I used to program quite a lot in high-school. Only I wasn't motivated to write good code and used to hack up solutions that just work.

Only when I started working (at 18) did I start paying attention to good code practices, and learning new languages, and getting better in design. So it took me that long because I was a kid, not because it's THAT hard

>> No.35433273
File: 210 KB, 1024x768, Jshit.jpg [View same] [iqdb] [saucenao] [google] [report]
35433273

>>35433237
>most hated language; Everyone shits on it.

What is Java

>> No.35433282

>>35433237
C++ is far from being the most hated language. That would be a battle between PHP and Java.

But C++ is not good. I can say that. It's just that it's very very powerful and, alas, nothing can compare to it yet.

>> No.35433309

You can optimize your IsPrime function by only checking primes that are less than or equal to sqrt(n), there's no need to go all the way to n.

>> No.35433312

>>35433252
So you code for more than 10 years and you are yet to have

1. a concise and uniform syntax
2. common sense when naming variables and objects

?

Ok...

>> No.35433355

There really aren't any real programming languages other than C, C++, and FORTRAN

Everything invented these days is utter crap or scripting.

>> No.35433372

>>35432314
How long would it take a noob to learn to fully program a decent application?

>> No.35433374

>>35433309
Yes indeed, although that wont make the program very much faster because it checks only a few primes.

But nevertheless, that's a good point.

>> No.35433379

>>35433312
Can you even read? Are you actually this retarded? I'm not even OP, but holy fuck you're stupid.

>> No.35433388

>>35433282
PHP is awful

>> No.35433390

>>35432314
> capitalizing the first letter of a variable name
i hope you change your ways lest i have to work with you some day (ill throw your fucking computer out the window if i do)

>> No.35433401

>>35433372
4 years

>> No.35433402

>>35432314
How long did it take you to learn C++? Have you taken any courses, is it good to learn by the book as I am now?

>> No.35433432

>>35433312
what's wrong with the names and the syntax?

This is a piece of a simple Project Euler solution for personal use, but still I would defend its readability. Everybody can see what's being done and how it's done.

>> No.35433448

>>35433282
Man, as a C++ programmer I can say that most of the syntax C++ introduced fucking sucks.

>TRY CATCH... TRY CATCH EVERYWHERE

I HATE when people use these things and then make ME use it in my functions because they couldn't simply return a number.

That and constructors, I rarely use constructors or consts inside a class, because the way they have to initialize these things within a class is assanine.

I honestly just use C++ as C with objects and inheritance...

>> No.35433463

>>35433372
in what language? If you're learning a language suitable for beginners like, say, Ruby... probably a couple of days.

But I guess that also depends on your definition of a "decent application"

>> No.35433474

C# vs C++ for application developing and then possibly game dev?

>> No.35433483

>>35433448
>TRY CATCH EVERYWHERE
i thought i was the only one hating that

>> No.35433490

>>35433237
On /g/ it's Java, but only because /g/ loves bandwagoning and failed its first year CS course.
Otherwise, it's probably PHP or Ruby.

>> No.35433495

>>35433463
Okay.. let's say the ability to code a simple chat client that connects via IPs and ports.
All from your own knowledge, without having to look anything up.

>> No.35433500

>>35433390
Capitalizing global non-constant variable names is a convention. The fact that YOU don't like it and use it, doesn't make it less readable or bad by itself.

>> No.35433508

>>35433448
>>TRY CATCH... TRY CATCH EVERYWHERE

That's JAVA

>> No.35433520

>>35433432
I understand what the class does of course, but if you make it an habit of using shit like

>prime : Primes

thats not very good..

also
>1=1
or
>1 = 1
But not both ffs...

MUH OCD

>> No.35433524

>>35433402
No courses. At the beginning I was mostly self taught. Then the internet and colleagues at my first job helped me gain speed. Then everything else I've learned almost exclusively through the Internet

>> No.35433561

>>35433508
Are you fucking kidding me? have you used boost before?

My god, its obnoxious as FUCK in most boost libs. I pretty much gave up on boost because of shit like that.

>> No.35433579

>>35433508
You end up using a shitload of libraries (or headers) for most C++ applications, so it could be C++ as well.

If your library likes to throw exceptions, then you're going to end up using them too. It's contrary to something like the STL, where there tends to just be a failbit set.

>> No.35433588

>>35433500
To each his own. I denote globals variables like so:
g_check_this_fucking_shit_out; // or
g_checkThisFuckingShitOut;

And member variables like so:
m_holy_fuck_my_syntax_is_good; // or
m_holyFuckMySyntaxIsGood;

I only capitalize the first letter of
* class names
* public class functions
* public / global scope functions

>> No.35433597

>>35433463
Not looking anything up is stupid. It's a bad idea to try to have EVERYTHING in your head. Leave the details to google.

But apart from that. I guess if you're a diligent noob you'll be able to write a simple chat program probably 1-2 months after you've started learning - but again: not C++

>> No.35433603

>>35433561
oh, that and the ambiguous compile time errors it spawned often because of the way some libs are constructed.

>> No.35433609

>>35433508
In Java all you need is one try-catch block that catches a generic Exception. Unless you're looking for specific exception messages, that works in 98% of situations.

>> No.35433610

>>35433524
it shows.

you code like someone who can't code.

>> No.35433675

Which of the Visual Studio versions are worth downloading? I do have access to ms dreamspark.

>> No.35433678

>>35433520
well yeah... OCD. This doesn't really matter. And what's wrong with "prime : Primes"?

>>35433588
Yet another convention widely used in programs that are bigger than a file and actually have classes defined in them. This one is neither. It's still readable and I can safely return to it in years and see what's been done. It's still consistent and when I see the first couple of lines, I'll know what to expect.

>> No.35433720

wait~ VS for C++ ?

>> No.35433731

>>35433610
Why exactly? You've seen 10 lines of code from a program I've written to solve a one time Project Euler problem and suddenly you know if I can code?

But I might begin to understand you if you show me what exactly is bad in that code.

>> No.35433808

>>35433720
MSVC is faster than gcc iirc. its worse in terms of compatibility though both when it comes to different platforms (a complete joke in this regard compared to gcc) and with respect to the c++11 standard

if you read the msdn visual studio blog... you'll often see the ms devs advocate unofficial and sometimes completely language-deviant behavior to solve problems (ie VS specific macros or whatever)

its such a huge vendor lock in thing it seems like a borderline scam sometimes

>> No.35433829

>>35433675
2012 express is probably the best c++ environment out there. The problem is that msvc is not very standard compliant and is missing many key features.

You might want to try VS2013 epxress preview, although I still haven't.

I call them the best because of the debugger, but that excluded Qt Creator is a pretty decent environment too: My favourite one for Linux but it works on all major operating systems

>> No.35433848
File: 233 KB, 640x480, 1370854419991.png [View same] [iqdb] [saucenao] [google] [report]
35433848

>>35433731
Welcome to /g/.
As long as you don't code in a way that is identical to the way he considers to be "the right way", he will continue to insist that you "can't code".

Don't mind him OP. Your code looks fine, and at least I thinks you code looks very clean and readable.

Also I'm curious, are you currently developing a game, and if so which one?

>> No.35433896

>>35433675
Libraries that come with project files tend to still use 2010. I have 2010 installed, but I use its compiler from 2012 whenever needed. 2008 is finally starting to fade out.

>> No.35433955

>>35433848
That *was* OP you replied to genius

>> No.35433956

>>35433474
C# is a much better language in many regards. But C++ is more powerful, especially if low level memory management and optimizations are concerned. Plus since it produces native code, and doesn't need a virtual machine, the same program in C++ and C# will be at least a bit faster on the C++ version.

But that doesn't need to make up your mind. Most games don't need C++. Especially desktop games. Current computers are really (as in REALLY) fast. It really takes a very complex game or a very heavy graphical scene to make you consider changing C# for C++ (not counting that you can do a bad job in C++ and make even a simple scene pretty heavy on the cpu)

If mobile games are concerned, then C++ may be the only choice for a bigger game, but again that's not necessarily so.

>> No.35433967

>>35433675
Visual Studio 2012 express is okay, but very crippled because Microsoft wants you to spend thousands of dollars on their "Pro" and "Ultimate" versions.

Personally I'd recommend you download Visual Studio 2012 Ultimate, and install it using the serial key found at piratebay.

>> No.35434010

>>35433848
I'm cant share what I'm working on my job. It's a tactical game, similar to Final Fantasy, but that's all I can say.

I'm also creating a small tic-tac-toe variant (ultimate tic-tac-toe : http://mathwithbaddrawings.com/2013/06/16/ultimate-tic-tac-toe/ ) in clojure for Android, as a personal project.

>> No.35434028
File: 998 KB, 500x281, e1ef9954ccbed3e51a7b0832e5e808b9.gif [View same] [iqdb] [saucenao] [google] [report]
35434028

>>35433955
Thank you, Captain Obvious.

>> No.35434094

Whats the difference between a developer and a programmer

>> No.35434109

what's a good IDE to code C++ besides VS

>> No.35434120

>>35434094
A programmer is a person who knows programming.
A developer is a programmer that's currently working on something.

>> No.35434128

>>35434094
The developer works on the creation of the software. A game designer is a game developer. A game programmer is a game developer.

A programmer writes/designs/debugs code.

A programmer is a type of developer

>> No.35434161

>>35434109
Personal preference.

Code::Blocks
Eclipse
Netbeans
Qt Creator

Test them all and pick the one you like the most.

>> No.35434203

>>35434109
As I said before: Qt Creator is pretty decent. It's definitely my number two.

Many people would also add Code::Blocks here, but I don't like it that much. It doesn't give you anything nice as an environment apart from the basic must-have features > a project tree, a project settings editor and a window to write syntax highlighted code.

Some people might also say Eclipse, but they're just crazy.

>> No.35434221

>>35434203
>Some people might also say Eclipse, but they're just crazy.
why ._.

>> No.35434255

OP, how do you handle #includes in large projects? Is there a sensible way to do this?

>> No.35434262

>>35434203
To be fair, Eclipse does have some good C++ debugging tools.

>> No.35434265

>>35434221
Eclipse is shit

>> No.35434310

>>35434265
Don't be one of those shitposting kids. Please elaborate.

>> No.35434320

Also, do you have a favourite build system, or just use what the IDE has?

>> No.35434322

>>35434221
Syntax highlighting when you're hiking across the Kalahari desert on a MIPS powered Lemote with satellite interbutts remotely logged in to a session on a server in Finland?

There's a plugin for that.


Vibrate your dragon dildo every time your project fails to compile?

There's a plugin for that.


Crash Eclipse every time you try to add a plugin?

You better believe there's a plugin for that.

>> No.35434323

What is the best package for solving a linear system or inverting a matrix?

>> No.35434324
File: 1.76 MB, 408x225, oh yeah (2).gif [View same] [iqdb] [saucenao] [google] [report]
35434324

>>35433956

>> No.35434330

>>35434221
Well... it WAS an overstatement, but Eclipse is pretty useless without a subset of some of its thousands of plug-ins. Finding an appropriate subset is too much work.

There are really too many of them. Many don't get updated, many don't work with others and you get strange crashes, many eat up your memory like crazy. And after a while it starts loading for literally tens of seconds and even minutes.

As a whole using Eclipse is much more a hassle than a convenience.

But again... I was joking before, It's not THAT bad. I just think that QtCreator gives you so much, while being fast, responsive, and good looking that I've even stopped thinking about Eclipse.

>> No.35434336

>>35434310
Java, slow even on a modern machine, bloated UI.

>> No.35434355

>>35434324
whats her name again

>> No.35434361

>>35434324
Which statement don't you like?

>> No.35434371

>>35434355
Cheryl Bong

>> No.35434386

>>35434361
just pick one at random

>> No.35434392

>>35434330
i see. thanks for the info

>> No.35434407

>>35434323
For C++: Eigen

Although I'd probably use Mathematica if I just needed a concrete system solved or a concrete matrix inverted.

We don't use Eigen at our job though, but that's because we only use 4x4 and 3x3 matrices and rarely if ever have to solve linear systems in our code.

>> No.35434466

>>35434386
C# is a much better language.

It's more readable. It has more powerfule templates. It has more poweful high-level language features. It's harder to "shoot yourself in the foot". It produces better compile time errors.

It can be a bit (or even a lot) slower than a C++ equivalent, but that's rarely relevant these days: as I said except for some very specific heavy duty cases

>> No.35434506

>>35433956
>C# is a much better language in many regards.
>>>/msn.com/

>> No.35434521

>>35434466
>more readable

Nigga please.

>> No.35434523

>>35434506
http://www.mono-project.com

>> No.35434551

>>35432314
>be coding java
>realize everybody fucking hates java and java programmers
>decide to learn c++
>undefined reference error
How do I fix it

>> No.35434562

>>35434361
Not the one you're responding to, however you're entire statement results around one thing:
"We have good computers so it's okay to use a slower language because we really didn't need all that speed anyways"

That kind of "my laziness > application performance" thinking is the reason why Minecraft is so completely shit-slow even when played on a computer from next year. And it should not be encouraged, ever.

Yes, you should use a language that's suitable for the project at hand.
However, when the decision lies between being lazy and using [Insert high-level language here] or spending a little more work in order to code it in C/C++ for the sake of making a better, more responsive, less resource-demanding application, you should always pick the one that results in a better application.

>> No.35434578

>>35434551
Well you've referred to some symbol in your code that's missing. It written right there in the error message which symbol it is.

>> No.35434579

>>35434562
beautifully said

>> No.35434594

>>35434551
Stop making references to undefined data.

>> No.35434621

>>35432314
Sublime

>> No.35434629

>>35434551
maybe post the code in question, genius?

>> No.35434644

>>35434578
Yeah, I sohuld have been more precise
I am using netbeans IDE,(i'm familiar with it), using MinGW compiler, and trying to get glfw to work. I put all the stuff in the lib folder into the MinGW lib folder, and did the same for the include folder. In project properties, I have all the libraries and pathfiles set up, and linking. There is no error when typing the code, just at compile-time, when it says the undefine reference error mentioned before.

>> No.35434656

>>35434562
That depends. Minecraft has use cases that ARE heavy duty. However if you create a tetris/sokoban/loderunner clone and use C++ instead of a "lazy" language you're just dumb. You should choose the one that will let you write it faster and with less bugs. It may be C++ if you only know C++, but if you know Python it's just as good a choice.

It's all about use-cases. And yes, I do use ruby for small programs that run for hundreds of milliseconds instead of less than a millisecond, but considering that I write them in 5 minutes instead of 15 minutes it's a pretty good tradeoff

>> No.35434674

>>35434644
The undefined reference is a linking error (not a compilation error). Which symbol is it for?

>> No.35434686

>>35434644
>I am using netbeans IDE
>using MinGW compiler
>and trying to get glfw to work.
Stop. Stop. Stop.

>> No.35434704
File: 20 KB, 800x600, Untitled.png [View same] [iqdb] [saucenao] [google] [report]
35434704

>>35434674
glfwInit();
I am assuming that any function that I call on glfw will not work, though I have not tested this.
I am just getting set up.

>> No.35434705

>>35434562
Your use of the term lazy suggests a very flawed perspective.

Developer time is costly, and spending time programming is not inherently good or virtuous.

There will always be a trade-off between developer time and product quality.

That poster was suggesting that C# allows for better trade-offs in some cases.

You are suggesting that reducing developer time at the expense of application quality is always wrong.

>> No.35434711

>>35434686
haha yep I expected someone to say that. Recommendations?

>> No.35434772

>>35434704
It seems that you're not linking properly to glfw (or somehow this function is missing from its code)

But unfortunately there's not much more I can say.

Bottom line is that you have this function declared, but not defined. If it's defined somewhere in the code you have, then this file is somehow not being linked with the executable

>> No.35434783

>>35434711
Since you're using Windows, why not use Visual Studio Express. It's free.

>> No.35434798

>>35434772
well thank you for responding it is definitely a link error.

>> No.35434814

>>35434783
sure

>> No.35434823

>>35434711
No IDEs. Learn the language like a real man and switch to an advanced text editor.
No MingW, gcc or clang.
No glfw, it's the worst way to draw windows with gl graphics, it was made as a proof of concept. Look into SDL.

Stop. Coding. On Windows!

>> No.35434830

>>35434711
What extension do these glfw library files have?

Are you trying to link MSVC (Microsoft's compiler) .lib files using G++ (another compiler, bundled with MinGW)?

>> No.35434871

>>35434823
Sure. Sure, I can do that. Why not just a normal text editor?

Also, why not code on windows?

>> No.35434877

>>35434830
I too thought about that but it can't be it. Mingw would expect .a extensions but since he's listed the library explicitly, the error would be "cannot find libglfw.a" instead of the missing ref

>> No.35434905

>>35434830
the files are of .a,.h,.dll type. I am using g++ bundled with MinGW.
>>35434823
Actually, sin't gcc a C compiler?

>> No.35434926

>>35434877
>>35434830
>>35434783
I can gaurantee that you will all facepalm at me once I figure out is going wrong. (cuz i'm a noob)

>> No.35434947

>>35434871
Bullshit. Do code in Windows if you like. Visual Studio is fine. But really stop with the glfw, but also don't try SDL.

Jsut use SFML for simple graphics.

SDL is fine, but it's not beginner friendly. SFML is.

>> No.35434964

>>35434871
A normal text editor, from my point of view, would be unbearable.

It is WELL worth your time to learn to use emacs or vim. It's important to use the right tool for the right job, you wouldn't hammer nails with a frozen fish, you shouldn't code with a "normal text editor."

Likewise, an IDE is like a nail gun: It's doing all the hard work for you. If you think that's okay, then go for it. I wouldn't use one unless I was made to by an employer.

>>35434905
It has a C++ compiler, g++.

>> No.35434967

>>35434947
Since glfw is getting the hate, I think I'll go SDL. I'm a noob to cpp, not to opengl.

>> No.35435000

>>35434964
>it has a c++ compiler, g++
Oh, ok. I thought they were two separate things.

>> No.35435069

>>35432470
hahaha 8/10
>find dead mutex with printf

>> No.35435099

>>35435000
$ pacman -Qo `which g++`
/usr/bin/g++ is owned by gcc 4.8.1-1


ymmv

>> No.35435109

>>35435069
I've never found a threading problem I couldn't diagnose with a well placed
printf("got here");

>> No.35435116

>>35432413
It really doesn't. You're sadly mistaken.

>> No.35435131

>>35435109
>printf without any format string
Use puts, you fool!

>> No.35435199

>>35434967
Go for SDL 2 if you are using SDL. It's in RC phase, you'll need to compile it yourself, but SDL 1 is outdated.

>> No.35435222

>>35435199
okay

>> No.35435224

>>35435109
imo won't work with a locket mutex in memory. but maybe i'm false ;)

>> No.35435232

>>35434320
>>35434255
>>35432314 care to reply?

>> No.35435260

>>35435224
lol, locked sry

>> No.35435313

>>35434255
>>35434255
>OP, how do you handle #includes in large projects? Is there a sensible way to do this?
Um, what exactly are you afraid of? No header file worth its weight in shit can be included twice because it is wrapped in
#ifndef _headerfile_name_h
#define _headerfile_name_h

/* stuff */

#endif


So just keep track of what has and hasn't been included.

>> No.35435321

>>35435232
I must have missed those.

I use CMake, although I hate it for its awful syntax. I've been reading good things about premake and I am a big lua fan, but I haven't gotten arount to trying it yet.

As for the includes, I'm not sure what you mean. I do use precompiled headers quite a lot. They really speed up the compilation. But still, what do you mean by "handling icludes"?

>> No.35435343

>>35435313
Don't use these... or at least use #pragma once before the retro include guards. All modern compilers support #pragma once and it's quite a bit faster than the preprocessor shit

>> No.35435362

>>35432314
Why the fuck are you checking against EVERY previous prime? Just check until sqrt(n) for fuck sake.

>> No.35435365

>>35435321
You just include all the headers for classes you use?
What about circular dependencies?
Do you put them in a specific order?

>> No.35435421

>>35435343
What in the world are you talking about?

I'm a C programmer, I want my program to be fast, I don't give a shit about compile times. And what does #pragma do, anyway? I feel like it's some annoying new-age crap.

>> No.35435429

>>35435365
I mean, haven't anyone come up with anything better than the header file cruft? The default way of doing this in C++ is a relict of the past and doesn't make much sense compared with the way Java handles classes for example.

>> No.35435454

>>35435224
I mean code like
mutex_lock(&_m);
printf("got here lel");


That way you can tell if your code didn't "make it" to a particular point because it was waiting on a mutex.

>> No.35435460

>>35435365
Er... well a good rule of thumb is to avoid including headers in other headers, unless absolutely necessary (this is mainly true for parents of classes).

Otherwise a forward declaration is usually sufficient.

So I just use lots of forward declarations and have minimal headers including headers.

A circular depdendency is something pretty rare and handled individually. Usually though it's easily resolved by forward declarations.

I try to have an order of more specific at the top, to more general at the bottom to easily spot unwanted dependencies

>> No.35435475

>>35435421
I'm talking about C++ to a person asking about C++, where compile time does matter.

>> No.35435489

>>35435421
#pragma instructs the compiler to compile your code the javascript instead of object code, and then output a skeleton program that launches a browser window with your code.

It is slightly slower, to be honest, but at least you avoid having to write #define everywhere.

>> No.35435494

>>35435429
Ah yes. That's absolutely right, and that's yet another thing that a modern language should provide. The header files in C++ are just ridiculous

>> No.35435515

>>35433150
That's not possibru anymore.

>> No.35435520

>>35435489
That's the #pragma javascrpitbrowser, but don't forget #pragma nobugs, that removes bugs from your code. I honestly don't know what I would do without it.

>> No.35435575
File: 60 KB, 618x522, 1359581844497.png [View same] [iqdb] [saucenao] [google] [report]
35435575

>clipboard2.jpg
>50 lines
>isprime()
>I'm C++ "programmer" guise

>> No.35435588

>>35435460
Ah yes, that's what do as well. I was just wondering if anyone came up with some smarter solution.
The problem with forward declarations is that you can't use them with aggregated objects (I ran into this a few times).
And writing
class A;
class B {
A *something;
};

feels weird

>> No.35435607

>>35432314
what's programming like in the field? I'm soon to seek a job in programming likely with java and I'm curious what to expect?

>> No.35435623

>>35435575
What would you prefer? Clipboard1.bmp?

Yes it's a screenshot from a small program.

Do you have a better name suggestion for a function that checks is a number is prime?

Well, yes I am.

>> No.35435670

>>35435588
Unfortunately nothing better exists, unless you change the language. C++ is full of relics from the past, and indeed that's one of the worse ones.

Precompiled headers might work for you, but if you change the code they include very often, they'll cause more harm than good.

>> No.35435693

>>35435623
>Clipboard1.bmp?
PNG. Screenshots are saved as PNG.

>> No.35435697

>>35435607
Not sure what you're asking here.

Since you'll probably start as a junior programmer, you'll have an introduction, then be given some simple tasks, you'll be supervised... regular stuff.

>> No.35435709

>>35432314
>function name starts with capital letter

>> No.35435768

>>35435693
Meh... .jpg was irfanview last saved setting to save a file. Why should I have bothered to switch it to png? To save a couple of kilobytes?

Pay attention to details where it matters

>> No.35435791

>>35435475
Compile time is massively less important than run time.
>>35435489
That sounds disgustingly horrible. If it's actually slower, then how do you figure there is any benefit at all?
>I just don't want to use the CPP
That's retarded.

>> No.35435795

>>35435709
> omg! somebody's using a convention that i happen not to use

And that's bad because?...

>> No.35435818

>>35435795
some men just want to see the world burn

>> No.35435823

>>35435791
And since there are things that influence the compilation time, and have no connection to the execution time whatsoever we should never use them?

Genius!

>> No.35435847

>>35435795
>I write my variables in EvErYsEcOnDcApCaSe because I'm a special snowflake

>> No.35435850
File: 443 KB, 237x237, 1317858776153.gif [View same] [iqdb] [saucenao] [google] [report]
35435850

>>35435623
>>35435768
Don't mind the trolls, bro.
They're just trying to get a rise out of you because they have nothing else to contribute to the discussion.

>> No.35435853

>>35435791
Why do you even use a compiler? Why not compile by hand. After all that way you'll guarantee that the program has the best execution time possible. It make take you months or years to compile it, but as you said, compile time is massively less important

>> No.35435854

>>35435791
It was a joke, I was making fun of you for thinking that something that like #pragma once could possibly have an effect on run-time performance.

>> No.35435867

>>35435850
Ah I don't mind them. I'm just asking questions in case they're not trolls and just stupid. But they don't bother me :)

>> No.35435905

>>35435847
and that's objectively bad because? :)

>> No.35435928

>>35435854
but how come he wasn't enthralled by #pragma nobugs? :(

>> No.35435954

>>35435905
have you ever developed in a larger team?
have you ever heard of coding conventions and y to use them?

>> No.35435989

>>35435823
Not even close to what I said...
>>35435853
You've heard of assemblers, right? It's not as impossible as you're making it sound, and once upon a time the preformance increases you could get knowing how to think so low lever were definitely worth it.
>>35435854
>>35435928
I still have no god damn clue what #pragma is, but if people seriously use it just because they are opposed to using #define statements to wrap a header file, then I'm appalled.

>> No.35436074

>>35435954
yes.

And have you ever heard that there may be different coding conventions than the one you happen to use and like?

For example see the std-style c_case code in boost, and let say the PascalCase/camelCase combination in a popular engine like Ogre3D, and also the entirely PascalCase code in DirectX.

I'm writing for two different projects with two vastly different coding conventions right now.

If a convention is readable, coherent, and unambiguous it's fine, whether you personally like it of not.

>> No.35436119

>>35435989
#pragma once as an include guard is faster than the #ifdef-style include guards.

While this can be noticeable only in a huge project, the fact that you don't have to think of different #defines for each file and be careful when copy pasting to #ifdef and #define the SAME thing, makes it a better choice.

It is both fast and less prone to errors. How is it bad?

>> No.35436177

Would you be able to build something similar to Boost.Phoenix?

>> No.35436266

>>35436177
What do you mean build? Boost.Phoenix is an include-only library. It doesn't need to be built.

If you mean to create one. Then yes. I think I can recreate the gist of Boost.Phoenix in a couple of days and probably the entire library in a couple of weeks if I'm allowed to look at the docs, because I don't know it by heart. But what would that show?

If you mean to think of creating it before it was there, then obviously no, since I didn't create it before it was there.

I am working on a pretty cool (at least I think so) C++ library of mine, but since I make it in my free time, and it's not the ONLY thing I make in my free time, it's in a too early stage to talk about.

>> No.35436324

>>35436266
I was talking about the black magic they do to infer types and make everything *work*

Also Proto... just... crazy.

So, the question is, "would you be able to write an equivalent without even reading their implementation?"

>> No.35436396

>>35436119
I guess it's not bad, I just recoil at the sight of idiot-proofing because I was taught long ago that the practice is for idiots.

>> No.35436586

>>35436324
That's a yes. But it will take me between a couple of weeks and a couple of months - full time - depending on what parts of boost I am allowed to use.

And indeed the greatest tricks I've seen in boost are in Proto and Spirit. So much so, that I'd never actually use them (as opposed to phoenix). They're just too unmanageable in terms of debugging or even reading and tweaking my own code with them.

And as much as they are great experiments of what can be done with C++ metaprogramming, they're also a prime example of what's bad with it. See how unreadable and undebuggable their code is. A good metaprogramming language would have none of that.

>> No.35436642

>>35436586
That's true. However, I think that the problem is the lack of tools for debugging and profiling metaprograms, not the language itself.

>> No.35436664

>>35436396
So if you make a tiny slip and miss something you're an idiot?

Come on!

It won't help you avoid bugs, it won't even save you more than a couple of minutes on a bad day. It's just more convinient.

>> No.35436754

>>35436642
Oh come on...

Consider this:
template<class T>
typename std::enable_if<std::is_floating_point<T>::value, T>::type
foo1(T t)
{
}


compared to the hypothetical but similar to hakell or rust:

template <FloatingPoint T> // typeclass FloatingPoint
T foo(T t)
{
}


Which one has a better syntax? :)

>> No.35436775

>>35436754
The latter is how concepts will look like. Exactly like that :)

>> No.35436817

>>35432470
toplel

>> No.35436936

>>35436775
Well not EXACTLY like that, but I know. It can also be achieved with something like Boost.Type Erasure (with a slight inconvenience)

It's just an example of how existing languages have better support for metaprogramming. Both rust and haskell also support return type overload resolution which isn't planned for C++. Anyway here's another example:

// returning something unknown... it will be determined at compile time
// and used with return type overload resolution
template <typename T>
T hash_table::on_nomethod(const char* methodName, ...args)
// on_nomethod is a keyword.
// this is called at compile time in cases of youclasses.undefined_method
{
return getValueForKey(methodName);
}

...

some_hash_table.name(); // suddenly an alias for some_hash_table["name"];


This exists in Boo and Nimrod.

There are thousands of examples of great metaprogramming features that don't exist, aren't planned and, sometime just cannot exists in C++.

It's just too retro. A modern metaprogramming driven language needs to emerge (possibly one like Nimrod) and make C++ more or less obsolete.

>> No.35436997

>>35436936
I really miss overloading on return types (yes, I know haskell), but I guess that something could be done with conversion operators.

I agree that the comittee is going nuts with all the stuff they are adding though (still no type-checking for uninstantiated constrained templates)

>> No.35437105

>>35436997
Check out Nimrod too. It's probably the closest there is (in terms of design and percent complete) to a C++ killer.

I'm not a great fan of its syntax overall, but it's much much more powerful than C++ in achieving middleware that is both readable, debuggable and provides ease of use with no performance sacrifices for the user.

C++ can arguably only provide the last of these at the cost of having awful and bloated code in the middleware itself, horrendeous compile time errors, and very slow compilation.

>> No.35437218

OP here
I'll be off to sleep.

Thanks for the chat y'all and good night

>> No.35437457

well that was fucking boring

>>
Name (leave empty)
Comment (leave empty)
Name
E-mail
Subject
Comment
Password [?]Password used for file deletion.
Captcha
Action