[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 36
qt programming girls edition

old >>55019779
>>
>>55024124
First for NO TRAPS
>>
File: it's a trap.png (873 KB, 1275x677) Image search: [Google]
it's a trap.png
873 KB, 1275x677
>14 posts early
no
>>
First for Berkeley DB
>>
>>55024135
Reported this transphobic post
>>
>>55024135
wanted to post this
>>
>>55024135
>man face
>name is Isis
It's trap and this thread is fucked...
>>
>>55024184
Call her man faced once more
>>
>>55024124
Post some quality Perl program :
             &p(qw(Ju));$x=
$/;$|=$$;$,=$/;$\=$!;
sub T{eval$_[0]};sub su{T
q%sel%.q +ect *a,*
a,*+.'a, .06';}sub
p{T(q;p;. q 5ri5.q
qntq)for @_}map{p
('u');& su;}(1..
17);sub s{+$_[0]
};&s(&su );$a='rl'
;$\=$x;&s(&p("st"));$\=$!;&s
(&su);sub r($;){+p($_[0]
)};p(q-A-);sub z{$\=$/?$;:
$,;$,=$;;su();map{&s(p('a'));&
s(su);}@_};z((1..7));$,=$x;$\=$,
;$"=$\;$,=$/; $_=q!!;s;;;;
p(q qnoq.q rthe\rr);$\
=$/?$;:$,;$ ,=$;;;;su();
r "P";map{r "e";&s||&su;
}(1..42);$\ =$;;&s(p($a)
);T(T(su())); r $/;r "H";$\
=$/?$;:$,;$/=$,;z(1..12);$,=$\;$\
=$/;$a=~s/(.)l//;p(q tcket.$1
);&s(p($"));$e='Felicien';
#MYFIRSTJAPH
>>
>>55024195
>man face
LMFAO LAD
>>
File: 80125012759.png (5 KB, 353x104) Image search: [Google]
80125012759.png
5 KB, 353x104
>tfw Java doesn't even have unions
>>
>>55024124
First for C is functional
>>
>>55024124
Never met a good programmer that is a woman, sure they can exist, but i have yet to find one that isn't retarded.
>>
how do i close my terminal after my script finishes running?

example:
i have this script
#!/usr/bin/env bash

HELLO="Hello"
WORLD="World"

echo $HELLO $WORLD



how do i do that?
>>
File: himegoto.jpg (53 KB, 640x480) Image search: [Google]
himegoto.jpg
53 KB, 640x480
Anyone ever wrote a code formatting program followning their own coding practices for whatever reason? Just curious

>>55024214
>man face
>>
>>55024272
maybe if you leave your basement every once in a while
>>
>>55024272
I have yet to find any non retarded programmers at all

>omg calculus was so hard when will I ever need this
>>
>>55024273
exit, pkill?
>>
File: out.png (6 KB, 500x300) Image search: [Google]
out.png
6 KB, 500x300
>>
>>55024291
what has leaving my fictional basement to do with meeting non retarded woman programmers? The amount of retarded male programmers is staggering, yet you expect that good woman programmers are so abundant that they can be easily found?

I think you have never met a good female programmer in you life either, and if you think that everyone in your vicinity is a good programmer than there are 2 options, you are extreamly lucky or you are just bad at programming.
>>
File: 33.png (13 KB, 768x420) Image search: [Google]
33.png
13 KB, 768x420
>>55024340
>>
>>55024313
exit would only exit the script itself, not the terminal

>>55024273
you would have to kill the terminal's process, you can pass the terminal's PID to the script and kill that when the script is finished although that isn't very "pretty"... you should probably do something like "script.sh && exit" instead.
>>
>>55024124
>isis
>>
>>55024273
General answer: you can't. No terminal user wants their terminal closed by some program on a whim, especially if their "terminal" is a console-mode terminal or a remote shell, not everybody uses a graphical terminal emulator. (Also what if the graphical terminal is part of the window of an app?)

You can do
kill -9 $(ps -p $$ -o ppid=)
inside a script
But it's ugly, contrived, contrary to all rules and such. It unhygenically kill your shell, assuming you have one running, and the parent process of the script is that shell, and that the window will close when that shell dies. If you don't understand then you're not qualified to close a window from within a script.
>>
>>55024367
man ly
>>
File: silent tripcode.webm (3 MB, 1280x720) Image search: [Google]
silent tripcode.webm
3 MB, 1280x720
>>55024377
>>
>>55024378
i have a script that downloads images from websites. after all images are downloaded i wanted my terminal to close automatically, simple as that
>>
>>55024364
Holy shit everyone, get a load of this guy
>>
>>55024273
>>55024378
Here it is with your shitty example:
#/usr/bin/env bash

echo "hello world!"
echo -n "this program is going to forcibly close your terminal in 3..."
sleep 1
echo -n " 2..."
sleep 1
echo -n " 1..."
sleep 1
echo " bye!"
kill -9 $(ps -p $$ -o ppid=)
>>
>>55024417
>getting loads from guys
No thanks faggot
>>
>>55024397
>>
>>55024416
How are you invoking it exactly?
>>
>>55024416

Do what I said here: >>55024370

use an alias or manually run your_script.sh && exit
>>
>>55024416
Also closing down the terminal is, again, stupid: it is where error messages go by default, so you don't have any indication that something went wrong, at least in some cases.
>>
>>55024431

./download_images <site url here>

>>
>>55024453
From a shell then. So the kill -9 thing will work, but your shell obviously doesn't exactly like it, since it's the equivalent of getting stabbed. But it doesn't matter.
>>
>>55024434
>>>55024416 (You)
>Do what I said here: >>55024370
>use an alias or manually run your_script.sh && exit

i tried using exit but it doesn't work , because i have that script in an alias like

in my .bashrc

alias dw='./download_images "$@" '




so if i tried

alias dw='./download_images "$@" && exit '



it doesn't work
>>
>>55024482
Does the script return an exit code of 0 (no errors)?

If not do alias dw='./download_images "$@"; exit'
>>
>>55024124
>codemonkey
>engineer

I wish people were fucking fined or sent to jail for giving themselves a title they do not fucking own, like people who pretend to be doctors.
>>
>>55024500
>Does the script return an exit code of 0 (no errors)?
no

>If not do alias dw='./download_images "$@"; exit'

this closes the terminal automatically and the script doesn't run
>>
>>55024226
Java doesn't even have real enums, it's a class instead
>>
>>55024124
>#isis
Off with her head
>>
>>55024544
So your script forks itself into the background??? Poaste script
>>
File: 06-11-16-50-53.png (5 KB, 348x321) Image search: [Google]
06-11-16-50-53.png
5 KB, 348x321
>>55024226
>using Java instead of glorious C#
Why?
>>
>>55024576
>So your script forks itself into the background??? Poaste script

can't post sorry. nevermind then
>>
>>55024537
>I'm so special because I have a B.Eng.
Calculus sure was hard eh? :^)
>>
>>55024544
>Does the script return an exit code of 0 (no errors)?
>no

Why not? If the script never returns an exit code of 0 you can use || instead of && but that isn't a good idea.
>>
>>55024482
you need a function not an alias if you want to pass arguments like that.

dw = function() {
/path/to/script/download_images $@ && exit
}
>>
>>55024576
Wait no you both suck at "alias":
$alias echo='echo "$@" && echo lol'
$ echo a

lol a


See what's happening? your script gets called with non argument an therefore does nothing, since alias doesn't set the $@ variable. If you try
$./download_images something.com && exit
it will be different than before. Do that, come back, and if it's a success, it means you can write this as a shell function.
>>
>>55024619
>javascript syntax
bitch please
>>>/wdg/
function dw {
/path/to/script/download_images "$@" && exit
}
>>
>>55024641
I've never written javascript in my life so calm your titties retard
>>
File: 1458548441832.jpg (57 KB, 871x960) Image search: [Google]
1458548441832.jpg
57 KB, 871x960
As a web developer that only knows php, javascript, jquery, html and css, am I missing something? What should be the next step? I am thinking about python DJango or Ruby.
>>
File: topgun_1280.gif (383 KB, 1280x720) Image search: [Google]
topgun_1280.gif
383 KB, 1280x720
>>55024619
well this works! thanks kind stranger

but i did
function dw() {
# code here
}


>>55024628
>>55024616
>>55024595
...
thanks everyone! its working now
>>
>>55024615
Do you like it if people who have been on codeacademy for 5 minutes start calling themselves computer scientists?

The same applies for any earned title or qualification, it's just misused a lot more with "engineer".

>Calculus sure was hard eh? :^)
Yeah, so hard it's a requirement for any decent Eng course. Math isn't your sekrit club anymore.
>>
>>55024661
invert me a binary tree.

Go on, i'll wait
>>
>>55024677
>implying calculus is even real math
it's basically just glorified arithmetic

see you in real analysis bitch
>>
>>55024715
>implying real analysis is even real math
it's basically just glorified math

see you in triple integrals bitch
>>
>>55024677
It wouldn't be much more cringe-worthy than the majority of BS Computer Science folks calling themselves computer scientists desu
>>
>>55024715
>studying things that are completely useless to your career makes you more important

Please tell me more about how your attitude towards education perfectly matches that of the liberal arts?
>>
>>55024746
>real analysis is useless
okay
>>
>tfw developing my language in Rust
Who else /absolute madman/ here?
>>
>>55024762
Why did you ditch Holy C?
>>
>>55024755
>useless to your career

At least people doing liberal arts can actually read.
>>
>>55024771
Why wouldn't I?
>>
>>55024715
>>55024734
See you in complex analysis.
>>
>>55024735
So because qualified dumbshits using a title is bad, we can improve the situation by just letting anyone use it and diluting the name even further?

Great solution, guy. Enjoy the average salary for your career plummet because you don't give a single shit about protecting qualifications and titles.
>>
>>55024797
>problem solving and rigorous thinking, which real analysis teaches, is useless in my career
okay
>>
>>55024828
>I need protectionism to save me from the competition
>>
>>55024124
Who is this semen demon?
>>
>>55024844
real as in R or real as in genuine? I much prefer complex systems
>>
>>55024661
Something (anything) that runs code on a computer.
>>
>>55024860
You fucking socialist. Not letting people who can't into a job get a paper saying they can into it is about saving everyone's time realizing they're impostors. Dummass
>>
>>55024844
>I need to be taught how to think because I can't do it on my own
>Pls hold my hand

>>55024860
It's not about the competition, it's about stopping HR and recruitment from hiring people wholly unqualified for their jobs, and then punishing everyone else for their fucking mistakes.
>>
>>55024880
>free markets and ccompetition is socialism now
>>
>>55024972
You know there are "teach homeless how to code" and "no prior experience required" programs all over the place right? And, to clarify, this doesn't run contrary to free market quite the opposite. But titles delivered by established institutions, just like money, can undergo inflation and lose their value if they get printed too much, their value being the trust people put in them when they recruit their holders. Socialist governments and bad business owners are the ones that cause this kind of situation, and free market tends to squash their merchandise when it gets a chance to. Diplomas having requirements isn't protectionnism, it's just that if they don't, they lose their raison d'être. Forcibly lowering the requirements is something an interventionnist government tends to do more often than not, hence you're a commie.
>>
>>55023402
I think basically due to ownership and borrow semantics the compiler knows when to insert free()'s (or drop() in Rust case).

e.g.:

fn main() {
let v = vec![1,2,3,4,5];
println!("{:?}", v);
//v is now not used anymore, so can be safely free'd
drop(v); //Usually inserted by the compiler
}
>>
>>55024972
The free market is largely responsible for the problem though.

It's fine if a company wants to hire an untrained monkey, but then when they give them the title of "software engineer" that fucker will happily go around thinking they are qualified.

Then they'll apply for other positions at companies that actually give a shit about qualifications, and be upset when they get told they're too fucking stupid for the job.
That's the best case, worst case is that HR doesn't check them out properly, they actually DO get hired, and then the company just assumes that all "software engineers" are just that fucking stupid and lower the pay grade.

>muh regulations are bad
Every time you visit a doctor without fear of them being a pleb with a knife who just wants to cut you open, you have standards and regulations to thank.
>>
i dont get it
theres a huge demand for good build systems (make, cmake, etc) and yet theres like 3 to choose from and they're all pretty bad
>>
>pattern synonyms can be part of type classes, thereby providing a mechanism for overloaded data constructors
I love GHC.

>>55025229
Actually, the problem is that C and C++ are horrible to compile. Sane languages with modules have great build systems.
>>
>>55025229
cmake does a pretty good job to keep your C/C++ mess compiling on different platforms.
>>
>>55023402
It's RAII, same as in C++.
>>
>>55025229
You forgot language specific ones. And they suck even more. But even though we now know how a good build system should behave (isolate jobs, keep coherency, work from the bottom up) there is so much technical debt that, well...
>>
>>55025246
>Actually, the problem is that C and C++ are horrible to compile. Sane languages with modules have great build systems.
? How are compilation units not on par with the rest?
>>
>>55025301
>compilation units
It's was designed in the fucking 60s when RAM was not in abundance and you could only hold a small amount of data in memory at any giventime.
>>
>>55025301
He'd rather compile java into .class files that take 20 times as long to complete, and are slower to execute.

Some people are just into self harm.
>>
>>55025316
>We have more memory now, so we should just let everything bloat and not actually have any performance increase with new technologies

Yeah no.
>>
>>55025301
Modules mean a) no headers and b) your source code describes how to build itself. Build systems with modules only end up being providers of compiler flags, more or less.

>>55025329
>implying I'm talking about fucking Java
>>
>>55025360
Oh, so you want to compare C and C++ to languages that are even slower than java?

Please, continue.
>>
>>55025377
Rust has modules and a good build system. So does Haskell.
>>
>>55025354
>compile once modules = bloat
>having 1500 compilation and linking steps because you refuse to use more than 2k of memory at the time and would rather do 1500 disk accesses = not bloat
>>
File: Capture.png (239 KB, 1299x742) Image search: [Google]
Capture.png
239 KB, 1299x742
I need help senpai I'm writing a simple addition progof 2 integers program in assembly, when I print out the result I get letters instead of the integer value e.g 1+1=b

What am I doing wrong???
>>
>>55025316
And how does that negatively affect the system? (Except for the fact that namespaces aren't coupled with units, or that badly written preprocessor code can leak, we're talking about compiling already proven correct programs) I'd argue programmers in this time and age were wise.

>>55025360
>no headers
Except when it requires them. See https://wiki.haskell.org/Mutually_recursive_modules
I personally find that it's a huge design fail for Haskell. C/C++ NEVER ran into this. Headers are there by default and why not? headers aren't bad, are they?

>your source code describes how to build itself
Mostly. You still have to add a list of dependencies in Cabal and Gem and whatever, but agreed, linking a C program requires a bit more work. Plan 9 had an interesting solution for this, meaning that if you've found the headers of a library, you don't need to search a second time to find the object files, their location is derived from the header's code. (http://doc.cat-v.org/plan_9/programming/c_programming_in_plan_9, see "an aside on linking") Assuming we have that, what else is wrong with the C toolchain?
>>
File: takei.jpg (11 KB, 441x408) Image search: [Google]
takei.jpg
11 KB, 441x408
>>55025391
Thanks for proving my point.

>>55025422
It's not about refusing to use more memory, it's about retaining the ability to compile on older systems that don't have it.
Even if it is technically inefficient, gcc is often STILL faster at going the "long" way around than other compilers taking their own shortcuts.
>>
>>55025452
>Except when it requires them.
I've never run into a situation where I've needed mutually recursive modules. Even then, if headers solve that specific problem well, then why not? You don't have to use them for everything, thank god.

>headers aren't bad, are they?
Christ.

>>55025455
>what is cross-compilation
>>
>>55025452
>And how does that negatively affect the system?
You prefer doing more disk writes/reads than using memory, which is horribly slow seeing as even state of the art NVRAM disks are still 150-200 times slower than RAM.
>>
>>55025491
Doesn't the kernel cache files? Honest question, I'm not versed in C compiler speed studies
>>
>>55025482
>>what is cross-compilation

A nice hack for getting around the fact your build system REQUIRES a powerful machine for a program that is meant to be run on a low-resources device.

>>55025491
Ignore this faggot, he does't even know what ccache is.
>>
>>55025552
>cross-compilation is a hack
>this is what C programmers actually think
>>
>>55024585
C# is actually decent but

>.NET
>>
>>55025552
>>55025501
Protip: If you have to rely on OS functionality in order to speed up compilation times, then you are doing it wrong.

>>55025501
>Honest question, I'm not versed in C compiler speed studies
C compilation (and especially C++ because of templates) times are horribly slow, but it is generally viewed as acceptable because of the massive performance gains you get from compiler optimisations when you do multiple passes.
>>
(I'm >>55025501)
>>55025552
It still occurs to me that rereading files induces parsing, even if it doesn't induce file access. Would it be possible to turn the compiler into a server that can build up it's knowledge of header files in memory during a compiling session, and spawn compiler thread that would actually do the work on C files, while having access to the shared, precooked knowledge? That would be a nice way of speeding things up (assuming they need to be) while remaining compatible and modular.

As for cross-compiling, why not cross compile? It's 2016, the IoT is coming, nonono it's not a meme. Seriously tho, why should a toaster be forced to be able to compile? As long as it's not tivoized I'm fine with a micro chip. Also, my raspberry pi was slow enough to make me want to cross compile for it on my desktop. Cross compiling should be an option.
>>
>>55025602
It is if it's a requirement to build anything substantial, it's no more of a hack than relying on ccache

>>55025637
Protip: If you have to rely on GBs of RAM in order to speed up compilation times, then you are doing it wrong.

See, I can have opinions too, isn't that neat!

>C compilation (and especially C++ because of templates) times are horribly slow
True for C++, not at all true for C.
You haven't even stated what languages exactly you are comparing to anyway

>inb4 hasklel and rust
Slower compilation for faster execution is a more than reasonable tradeoff, and even that is assuming I believe your claim that rust compiles faster on the same machine compared to C.
>>
>>55025691
>Protip: If you have to rely on GBs of RAM in order to speed up compilation times, then you are doing it wrong.
You already have to do this when compiling STL containers because of MUH GENERIC PROGRAMMING USING TEMPLATES
>>
>>55025691
I realized recently that 8GB of system memory was not nearly enough for hasklel, just so you know. If C++ is bad, it's definitely not as bad as Haskill.
>>
>>55025663
>Cross compiling should be an option
Of course it should, but it should not be a requirement. The whole point of C is to be portable, if you don't care about then use something else and stop complaining.
Best of luck finding something else that works well with your embedded shit though.

Build systems that are only not grinded to a halt with massive amounts of RAM are no better than GCC and make in the vast majority of use cases.
>>
>>55025713
Nobody here is going to defend C++, templates are for the braindead.

I know first hand that C++ compilation is orders of magnitude slower than C, that's why I avoid it at all costs.
>>
>>55025725
If I'm writing an embedded program to control traffic lights in C does that mean I have to compile it on the traffic light? Seriously, what is wrong with cross-compiling?
>>
>>55025742
No, but if it's a lightweight program running on a micro with a few KB of ram, why the hell should you need GBs of ram to compile it?

You are trying to argue that programming cheap micros using only incredibly expensive workstations makes any sense at all.

Also, if something is being programmed in the field, you probably want a portable way to make changes and reprogram it at the site.
Unless you'd rather outsource to India and wait 2 weeks for Pajeet to upload your .exe, having a build environment that can work with minimal resources is incredibly useful for many people.
>>
>>55024615
>>55024677
in the Canada leaf land Engineer is a legal title just like doctor.
Also calculus I and II were easy.
>>
>>55025785
>only "incredibly expensive workstations" have gigabytes of RAM
Open your eyes, grandad.
>>
>>55025813
https://en.wikipedia.org/wiki/List_of_Arduino_boards_and_compatible_systems

Show me the Gigabytes in there, kiddo
>>
>>55025859
In what fucking real world scenario would you be compiling on an Arduino?
>>
>>55025438
Your input is ASCII based. So 3+3 is actually 0x33 + 0x33 = 0x66 = 'b'.

Subtract 0x30 from each character received. Don't forget you will need to build the binary value for values greater than 9.

E.G:
First operand = 52

This is received as: '5','2' (0x35, 0x32)

So something like this:
mov eax, 0 ;store result in eax, so clear before use

mov ebx, '5' ;load first character
sub ebx, 30h ;remove ASCII offset
add eax, ebx ;add to result

mulu eax, 10 ;multiply up result
mov ebx, '2' ;repeat for remaining characters in buffer
sub ebx, 30h
add eax, ebx
>>
>>55025876
Don't know, I'm not him. Not sure you can...
>>
>>55025813
Expensive in comparison to the micros you are flashing, mongo.

I thought you brought up making software for micros specifically in regards to cost savings, so brought up the point that how does that matter anymore when you need modern machines to compile?

There are advantages to build systems that scale a lot better with extra memory, but most people don't actually need them because they use a compiler that isn't shit to begin with and needs to compensate.
>>
File: image.gif (663 KB, 291x300) Image search: [Google]
image.gif
663 KB, 291x300
Does anyone know where j can buy reliable proxy lists that I can just plug into my program?
>>
>>55025859
>portable
>links to arduinos
hey autismo why dont you disconnect your ethernet cable and hang yourself with it in your step dads basement
>>
i thought this was haley from modern family
>>
>>55024677
>Do you like it if people who have been on codeacademy for 5 minutes start calling themselves computer scientists?
Can they write good code?
>>
>>55026018
How was anything related to portability? You don't understand anything about this discussion, computers, life, or women for that matter. May I suggest YOU end yourself?
>>
I feel like making some game to pass my neet days. I know basic C# and Java, which arent too good in video game developing.
Anyone have suggestions what I should learn if I want to make some basic 2D game.
Also on a sidenote, are fanfic databases good places to take some half assed plots/stories from
>>
File: Capture.png (169 KB, 1275x718) Image search: [Google]
Capture.png
169 KB, 1275x718
>>55025882
wow dude you made me really happy with this answer
>>
How can I learn Idris?
>>
>>55026093
http://docs.idris-lang.org/en/latest/tutorial/
>>
>>55026093
Type-Driven Development with Idris
Or learn Agda first.
>>
File: me with kr and rms.jpg (189 KB, 720x720) Image search: [Google]
me with kr and rms.jpg
189 KB, 720x720
Is there any reason to start a new project in C in 2016?
>>
so i've got all my git repo's hosted on a virtual server but id also like to run somekind of continous integration so i dont have to run the entire build process manually from SSH
any recommendations on software?
doesn't have to be super feauture heavy, just something that works
>>
>>55026193
If your project is a kernel module, then yes. If not, probably no.
>>
>>55026193
portability and embedded systems development
otherwise just use C++ or a higher level language
>>
>>55026193
What kind of project?
What is it aimed to be run on?

Do you have certain development requirements?
Is the project computationally intensive?
>>
>>55026193
>compiles everywhere
>doesn't require a bloated IDE
>encourages you to keep things simple
>no hipsters

Nah just use java instead.
>>
I don't think I'm good at building a respectable open source project.

How do people organise their changelogs? Does everyone use git flow? What about versioning systems? TravisCI for continuous integration? Test coverage, documentation, standardization... there's so much to do. I often just build the functionality and then drop the project.

How do you people do it? It's so much work for a single person. Using Python btw (no hate pls)
>>
>>55026194
>so i dont have to run the entire build process manually from SSH
Use a remote for the server and check the project out to work on it.
>>
rate my linked list

#include <stdio.h>
#include <stdlib.h>

typedef struct node
{
int value;
struct node* next;
} node;

node* create_linked_list(int value)
{
node* head = malloc(sizeof(node));
head->value = value;
head->next = NULL;
return head;
}

node* add_item(node* head, int value)
{
node* new_node = malloc(sizeof(node));
new_node->value = value;
new_node->next = NULL;

node* current_node = head;
while (current_node->next != NULL) {
current_node = current_node->next;
}
current_node->next = new_node;

return new_node;
}

int linked_list_length(node* head)
{
int length = 0;
node* current_node = head;
while ((current_node = current_node->next) != NULL) length++;
return length;
}

int get_value(node* head, int position)
{
node* current_node = head;
for (int i = 0; i < position; i++) {
current_node = current_node->next;
}
return current_node->value;
}

void destroy_linked_list(node* head)
{
node* temp = NULL;
while ((temp = head) != NULL) {
head = head->next;
free(temp);
}
}

int main()
{
node* head = create_linked_list(1);

for (int i = 0; i < 20; i++) {
add_item(head, i + 2);
}

for (int i = 0; i < linked_list_length(head); i++) {
printf("%d\n", get_value(head, i));
}

destroy_linked_list(head);
return 0;
}
>>
>>55026237
>no hipsters
hearty kek
>>
>>55026237
>no hipsters
Instead you have people who are really stuck in the past instead of just pretending to be.
>>
>>55026203
>>55026210
>>55026234
>What kind of project?
>What is it aimed to be run on?
>Do you have certain development requirements?
gotcha

>Is the project computationally intensive?
What if it is, but C is too low-level? (I know there are many fantastic libraries, like GMP and BLAS.) Is Fortran worth learning?
>>
>>55026254
>not checking return value of malloc
>get_value could potentially cause a null pointer access if position > number of actual elements
>head is not freed

6 / 10
>>
>>55024124
Shes looking for a rich husband. You can see it in the eyes
>>
>>55026303
If you think C is too low-level, then go with C++/Rust/Go/D/Forth instead.

Fortran is a remnant from ancient times. It's like C minus half of the standard library.
>>
>>55026319
>head is not freed

really? when I run it with 3 items in the list with printf it runs 3 times
>>
>>55026339
Is Forth ever used anyway? I've only seen it mentioned here and on Lain. Most likely by the same.
>>
>>55026347
Never mind, I misread. You're right, head is freed.
>>
>>55026339
>Go
>>
>>55026328
Basically, if a woman wears makeup then she is a gold digger.
>>
>>55026391
Not every woman with self esteem issues is a gold-digger anon, just 75% of them.
>>
>>55026073
No problem, glad I could help. Now you just need to implement some buffers so you can handle multiple digits!
>>
>>55026391
What if a man wears makeup.
>>
>>55026473
Then he's a woman.
>>
File: feminism1.jpg (21 KB, 527x278) Image search: [Google]
feminism1.jpg
21 KB, 527x278
>>55026473
>>
>>55024124
>isis
>>
>>55026303
If you use the right libraries, C doesn't have to be low level at all.
Arduino is a good example of this (yeah I know it's actually C++, but it uses very little C++ features not already present in pure C).

I'm not actively recommending you use C, just don't discard it as an option because some dudes on /g/ told you it was a meme.
>>
File: 1462912165739.gif (398 KB, 500x460) Image search: [Google]
1462912165739.gif
398 KB, 500x460
>>55026542
>yeah I know it's actually C++, but it uses very little C++ features not already present in pure C
>>
>>55026603
Well the software I write is pure C, and the only C++ elements are in the libraries that I call.

So I'm writing low-level C to interface with C++ parts, without actually having to get my head around the clusterfuck that is C++.

Everybody wins.
>>
File: mailchimp-plushies.jpg (153 KB, 500x375) Image search: [Google]
mailchimp-plushies.jpg
153 KB, 500x375
>tfw I am too retarded to use the Mailchimp API

Not sure if I'm a shit programmer or just too hungover to learn this

Can't figure out how to use the python wrapper, and doing it the curl way hurts my brain.

Why can't there be a simply-documented wrapper for retards like there is for salesforce ;_;
>>
Anyone used Elm?
>>
>>55026651
MailChimp API v3.0 Examples

https://github.com/mailchimp/APIv3-examples
>>
>>55026663
>>>
why would anyone waste time that language?
>>
I was inspired by the phone number html slider input, so I decided to make a slider input for text.
>>
>>55026736
post source so i can learn
>>
>>55026714
Aaaah

Cheers m8, I could only find the Django examples, I was beginning to doubt my sanity
>>
>>55026736
Now make an emoji slider.
>>
I have a c# program that will get a URL's HTML into a string. What would be the best way to parse the string to delete all the HTML tags? I tried REGEX and it is kinda sloppy going to either just do a loop that checks for angled brackets or a stack that matches brackets. Anything I come up with ends up not being 100% accurate for all cases though. Ideas?
>>
>>55025246
Pattern synonyms are still unusable
>>
>>55026793
Use an HTML parser.
>>
>>55026793
Just google up a fucking lib you newfag webshit. It's not the kind of thing you need to roll your own for, quite the opposite. Now go being an unoriginal douchebag somewhere else. Also "URL's HTML" you mean a webpage
>>
what programming language will make 2d real
>>
>>55026736
>>55026739
this is the javascript:
letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];

function update() {
var output = document.getElementById("output-box");
var slider = document.getElementById("input-slider");

val = slider.value;
valString = "";
for (var i = 6; i >= 1; i--) {
valString += letters[Math.floor((val % Math.pow(letters.length,i)) / Math.pow(letters.length,(i-1)))];
}
output.innerHTML = valString;
}


And this is the body of the html:
    <h1 id="output-box">0</h1>

<input id="input-slider" type="range" min="0" max="308915776" value="0" style="width:960px;" oninput="update()">
>>
func Hash(path string) {
f, err := os.Open(path)

if err != nil {
fmt.Fprintf(os.Stderr, "%s: %s\n", path, err)
return
}

defer f.Close()

fields := []string{"md5", "sha1", "sha256", "sha512", "crc32"}

hashers := []hash.Hash{
md5.New(),
sha1.New(),
sha256.New(),
sha512.New(),
crc32.NewIEEE(),
}

results := make([]string, len(hashers))
chans := make([]chan []byte, len(hashers))
var wg sync.WaitGroup
wg.Add(len(hashers))

for i, hasher := range hashers {
h := hasher
c := make(chan []byte)
result := &results[i]
chans[i] = c

go func() {
defer wg.Done()

for blk := range c {
h.Sum(blk)
}

*result = fmt.Sprintf("%x", h.Sum(nil))
}()
}

buf := make([]byte, 16*1024*1024)

for {
n, err := f.Read(buf)

if err != nil {
if err != io.EOF {
fmt.Fprintf(os.Stderr, "%s: %s\n", path, err)
}

break
}

blk := buf[:n]

for _, c := range chans {
c <- blk
}
}

for _, c := range chans {
close(c)
}

wg.Wait()

fmt.Println(path)

for i, name := range fields {
fmt.Printf("%s: %s\n", name, results[i])
}

fmt.Print("\n")
}
>>
>>55026859
Fellow Go bro.
>>
>>55026814
Download a package for one? I can't find an API for one.

>>55026823
URL is the address of the webpage yes. and the HTML is the skeleton of the webpage yes. I Already have the URL I want to parse the HTML.
>>
>>55024124

So I'm building a program to organize data from a PNG file to make it easier to work with in Python

Is it fair to say that the advantage of a dictionary over a list is that you can represent large pieces of data with a smaller variable, so it doesn't have to rewrite the large entry because it is represented by a key?
>>
>>55026858
hmm, what about the css? i can't see the circular thing to grab with the mouse
>>
>>55026859
what is this suppose to do , anon?
>>
Finished a C intro class for an elective. Should I go deeper into C (I don't know anything past pointers, lists, arrays, and structures (and matrices)) or start with Python, Java, C++ or something?
>>
>>55026984
No css. The circle is default with the slider (input type=range) in most browsers I think. It shows up in chrome, firefox, and safari on Mac anyway. Maybe it looks different on Windows.
>>
>>55027035
you're right. nvm
>>
>>55027022
Learn another language. Pedagogically, you have already gotten as much value from C as you can. C isn't nearly used as often any more as the languages you listed, so it would be in your interest to learn something else. I would recommend Python and C++.
>>
File: IMG_20160611_190150.jpg (2 MB, 3264x2448) Image search: [Google]
IMG_20160611_190150.jpg
2 MB, 3264x2448
playing around with shift registers, but you cucks dont care anyways
>>
What do you guys think about Elixir?
>>
>>55027224

pretty cool!

Also, you can find like minded people here

>>>/diy/998973
>>
>>55027224
People in a programming thread, populated with Java, C# and <meme of the month> hipsters, not caring about discrete logic circuits?

What a fucking surprise!
>>
So I have a question /g/.

I'm making a music manager and I scan all the mp3 files and store the path into a txt along with the id3 tags/info for fast searching. So when the user searches a keyword it just goes through line by line of the txt for matches.

Is storing strings/data in a .txt a bad idea? Is there something faster? This is in python if that matters.
>>
>>55027261
not discrete logic.
programmed with C on an atmega8a.

I do have nand gates here though. Maybe someday I'll do something sweet with em
>>
>>55025787
So was calc 3, and diff eqs, and pretty much all engineering math
>>
How difficult is it to get a good programming job by showing off what I've made alone? No expensive degrees or anything?
>>
>>55027322
Why would it be a bad idea?

Unless your .txt will have hundreds of thousands or maybe millions of lines, there's no real reason to not do it that way.
>>
When should I make a class members a pointer?
>>
>>55027431
not that hard if the products you show are any good. honestly some companies are glad if you understand the concept of 2d arrays and more. Because the stuff you learn in college is hardly advanced by any means, take up a good book or 2 for a single language and you know them better than the average college grad. If you have a good advanced working program that works with a database, they will hire you over college kids. But they will not hire you over someone with experience in the field. so it depends luck, also companies can only hire what they get, if you are the only person to respond to their deadline, chances are you will get the job even if your program sucked.
>>
>>55024307
This a thousand times
>>
>>55027662
when the cock's to big for you're mom's mouth
>>
>>55027662
why the fuck would you even consider doing that?
>>
>>55026351
1) Legacy (duh)
2) It's still legit used in low level mathematical libraries (e.g. LAPACK) and some supercomputer computations.
But from what I know, it's being replaced by C(++) in the recent years.
>>
>>55025637
Template compilation is way faster in sepples now on modern compiliers, and even easier with build systems that don't rebuild parts of a program that haven't changed
>>
>>55027664
>if you have a good advanced working program that works with a database, they will hire you over college kids

why with a database? do companies love databases?
>>
>>55026339
>this n00b never used Fortran 90 or later
>this n00b doesn't know about FLPL and thinks car, cdr, and cons came from Lisp
>>
>>55027664
college cucks on suicide watch
>>
>>55027683
>Made a coordinate class
>holds two ints and a string
>those three members are pointers to new data in free store
>making a new class which holds my coordinate class right now
Should I just initialize it normally or make it a pointer?
>>
File: CkpFw2sVEAIWq3J[1].jpg (83 KB, 1110x520) Image search: [Google]
CkpFw2sVEAIWq3J[1].jpg
83 KB, 1110x520
Pytards will defend this.

Btw this caused Lets Encrypt to leak 8000 of their users' e-mail addresses.
>>
>>55027770
Oh and btw guns kill people.
>>
>>55027770
I don't care about let's encrypt poorfags. Hope they all get screwed
>>
>>55027817
>his e-mail library is a gun
>>
File: pepe_fu.jpg (24 KB, 495x495) Image search: [Google]
pepe_fu.jpg
24 KB, 495x495
>>55027770
>2.7
>>
>>55027718
sorry it's because i am working with databases a lot. Some companies will love it when you know how to connect to a database, because it saves them time, time that would otherwise be spend for you learning it. Others will probably not care. Just look at the job description.
>>
>>55027861
dumb frogposter
>>
>>55024424
You should trap sigint for keks too and have it echo NO ESCAPE

also pkill is a thing you fag lovers.
>>
>>55027894
ekekekekekekekeke get reeeeeeeeekt m8 XDDDDDDDDDDDDDDD
HAAHAHA
>>
>>55027664
>>55027718
>>55027889
I have never worked for a company or project that doesn't use databases extensively in one form or another.
>>
File: Capture.png (55 KB, 164x246) Image search: [Google]
Capture.png
55 KB, 164x246
>>55027889
Thanks anon
>>
Reminder that if you use a debugger, you are not a real man.

https://lkml.org/lkml/2000/9/6/65
>>
>>55027770
This is why operator overloading is bad.
>>
File: fixed.jpg (49 KB, 489x363) Image search: [Google]
fixed.jpg
49 KB, 489x363
>>55024124
>#ilooklikeanengineer

Good for you, just do your job. We don't care what you look like.
>>
>>55028077
> you are not a real man.

i know because i'm a girl
>>
>>55028077
If you can't debug by just thinking about your code carefully and you need a monstrosity like gdb consider killing yourself
>>
>>55028077
im only 20 iq pts behind a man (einstein) who debunked the majority of physics by thinking about trains. And seeing as physics deals with true complexity and other science do not, its even more reasonable for a 140 to be able to trash your kind than it was for a 160 to trash physics ;)
if ur iq was above 140 u wouldnt be as butthurt about the concept of a 140 hyp grad lurking this beta barn..
so the logical conclusion is that ur iq is lower than 140 (possibly much lower)
if you met me in real life you would instantly be blown into a world where all that mattered was getting me to acknowledge your existence and even hopefully be your friend... But i would probably find you to be a desperately uninteresting person and want you to exit my awareness as fast as possible.
the fact that i dont lie about my iq is what gives me the edge necessary to call you an inferior little girl who couldnt understand basic physics, and BE RIGHT ABOUT IT.
honestly if i woke up one morning and for some reason my thinking capacity had devolved to your level, it would take me less than 5 min to run to the kitchen and slit my throat...
maybe your going to tell me u work at goldman..
but ud still be way inferior, as is anybody who projects their iq to be higher than it is..
>>
>>55028249
tl:dr
>>
>>55028077
Reminder that syntax highlighting is for babies.
>>
>tfw found my old high school Pascal programs from 2001/2002
>haven't touched a programming language since
>tfw suddenly feel like trying my hand at programming again to make a vidya gaem

What do?
>>
>>55028271
Start off with something easier.
>>
>>55028271
Get a codeblocks+mingw
Set up SDL2 (there are tutorials)
Compile my C game http://pastebin.com/AcmcNzMX and play with it

on linux it is much easier though
>>
>>55028261
he's autistic
>>
>>55028077
>Even considering the argument that a method of weeding out shit programmers is not a good thing

Based as always
>>
>>55028271
I have no idea about games, but.. you could learn C# + unity, or python+pygame, or something similar
>>
>>55028271
Easiest platform to make games is HTML5/Canvas/Javascript. Just do it. You don't need anything more than a browser and a text editor.
>>
>>55028249
Is that a copy pasta or legit autism?
>>
>>55028435
I took it and adapted it from >>>/biz/1298739 , I think the source is not copypasta
>>
File: 1457858073150.png (72 KB, 244x241) Image search: [Google]
1457858073150.png
72 KB, 244x241
Made my first database application with Clojure and am expanding it now. Oh, it was also my first programming done in Clojure. Took a day. Extremely pleasant language. Syntax is easy af.
>>
>>55028516
lisp is comfy

first experience with any lisp?
>>
>>55027662
when it needs to have members of its own class (like a linked list)
>>
>>55028516
why do i see akari getting posted so much all over the boards
>>
File: scala-icon.png (11 KB, 680x680) Image search: [Google]
scala-icon.png
11 KB, 680x680
Hey /g/, is Scala any good for developing the backend of a mobile app? How do I go about learning it?
>>
>>55024661
Find anagram of a string.
>>
>>55028721
Isn't android still stuck on java 6?
>>
>>55028755
It's Java 7.
>>
>>55024661
Go.
>>
>>55028765
scala might be a good choice, then
>>
>>55028721
It's a C++ tier overcomplicated language, I do not recommend it.

If you want functional@jvm there is clojure.
>>
>>55028834
Clojure is dynamically typed, though.
>>
>lots of discussion about overloading/disambiguating record fields in Haskell
>nothing about doing the same for data constructors
I just want to be able to write something like this, dammit!
data Foo = Baz Int
data Bar = Baz Int
foobar :: Foo -> Bar
foobar (Foo.Baz x) = Bar.Baz x
>>
>>55028873
And also crap.

http://ashtonkemerling.com/blog/2016/06/11/my-increasing-frustration-with-clojure/
>>
>Have to write a two-pass assembler in C++ for MIPS that will essentially spit out the machine code in hexadecimal format
>Have no clue what abstract data type to use (if any)

Help /dpt/. I can't even start making my parser till I figure this out.

It would basically take a segment like this and turn it into hex (also using any .data that will always be located after).

.text
addu $s0,$zero,$zero 00008021
addu $s1,$zero,$zero 00008821
addiu $v0,$zero,5 24020005
syscall 0000000c


My question is purely what method is probably best for storing these segments and recognizing/interpreting them after? I was thinking some form of associative array or a multimap but I just don't know what would be best.
>>
>>55028990
https://en.wikipedia.org/wiki/Abstract_syntax_tree
>>
>>55028834
Don't forget about Frege.
>>
>>55028982
kek

I can't believe we're still churning out crap programming languages year after year. I mean sure, Haskell and ML aren't perfect, but we should build on their good parts, not throw away the whole thing
>>
>>55029103
Why don't you build on the languages where Haskell and ML got their features from instead?
>>
Javafag here. Trying to get into C. How does proper memory management work? I'm trying to wrap my mind around it now before I make anything serious with C.

Take this stupidly simple project below. The purpose is to create 2D points and use those points to create triangles. What is the best way to create the points and triangles? I am using malloc to create the points and triangles. Is this stupid? Should I just create them as variables? But what happens if I need to delete points and triangles I have already made?

//main.c

#include <stdio.h>
#include <stdlib.h>
#include "point.h"
#include "triangle.h"

int main()
{
point *pointOne = createPoint(10.0f, 12.0f);
point *pointTwo = createPoint(23.0f, 65.0f);
point *pointThree = createPoint(3.0f, 5.0f);

triangle *t = createTriangle(pointOne, pointTwo, pointThree);

printPointCoor(t,0);

free(pointOne);

return 0;
}


//triangle.h

typedef struct{
point *p0;
point *p1;
point *p2;
}triangle;

triangle* createTriangle(point *P0, point *P1, point *P2){
triangle *t = malloc(sizeof(triangle));
t->p0 = P0;
t->p1 = P1;
t->p2 = P2;
return t;
}

point* getPoint(triangle *t, int a){
switch(a){
case 0:
return t->p0;
case 1:
return t->p1;
case 2:
return t->p2;
default:
printf("Choose a value from 0 to 2!");
return t->p0;
}
}

void printPointCoor(triangle *t, int a){
switch(a){
case 0:
printf("x: %f, y: %f \n", t->p0->x, t->p0->y);
break;
case 1:
printf("x: %f, y: %f \n", t->p0->x, t->p0->y);
break;
case 2:
printf("x: %f, y: %f \n", t->p0->x, t->p0->y);
break;
default:
printf("Choose a value from 0 to 2!");
printf("x: %f, y: %f \n", t->p0->x, t->p0->y);

}
}


//point.h

typedef struct{
float x;
float y;
}point;

point* createPoint(float X, float Y){
point *p = malloc(sizeof(point));
p->x = X;
p->y = Y;
return p;
}
>>
>>55029153
Because Haskell and ML have additional good parts, so by building on them we get the benefits of both those parts and those of their predecessors transitively.
>>
>>55029162
You allocate memory with malloc. You tell it how many bytes you want and it gives you back a pointer. If that pointer is NULL then it didn't manage to allocate the memory for you. You free the memory by passing the pointer to free.
>>
>>55029171
All this talk of building on things sounds like inheritance over composition.
>>
>>55029171
>and those of their predecessors transitively.
Then why doesn't OCaml have parallelism or overloading?
>>
>>55029205
kek

well, inheritance isn't all bad. remember that Monad extends Applicative, which in turn extends Functor
>>
>>55029153
It all comes down to mathematics in the end, so yes.
>>
>>55029225
Because OCaml doesn't exist, it's a fiction, nobody would create and use a language that can't use more than one thread, that would be stupid.
>>
>>55029225
Point taken.
>>
>>55024307
This. Regards from the mathematics department who has watches what "programmers" have done to several mathematics courses over 25 years.
>>
>>55029301
Yet here you are.
Thread replies: 255
Thread images: 36

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.