Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
quiggy
Aug 7, 2010

[in Russian] Oof.


Awia posted:

what does Malloc do over malloc? why does it take a type and a random variable and return a pointer?

Malloc is a macro that performs a sizeof on the first element and then returns memory of that size. i dont remember what the random variable does

and no the macro is not parentheses-wrapped

Adbot
ADBOT LOVES YOU

oh no blimp issue
Feb 23, 2011

becuase that's so much easier than (int*)malloc(sizeof(int))?

qntm
Jun 17, 2009

BattleMaster posted:

lol ugh i'm glad that "programming needs to be hard" is an attitude that has largely died off

it's sort of coming back, significantly lowered barriers to entry are the root cause of the whole leftpad debacle

HoboMan
Nov 4, 2010

The root cause of the leftpad debacle is anyone thinking javascript is a viable language

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Awia posted:

what does Malloc do over malloc? why does it take a type and a random variable and return a pointer?

it's probably

code:
#define Malloc(type, count) calloc(sizeof(type), count)

because they'd didn't want to type out the sizeof

or it might be

code:
#define Malloc(type, count) malloc(sizeof(type) * count)

to avoid calloc's zeroing of the returned bytes "for performance"

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

qntm posted:

it's sort of coming back, significantly lowered barriers to entry are the root cause of the whole leftpad debacle

yeah

it's not so much "programming needs to be hard" as "programming well is hard" and significantly lowered barriers to entry result in more lovely programming

that was the main problem with BASIC back in the day, then with Visual BASIC, and now with JavaScript

about the only decent software I ever used on the Apple II that was written in BASIC were EAMON text adventures, everything decent was written in Pascal or directly in assembly, or cross-compiled in a more exotic way (such as Infocom's text adventures, which were written in a Lisp-based DSL on their PDP-10, and cross-compiled for their virtual machine to run on all the different personal computers)

in a way I'm glad Apple never got to release Don Denman's MacBasic, it would have been like when Visual BASIC was released but half a decade earlier, and so many people would have probably turned out lovely software it could have hurt the overall market perception of the Mac

Bloody
Mar 3, 2013

qntm posted:

it's sort of coming back, significantly lowered barriers to entry are the root cause of the whole leftpad debacle

the root cause of leftpad is the overpopularization of a language with no stdlib

HoboMan
Nov 4, 2010

question: how do i learn to be less terrible? is the only option to somehow apprentice with a legit good code shaman?

i am a programmer simply because i'm the only one who raised their hand when we were asked if anyone knows what an ide is. i feel i am missing important information needed to do a good job.

oh no blimp issue
Feb 23, 2011

HoboMan posted:

question: how do i learn to be less terrible? is the only option to somehow apprentice with a legit good code shaman?

i am a programmer simply because i'm the only one who raised their hand when we were asked if anyone knows what an ide is. i feel i am missing important information needed to do a good job.

read a book

Notorious b.s.d.
Jan 25, 2003

by Reene

ok so how do i know that all these weird pirate tools aren't going to send my credit card numbers to st petersburg or something?

Bloody
Mar 3, 2013

HoboMan posted:

question: how do i learn to be less terrible? is the only option to somehow apprentice with a legit good code shaman?

i am a programmer simply because i'm the only one who raised their hand when we were asked if anyone knows what an ide is. i feel i am missing important information needed to do a good job.

spend time in this thread

HoboMan
Nov 4, 2010

i mean i can just google poo poo, but i am getting the creeping feeling i have some unknown unknowns here.

oh no blimp issue
Feb 23, 2011

read a book

Bloody
Mar 3, 2013

post itt

PokeJoe
Aug 24, 2004

hail cgatan


HoboMan posted:

i mean i can just google poo poo, but i am getting the creeping feeling i have some unknown unknowns here.

im a poo poo programmer and these books made me improve:

http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882

http://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670

AWWNAW
Dec 30, 2008

this should help too https://www.se.rit.edu/~tabeec/RIT_441/Resources_files/How%20To%20Write%20Unmaintainable%20Code.pdf

Brain Candy
May 18, 2006

Bloody posted:

post itt

the #1 thing is to getting someone to yell at you when you do/say dumb things

oh no blimp issue
Feb 23, 2011

code reviews are an excellent way to stop you being a terrible programmer, or at least to be terrible in the way your colleagues expect you to be
but i don't think that's an option for you?

Illusive Fuck Man
Jul 5, 2004
RIP John McCain feel better xoxo 💋 🙏
Taco Defender

this owns
code:
char *p;
switch (n)
{
case 1:
    p = "one";
    if (0)
case 2:
    p = "two";
    if (0)
case 3:
    p = "three";
    printf("%s", p);
    break;
}

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
that if(0), goddamn

pgroce
Oct 24, 2002

HoboMan posted:

question: how do i learn to be less terrible? is the only option to somehow apprentice with a legit good code shaman?

step 1: write terrible code, watch it cause you pain, figure out why. you will never stop doing this.

step 2: listen to people. read books, blogs, talk to coworkers, whatever. be skeptical, but try out their dogmatic ideas. some of them have some wisdom. many more will cause you pain. (protip: try out new things where it will cause you minimal pain.)

step 3: eventually you will start having your own dogmatic ideas. be skeptical of them, too. your dogmas aren't any better than anyone else's. but it isn't always worse, either. after all, no one's doing exactly what you're doing but you.

basically fail a lot, think hard about why, and apply that thinking to other people's failures and successes. programming is still a craft, and you only improve at a craft by messy practice, by carefully trying out the techniques of others, knowing that they may not work for you, even if they work in other environments.

programming is communication, mostly with other people (including future you), and secondarily with computers. get out there and talk to people, and secondarily computers.

HoboMan
Nov 4, 2010

Awia posted:

read a book

books r 4 nerds nd i neve read a book in my life and it got me very far


i bought that second one once for a class but they didn't use it for giving assignments so i returnded it without even looking at it, lol

lord funk
Feb 16, 2004


:lol: i couldn't breathe by the end of the LISP paragraph

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

yessss i've been looking for this

Clockwerk
Apr 6, 2005



clean code by and code complete 2 ftw

Luigi Thirty
Apr 30, 2006

Emergency confection port.

i'm a 10x programmer

every code review gets kicked back to me 10 times

MeruFM
Jul 27, 2010
code complete 2 is good if you have 300 uninterrupted hours at work to do literally nothing but read it and maybe try a few examples (like if you got put on "special projects" for 6 months)

It's very dogmatic and you should only follow what might work in your situation. It helped me think about programming differently early in my career.

quiggy
Aug 7, 2010

[in Russian] Oof.


i looked up the macro for you nerds

code:
#define Malloc(type,n) (type *)malloc((n)*sizeof(type))
academic code Owns

tef
May 30, 2004

-> some l-system crap ->

Notorious QIG posted:

i looked up the macro for you nerds

code:
#define Malloc(type,n) (type *)malloc((n)*sizeof(type))
academic code Owns

you don't need the type cast :toot:

tef
May 30, 2004

-> some l-system crap ->

qntm posted:

it's sort of coming back, significantly lowered barriers to entry are the root cause of the whole leftpad debacle

it never really went away, it just never stopped or influenced the people trying to make programming more accessible

it's ok i have come to understand that people will write the most unapproachable horrors in whatever language they are given so i feel the argument is moot: we can make programming languages more accessible and the ones opposed can continue to make their projects garbage for for coworkers.


also root causes are for children's stories :toot:

- javascript doesn't have a mature standard library
- even if it did people have to distribute polyfills because of the way of browsers
- people have patched over it and punt on it to npm
- npm allows people to unpublish work,
- people included these polyfils but did not vendor them
- someone unpublished a module which people depended on and broke builds
- people rely on third party tools written by volunteers and would rather complain on hacker news than fix things
- no-one has any good opinions on what to do or change b/c it's easier to argue about how trivial a module was rather than the wider ramifications of builds not being repeatable or deterministic

(toot)

tef
May 30, 2004

-> some l-system crap ->

HoboMan posted:

question: how do i learn to be less terrible? is the only option to somehow apprentice with a legit good code shaman?

- practice
- make less of the mistakes you know
- make new mistakes and learn from them

really being a good programmer is not about doing the right thing but knowing lots of bad things and avoiding them

good ideas tend to be unique to a project but the bad ideas are everywhere

quote:

i am a programmer simply because i'm the only one who raised their hand when we were asked if anyone knows what an ide is. i feel i am missing important information needed to do a good job.

honestly the most important poo poo is nepotism and company politics, after that coding mostly becomes

- code that won't wake you up at night
- code that won't gently caress over your customers
- code that doesn't leak secrets it is meant to keep
- code that doesn't get in the way when you change your mind

but most of what you do in coding depends if you make money for the company or are a cost of money :shrug:

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

HoboMan posted:

i mean i can just google poo poo, but i am getting the creeping feeling i have some unknown unknowns here.

imagine a blinking gif that says "just code"

be interested enough in programming that you sometimes read a book or watch a video

learn from you mistakes. have facepalm moments when looking at code.

make something for yourself, even if it's some dumb thing like a greasemonkey script that alerts you when a thread on sa is ripe for snypin'.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
#justprogrammerthings

ErIog
Jul 11, 2001

:nsacloud:

HoboMan posted:

i mean i can just google poo poo, but i am getting the creeping feeling i have some unknown unknowns here.

It's like lots of other disciplines. You need to do it a lot, review your old stuff honestly, and work to try your hand at different aspects of it in order to gain a real understanding. You only get better through failure and reflection. If you're not failing then you're probably not learning very much, and it's probably better for you to fail more often in your own personal projects than with work projects.

So work your way up from small hobby projects, and keep at it. Eventually you might become a not terrible programmer. all programmers are terrible because programming is terrible

ahmeni
May 1, 2005

It's one continuous form where hardware and software function in perfect unison, creating a new generation of iPhone that's better by any measure.
Grimey Drawer
remember that programming is a discipline and that you should write some loving tests, where are your goddamn tests man

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

Awia posted:

becuase that's so much easier than (int*)malloc(sizeof(int))?

you don't need to cast void *, unless you forgot to #include <stdlib.h> and malloc is implicitly declared as returning int (which is fun fun fun when int is smaller than void *)

Bloody
Mar 3, 2013

ahmeni posted:

remember that programming is a discipline and that you should write some loving tests, where are your goddamn tests man

or at least acknowledge you should write tests then sigh wistfully and get back to implementing new features without fixing old bugs

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal

hackbunny posted:

you don't need to cast void *, unless you forgot to #include <stdlib.h> and malloc is implicitly declared as returning int (which is fun fun fun when int is smaller than void *)

whoa, what? is that standard behaviour or some weird rear end compiler-specific thing?

either way it does sound like a ton of fun indeed

weird
Jun 4, 2012

by zen death robot

YeOldeButchere posted:

whoa, what? is that standard behaviour or some weird rear end compiler-specific thing?

either way it does sound like a ton of fun indeed

if you use an undeclared function, it's implicitly declared to return int, in c89 at least, i think as of c99 it's just an error

Adbot
ADBOT LOVES YOU

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

YeOldeButchere posted:

whoa, what? is that standard behaviour or some weird rear end compiler-specific thing?

either way it does sound like a ton of fun indeed

standard C behavior. if a function isn't declared, it's declared on first use as taking a variable number of arguments and returning int. I wonder if they finally deprecated it. other things you probably didn't know:

C++ code:
/* This function has a fixed amount of arguments, but the argument types are only known to the function
   implementation, so any number and type of arguments can be passed to it */
void poop();

/* This is how the function implementation creates a local-only declaration of argument names and types.
   No, it's not incompatible with the previous declaration */
void poop(turdType, turdLength, velocity)
	int turdType;
	unsigned turdLength;
	// velocity has implicit type int
{
	// ...
}

// This function returns an int
measureTurd(struct turd *);

  • Locked thread