Why don't you write C & C++ /g/?*ptr = (((data->header) & 0xFF00) >> 8); ptr++;
C++ got to be the most complex and obscure language in the world.
>>53861676
>obscure
i need some of what this guy is on
>>53861661
cause it's clearly unreadable, overcomplicated, deprecated and it's being shadowed by go?
>>53861718
>unreadable
It's perfectly readable. I love programming in it.
>>53861661
But I do senpai. I use C all the time.
What do you mean by C++? Oh, you mean Rust right? ;^)
>>53861676
Nope, Rust now beats C++ with that
>>53861661
Modern C++ doesn't use raw pointers anymore m8
in fact they should just not allow you to write raw pointers anymore in C++
>>53861763
Eh, honestly, I use raw pointers a fair amount. I should probably get used to using smart pointers more often.
That snippet is for serializing a structure into an array to be sent, networking m8.
>>53861763
>Modern C++ doesn't use raw pointers anymore m8
Good luck using polymorphism without pointers.
How do I point in python? xDDD
>>53861852
smart pointers
What is the language that sets men and boys apart?
>>53861661
>>kids actually think what was written is obtuse.
>>53862003
Slightly worrying isn't it?
>>53861974
haskell
>>53861974
Brainfuck.
>>53861661
>hard coding an address
>>53861969
>smart pointers
These are structures for those who can't into memory management.
>>53862121
Do you mean 0xFF? It's not, it's the higher order byte.
>>53861718
>unreadable
Any language is "unreadable" if the one that reads it doesn't know the language well.
>all these ppl saying C++ is hard and complicated
/g/ pls
>>53862455
Why do plebbitors post like this? It's sickening.
>>53861752
this. Rust is pure WTF
>>53861661
Because Swift is so much better.
What happened to /g/, since when was C++ hard?
>>53862761
>actually using swift
>>53862764
Everyone competent moved to lain and full a long time ago.
>>53862788
It's literally the best language.
> easy
> fast
> powerful
> open sores
Templates are top stuff.
>>53862764
/g/ only knows programming well enough to write fizzbuzz
>>53862761
Fucking disgusting. Returning the string "Erro" instead of throwing a god-damn exception?
>>53863249
Templates are an ungodly Turing tarpit.
>>53863442
exception is thrown by the motorMatematicoPrincipal function, I just catch it and return the String.
>>53863534
Just let the exception go up the stack, seu bosta.
>>53863671
Literally why? It just works this way.
>>53863697
No it doesn't. The caller doesn't get to decide how go handle the exception.
>>53863721
The catch alone catches any exception thrown by the function.
>>53863721
>>53863757
pic related
>>53863782
people like you should not be allowed to use a computer.
>>53863831
just die.
>>53863782
Shouldn't error handling usually be... well, handled by the caller
if(complicated_function(val, structure, pointer) == false){
//Handle error
}
>>53863930
What?
>>53863782 Is terrible programming.
>>53863944
The way I handle the error is by returning "error" to the calculator display instead of the result, what else did you expect me to do?
>>53863721
The caller needs to know if the function passed because the function you called may not have the information to fix it. Are you stupid?
>>53863960
It's fucking expensive.
Why are you returning a string?
What's wrong with something like this (partial pseudo & C style)int getthingy(string & dest){
if(function(dest){
return false;
}
return true;
}
string mystring;
if(getthingy(mystring)){
//Oh no!, we don't have a result, something broke!
}
Obviously change where appropriate. This is a very basic example of very basic programming.
>>53864025
>>53863973
Correction:
if(getthingy(mystring) == false){
//Oh no!, we don't have a result, something broke!
}
>>53864025
>>53864050
see: >>53863782
the first function tries to solve an equation, it may return Double but if something goes wrong it will throw and exception.
The next function ALWAYS returns a string, if something goes wrong it will catch the exception and make sure to return a string instead of breaking the app.
The String goes directly into the calculator display, it may be a valid result or the message "Error".
>>53863973
>>53864163
I know it's swift, but if you trumpet swift, then at least program well.
Is it really necessary to catch?
If you validate your error and have a error code scheme, it makes your life a fair amount easier.
Return an error code, then operate on that, don't give the responsibility to the function.
>>53864334
>>53864163
Most of all, DON'T return strings as error codes!
Leave that abstraction to the interface.
There is literally no point to having the program operate on a string like that. It's also slow!
Something like.
if(retval = mymathfunction());
if(retval == somerrror){
//Put on screen "Math Error"
}else{
//Put result
}
Or even an error lookup if you're feeling fast.
string error_table(int code){
switch(code){
case MATH_ERROR:
return "Math Error";
break;
}
}
Pretty shit examples, but that's the idea.
>>53864334
official Apple documentation.
>>53864443
>"Clear and expressive"
I.. I..
Am too used to programming in proper languages™? :^)
Does the compiler turn it into something much faster?
Am I missing something?
Do you really need your hand held this much you rely on the runtime to check your shitty programming?do{
//Something that I apparently can't error check like a normal human?
}catch{
//oh god, I can't program pls halp me
}
Jesus.
Well, apple designed it.
>>53864425
see: >>53864443
>>53864443
this makes me want to an hero
remind me why apple is so hip?
>>53864508
>>53864563
I don't get why you're bitching, it just werks and it's fast.
>>53864633
>it just werks and it's fast.
Well, there's your problem.
So to make it easy, we sacrifice actual decent programming?
gg
Python does everything I want it to do (mathfag btw)
>>53864679
how solve 0/0
>>53864659
The Swift team created a whole new programming language, a based compiler, made it open source and you are saying you know more than them?
kek.
> My language does error handling this way
> Ewwwww you language does it differently
>>53861676
Bad style =/= Bad language
>>53864743
I'm fine with the language, but I'm being autistic about the amount of hand holding it carries with it.
>>53864734
that is not defined jackass (in a mathematical context) & if at any point you are diving numbers where the denominator could potentially be zero you should check to make sure it is NOT zero; I wouldn't be surprised if python or a different language gave you some garbage answer if you try to evaluate 0/0
>>53864743
programming language arguments are reserved for freshman CS babies who think C/C++ is the ONLY way to go about doing things
>>53864787
No fucking shit
It's a joke.
Did you not notice that? I asked you to divide nothing by nothing.
>>53861661
Why don't you write in FORTRAN or BASIC anymore?
Same reason
>>53864805
Visual Basic? Aka, Basic & CLR
gj, well memed
>>53864804
sorry I thought you were just being a nostalgic /b/tard. Also how the fuck is that a joke? That's not funny no matter what way you interpret it
>>53864050
>== false
Nigga, are you serious? just use a '!'
>>53864827
>Introduced yourself as a "(mathfag btw)"
>I jokingly ask you to solve 0 / 0
>Sperges
>>53864823
>Visual Basic
>Any year
>>53864839
Sorry about that.
>>53864679
I thought R was better for math stuffs
>>53864851
how is that a joke? dividing by 0 isn't defined and 0/0 isn't defined either... Is the joke supposed to be the
>"le divide by zero and things go wrong XD"
meme or did you have some other interpretation? I seriously don't understand your neckbeard humor.
>>53864898
someone got trolled hard lol
>>53864884
R is also widely used. Some of my professors use mathematica as well
>>53864915
>I was only pretending to be retarded
ok anon I get it now. Have a nice day
>>53864898
¬.¬
>>53861676
I would have agred with that 5hours ago but while I was playing with Rust FFI I stumbled uponenum sad_pepe {
//Ahahah there is nothing there, ahahahah !!!!
}
type THAT_FEEL = *mut sad_pepe;
All that shit so you can#[link(name = "User32")]
extern "system" {
fn meme_up(some_meme : THAT_FEEL)
}
fn main() {
let my_meme = 0 as THAT_FEEL;
unsafe {
meme_up(my_meme)
}
}
And you can't cast shit into other shit without using some shit, C++ is trully easier.
>>53861763
raw pointers are fine.
raw pointers which own what they point to are not.
>>53861763
>>53866434
As such.void func(){
char * ptr = new char[1024];
return; //Oh dear.
}
>>53861661
What's wrong with that?
It makes *ptr equal to the value of the second byte (bits 8-15 as a binary number) in data->header.
Any programming where shit gets real this is basic shit. This is like the first thing you start doing when you use a microcontroller for example.