[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: 25
File: 1441508098092.jpg (33 KB, 500x375) Image search: [Google]
1441508098092.jpg
33 KB, 500x375
What are you working on /g/?
Last thread >>55544625
>>
2D game engine in C++ with SFML and Lua.
>>
>>55554990
>C++
Bad

>SFML
lol

>Lua
Fucking cancer

Kill yourself
>>
>>55555011
off yourself retard
>>
>>55554990

C++ and lua is always painful. Especially if you write the bindings by hand.
>>
Working on my Lisp library in C.
I need a way to deal with memory leaks of the resulting program. I should also probably take a look at a JIT library.
If you have any tips or experiences please tell me.

>>55555036
>Lua user calling others retards
>>
>>55555011
What's wrong with C++?
>>
>>55555072
Nothing.
>>
>>55555072
It is a slow to compile and implement mess that tries to do everything but ends up doing nothing well.
>>
>>55554990
>2D game engine
Sure, another one I guess
>in C++
Nice if done right
>with SFML
Ok? Really? Why would you write an engine then?
>and Lua.
Into the trash.
>>
>>55555109
>>55555054
>>55555011
What's wrong with Lua? Besides things like array indexes starting from 1.
>>
>>55555115
>What's wrong with Lua?
What's the point of lua?
>to be easier to work with
Turns out that there's no real reason to use Lua if you're interacting with anything else.
If you really want stuff like dynamic code reloading or whatever for the engine just do something like this:
https://blog.molecular-matters.com/2014/05/10/using-runtime-compiled-c-code-as-a-scripting-language-under-the-hood/
And now anyone can just generate a suitable DLL and everything works fine.

Lua is pointless for this purpose. Same as any scripting language really.
>>
>>55555115
Absolutely nothing.
>>
>>55555115
It is yet another useless language that serves no purpose. Want plug-ins? dynamic loading. Want scripting? Scheme/bash/whatever.

Anyhow, read this https://github.com/saniv/text/blob/master/criticism/lua.md

>>55555083
>>55555142
tard
>>
/dpt/ get
>>
>>55555115

Global by default.
>>
>>55555235
That's not even close.
>>
>>55555174
God, what kind of idiot wrote that document?
>>
>>55555266
Don't let that moron taint your opinion of anti-useless-scripting-language people.
>>
>>55555011
another "im superior because i have to write features that should be built in myself" retard

kys
>>
>>55555315
lol what?
>>
>>55555555 get needs to say Java is going to be a dead language by next year

fuck java
>>
>>55555323
It needs to be an interjection
>>
dpt, extortion edition.
>>
>>55555323
Java is going to be a dead language by next year
>>
How many of you le epic haxxors have made a script to get octuples today?
>>
>>55555376
post code for le script kiddies
>>
>>55555315
>kys
You might as well kill yourself and fuck off back to YouTube.
>>
Praise kek
>>
>>55555102
KEK

Only if you're a fucking incompetent developer
>>
Java is going to be a dead language by next year
>>
>>55555323

Kek willing
>>
>>55555432
>>55555439
>>55555471
>>55555474
Consider eating a freshly fired bullet.
>>
Java is dead m8
>>
>>55555487
lmao
>>
Drumpf has absolutely no chance.
>>
Fuck java it's a piece of shit language made for poo in loos and it's going to die next year
>>
>>55555487

deal with it autist
>>
For trump
>>
File: line_000.png (2 KB, 640x480) Image search: [Google]
line_000.png
2 KB, 640x480
I implemented Bresenham's line algorithm in 16-bit x86 assembly, in 640x480 black and white mode. It works, but only in first octant. Pixel data is written directly into video segment memory, int 10h isn't used.
Pic related - a triangle drawn using three lines.

Now I should make it work in all octants.
>>
>>55554965
Get for D
>>
>>55554965
Nothing.
Just fucking around on /g/
>>
C is a waste of time.
>>
Fuck java it's a piece of shit language made for poo in loos and it's going to die next year

no lives matter

trump is going to win
>>
>>55555436
nope
>>
>>55555555
>>
File: SLpFiFd.png (5 KB, 411x204) Image search: [Google]
SLpFiFd.png
5 KB, 411x204
>>55555584
:^)
>>
>0 posts about programming anything
>bazillion posts about "muh language is butter than ur language"

How embarrassing.
>>
File: 1427446643759.jpg (374 KB, 837x1184) Image search: [Google]
1427446643759.jpg
374 KB, 837x1184
Why should I learn a scripting language like Python/Ruby/Lua/PHP/Javascript when I can program is something like C/C++/Java/C#? Scripting languages seem so pointless unless you want to make something rough and ready.
>>
>>55555642
You must be new here.
>>
>>55555642
But that's what /g/ is for.
>>
>>55555649
Separate data from implementation.
>>
>>55555649
If you don't see a reason to learn one then don't learn one, simple as that.
>>
>>55555649
>unless you want to make something rough and ready
They don't have much advantage over a compiled language in this regard. It's not like it takes more than a fraction of a second to compile and run.
>>
>>55555682
Are you implying that compiled languages don't do this as well?
>>
>>55554965
Can someone tell me about job references? The one I'm applying to asked me to provide them with a couple after the interview. I have no idea what this involves and how I should handle it.
>>
>>55555707
You call your previous employees and ask them for a reference, that's it.
>>
>>55554990
Sounds pretty cool. I've barely learned about nodes and linked lists in C++, and I have no idea what to do with them.
>>
>>55555649

So you can deal with code that people have written in languages like Python/Ruby/Lua/PHP/Javascript.

You're asking for reasons why you shouldn't learn something as if there's ever a reasonable excuse.
>>
>>55555717
Ask them for a reference? This isn't the same thing as a letter of recommendation, right? I get their contact information then my new potential employer will contact them?

What kind of questions can they ask? A lot of the freelance clients I've had are western Europeans living in the states who speak poor English.
>>
Need some help with Database Design.
So far I have picture related, it's basically a Database to keep track of Inventory and Purchases.
I wanted to also keep track of how many of each item is sold in a Purchase. What should I do to achieve that?
The Quantity field in the Item table is used to keep track of how many of that Item is in the Shop's Inventory. Should I create a Inventory table to register that or it's fine this way? Should I add a Quantity field in my ItemPurchase table to know how many of each item was bought?
>>
>>55555735
Turn them into templates, if you haven't already.
>>
>>55555801
If you have a letter from your previous employer that contains a reference then it's all you need to hand your new employer.
>>
Dear anon >>55554563
Thanks a lot
You saved my day
>>
>>55555555
Mm
>>
>>55555857
Will do, but my problem is that I have no idea about what to do with these data structures. They're kind of hard to grasp, but I still want to do a project with them, if not anything, just so I can understand nodes and the rest better.
>>
>>55555912
Make some simple pool allocator.
>>
>>55555867
I don't. What should that letter contain?

I've never had an actual employer. Up till now I've only done freelance work and am finally trying to make the switch. I think I have a decent chance at this job but need the references.
>>
Picked up the project of building a network stack in Python again.
It's something I've been wanting to do for a very long time.
I can now receive and decode Ethernet II and ARP frames

<EthernetIIFrame dst=ff:ff:ff:ff:ff:ff src=00:14:5c:XX:XX:XX ethertype=ARP>
<ARPPacket op=Request sha=00:14:5c:XX:XX:XX spa=10.3.1.156 tha=00:00:00:00:00:00 tpa=10.3.1.89>


Now I have to send replies, but first I have to make an IO loop.
I'll probably use the Tornado one.
>>
File: 1442529695090.jpg (19 KB, 305x222) Image search: [Google]
1442529695090.jpg
19 KB, 305x222
>>55555926
Not sure what it is, but I'll give it a go. Thanks anon.
>>
>>55555981
https://en.wikipedia.org/wiki/Object_pool_pattern
>>
Is there anyway something could remove itself from a container in C++?

I want each enemy in my game to have a vector of every other enemy to test for collisions, but I can't think how this vector could discard the enemy holding the vector.
>>
File: 1468370790503.gif (17 KB, 297x420) Image search: [Google]
1468370790503.gif
17 KB, 297x420
I'm new to programming without much experience. I'm a couple weeks into learning python and I would like to add C to my study plan.

In the /sqt/ I asked for a book that would help me learn C and not assume any prior programming knowldege. I only got one serious reply and they suggested I buy a rasberry pi and install riscos to learn BASIC. Is that reasonable advice? Is there a better way or a book that fits my criteria?
>>
>>55556086
I'd go with either "C Programming: A Modern Approach", or "Pointers on C". Although, I believe the second one assumes a tad bit of programming knowledge.
>>
>>55554990
plz senpai
I want one like that but I'm too much of a lazy shit to write it myself
>>
>>55555840
>>55555840
>Should I add a Quantity field in my ItemPurchase table to know how many of each item was bought?
Yep, that's the easiest way to do it.

Just a recommendation: don't give all of your tables the same primary key name.

Instead of 'id' everywhere, use ItemID, PurchaseID, etc.

It's easier to write queries later.
>>
>>55556120
I'll contact you in a year, or two when it's done. :3
>>
yesterday someone posted a "challenge" to calculate the sum of the multiples of 3 and 5 up to 1000 (exclusive)

let's make it harder:
find the sum of the multiples of an arbitrary amount of numbers up to an arbitrary bound (exlusive)

you may disregard overflows
>>
>>55555840
In that case, yes, you'd just want to add another field to ItemPurchase.

I'm assuming you're doing an incredibly simplified web-store app?
>>
>>55556136
here's my own solution, in Ocaml

no peeking
let removeDupes list =
List.fold_right (fun e acc -> if List.mem e acc then acc else e::acc) list []
;;

let rec power list =
match list with
| [] -> [[]]
| car::cdr -> (List.map (fun l -> car::l) (power cdr))@(power cdr)
;;

(*not me*)
let rec gcd a b =
if b = 0 then a else gcd b (a mod b);;
(*not me*)

let lcm a b =
(a * b)/(gcd a b)
;;

let leastCommonMultiple list =
List.fold_right (fun e acc -> lcm e acc) list 1
;;

let sumOfMultiplesUpTo list bound =
let lcm = leastCommonMultiple list in
let actualBound =
let a = float_of_int (bound - 1) in
let b = float_of_int lcm in
let quot = int_of_float (floor (a /. b)) in
quot in
let naturalsSumTo n = (n*(n+1))/2 in
lcm * (naturalsSumTo actualBound)
;;

let sumOfMultiples list bound =
if List.length list = 0 then invalid_arg "There's nothing to be summed" else
let powerset = power (removeDupes list) in
let ordered =
let len = List.length in
let cmp l1 l2 = if len l1 > len l2
then 1
else if len l1 < len l2
then -1
else 0 in
List.sort cmp powerset in
let final = List.tl ordered in
List.fold_left
(fun acc e ->
if (List.length e) mod 2 = 0
then acc - (sumOfMultiplesUpTo e bound)
else acc + (sumOfMultiplesUpTo e bound)) 0 final
;;
>>
>>55556129
qq

I'm kind of working on one myself, got as far as window-scaling (everything drawn to an internal texture that is then displayed on a specific internal sprite)
but I never understood masking (need it for interfaces)
>>
>>55556136
>an arbitrary amount of numbers up to an arbitrary bound
Can you repeat the question?

Also, stop putting text in code tags, faggot. It's for code, not reddit emphasis.
>>
>>55554965
A Turing machine screensaver. Just because I want one.
>>
whats the best book for learning Go?
other tips for a new gotard appreciated too
>>
>>55556136
template <typename ... ArgList>
int sum(int max, ArgList ... args)
{
auto total = 0;

for (int i = 0; i < max; ++i) {
for (auto j : {args...}) {
if (i % j == 0) {
total += i;
break;
}
}
}

return total;
}


Probably could've been done better.
>>
>>55556187
I think he means that the function calculating the sum should accept two arguments, one being a list of divisors, the other being the upper bound of the operation, so like like for the example the function would be called like so:
calc({3, 5}, 1000)
>>
>>55556136
Is that supposed to be multiples of BOTH numbers or EITHER?
>>
>>55556276
Either.
>>
>>55556124
Thanks for the reply, I was stuck in this for at least 2 days trying to find the right answer.
I wanted to make a stupid question and I wouldn't mind at all if bash me.
How are the fields in the ItemPurchase table will be filled? I know the Quantity field will the filled by me, but are the ItemId and PurchaseId field be filled by themselves or do I need to add the ids by myself?
>>
>>55556187
It means the function should be able to accept any amount of numbers (2,3,4,5,6,7 as an example) and sum multiples of each of those numbers under some specified constant (1000, for example, would mean that you'd consider 2, 4, ..., 998 for the multiples of 2).

>>55556276
Multiples of either of the numbers. Remember to remove dupes (ex: sum of multiples of 3 and 5 up to 16 should only count 15 once).
>>
>>55556154
>I'm assuming you're doing an incredibly simplified web-store app
Exactly. If you can, please read >>55556328
>>
File: IFDYgph.png (22 KB, 951x258) Image search: [Google]
IFDYgph.png
22 KB, 951x258
>>55556136
>>55556250
>>55556374
I'm not sure how high we're supposed to allow the number to go. What's the data restrictions?

Here's a stab:

static long SumOfMultiplesOfAnArbitraryAmountOfDivisorsBelowAnArbitraryUpperBound(int upperBound, params int[] divisors)
{
return Range(1, upperBound - 1).Where(x => divisors.Where(y => x % y == 0).Any()).Sum();
}
>>
>>55556282
>>55556374

Thanks senpaitachi.

My entry:
function calc(divs, bound)
local sum = 0
for i = 1, (bound - 1) do
for _, div in pairs(divs) do
if i % div == 0 then
sum = sum + i
break
end
end
end

return sum
end

assert(calc({3, 5}, 1000) == 233168, 'Something happened.')
>>
quick question

max = 5
for i in range(0, max):
max = 10



this means the loop will run 10 times now, right?
>>
>>55556400
No, the range evaluates with the 5 as param and returns the iterable object.
>>
>>55556400
No
>>
>>55556389
>
Range(1, upperBound - 1).Where(x => divisors.Where(y => x % y == 0).Any()).Sum();

I just popped a LINQ boner.
>>
>>55556435
>>55556427
How do I update the max range within the loop then?
>>
>>55556136
my two solutions from yesterday
foo = lambda ms, n: sum({i for r in (range(m, n, m) for m in ms) for i in r})
foo = lambda ms, n: sum(i for i in range(0, n) if any(not i % m for m in ms))
>>
>>55556450
You don't use an already iterated object for a loop. Use a traditional loop.
>>
>>55556400
fyi, what you're asking is whether max is passed by value or by reference (useful if you wanr to google it)
>>
>>55556389
Whoever invented six-character limits for identifiers had the right idea.
>>
>>55556450
Switch to a while loop or recursive solution.
>>
>>55556466
>>55556479
>>55556491
thanks
>>
>>55556483
I purchases a 3440x1440 ultrawide to facilitate my naming convention.

In the future, I will require my employees to use similar monitors, as they will be required to name everything as descriptive as possible.

Comments are for losers and women.
>>
I'm learning C from The C Programming Language 2nd edition. This is pretty cool and the language is pretty simple.
>>
>>55556453
am I a python wizard now?
>>
(for the people answering >>55556136)

Take what I say with a grain of salt, I'm obviously not paying much attention to all of your code/am only getting the gist of some of the answers since I'm not familiarised with all your languages, but

I'm pretty sure most of your answers count some numbers twice. Taking 3 and 5, under 20, as an example:

[3, 6, 9, 12, 15, 18]
[5, 10, 15]

wouldn't your answers count the 15 twice?
>>
>>55556510
>Comments are for losers and women.
Enjoy coming back to it later and having no idea what your code is supposed to be doing.
>>
>>55556520
You should give Lisp a go. It's even simplier and it's the most powerful language on the planet.
>>
>>55556520
I'm reading up on it as well. Currently on the fifth chapter on pointers and arrays. I wouldn't really recommend it for first timers, they outright say that it isn't an introduction to programming or computer science, it's an introduction to the language.
>>
>>55556573
Lisp is not a language. Lisp is a family of languages.
>>
>>55556552
Nope.

I'm >>55556389

If the modulus of any of the given divisors is 0, then the number will be included in the sum.

If the number is divisible by two divisors, it only adds it once.

>>55556557
A jest, friend. I only do those insane identifiers because it triggers /dpt/.

I'd shoot an employee if they submitted that shit to me for review.
>>
>>55556573
>>55556575
>>55556581
Which lisp dialect should I go with? GNU lisp? SICP? Racket?
>>
>>55556552
I can't talk about the others but at least the C++ and Lua solutions will not since they do not generate lists of numbers for each divisor them sum them up, instead they loop through all the numbers in the range, and check every divisor until it passes, then they break immedietely for that number and continue with the next.
>>
>>55556552
no, >>55556453 doesn't either.
the second solution is pretty obvious.
the first solution doesn't because all sum ranges are added to a set, which eliminates the duplicates.
>>
>>55556601
>>55556552
The Python and C# solutions are using set comprehension with lambdas, so they avoid that issue as well.
>>
>>55556595
try multiple dialects and see which one suits you best

personally, I find all lisp dialects lacking in equally important things. I'll only be comfortable using lisp when I get around to writing my own dialect
>>
>>55556601
>>55556608
>>55556614
oops, I'm just retarded, I was still looking at things through my solution's perspective
>>
>>55556634
I guess I'll try SICP.
>>
>>55554965
First for rebol>>55554965
>>
>>55556595
None. Lisp will make your projects fail.

There's a blog called LoperOS. All he does is whine about why everything sucks. In the time it took him to whine, people wrote GUI operating systems in assembly.

See >>55556109
>>
Is python the best language for a beginner?
>>
>>55556726
SICP is a book for high school kids.

Everything it says about compilers and interpreters is dumbed down toy crap.
>>
>>55556510
>as they will be required to name everything as descriptive as possible.
It's pain to type it all, moron.
>>
A virtual assistant that doesn't require Internet connection and is bassed in neural networks. Adapts to the user instead of being the same for every user as common assistants are (Cortana, Siri ,etc.)
>>
>>55556634
>personally, I find all Java dialects lacking in equally important things. I'll only be comfortable using Java when I get around to writing my own dialect
The next time someone on /g/ complains about Java, I'll say Java is a perfect language because if you don't like it, you can "write your own dialect."
>>
How can i use the integrated visual studio code to compile the file that i have open?

I suppose that's how you use the integrated terminal right?
>>
>>55555011
>>C++
>Bad
kys

>>55555011
>>SFML
>lol
>>Lua
>Fucking cancer
>Kill yourself
these
>>
>>55555555
>>
I have a C program that uses win32's PlaySound function. Is there a way to add the .wav file into the executable?
>>
File: 2016-07-13_11-30-35.webm (258 KB, 1000x148) Image search: [Google]
2016-07-13_11-30-35.webm
258 KB, 1000x148
>>55556818
It was a joke, you silly goose.

Also,
>not having intellisense
>>
>>55556955
yes
>>
>>55556978
And what is it?
>>
>>55556874
1 - I never said any dialect of Lisp was perfect
2 - Writing your own lisp is much more simple than an Algol-like (just think about lisp's syntax vs all the weird cases in C or C++)
>>
I just installed python 3, Is IDLE that comes with it good enough for python?
>>
Question, /g/. When I pass the pointer with the constant string, it's pointing at the start of it. Thing is that when I pass it to the function, it doesn't point elsewhere after the execution.
Is it because of the same reason when passing normal variables to functions and not its addresses, i.e. passing a copy of the content? Would I need to pass the address of a pointer to modify it?

#include <stdio.h>
#include "../mylib.h"

void move_pointer(char *st, int n);

int main(int argc, char *argv[]){
char *p = "Filler string";

if(argc != 2)
return 1;

int times = atoi(argv[1]);
move_pointer(p, times);

printf("%s\n", p);

return 0;
}

void move_pointer(char *st, int n){
for(int i = 0; i < n && st; i++){
st++;
printf("%s\n", st);
}

return;
}

>>
>>55556983
You can either use a resource file or a static char array.
>>
>>55557028
You need a pointer to a pointer to modify the pointer itself, senpai. Otherwise you can only modify the object pointed to.
>>
>>55557061
That's what I was thinking. Thanks senpai.
>>
>>55557028
* is literally just a meta tag.
int a is an integer
int* a is a pointer to an integer
int **a
is a pointer to a pointer to an integer

There is no practical limit to pointer depth. Let's get meta.
>>
in C, what is the behaviour of

int ***a = &(*a)


99% of people will get this wrong
>>
>>55557237
undefined behaviour
>>
>>55557237
UB bby
>>
>>55557260
bzzzzt, wrong
>>
>>55557274
nope
>>
>>55557282
yep, I'm 100% sure it's not undefined behaviour
>>
>>55557237
Well,
(*a) can be considered a int**
&(int**) can be considered int***

You're setting a to itself. However, I'm not sure you can do that in the line that declares a.
>>
>>55557237
You will have a pointer of type (typeof(a))** stored in a variable of type int***. The typechecker may yell but could be circumvented by a static cast
>>
>>55557309
I think it only works if the a on the rhs is being shadowed (e.g. it is a global variable)
>>
>>55557237
It means the same as
int ***a = a
, which accesses an uninitialized variable, which is undefined behavior.
>>
>>55557328
correction: the rhs is of type (typeof(a)), as &(*a) == a. My C is rusty
>>
>>55555649
>when I can program is something like
doesn't sound like you can
>>
File: 20160713170702557.png (102 KB, 1018x578) Image search: [Google]
20160713170702557.png
102 KB, 1018x578
How many points can you score?
http://q.viva64.com
>>
>>55557445
s/is/in
https://en.wikipedia.org/wiki/Principle_of_charity
>>
>>55557290
I'm 100% sure you don't have a clue what you're talking about
>>
>>55557455
This test is just bad
>>
>>55557363
>which accesses an uninitialized variable, which is undefined behavior.
Wrong
>>
>>55557455
What is this cancer
>>
>>55557456
wasn't talking about the typo; if you'd actually be able to program C/C++/Java/C#, ie. actually know them, you'd be knowledgeable enough already not to ask that retarded question; which suggests you can't actually program C/C++/Java/C#; anything else?
>>
>>55557495
>reading uninitialized variables is not undefined behavior
anon, do you even C?
>>
>>55557515
Basically they ran their static analysis tool through tons of popular OSS projects to detect bugs in the code, then made a quiz that lets you try to find those bugs to show that static analysis tools are necessary because those bugs live in projects used every day and programmers do not notice these typos and other mistakes.
>>
>>55557532
Yes, I do.
Do you even know what UB is? Because I doubt that.
>>
>>55555592
Don't kid yourself. C++ is shit if you're retarded but otherwise nah
>>
>>55557600
C++ does not need a retard to be shit.
>>
>>55555649
Short answer is they're easier, more abstract, and hold your hand more than the deeper languages. If you're up for the challenge definitely take Java and the C family of languages over scripting languages first. They'll teach you more and you'll actually understand programming rather than just hacking shitty libraries together and hoping they work.
>>
>>55557561
>Yes, I do.
please, you're retarded
>>
>>55554965

Any of you memers use spacemacs? Decided to learn common lisp along with spacemacs, but I'm feeling a little lost. In vim my workflow involves a lot of :tabe and I have tabnext and tabprev bound, in spacemacs however I dont really know how work with multiple files.
>>
>>55557651
Feel free to prove it then, where does the standard say that this is UB?
kill yourself
>>
>>55557678
spacemacs is just an emacs addon
>>
>>55557455

!qIsFinite(w) || !qIsFinite(w))

>Select the left w
>Wrong, it was the right w

Seems like their analyzer didnt quite catch that :^)
>>
Answer to this >>55557237:

The behaviour is none, as it is not a valid C program.
>>
>>55557758
how?
>>
>>55557774
Missing semicolon.
>>
>>55557780
^

Thank you all for playing. As always, you're all shit at C.
>>
>>55557455
bool QConfFileSettingsPrivate::readIniLine(....)
{
int dataLen = data.length();
....
if (i == lineStart + 1) {
char ch;
while (i < dataLen &&
((ch = data.at(i) != '\n') && ch != '\r'))
++i;
lineStart = i;
} else if (!inQuotes) {
....
}

>click on int (should have been size_t)
>wrong
>>
>>55557780
>>55557800
You both are homosexuals
>>
>>55555555
>>
>>55557758
>not a valid C program
aka undefined behavior
>>
>>55557821
So? Homosexuality is objectively superior to heterosexuality, just like the functional paradigm trumps all others.
>>
File: 1465740412771.jpg (175 KB, 1920x1541) Image search: [Google]
1465740412771.jpg
175 KB, 1920x1541
>>55557698

That's a very astute observation anon, have a (you)
>>
File: 1468361783578.png (463 KB, 785x678) Image search: [Google]
1468361783578.png
463 KB, 785x678
>>55555072
>>
File: functional programming.jpg (64 KB, 440x389) Image search: [Google]
functional programming.jpg
64 KB, 440x389
>>55557837
f a l s e
f a g

gays are not allowed to program at all, let alone functionally
>>
>>55557862
please be a boy
>>
File: 1354309914592.png (183 KB, 493x536) Image search: [Google]
1354309914592.png
183 KB, 493x536
>>55555649
Depending on the language, they can be much faster to develop with, and often have a much tighter feedback loop than compiled languages.

>Lisps epitomise this by letting you change anything, whenever you want during execution
>JavaScript is also really nice for it with hotswapping, and amazing debugger support
>Ruby has Pry, probably the best REPL for any language ever

Also, often scripting languages are put inside of a program to allow you to extend them without digging into their codebase. (This is usually what Lua is used for)

And sometimes, they are the only option for some platforms, like JavaScript on the web.
>>
>>55557780
You never said that was a complete "C program" just "in C".

(int) and
(int *)
aren't complete C programs but they occur in C and it's meaningful to ask about them.
>>
File: 1468431474923.png (630 KB, 785x678) Image search: [Google]
1468431474923.png
630 KB, 785x678
>>55557862
Wow great argument fag.
>>
>>55555840
Lol at the Purchase table.
Why you need 2 purchase table?
Stop utting total price in a table,that you can get with a query ,Make an Item Table with a primary key and some other detail column and a Sales table where you reference an Item and add some extra detail columns.
>>
>>55557618
Yeah, just some fag that only writes Ruby while sitting at Starbucks. Almost the same thing
>>
>>55557894
>C++ is light
>C is bloated
lol?
>>
File: 1467677762738.png (1 MB, 1200x1800) Image search: [Google]
1467677762738.png
1 MB, 1200x1800
>>55557894
>>
>>55557921
C++ is shit by itself.
>>
>>55557880
In C#, I can just drag the execution pointer to whatever line I want to start at, and modify the subsequent lines, thus being able to modify a program midway through execution, while also retaining type safety.
>>
>>55557869
The homosexual brain has the best traits from the heterosexual brains of each sex. This, combined with the social structure provided by homosexuality (more female friends, since they don't feel threatened by a homosexual man, to keep them updated on all the latest occurences + close male lovers who will not be afraid of pouring their bodies and minds into making you feel good, contributing to your well-being and clarity of mind, as well as being amazing for pair programming if you're in a relationship), makes the homosexual male the best kind of programmer, on average.

It may be true that in the future machines will programing themselves, but before that we'll yet witness the overtaking of the field of computer science by homosexuals, and it will be glorious. Homosexuality > Heterosexuality just as Functional Paradigm > Any other Paradigm.

Know your place, heterocucks.
>>
File: 1462399412449.jpg (410 KB, 876x2350) Image search: [Google]
1462399412449.jpg
410 KB, 876x2350
>>55557931
C++ code is light
C code is bloated
>>
What is a good book to learn Unix programming in C for beginners?
>>
>>55557931
C++ is nice, C is unpleasant.
>>
>>55557975
>casting from/to void is nice
>>
>>55557943
>tfw C# isn't a loli anymore at the ripe old age of 16

Someone should update the image.
>>
>>55557989
Well you do that in C. In C++ you don't have to.
>>
>>55557989
never happens
>>
>>55558008
I think you confuse C and C++.

>>55558010
Wrong
>>
>>55558008
>you do that in C
nope, why do you need to post if you don't know anything about the topic?
>>
>>55557989
???
>>
>>55558021
>I don't know C++
just say so rajesh
>>
>>55558029
>>55558008
How would you implement a general data structure in C without casting from and to void*? In C++ you can just use a template.
>>
I'm not sure I understand Lambdas in C++.
I'm not particularly interested in learning them either. I don't think I am anyway. I'm very interested in learning them if they're a construct that lets me move code out to functions without actually having a function call.

Anyway, does anyone know good resources to learn?
>>
File: Cube.webm (2 MB, 1920x1052) Image search: [Google]
Cube.webm
2 MB, 1920x1052
>>55557952
I mean like this though.

Even if you don't like the language, you gotta admit the ability to do that is pretty slick.

Java has hotswapping too, but it isn't a sure thing, and you can't build an entire program by running it and incrementally adding things while it's running.
>>
>>55558061
yes, it creates an external anonymous class with an operator() containing the code
>>
>>55558029
Not him, but I think you're deluding yourself. Write a generic hash table in C without using void* or a preprocessor hack.
>>
>>55558061
Lambdas are essentially syntax sugar for structs that catch some state as members and define an operator()()
>>
>>55558044
I start to seriously doubt that you know what you are talking about.

>>55558054
>without casting from and to void*?
Ehh... by not casting from and to void *, it's that simple.
You can also do it with macros.

>In C++ you can just use a template.
Enjoy your slow compile times.
Also, this is another badly implemented feature of C++. Just use a language with parametric polymorphism.

>>55558074
What does this has to do with the topic?
>>
>>55558054
>How would you implement a general data structure in C without casting from and to void*?
Well I'd probably find a good metaprogramming library/preprocessor that'd allow me to do that in a much nicer way than C++ templates. Even if they were nice, if they have the same compile times and debugging issues they do right now then they're not worth it. Copy paste.
>>
>>55558082
>>55558074
I'm really sad capture by move wasn't in C++11. Such a wart.
>>
>>55558073
>>55558082
Ok thanks that's helpful.
>>55558102
What is this though?
>>
>>55558062
Yeah, I know, and that's cool and all, but it would be trivial to create an actual user input at that point that is validated and type safe. That would make it so that an error typing real-time in your code doesn't crash the program or cause some other sort of destructive tomfoolery.
>>
On the list of things you never knew you needed:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Recommended for catching common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

#f::
Send, feels good{Enter}
return


feels good
>>
>>55557973
Community college
>>
>>55558102
Was meant for
>>55558082
>>55558073

>>55558114
Like the other anons said, lambdas in C++ construct an anonymous class with state "captured" from the environment you create the lambda in. You can capture by ref, and capture by value, but there's no built-in syntax to copy by move. So, for example, moving a uniqueptr or vector into a closure is more annoying than it needs to be.
>>
>>55558062
Just compile your code as a DLL and load it while you check for changes regularly.
It works well in any situation where I can imagine it makes sense to have hotswappable code.
>>
>>55558093
C++ templates aren't the proper implementation, but they're better than the C answer of "just write it once for each type".

There is no arguing that C++ allows you to offer abstractions that C does not, or that these abstractions are useful. When you don't need them, C is great, when you do, C is the wrong language.
>>
>>55558093

>Do it with macros

I think C++ is an awful language and I vastly prefer C, but implementing generics with preprocessor macros is about as appealing as putting my hand in boiling water...
>>
>>55558125
>Yeah, I know, and that's cool and all, but it would be trivial to create an actual user input at that point that is validated and type safe.
Though, you don't have to create this... This is built right into the environment and is battle tested.

>That would make it so that an error typing real-time in your code doesn't crash the program or cause some other sort of destructive tomfoolery.
Yeah, that kinda sucks when that happens, but that just signals a condition which lets you retry the last thing you screwed up. After you fix it, you are back in business.

>>55558159
Oh? That sounds pretty cumbersome and error prone, but I don't actually know about swapping anything in and out realtime while developing.
>>
>>55558054
>In C++ you can just use a template
in C, you just don't need to cast
>>55558074
>generic hash table in C without using void*
why not use void*? you can use it at will without needing a cast; do you know anything about C?
>>
>>55558236
I don't disagree, but even when you do need them, C++ is again the wrong answer.
>>
>>55555011
>>55555011
Show us what you're working on, faglord
>>
>>55558062

the NEETCUBE
>>
>>55558259
Did it already.
>>
>>55558093
>doubt that you know what you are talking about
I know more than you tho
>>
>>55558266
Yeah. It was from back when we used to have Lisp generals.

I didn't have any compelling webms to show off hotswapping besides that one, so I just used it.
>>
>>55554965
Working on a badass swiss-army reverse engineering tool called PINCE

https://github.com/korcankaraokcu/PINCE

I know I posted this project to here before but I just wanted to share the updates. PINCE now has a disassemble screen with a few cool functionality on it, a GDB Console, complete docstrings(except PINCE.py), initial code injection, settings screen aaand a wiki page

Only 1 year remaining on my schedule. Am I going to make it /g/?
>>
>>55558251
>in C, you just don't need to cast
So you're complaining that type-casting to/from void* isn't done implicitly in C++?
>>
>>55558285
Your posts clearly show that you do not.
>>
>>55558301
There is no implicit typecast.
>>
>>55558249
>pretty cumbersome and error prone
Not all that cumbersome. Depends on how your dll-side code interacts with the outside code.
Was linked earlier in thread too: >>55555141
And that's for code that's intended to interact heavily with the non-dll codebase.
If you have a platform layer of some sort and load all the code you may want to swap as a DLL there's practically no difficulty in this. You pretty much only need two OS features, loading the DLL and getting the/a function pointer(s) from the DLL so you can call it.

Watch out for global variables though. You can fix that but it's harder.
>>
>>55558300
Looks neat mate, keep up the good work
How much fuckery can you commit with PINCE as it stands right now?
>>
File: 6456421.jpg (63 KB, 512x384) Image search: [Google]
6456421.jpg
63 KB, 512x384
>>55558342
That's...really cool actually. I'll have to give it a shot the next time I am working with C.
>>
>>55558301
>So you're complaining
I'm not complaining about anything, do you know how this subreddit works?
>>
File: line_001.png (2 KB, 640x480) Image search: [Google]
line_001.png
2 KB, 640x480
>>55555547
Looks like it works.
>>
is it possible to get a low-level programming job with very basic programming ability?
>>
>>55558302
I clearly showed you don't know C++
>>
>>55558396
You should be specific.
>>
>>55558371
That really has nothing to do with C. It was another thing that Unix took decades to copy from Multics.
>>
>>55558396
...you did not?
>>
>>55558392
Not really. You might be able to bullshit your way in, but you'll be out before long.

Why not practice a bit on a side project or two? (Or contribute to an OSS codebase to see what you are getting yourself into.)

>>55558412
Well, I mean if I were to do it, I would basically treat it like an LD_PRELOAD that only becomes effective during runtime, and I usually write my system libraries using C.
>>
>>55558430
sure did
>>
>>55558442
>Why not practice a bit on a side project or two? (Or contribute to an OSS codebase to see what you are getting yourself into.)
Good point. How much actual experience in terms of hours would a NEET like me need in order to get some shitty entry-level position?
>>
>>55558451
Wrong
>>
>>55558462
No one knows/thinks about it in terms of hours. If you have strong portfolio and relevant domain knowledge, you can let your skills speak for themselves.

What kind of "low level" programming do you want to do?
>>
How much data is being wasted if you make unnecessary line breaks?

 one = 1


two = 2


three = 3



vs

 one = 1
two = 2
three = 3


If I did shit like that all the time.
>>
>>55558499
the only thing being wasted is a few irrelevant fractions of a second for the lexer to discard the whitespace
>>
>>55558499
1-2 bytes per line break, depending on break style, or ~ 0 with compression. No change in compiled code.
>>
>>55558499
One byte per new line, I wouldn't worry about it.
>>
>>55558442
>usually write my system libraries using C
stop lying, you don't even know C
>>
>>55555102
>tries to do everything but ends up doing nothing well

You clearly haven't looked at C++ since the 90s then you fucking retard. Stop regurgitating shit.

C++11/14/17 is amazing and basically reinvented the language.
>>
File: avgint.png (3 MB, 882x782) Image search: [Google]
avgint.png
3 MB, 882x782
PLC program for averaging three 8-bit integers
Thread replies: 255
Thread images: 25

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.