[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 61 KB, 400x400, wrapping_paper-binary.jpg [View same] [iqdb] [saucenao] [google]
2514173 No.2514173 [Reply] [Original]

Mathfag here. I'm leaning toward applied, so I feel like I should know more programming. If I was living in the Matrix I would download the following to my brain. Since I can't do that, which one one should I take up for independent study?

R, C++, Matlab, Mathematica, Python

Also, did a moderate amount of VBA in a previous job so I can skip the basic flowchart command business.

>> No.2514189

I remember everybody loved Mathematica but my University only had few licenses so people cursed and hat to settle for Matlab for most of the time.

>> No.2514188

>>2514173
just learn C

>> No.2514194

If you're a mathfag I'd imagine mathematica would be the most useful for you, followed by matlab. Python's a good beginner langauge, C++ is versatile but more complex than Python.

>> No.2514193

>>2514173 C++

I've never met a mathfag with experience in C++. Matlab was essentially created so people with a math background wouldn't need to learn much new to be able to program.

>> No.2514200

learn R so that all the quants will think you're cool

>> No.2514216

If you're a mathfag, look into F#. You can download F# as part of the free version of visual studio. There are some cool intro vidias floating around for F#.

>> No.2514217

>>2514216
are you indian or chinese?

>> No.2514229

>>2514217
no. but I occasional eat their food. Maybe that's what you're smelling.

>> No.2514236

C and C++ are both overkill for programming some math equations. In fact you'd probably be better off with a functional language like Lisp or StandardML. In SML calculating a fibonacci sequence looks something like:

fun fib 0 = 0
| fib 1 = 1
| fib n = fib(n-1) + fib(n-2);

I personally don't like Lisp because goddamn parentheses everywhere...

>> No.2514248

R is quite nice. It has the bonus of being a functional language (largely based on Scheme), so if you want to be awesome and learn LISP later (and everyone eventually wants to), it will be easier. It's pretty much as good as Matlab or Mathematica (for everything you'll want to do), plus it's free.

C++ is okay if you want to learn the theory behind how computers work, but in practical terms, development with it is really slow.

>> No.2514261
File: 4 KB, 300x57, captcha wareqK sequence.jpg [View same] [iqdb] [saucenao] [google]
2514261

Or Haskell... I know a couple guys who do glacier modelling who absolutely love it. It's functional like LISP, R, and so on, but it's got some features that make it nicely suited to math programming.

> yes, captcha, I'll get right on calculating those war equilibrium constants

>> No.2514273

Start learning C and Matlab. In California all numerical analysis anf linear programming courses are taught with Matlab. Engineering controls/linear systems also use Matlab. Try to take some courses in another area you enjoy. Plus Matlab is interactive and visual so it is funner to code in. Here is some free stuff to get you started,

http://www.mathworks.com/moler/

>> No.2514275

>>2514261
The only winning move is not to play.

>> No.2514277

C. Plain C.

or Fortran

This is what you write with if you wish to write simulations.

and you better know your code optimization techniques.

it's a fun branch -- simulation writing. because it's both hardcore programming and hardcore science.

>> No.2514281

>>2514277
Why in the world would you learn plain C? C++ encapsulates it, and adds objects, which are pretty essential if you want to build anything of real complexity. What's the advantage of using a crippled language?

>> No.2514283

>>2514261
F# takes all the best things from those functional languages, and makes it OO as well, and gives it a nice IDE.

>> No.2514291

>>2514281
> C++ encapsulates it,
keep telling yourself that. Were you waiting for that? Or maybe you have an argument ready for "C is faster than C++". Go ahead and reply with those if it makes you feel better.

but more seriously. I never had to use anything from C++ that wasn't in C. So why bother? I'm an old man and I'm stubborn.

>> No.2514295

>>2514281
also OOP and fast code needed for simulations don't mix.

>> No.2514309

OP again. I appreciate that you guys know more than me, but anything not on the list gets disregarded because it's hasn't come up enough in conversations with people whose position I like to emulate.

Also, using programmer vocab to describe why a language is more useful than other isn't helpful.

>>2514193
Enlightening

>>2514295
Not so much

Thanks, but just saying...

>> No.2514316

>>2514291
We already had this debate with C versus Assembly 20 years ago.

>> No.2514318

>>2514295
>also OOP and fast code needed for simulations don't mix.
That's not true at all, and OOP is essential to a lot of types of simulations.

C is good if you're using it for a shortcut to writing assembly, especially for embedded systems, where you want to strip down the size of everything.

C++ is good for any kind of large program or complicated design that will be aided by OOP

>> No.2514324

>>2514316
ok you got me there. Yes, I pick C because it's more portable than Assembly, and I suppose the same argument can be made for picking C++ over C... at least if you replace "portability" with "maintainability", I think. Anyway, I guess I just choose to draw the line at C as a personal preference.

>> No.2514338

> he thinks C is crippled
> he thinks you need objects for complex programs

could the people who barely passed a 1000 level CS course kindly shut the fuck up

to the op, applied mathfag here. matlab, python or a function language are great for quick and dirty work or relatively small problems. if you want to get into the heavy lifting, it's time to learn C and MPI. might as well learn openMP too.

>> No.2514342

http://mschnlnine.vo.llnwd.net/d1/pdc08/WMV/TL11.wmv

Here's the video that sold me on F# and functional programming for math. And the guy has a cool Italian accent.

>> No.2514350

>>2514277
Lets be realistic here. There's no reason why a mathfag should invest countless hours learning how to write highly optimized C code, that's what professional programmers are for.

If I were OP I'd focus on Mathematica or Python so I could do relatively small things on my own, and just go to the CS department at the uni or hire someone if I needed a full scale simulation done up.

>> No.2514352

>>2514350
i'm a professor in applied math, and I routinely write simulations in C. Now, not all researchers do this, but I do.

>> No.2514357

>>2514173
What the fuck is R? I'm a professional coder, and even I haven't heard of that, like, ever. Some embedded thing perhaps?

To be an excellent coder, learn C or C++ as your first language. At some point learn a functional language like Haskell. Throw in some lisp if you're feeling adventurous. Then code using whatever language best fits the bill, which includes /business/ concerns such as "What languages are the team comfortable with using and proficient using?"

>> No.2514358

>>2514357
It's like matlab but more for stats.

>> No.2514359

>>2514350
and more to the point about having someone else write the simulations for me.
1. a lot of my best optimizations came about because I knew the math to reduce the complexity of the algorithm.
2. you need to pay people in a professional academic setting. I like to keep my funding around for purchasing big computers
3. It's very hard to find people to collaborate with you if you approach them and say "Hey you have a Ph.D. want to be my code monkey?" If I do they'll probably respond "Don't you do this kind of stuff?"

>> No.2514363

>>2514350

it isn't countless hours... and after you've learned it you're a mathfag who is also a good programmer... why wouldn't you take the time?

>> No.2514365

>>2514338
>>2514318
>>2514295
>>2514291
>>2514277
This discussion is quite silly and has nothing to do with the actual merits of the situation.

Believe me or not when I say I make 100k/yr coding C++ and Java.

C++ contains basically all of C as a subset, so to say that C++ is slower than C requires some very specific definition of "slower". One might argue that idiomatic C++ is slower than idiomatic C. If both hypothetical coders are well proficient and aiming for speed, then I highly doubt it.

C++ is not /just/ an OOP language. It's also procedural, (shitty) functional, and OOP. It's a multi-paradigm language.

Also, most of the constructs of C++ don't impose overhead over their equivalent C constructs. If you have an OOP design in C++, you can write it in C with explicit function pointers. It's a lot less pretty, but the same assembly will result. If you don't need runtime polymorphism, and you need speed, then maybe you shouldn't be using dynamic dispatch in C /or C++/.

>> No.2514373

>>2514365
shut up, faggot

>> No.2514399

>>2514365
>namefag
>always bragging about his salary on 4chan
Fuck off loser. I'm a programmer too, and make the same, but I don't feel the need broadcast it constantly to give myself credibility.

>> No.2514406

>>2514399
It's 4chan. I get to let off steam and have fun. Deal with it.

>> No.2514427
File: 27 KB, 443x547, mylittlepony.jpg [View same] [iqdb] [saucenao] [google]
2514427

>>2514406
NO I WILL NOT DEAL WITH IT. I MAD BRO.

I MAD

PIC RELATED

>> No.2514429

>>2514365

as i don't need anything that C++ provides over C (and i don't try to shittily imitate it), i maintain the argument that C is not crippled and that you can make complex programs without objects

my world is made up of tight loops running on hundreds of processors... C is perfect for me

>> No.2514433
File: 10 KB, 241x209, images..jpg [View same] [iqdb] [saucenao] [google]
2514433

>>2514427
whoops. wrong pic.

still mad tho

>> No.2514443

>>2514429
Reasonable position to hold.

I like my syntactic sugar of member function, virtual functions, function overloading, destructors (Oh how I love destructors), and so on, and I can and do write just as tight loops as you do.

>> No.2514446

>>2514427
>>2514433
lold

>> No.2514458

>>2514429
>you can make complex programs without objects
Obviously you can. That doesn't imply that you should.

>> No.2514468

>>2514443

cause i said C is better at loops than C++ -.-

>> No.2514472

>>2514468
I never implied anything like that. I was just being clear and verbose.

>> No.2514485

>>2514472

feels like we agree but are still arguing for some shit reason

and where are all the zomgassembly or death fucks

>> No.2514488

>>2514295
Ha ha what? Have you ever actually timed your C++ code? Because it runs *exactly* as fast as equivalently coded C.

>>2514338
Um, professional scientific programmer here. Take your first year comp sci and stuff it. I've wasted too many hours pulling apart spaghetti code C and Fortran to even tell you. OO programming is a fucking godsend.

>> No.2514493

>>2514485
Stop trying to be amicle with me. I still think C++ is superior to C and that I could outcode you in any task.

>> No.2514492

>>2514485
I think I was refuting some of your claims that idiomatic C++ must be slower because of virtual functions.

That's like saying "C with the function make_me_slower()" is slower than standard C. It just doesn't make any sense under the usual understanding.

>> No.2514495

>>2514493
Oh the joys of no trips. Believe what I say for its merit, not based on who I am.

>> No.2514496

I'd think the main benefit of C++ over C comes when you have multiple persons writing the code or when your code gets large.

Often the runtime performance is not very critical and most of the time it is possible to write fast code even in Java although some things are harder, than they should be.

>> No.2514502

>>2514496
Java is a fine language. C++ is a fine language. C is a fine language. They all have their uses.

>> No.2514507

>>2514496
>Often the runtime performance is not very critical

i hate you.

>> No.2514515

>>2514507
It's often not. Have you ever written a shell script, ever? Why didn't you write that in C and compile with the best optimization settings?

However, sometimes the performance is important when they thought it wouldn't be, and then I hate them too.

>> No.2514516

>>2514492

i never claimed C was faster than C++

>>2514495
>>2514493

go fuck your mother then, i've got no clue who you are

>> No.2514521

>>2514488 it runs *exactly* as fast as equivalently coded C.
Bullshit. It run at least 5% slower on average, and takes up around 30% more space. Look at the assembly. Compilers throws JMP all over the fucking place because they can't organise all the private class data into a single piece of code as well as a programmer can do it manually in C.

>> No.2514524

learn R it does everything you'll ever need. and its free

>> No.2514527
File: 287 KB, 1280x1024, my little pony.png [View same] [iqdb] [saucenao] [google]
2514527

>>2514515
I HATE YOU!!!!!!!

>> No.2514534
File: 12 KB, 251x251, i_mad.jpg [View same] [iqdb] [saucenao] [google]
2514534

>>2514527
GOD DAMN IT!!

>> No.2514538

>>2514521
>Compilers throws JMP all over the fucking place because they can't organise all the private class data into a single piece of code as well as a programmer can do it manually in C.
Any of that "could do manually in C" they could also do in C++.

As to whether your idiomatic usage of C++ results in slower code than C, I highly doubt either of us are in possession of reliable evidence on that point.

As to your last point about program size, I grant you that C++ programs tend to be measurably larger than the corresponding C programs. That's the one downside of exception support. It's not an issue with virtual memory, and can even make the program run faster when the compiler properly implements exceptions as modern gcc does on linux, but it takes extra memory (which again isn't a problem with virtual memory, but can be on embedded systems and the like).

>> No.2514544

>>2514538
>>2514538
> virtual memory

Ok. I lost my respect for you.

>> No.2514551

>>2514544
What? I've been open and honest with my assessments.

Do you have a problem with virtual memory? I presume you have no problem with virtual memory systems as an implementation technique to achieve fault isolation between processes. The MMU is a very crucial element to modern operating system stability and security.

>> No.2514558

>>2514538 Any of that "could do manually in C" they could also do in C++.

What's the point of using C++ if you're not going to OOP? Also even if you were to write all of your own code C style there's still the standard libraries.

>> No.2514567

>>2514544
To continue, my argument is that the exception handlers, if never run, on a system with virtual memory, the exception handler code will never be loaded into main memory and thus carries no cost at all except the commit charge (which can be trivially countered by increasing the swap partition / page file size), and a bigger footprint on disk. It's a tradeoff speed and code sanity and virtual - not resident - memory size. That seems to have no particularly right answer - it would depend on context.

>> No.2514570

>>2514558
Why are you even giving out programming advice? You didn't even know you could do multiple initializations in a C for loop.

>> No.2514571

Link might be of interest for this thread - http://shootout.alioth.debian.org/u32q/which-programming-languages-are-fastest.php

Programming languages shootout.

>> No.2514574

>>2514558
Desctructors my friend. Destructors. (Well, templates are pretty cool too. And function overloading. And a couple other pieces of syntactic sugar.)

>> No.2514579

>>2514538 Any of that "could do manually in C" they could also do in C++.

That's just stupid. Within C or C++ you can embed assembly code. That doesn't make C and C++ as efficient as assembly.

>> No.2514582

>>2514579
But unlike C to assembly, C /includes/ all of C++. Basically every valid C program is also a valid C++ program. (At least, after you fix up a couple minor issues, like void pointer implicit conversions, sizeof('a'), and stuff like that.)

The C standard doesn't define any particular assembly.

>> No.2514586

>>2514582
Err, C++ /includes/ all of C. My bad.

>> No.2514600
File: 63 KB, 817x1264, u_mad.png [View same] [iqdb] [saucenao] [google]
2514600

The fucktarded C++ fucknuggets seriously need to SHUT THE FUCK UP.

Or create a thread on /prog/ about how C++ supersedes C and makes it obsolete.
Seriously, you have NO fucking idea what you're talking about.

And do you really think the linux kernel could've been written in C if it weren't object oriented?
Seriously? The amount of retardation required to believe something so overloaded with obvious fucktardedness is mindboggling, but you somehow managed to pull it off.
Yes of course, the entire linux kernel has NO ABSTRACTION whats-o-ever, it's just one subroutine call after the other, no objects, no inheritance, etc.
>HURF
>HURF TURF

Oh and by the fucking way, comparing C with Assembly? Yes? Really? Is that what you're doing?
Because they're from a CS point of view not the same, one is a high-level language, the other is not. C++ is just another high-level language.
Assembly is not, your comparison shows you no NOTHING of the things you so blatantly vomit neurological feces about in our eyes.

SHUT
THE FUCK
UP


in before >he mad

>> No.2514603

>>2514586
SHUT IT. I'M TAKING YOUR NAME

>> No.2514606

>>2514582
Yes but if you write it in Notepad or something that doesn't say "hi, I'm a C++ compiler" then can't someone looking over your shoulder say "you're writing C code" ?

>> No.2514609
File: 40 KB, 435x480, skeptical.jpg [View same] [iqdb] [saucenao] [google]
2514609

>>2514586
So you think it's accurate to say C and C++ run at the same speed just because you can use C++ to write C?

>> No.2514614

>>2514600
>The fucktarded C++ fucknuggets seriously need to SHUT THE FUCK UP.
>And do you really think the linux kernel could've been written in C if it weren't object oriented?
That anon left a long time ago, and made only like 2-3 posts AFAIK.

I /hope/ that that's not directed at me, because I agree with what you say, and I've said that else-thread.

>> No.2514615

>>2514600
>your comparison shows you *know NOTHING

>> No.2514620

>>2514609
As I said else-thread, it depends on your definition of slower. Is idiomatic C++ slower than idiomatic C? I doubt either of us know sufficiently good evidence to make such a claim. They're sufficiently similar that I doubt it.

You can write slow C code, and you can write slow C++ code. There's nothing about idiomatic C++ which makes it slower than its equivalent idiomatic C for a large majority of cases IMHO, precisely because that C++ code is likely transformable by the compiler into the corresponding C code.

>> No.2514627

>>2514603
My secret evil goal is for everyone to post under Scientist, and that becomes the new Anonymous of /sci/.

>> No.2514632

Uh, hey, everybody! I'm a stupid moron with an ugly face and big butt and my butt smells and I like to kiss my own butt

>> No.2514636

>>2514620
>There's nothing about idiomatic C++ which makes it slower than its equivalent idiomatic C for a large majority of cases IMHO, precisely because that C++ code is likely transformable by the compiler into the corresponding C code.
Correction: Except for exceptions, as detailed else-thread. They don't map one to one to C code at all. They have different performance characteristics, which are sometimes good, and sometimes bad.

>> No.2514638

languages don't have any inherent "execution speed"

yeah that's right, I said it

>> No.2514640

>>2514638
And you would be correct. We have to look at the standard and or average implementation to make such comparisons.

>> No.2514651

>>2514638
Well, I take that back. We could talk about O(1) in terms of one of its operations, and in which case we could say that practically every commonly used programming language is faster than a turing machine, or brainfuck.

Sorry. It's pedantic, but I'm anal, so I brought it up.

>> No.2514660

arguing speed between C and C++ is retarded. either use a better algorithm, or the problem is so large that language has no real impact.

>> No.2514680

>>2514606
>Notepad
>"hi, I'm a C++ compiler"
windows code monkey detected.

>> No.2515287

OP you will need to know one regular language of your choice and either Matlab/Maple/Mathematica.

>> No.2515325

http://harmful.cat-v.org/software/c++/I_did_it_for_you_all

>> No.2515355

Anyone seriously contemplating C++ has never read the C++ FQA.

http://yosefk.com/c++fqa/

>> No.2515376

>>2514248
> C++ is ok if you want to learn the theory behind how computers work
This is what C++ programmers actually believe!

>> No.2515386

>>2515376
should be amended to:
>C++ is ok if you want to get some kind of idea how computers kinda work

>> No.2515395

I'd say just learn Matlab OP, if you refuse to buy/pirate go R

For programming language, start with Java/C#, work your to lower level if you really need performance (chances are a better algo design would beat your micro-optimizations)

>> No.2515420

Go for LISP to learn programming, go for C++ to learn software engineering

>> No.2515544

>>2515420
> go to lisp to learn programming
I agree. So, R.
> go to C++ to learn software engineering
Um... Java, maybe. C++ has so many gotchas and edge cases that it should be the last language anyone learns. One should be fully versed in different programming languages and styles before attempting to write C++ code. One benefit of this is that, 99% of the time, when needing to start a project you'll find that, surprise!, you don't need C++ at all.