[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


Thread replies: 320
Thread images: 30

File: malloc.jpg (33KB, 674x115px) Image search: [Google] [Yandex] [Bing]
malloc.jpg
33KB, 674x115px
Pointer arithmetic edition

Pointer to the old thread:
>>54579670

Did you implement malloc today /g/?
>>
FIRST4TRAPS!
>>
File: 3ZDU63Q.jpg (744KB, 2000x3000px) Image search: [Google] [Yandex] [Bing]
3ZDU63Q.jpg
744KB, 2000x3000px
cara
>>
>>54585050
static void* mymalloc(size_t size)
{
return malloc(size);
}

static void* myrealloc(void* ptr, size_t new_size)
{
return realloc(ptr, new_size);
}

static void myfree(void* ptr)
{
free(ptr);
}
>>
>>54585050
Post your inverted binary trees

Also am I doing it right? I'm not sure if lonely branches should switch sides or stay the same

# node = {
# left: node or value,
# right: node or value
# }
def reversed_node(node):
if type(node) != dict:
return node

if 'right' not in node:
return {'right': reversed_node(node['left'])}

if 'left' not in node:
return {'left': reversed_node(node['right'])}

return {
'left': reversed_node(node['right']),
'right': reversed_node(node['left'])
}

struct = {
'left': {
'left': 3,
'right': 4
},
'right': {
'right': 5
}
}

print(struct)
print(reversed_node(struct))
>>
File: obanto.jpg (42KB, 401x349px) Image search: [Google] [Yandex] [Bing]
obanto.jpg
42KB, 401x349px
I am looking to see if there is an alternative to SDL that may fit my needs better. I am looking for a simple library to manipulate 2D primitives. Collision detection etc would be nice but I am not looking for a game engine, simply a way to easily manipulate squares.

Thanks
>>
>>54585083
trap thread confirmed

https://www.youtube.com/watch?v=fPoq316yM40
>>
>>54585114
SDL2. It's easy as fuck making games with it, even without the other modules like Image, etc
>>
>>54585114
OPENGL
>>
>>54585114
raw opengl
>>
>>54585113
You don't need either of those if statements
>>
Dubs decides something trivial I can program.
>>
>>54585147
That's true IF I switch lonely branches, which is why I asked the question
>>
>>54585174
program a packer that embeds the stub within the executable
>>
>>54585181
There is no such thing as only having one branch. Just put None where you don't want data
>>
>>54585174
Convert an image to black and white
>>
>>54585200
Ok, then let me rephrase.

That's true IF I switch the branches of nodes where 1 of the node's branches is None
>>
>>54585097
>^=
>bool1 toggles if the above conditions are true
so basically the same as if?
>>
Why are quadtrees so comfy?
>>
>>54585114
SDL is a way to tie into renders and create a screen to render on. If you just wanna do math you need a math library.
>http://wiki.call-cc.org/eggref/4/2d-primitives
>>
>>54585225
Not him, but the hell are you on?

Toggle as in, if it's off, it's on. If it's on, it's off
>>
>>54585270
toggle as in on forever
basically trying to emulate pic related with a button
>>
>>54585309
What?

You want it to toggle, but you want it on forever? But you also want to toggle like a light switch like the guy's solution?

What are you saying?
>>
>>54585224
Why wouldn't you? Also, your tree is shit since only leaves have values
>>
>>54585225
bool1 ^= cond;


is equivalent to

if(cond) {
bool1 = !bool1;
}
>>
File: 7593-2356923[1].jpg (10KB, 249x300px) Image search: [Google] [Yandex] [Bing]
7593-2356923[1].jpg
10KB, 249x300px
>>54585327
I want to make a switch
>>
File: comfy_alists.png (9KB, 356x137px) Image search: [Google] [Yandex] [Bing]
comfy_alists.png
9KB, 356x137px
>>54585228
They're comfy because they're built out of the comfiest combinational data type, the pair. Association lists are also pretty comfy.
>>
>>54585353
That is some of the most obtuse shit I've ever seen
>>
I'm working on a CHIP-8 emulator. I'm running in to a lot of problems though, specifically with rendering. Would anyone have some tips on how to closely emulate 500Hz without using usleep?
>>
>>54585380
>has never seen XOR

Webcucks go this way >>>/g/wdg/
>>
>>54585380
https://en.wikipedia.org/wiki/Exclusive_or#Bitwise_operation

1 xor 1 = 0
1 xor 0 = 1
0 xor 1 = 1
0 xor 0 = 0
>>
>>54585405
Use a loop that keeps going until time elapsed since last clock is >= 1/500 maybe
>>
File: 1453653438419.gif (147KB, 850x613px) Image search: [Google] [Yandex] [Bing]
1453653438419.gif
147KB, 850x613px
>>54585405
What language lad?
>>
>>54585105
>static void* mymalloc(size_t size)
>{
> return malloc(size);
>}

Please stop stealing my intellectual property.
>>
>>54585080
>XOR gate
button = input a and bool = input b
bool = output

fuckin works
>>
>>54585439
>>54585439

Jesus you fags get triggered so easily. Do you retards not know what obtuse means? I know what XOR is, it's just a really retarded way to write that code hiding its purpose. The only thing you gain from writing shit like that is job security.
>>
>>54585449
>use another loop
literally just have a "if (timedelay < whatever) continue;" at top of main loop
>>
What's your favorite encryption algorithm? I like the XOR algorithm
>>
>>54585468
ok oracle
>>
>>54585485
it's readable as hell stupid tard, and don't put if statements where they're not needed >>>/g/wdg
>>
>>54585485
And a quicker program you mongoloid
>>
>>54585485
>it's just a really retarded way to write that code
You'd say that since you've barely programmed, but it makes perfect sense for people who deal with logic gates a lot, which is common in programming

Even intermediate programmers might consider basic graphics programming, or multithreading "obtuse". Guaranteed, you probably would. It isn't actually, obtuse, you're just not accustomed to it
>>
>>54585514
post benchmarks
>>
>>54585405
nanosleep. You could also busysleep yourself by checking CLOCK_MONOTONIC until the appropriate number of nanoseconds ahve past.
>>
>>54585505
>tfw sun is no more
;_;
>>
>>54585485
http://macdevelopertips.com/c/using-xor-to-toggle-an-integer-between-1-and-0.html
>This should have been like day 3 of CS-101.
kys
>>
>>54585453
C++. I think the actual opcodes and such are working spot on, but when I try to render any programs I can only get a few pixels at a time. It's really weird.
>>
>>54585511
>this is what neckbeards actually think

>>54585514
>what are compilers
hahaha you're even more retarded than the other guy

>>54585516
>thinking everyone writes shit code like you do
>>
>>54585539
stay delusional Cshart
>>
>>54585557
Nice counterargument, brogrammer
>>
>>54585539
>thinking everyone writes shit code like you do
Explain how ^= is shit code?

To anyone who wants to toggle, that is what they generally go for. It's pretty much English for 'toggle' after some use.

Just like &= is English for 'mask with'
>>
>>54585566
you suck at programming like the typical C# codemonkey, if you're a beginner it would be acceptable to not know it, but you're just being incredibly arrogant and unwilling to learn
>>
>>54585535
For instance, when I try to load/execute a ROM I'll get something like this that just flashes constantly.
>>
>>54585483
while(true)
{
bool = button ^ bool
}


would this work?
>>
File: chip.png (4KB, 645x351px) Image search: [Google] [Yandex] [Bing]
chip.png
4KB, 645x351px
>>54585590
Forgot image.
>>
>>54585114
Give SFML a look, perfect for your need.

>collsion detection in 2D
What do you mean? This is something you'll have to code
>>
>>54585532
Why not just use x=!x
>>
File: image.jpg (55KB, 674x506px) Image search: [Google] [Yandex] [Bing]
image.jpg
55KB, 674x506px
>>54585190
>>
>>54585606
no it would keep switching back and forth between true and false while you have the button pressed

>>54585625
similar issue as >>54585606
>>
>>54585583
And when you realize you're losing an argument you resort to a endless stream of ad-hominems. There's literally nothing lost by using an if statement and it makes it that much easier to read for someone who hasn't seen that operator before, saving everybody time. But since using fancy operators to do trivial shit makes your dick hard and you'll never actually have a job, by all means keep doing it.
>>
>>54585618
SFML is pretty comfy indeed

Anyone know how the C bindings are? C++ is just a mess.
>>
File: snake fast.gif (36KB, 640x321px) Image search: [Google] [Yandex] [Bing]
snake fast.gif
36KB, 640x321px
>>54585590
Sounds weird. Could be anything. Personally, I experienced flicker when I had shitty rendering algorithms.

After I switched from double-buffering the entire screen to updating ONLY the squares that change, my emulator went smooth no matter what. Otherwise, the more white squares on screen, the more sluggish
>>
>>54585643
>for someone who hasn't seen that operator before
wow you think it's acceptable for a professional programmer to not have seen a FUCKING OPERATOR

even in C# you should know your goddamn operators, it's not that hard

WOW FUCKING KILL YOURSELF
>>
>>54585643
>endless stream of ad-hominems
>you'll never actually have a job

POTTERY
>>
goddamn delusional millennials, instead of blaming your own incompetence on everyone else, just face it, there was something that you hadn't learned yet, but fear not, you can easily learn it if you just dare to try
>>
>>54585662
You seem to have gotten mad over an insifgnificant topic again. Does this happen often? Have you taken your autism pills today?
>>
>>54585643
Don't respond to him. Hostile nocaps MCFUCKING KILLURSELF is some loser who has a shitty customer service job and posts in between customers to pass the time.
>>
>>54585625
With the original guy's question, I believed you needed XOR. If you had 5 buttons
10110

and you pressed the 3rd, you would XOR with
00100

to get
10010


Using ! would change it to
01001

with more leading 1's based on the size of the data storing the button's state. Clearly that's toggling everything which is undesirable.

As you can see, XOR works in all cases, so using ! would seem like a random edgecase
>>
>>54585583
>you suck at programming like the typical C# codemonkey

Java programmers are better, right?
>>
still fucking around in python so when my Wife learns it in September i'll have half a clue whats going on.
>>
>>54585695
>>54585697
you're both fucking pathetic, you're fucking jokes, you're the cancer that is killing /dpt/

this is like the 8th retarded "discussion" just this day

KILL YOURSELVES
>>
>>54585353
while(true)
{
if ((button != buttonPrev) & button;)
{
bool1 = !bool1;
}
buttonPrev1 = button1;
}


So this would work?
>>
>>54585643
>who hasn't seen that operator before
Not everyone who gets into programming instantly knows every operator. Doesn't mean you should rely on just arithmetic or whatever other restriction you want
>>
>>54585694
>goddamn delusional millennials, instead of blaming your own incompetence on everyone else
that's what teenagers do, not people in their mid-thirties
>>
File: bird.png (31KB, 581x556px) Image search: [Google] [Yandex] [Bing]
bird.png
31KB, 581x556px
>watch all these videos about new C++ standards and features
>oh that's some cool stuff
>go to look at syntax and more in depth examples
>nope.avi
>>
>>54585721
sure, unless button can be for example 2, then you should have & (button != 0) instead of & button

and drop the semicolon inside the if statement conditional
>>
File: 1463120642088.jpg (220KB, 1496x1264px) Image search: [Google] [Yandex] [Bing]
1463120642088.jpg
220KB, 1496x1264px
class Laskin {
static void laske(String[] input) {
int tulos = Integer.parseInt(input[0]);
for (int i = 0; i < input.length; i++) {
if (i % 2 != 0) {
if (input[i] != "+") {
tulos = tulos + Integer.parseInt(input[i+1]);
}
else {
tulos = tulos - Integer.parseInt(input[i+1]);
}
}
}
System.out.print("Laskun ");
for (int i = 0; i < input.length; i++) {
if (i > 0) {
System.out.print(" ");
}
System.out.print(input[i]);
}
System.out.print(" tulos on " + tulos);
}
}


Here is my attempt at a terrible java plus minus-calculator (input from main is args, so its {1, +, 2, -, 3} or so). The part where they are either added up or substracted from the current "int tulos" is all substracted.
Why isn't my "if (input[i] != "+")" working?
>>
>>54585747
I'll tulos your laskin
>>
>>54585721
>if ((button != buttonPrev) & button;)
>{
> bool1 = !bool1;
>}
This will only toggle bool1 IF button is on

& is bitwise AND
&& is boolean AND

If button is off, and you toggle it, you'd get
((button != buttonPrev) & button)
(0 != 1) & 0
0 & 0
0

which resolves to false
>>
>>54585789
that's the point, you press it like a switch and it stays on, you press it again and it turns off
>>
>>54585801
If it is off, and you turn it on, that condition resolves to false and
bool1 = !bool1

is never called. Your button never toggles
>>
>>54585816
wrong
>>
>>54585643
I applaud your trolling efforts. You've gotten quite a few (you)s.
>>
>>54585827
i think he might be serious, i think he's one of those sub-105 IQ C# normies that should fuck off to stackoverflow
>>
File: snake_faster.gif (36KB, 640x321px) Image search: [Google] [Yandex] [Bing]
snake_faster.gif
36KB, 640x321px
>>54585650
we have to go faster
>>
>>54585743
>what kind of syntax do you want?
>JUST

auto start = std::chrono::high_resolution_clock::now();
// ...
auto diff = std::chrono::duration<double>(std::chrono::high_resolution_clock::now() - start).count();
>>
>>54585838
what's wrong with having an average IQ? we gotta exist for you 140s to exist too
>>
>>54585825
You're right, it's the other way around, it only toggles when you turn it on. Consider button being either 0 or 1 (currently on or off) and buttonPrev being either 0 or 1 (previously on or off due to the last line of code)

button buttonPrev button != buttonPrev (x) x & button
0 0 0 0
0 1 1 0
1 0 1 1
1 1 0 0


The condition that calls
bool1 = !bool1

is only 1 (that last column) when your button is previously off, but is now on in this step.
>>
>>54585881
nothing wrong with it, but how fucking arrogant do you have to be to think you're a qualified professional programmer when you don't even know XOR, and to think that no one else is allowed to use such a core feature just because you're unable to understand it instantly with no effort. he's not even trying to learn and he's seemingly not even entertaining the possibility that he's not the best programmer in the world. just pisses me off with these idiotic "discussions" that we have several times a day in /dpt/
>>
>>54585838
>, i think he's one of those sub-105 IQ C# normies that should fuck off to stackoverflow

But what about the sub-90 IQ Java users that inhabit this thread on a daily basis?
>>
>>54585907
it's like a light switch, you only want the light to turn on or off when you hit the switch, otherwise you don't want anything to change

>>54585934
i'm literally the smartest person in /dpt/
>>
>>54585922
give him a break man, while you're a really intelligent guy he's not that smart so he doesn't see things the way you do.
>>
>>54585950
>i'm literally the smartest person in /dpt/

lmao k java tard
>>
>>54585934
Java is better than C++. And /dpt/ isn't hostile to C++tards. So does that make C++tards sub-75?

t. Ctard.
>>
>>54585980
you're right maybe i went a bit too hard on him but this is 4chan after all :^)
>>
>>54585950
>it's like a light switch, you only want the light to turn on or off when you hit the switch
As you can see from that table, nothing changes when the button is not touched and when button is 0, but buttonPrev is 1 (previously on, but now switched off)
buttonPrev => 1
button => 0
button != buttonPrev => 1 (true)
(button != buttonPrev) & button => 1 & button => 0

The condition doesn't evaluate to true, so like with the other conditions, nothing changes

So no, your solution is not equivalent to what you want.
>>
>>54585997
>Java is better than C++

I don't know about that, chief.
>>
>>54585789
okay let's start from the beginning
when I press it
buttonprev currently = 0
(1 != 0)
and the button is being pressed so
(1 != 0) and button == 1
everything is aight so it does the if
bool1 = !bool1
bool1 has now changed from 0 to 1 bool1 = 1

outside of the if it runs the next line
buttonPrev1 = button1;
so buttonprev1 = 1

now let's keep pressing it and loop back

((button1 != buttonPrev1) & button1 == 1)
(1 != 1) & button == 1)
1 = 1 so it doesn't do the if

if we're not pressing the button then 1 !=1 but button1 != 1
so the if doesn't run
then
buttonprev = button1
buttonprev now = 0

now let's loop back with buttonprev = 0 and button = 0
0 != 0 & button == 0
doesn't run the if


Hope you were able to follow this
>>
>>54586048
Why isn't C++ used for <almost every enterprise, business-critical codebase>?

Check and mate, tripcuck
>>
>>54585114
SDL2 sounds perfect for that job.
>>
>>54586038
you press the switch. the light turns on. you stop pressing the switch. the light stays on. you don't want it to change when button=0 and buttonPrev=1

>>54586064
so it works the way you want, right?
>>
>>54586068
><almost every enterprise, business-critical codebase>
citation boys
>>
>>54586068
>Why isn't C++ used for <almost every enterprise, business-critical codebase>?
Why isn't Java used for <any Operating System>?
>>
>>54586106
>so it works the way you want, right?
yes


thanks anon ;3
>>
>>54586064
So per your 1st paragraph,you've confirmed it only does the if, if you are turning it on, but per your other paragraphs, it doesn't affect the if

So you only want to toggle bool1 if you turn it on? But not when you want to turn it off? That's exactly what I was saying, looking at the table, you are only reaffirming what I've shown. If you're certain that's what you want, go ahead
>>
>>54586113
Why isn't C++ used for <any Operating System>?

Oh wait because the retards on the standards committee were too busy sucking each other's dicks and adding redundant functionality to standardize name mangling.
>>
>>54586152
>Why isn't C++ used for <any Operating System>?

It's use for Wandows, though.
>>
>>54585747
if (!input[i].equals("+")) 
>>
>>54586175
Is it really? Wangdows applications only work with one compiler?

Coulda sworn the low level libraries like win32api were written in C.
>>
>tfw you find the shortest path in a graph in linear time.
>>
>>54586209
C, by definition and standard, is portable, it doesn't mean the low-level binary data you're reading from is going to be present in every OS, and win32api specifically talks to data that is windows-only
>>
Also in C is int 32 bit?

And If I want a signed int to become negative i do (1 << 31) ?
>>
>>54586245
nice meme
>>
im trying to learn python
for i in xrange(0, len(cuck)):
cuck[i].replace("('", "").replace("', '\n')", "")


cuck is an array/list(?) of strings
how come this doesn't work?
>>
>>54586280
post one example of cuck
inb4 me
inb4 op
>>
>>54586311
pattern = re.compile(regex)
cuck = re.findall(pattern, html)
cuck = str(cuck)


and

>>54586311
>>
>>54585641
if button=pressed:
if bool=false
bool=true
else
bool=false

and you can have some sort of switch which only does it once per press
>>
>>54586280
Python is for cucks
>>
>>54586280
Shouldn't it be
cuck[i].replace("('", "").replace("', '\n')
>>
>>54586259
int is a nonstandardized side. You can find out its size in bytes with sizeof(int). On most systems it's 32 bits but if you really wanna be sure include inttypes.h and use int32_t

Make signed int negative like this: -1 * i. Don't overthink it maaan.

>>54586247
No what I mean is so there's name-mangling in c++ so
int foo(int i)

gets mangled to a name of zfooz or ifooi or z_foo_z or int32_tfooint32_t depending on your compiler. This is bad for OS's since it means everything (including userspace) has to be compiled with the same compiler otherwise the binaries won't link.
>>
>>54586373
wow nvm, what are you doing senpai

cuck[i].replace("(", "").replace("", "\n")


don't mix " and '
>>
>>54586341
findall returns a list iirc, which in str form is [ not (
>>
>>54586280
it does work, you just aren't printing cuck

and if that doesn't work try this:

split it to an actuaal array
then do this:

i=0
for elements in arr:
array[i]=elements.replace('penis'),('cuck')
i+=1

ids not that complicated
>>
>>54586390
Not him, but that is not equivalent.

Also it's perfectly fine to mix " and ' in python. His code was legal and will work as it's shown
>>
>>54586409
oh so python is a meme then

jk, but why
>>
If I need to pass data between different classes, how should I do it? Should I have them all send it via an "overseer" class or have some kind of seperate event handler that knows about all the instantiated classes and recieves and sends data from/to them? I assume it's bad practice to have classes all knowing about and interacting with each other?

This is in the context of a GUI application with a lot of sub-windows and frames that are all seperate classes.
>>
>>54586420
>jk, but why
The string begins with ", it must be closed with "

' inside it is just a normal character as " is not '. I don't think there are many languages that do some weird voodoo nested quotes shit, it just doesn't make sense
>>
>>54586425
serialization
>>
>>54586425
a statics class

this is literally what they were made for
>>
>>54586425
In that situation you would in your event handler call a function that gets data from one class and passes it to another.
>>
>>54586441
that's what i mean tho, on the second replace he does " and then ', wouldn't that leave it open and throw an error?
>>
>>54586465
" is not '
>>
>>54586476
ah shit, i missed the second quote, thought he opened the second replace quote and then tried to end it with '

fucked with my head
>>
>>54586448

As in, a class where you don't have to have a specific instance of it running to use methods from it? How does it help in that context?
>>
FUCKING TUPLE SHIT PYTHON
REEEEEEEEEEEEEEEEEEEEE
>>
>>54586540
>>python
>>
>>54586540
why don't you code like a pythonista ?
>>
>>54586533
well you can only access static variables across classes, yes?

You make a class that has something like

static final int prevClass="";

then every time you want to update that from any function you can do that, then call it from another one.
Unless you're talking about sending arrays or something, which is harder.

statics classes usually have static functions too though yes
>>
File: ifelikerobot.jpg (35KB, 615x410px) Image search: [Google] [Yandex] [Bing]
ifelikerobot.jpg
35KB, 615x410px
who /clojure/ here
post some sample code in it
ideas:
implement a tree with infinite child nodes and a function to invert such a tree

recursive length function with constant space usage
e. g. strict

or linear fibonacci

I just want to see the syntax

anyone welcome to do the above in any FP lang or lisp
>>
>>54586599

I admit I'm using Python which doesn't seem to have these "static" concepts as far as I know, but now everyone will laugh at me for using le meme snek language
>>
File: dunno.png (28KB, 779x853px) Image search: [Google] [Yandex] [Bing]
dunno.png
28KB, 779x853px
Sorry, I'm really retarded when it comes to arrays and pointers... Can someone tell me what I'm doing wrong? (errors n shit)

TL;DR I want to convert a word into its morse code equivalent by concatenating a new string with the morse.
>>
>>54586621
>recursive length function with constant space usage
(define (length lst)
(define (iter lst acc)
(if (null? lst)
acc
(iter (cdr lst) (+ acc 1))))
(iter lst 0))
>>
>>54586695
couldn't u pick a more cancerous theme
>>
>>54586730
What is default for 500, Alex?
>>
>>54586743
default neckbeard theme
>>
>>54586743
Not him but the blue is unreadable. I'd totally choose a different color scheme for my terminal. I use Gnome's Tango color scheme.
>>
>>54586726

not going to lie, the syntax is real hot

which lisp is this
>>
>>54586800
>the blue is unreadable
this
>>
>>54586695
here my friend https://raw.githubusercontent.com/wrvc/etc/master/str2morse.c

im not a good code artisan but you might get some ideas
>>
File: kawaii.jpg (12KB, 320x320px) Image search: [Google] [Yandex] [Bing]
kawaii.jpg
12KB, 320x320px
>>54586185
Looked more into equals and compareTo, thanks /dpt/bro.
>>
>>54586826
Scheme.
>>
>>54586800
>>54586835
The blue is commented out.. don't worry about reading that...
>>
>>54586695
The whole program is one giant cluster fuck.

But as a starting point, rewrite char morse[26][5] as char* morse[26]
>>
>>54586872
>edit
>profile preferences
>colors
>palette
>built-in schemes
>select tango
Boom done.
>>
hey /dpt/, how does it feel knowing those so-called pajeets of yours are able to replace you so easily because they
>are better programmers
>willing to work for less
>don't act like a smug assholes towards thier coworkers
>literally have better hygiene than your pimply asses
>>
>>54586996
>better hygiene
>literally shit in the street wipe their ass with their bare hand
>>
>>54585838
>i think he might be serious, i think he's one of those sub-105 IQ
>normies
I can guarantee you aren't as smart as you think you are.
>>
>>54587072
>IQ average is 100, including all niggers in the world.
Clearly smarter than you.
>>
File: 3LVJldM.gif (575KB, 500x234px) Image search: [Google] [Yandex] [Bing]
3LVJldM.gif
575KB, 500x234px
>get hired
>"we're having problem with times and dates"
>project uses it's own timestamp thing
>sql date/time functions rendered useless
>time/date filtering/sorting done within the application most of the time
>int64_t everywhere, timestamp variable naming not consistent
>>
File: lol1.gif (11KB, 155x202px) Image search: [Google] [Yandex] [Bing]
lol1.gif
11KB, 155x202px
>>54587210
>>
File: atomica.png (78KB, 499x798px) Image search: [Google] [Yandex] [Bing]
atomica.png
78KB, 499x798px
Cleaned up UI more and improved stability. Finally have free time to fix it up more after 23 fucking credit semester is done.

Next feature is to have resizability and scaling with it, mostly to see the artists that have really long track/artist/album names.
It will be such a bitch to implement in Tkinter though, i'm thinking about abandoning it all together for PyQt 4. So lazy though.

Any suggestions?
>>
What the fuck am I supposed to do when I can't break changes down to smaller commits without breaking the build?

There are 210 files in this project, about 8000 loc. My change affects about 160 of them.
>>
How did I fuck up this time senpai-tachi?

Log *log_init(const char *name) {
Log *self = malloc_s(sizeof(Log));
self->first = calloc_s(1, sizeof(Entry));
self->last = self->first;
self->name = strdup(name);

return self;
}

void log_push(Log *self, const char *text) {
Entry *entry;

if (!self->first->text) {
entry = self->first;
} else {
entry = calloc_s(1, sizeof(Entry));
entry->prev = self->last;
entry->prev->next = entry;
entry->prev->prev = self->last->prev;
}

self->last = entry;
entry->text = strdup(text);
}

char *log_name(const Log *self) {
return self->name;
}

char *log_list(const Log *self, const int newln) {
Entry *tmp = self->first;
char *ret = strcat(strdup(tmp->text), newln ? "\n" : "");

while (tmp->next) {
tmp = tmp->next;
size_t size = (strlen(ret) + (strlen(tmp->text) + (newln ? 1 : 0)));

if (size >= (strlen(ret) * 4))
ret = realloc_s(ret, size / 4);
else
ret = realloc_s(ret, size * 2);

ret = strcat(strcat(ret, tmp->text), (newln ? "\n" : ""));
}

return ret;
}

void log_free(Log *self) {
while (self->last->prev) {
self->last = self->last->prev;
free(self->last->next->text);
free(self->last->next);
}

free(self->last->text);
free(self->last);
free(self->name);
free(self);
}


void *j9_realloc(const char *fname, const int lineno, const char *fxname, void *ptr, size_t new_size) {
ptr = realloc(ptr, new_size);

if (!ptr) {
fprintf(stderr, "CRITICAL ERROR: realloc failure in (%s)::%s::%i\n", fname, fxname, lineno);
exit(EXIT_FAILURE);
}

return ptr;
}

char *strdup(const char *src) {
char *ptr = malloc_s(strlen(src) + 1);
return strcpy(ptr, src);
}
>>
>>54587275
Python users
They never learn
They never
Learn
Beyond the point
When their desktop burns
When their faggy desktop
Burns
>>
>>54587595
Can someone translate this to non-autistic for me?
>>
>>54587615
https://www.youtube.com/watch?v=TTAU7lLDZYU
>>
>>54587615
the anon doesn't like python and instead of saying anything constructive they are shitposting.
>>
Hello, World!
[\code]
>>
File: 1453261446276.jpg (35KB, 200x200px) Image search: [Google] [Yandex] [Bing]
1453261446276.jpg
35KB, 200x200px
>>54587645
Haha holy shit.
>>
I'm working on a C# project for my class and it's done, but I wanted to fix a small problem I had with it.
It won't affect my grade, but I still want to figure out the problem because it's driving me nuts.

Basically, I'm trying to have people search for a book title, I got it to work, but it's case sensitive.
How can I make it case insensitive?

Here's my Program.cs code as a reference, I'm not going to include my other class tab.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test3
{
public class Program
{
public static void Main(string[] args)
{
Books book1 = new Books("1111111111111", "Of Mice and Men", "John Steinbeck", 111 , "Realistic Fiction");
Books book2 = new Books("2222222222222", "The Catcher in the Rye", "J. D. Salinger", 222 , "Realistic Fiction");
Books book3 = new Books("3333333333333", "The Lord Of the Rings", "J. R. R. Tolkien", 333 , "High Fantasy/Adventure");

string response = "go";

while (response != "stop")
{
Console.WriteLine("Search for a book by title, press 'Enter' to show all books, or input 'stop' to stop searching.");
response = Console.ReadLine();
Console.WriteLine();

if(book1.Title.Contains(response))
{
Console.WriteLine("ISBN: {0} \n" +
"Title: {1} \n" +
"Author: {2} \n" +
"Page Count {3} \n" +
"Genre: {4}",
book1.ISBN, book1.Title, book1.Author, book1.PageCount, book1.Genre);
Console.WriteLine();
}
}
}
}
}
>>
>>54587798

Googled "C# Contains insensitive" and found: http://stackoverflow.com/a/17563994/653076
>>
>>54585104
Cara :D
>>
Only two mainstream languages allow users to create their own operators

Perl is the most rapidly disappearing language in the industry and Swift employment is crazily unstable and it doesn't work on PC
>>
>>54587835
I did that and tried that one and it didn't work. I was hoping for an easier solution. :(
>>
>>54587850
>Only two mainstream languages allow users to create their own operators
>choosing my own definition of mainstream language to fit the argument
>>
>>54587857
What was the issue? Were there any errors?

You can try the other answer in there as well:

if (book1.Title.IndexOf(response, StringComparison.OrdinalIgnoreCase) >=0) {
Console.WriteLine()
}
>>
>>54587882
name another language that does. Don't include languages that only allow you to overload operators like C++ or C#
>>
>>54587907
Looks like F# does, dunno if I'd call that mainstream though.

>>54587882
I am not this guy
>>
>>54586375
>use int32_t
not portable
>>
>>54587275
>23 credit semester
What the fuck anon. You idiot.

>>54587850
Position of a function call doesn't change jack shit about it.
>>
File: Capture.jpg (28KB, 581x294px) Image search: [Google] [Yandex] [Bing]
Capture.jpg
28KB, 581x294px
Explain working out pls
>>
>>54588019
>portable data type
>not portable
Maybe not portable on compilers that lack c99 mode. Luckily I've never had to work on satellites from the 70's with closed source compilers.
>>
>>54588038
operators make it quicker and more intuitive to express certain functions, especially mathematical ones

for example |x| instead of abs(x) or 2i instead of new Complex(0, 2)
>>
>>54587888
That one worked perfectly, thank you so much!

Do you know why there's a ">=0" after the closing parenthesis?
I tried using it without that and it didn't work, but it did once I put it in, I wasn't sure what it was referring to.
>>
>>54588077
He's probably referring to the fact that (u)intN_t, isn't guaranteed to exist.
>>
>>54588047
jesus christ man have you even tried yet? can you follow up with what you think it is and why so that your reasoning can be corrected instead of fed to you?
>>
>>54585777
zee treeps, zey do not lie
>>
>>54587907
off the top of my head?
Scala
Haskell
Racket/Scheme

probably countless more in the languages I'm not as familiar with
>>
>>54588130
Haskell and Scala are on the chart, but as you can see they really aren't all that popular
>>
>>54588098

IndexOf returns an integer of the index where it found the string you are looking for - if its greater than or equal to zero, it means the string was found inside your book title, if it returns anything less than 0 (e.g. -1) it means it wasn't found.

>=0 is the conditional that will be resolved on the if statement (true or false - it was either found or not)
>>
>>54588096
>|x|
>quickly and intuitively processing certain functions
Top kek. So is |x| absolute value, 1-norm, euclidean norm, 3-norm or infinity norm? Guess I have to check the documentation.

>>54588130
This guy wouldn't count Scheme because everything's prefix and requires parentheses.
>>
>>54587798
if(book1.Title.ToLower.Contains(response.ToLower))
>>
>>54588213
>>54588098

this also works by obviously putting both the strings to lower case before comparing them, I would actually recommend going this way as it makes more sense at a glance.
>>
>>54588038
>23 credit semester
>What the fuck anon. You idiot.

Yeah well I fucked up a little early on so I had to.
I actually did pretty fucking good too, 3.5 GPA, skipped every lecture in two of the classes though.

Also won first in project competition. Stimulants are something else boys.
>>
>>54588199
Why can't it be all of them?

The only argument I've heard against operator overloading that sort of holds water is that, in contrast to "normal" functions, operators are expected to have algebraic properties.

As long as you ensure that, there's no issue.
>>
>>54588199
>>54588294
Well, I suppose while you can only have one instance of the norm for scalars, there are (infinitely) many possibilities for anything higher-dimensional. But those are already disambiguated in ordinary notation, so they would be anyways in the code.

You could have a generic norm that takes a function computing the norm as a subscript, where the norm part just talks about the algebraic properties.
>>
File: Capture.png (83KB, 1361x711px) Image search: [Google] [Yandex] [Bing]
Capture.png
83KB, 1361x711px
>>54588294
Was going through a tutorial and it said that including the gdi32 library was necessary. But I don't think I even have a library called gdi32 first of all, and secondly how would I know that unless it was told to me? It doesn't seem evident in my code or the errors at all (which just reference the first library).

So my question is how do you debug such things? How do you figure out which flags you need to compile properly if it's not self-evident in the code?
>>
>>54588487
shit didn't mean to reply to >>54588294
>>
>>54588077
>I'm a faggot that doesn't know C
>>
>>54588294
All the various norms take the exact same input though. Operator overloading doesn't apply.
>>
>>54586375
>-1 * i
>not just -i
>>
can an anon give me any tips on how to tackle algorithm based problems. I've been working on some things on hackerrank (coding site with project euler type problems and more) and it takes me around three hours to finish 1 single problem that's labeled easy. idk what to do it feels like i'm getting nowhere.
>>
>>54588524
try to practice loops inside loops

also write out initial values for all the variables and try to step through what needs to happen to them, sometimes that helps
>>
>>54588515
See >>54588424.

I suppose the biggest limitation is that there aren't any languages that transcend plain ASCII (and sometimes Unicode) text for syntax. So operators are very limited.

Except Epigram. Epigram is neat.
>>
>do first exercise set in SICP, flip to back
>no solutions anywhere in the book
>>
>>54588594
the solutions must come from within
>>
>>54588555
Does perl have the ability to define a ||x||_2 operator?

In the end I think trying to write code that looks like math symbols is a horrible pursuit. Things that are procedures should be look like procedures.

Math's syntax isn't something to be admired; it's pretty fucking awful and nonstandard and that's why every math paper has a long introduction defining the syntax.
>>
>>54588594
I love old technical books.
No easy outs, no answers in the back of the book, no 1000 pages of man pages to make the book look more impressive on store shelves.
>>
C#
I have a textfile with a bunch of email addresses that I want to split into usernames and domains then send to a textbox. Ive figured out how to do this with one address but when i try multiple it always fucks up somehow. halp pls.
>>
>>54588594
there are a shitload online
>>
>>54588636
Split up the file by "\n" characters or whitespace or whatever and then apply your one address function to each smaller string.
>>
>>54588550
alright thanks i'll do that. and also now that you mention it a huge chunk of my problems happen because i forget to initializing my variables.
>>
>>54588614
>Things that are procedures should be look like procedures.
Yes, but norm is a function, and it has algebraic properties.

>Math's syntax isn't something to be admired; it's pretty fucking awful and nonstandard and that's why every math paper has a long introduction defining the syntax.
Same for code. Every language and library has different conventions. You can't solve this problem.
>>
>>54588179
Oh, okay. I haven't learned stuff like that, yet.
This is my first programming class.

Thanks, again!
>>
>>54588240
I was going to do that, but I also need to print a result and then it would print in all lowercase, which I don't want.
>>
>>54588240
this
>>
>>54588692
What? Just keep around the capitalized name and only use the lowercase version to check against.
>>
>>54588664
Algebraic properties can be used for procedures. Algebra is not solely defined in terms of the syntax taught in high school.

Here's the distributive law in Scheme's syntax:
(* (+ a b) c)
-->
(+ (* a c) (* b c))


I disagree about the bit of code syntax being awful. Math syntax is awful. C++ syntax is awful. Languages which try to emulate math syntax are awful. But there exists languages with good syntax, like Scheme.

Fuck math syntax.
t. Mathematician
>>
>>54588692
using ToLower only makes a copy in lowercase, the original is still there.
>>
>>54588640
i don't have internet on my laptop bc i fell for the linux meme, and that's where my set up is at
>>
Writing a chrome extension to quickly bookmark stack overflow questions that you come back to a lot, or answers that you find useful

Suggestions?
>>
>>54588753
don't
>>
>>54588753
Why is that necessary? Can't you just press the bookmark button?

I guess if it automatically bookmarks shit for you based on how often you frequent pages, it should apply to more than just stackoverflow.
>>
>>54585405
Use frame timers
>>
>>54588780
Well, you can bookmark the page yes, but the plugin would organize these questions / answers.

I guess you could just organize your bookmark folders, but my thing is this: I have a few stack overflow questions bookmarked for syntax shit I always screw up on, but I hate having to go through all that clicky clicky.

It would be cool if I had an interface that just showed a question, and the answer I want.
>>
>>54588713
If you're going to call everything a procedure and then declare that there is a god-given way to write procedures, you're not saying much.

And I understand that, but all I brought up algebra for was to address the common gripe about operator overloading. The mentality that "symbols mean math therefore algebra" is quite prevalent, and it sort of makes sense because it's how you can quickly interpret expressions like x+y*z.

I personally don't like to distinguish between "functions" and "operators" either, but I also don't want to limit it to prefix notation because that adds a lot of verbosity. Mixfix in plain text can be too ambiguous, so I want a language that can look like Epigram.
>>
What's the largest Python project you've worked on?
>>
>>54588594
GitHub has nerds posting their solutions
>>
>>54588812

Meh, I am spending a good amount of time just to do away with 2-3 extra clicks.

>>54588780
But wouldn't that be just as frustrating? I know I'm not the only developer who has that one command / language idiom that he always forgets.

I have to check the syntax for svn changelist every time I'm about to commit a changelist. No idea why, it just wont stick in my head for some reason.

I could take a screen shot of the stack overflow question / answer for quick visual grepping.

I could bookmark the page, but that's annoying.

I guess the autist in me is calling. It's my first side project for something this insignificant, but it truly irks me when I have to go to stack overflow for a question that I check every 2 days
>>
>>54588821
I'm not saying that Scheme is the only way to write. I'm saying I like Scheme's syntax.

In fact I'm saying that the typical math syntax is not the only way to write. I only offered Scheme's syntax as an alternative.

Anyways is that image epigram? What exactly does that do?
>>
>>54588836
My manga scrapper
Gets the latest release based on your search term and saves the images to disk for later viewing
>>
>>54588862
Epigram is basically proto-Idris but he dropped the LaTeX syntax.
>>
File: 1461549226989.jpg (106KB, 960x731px) Image search: [Google] [Yandex] [Bing]
1461549226989.jpg
106KB, 960x731px
>learn about unification
>really tedious and ugly to implement
>can't not do it because I know how amazing it is
>>
>>54588594
Just like life
>>
I'm a 20 year old web developer with no college experience

I started coding at a fairly young age, taught myself very basic OOP and spent about 6 years watching youtube tutorials and making unfishished github projects every 2 weeks
I went to a tech bootcamp for credibility

I'm 2x as good as any of my co-workers, what the fuck gives?

Did they teach you guys anything useful at all in college?

Also, what would I learn from 'Programming Paradigm' or 'Programming Theory' classes?

I have actual experience developing with modularity in mind. My first attempts at big projects became clusterfucks of huge monolithic files. So I learned the hard way.


Is there anything I'm missing /g/? I want to get out of web development and into machine learning / computer security as quickly as possible, what skills do recruiters in this field look for?
>>
>>54588903
What do you mean by unification?

>>54588836
Scheduling tool that I gave up on because I decided I hated python.
>>
File: 1353024259184.png (217KB, 480x480px) Image search: [Google] [Yandex] [Bing]
1353024259184.png
217KB, 480x480px
>>54588924
>he doesn't know unification
>>
>>54588924
As part of elaborating a program from its high-level representation to a core (but more verbose) representation. Elaborating produces a bunch of holes, which unification fills.
>>
>>54588903

I implemented the unification algorithm in Haskell, I would recommend, was a lot of fun.
>>
>>54588991
Which one? I'm probably just going to stick with higher-order patterns for the juicy decidability.
>>
>When the F12 key is pressed and the application in focus is being debugged, Windows NT calls a function similar to DebugBreak(), which executes a hard coded breakpoint instruction. The integrated debugger then traps the exception generated by this instruction

Fucking windows
>>
>>54585050
I implemented malloc last week.
Features:
>alloc and dealloc are usually O(1) if you dealloc in reverse order that you alloc
>simple, less than 200 LOC
http://pastebin.com/Jz8Hzzsu
>>
>>54589014
https://en.wikipedia.org/wiki/Unification_%28computer_science%29#A_unification_algorithm
>>
>>54588711
>>54588722
Ohhh, I didn't know that.
>>
File: 1377580166133.jpg (83KB, 406x263px) Image search: [Google] [Yandex] [Bing]
1377580166133.jpg
83KB, 406x263px
/dpt/ I have a dumb question on pointers since this thread is pointer themed.

Should I always use a pointer to a type instead of the type itself if I am passing it around a lot but never modifying it? Is there any reason not to do this? Copying large amounts of data for each pass seems like a big waste of time and memory if I'm just going to be reading values from a struct.
>>
>>54589094
pass-by-const-reference exist
>>
>>54589094
It saves the cost of the copy, but it adds the cost of dereferencing the pointer.
>>
>>54589094
It depends on how large the object is. A pointer on a typical computer is 64 bits.
>>
>>54589094
>>54589117
Maybe I shouldn't say the cost of dereferencing, rather an extra layer of pointer indirection in general.
>>
Since the AI general isn't up, can anyone here recommend starting points for educating myself on things such as Artificial Intelligence and Machine Learning? I have some free time now so I feel like learning something new.
>>
>>54589113
The particular thing I'm working on isn't in C++.

>>54589117
>>54589159
So that's strictly a logical concern for the programmer and not the program itself right? Derfeferencing should always be less instructions than a typical copy/pass, is that right?

>>54589146
So as long as the type in question is larger than the length of an address it would be better to use a reference instead of a copy if I can, right?
>>
>>54589094
L1 cache is 64 bytes. If the copy of all the data you're passing around can fit in there then don't do it.
>>
>>54589214
Instruction count is basically irrelevant to the actual cost.

There's no hard-and-fast rule that says whether to use one or the other. It's more of an issue in C++ than C because in C++ an implicit copy can incur more than just a memcpy, which can trip beginners up.

Basically, it probably won't affect the performance enough for you to care, and if it does, just profile both and pick whichever is empirically better.
>>
>>54589214
>So as long as the type in question is larger than the length of an address it would be better to use a reference instead of a copy if I can, right?
greater than double the size of a pointer, since a pointer to something would be pointer size (64 bits) + the struct size in memory. If the struct is 2 integers there's no point.
>>
>>54589214
>Derfeferencing should always be less instructions than a typical copy/pass, is that right?
Take this into account:
1) when you take a reference, you are passing around 4 bytes of memory.
2) Dereferencing adds additional instructions EVERY TIME you dereference, while copying only happens once.
3) Premature-optimization is the root of all evil. If you're losing sleep over it, then make a rule of thumb, e.g. "if it's larger than 12 bytes, use a reference" or even "always use a reference for structs".
>>
>>54585050
I will just stick to using new :^)
>>
>>54589247
Got it, I'll look into running some tests to get some statistics on it later. Thanks. Thinking of the life of the struct is what made me concerned, it's a big struct and gets passed around a lot so having a lot of copies seemed bad when the data isn't going to change after the initial assignment.

>>54589268
Good to know, thanks. I'm mostly concerned about instilling good practices while I'm still learning than I am concerned about optimizing, if I can implement it in a preffered way the first time without hassle I'll be happy with that. Like if I have no reason not to use references here then I'll write it that way first so I don't need to change it later.

>>54589252
Got it, thanks.
>>
>>54589367
You should really switch to C++.
There are some nice things, for instance implicit references make it so that if you decide to switch from references to copies, the syntax used in all of the calls stays the same, only the function signature needs to be changed.
>>
>>54588836
https://github.com/AlDanial/cloc
use this instead
>>
>>54589398
I've considered learning it but haven't had the need to yet. It's probably going to be the next language I look at regardless though unless something I'm required to learn pops up. It's too big to ignore.
>>
>>54589398
>suggesting someone switch to C++
It's trash. The syntax of C++ is actually undecidable. C++'s standard library is a piece of trash. C++'s binaries have awful interoperability. C++ isn't as well supported as C. C++ compilers are shit.
>>
>>54588199
anon, custom operators are only allowed in languages that have some level of static typing and allow multiple versions of functions with different args. You can define it for all cases, whether it be complex numbers, quaternions or determinants. Of course, only perl uses circumfix operators so the abs case is out

>>54588294
they need not be algebraic. for example, you could have an in/contains operator that returns true if value n is in list/dict L
>>
>>54589398
>>54589460
Yep, I would definitely suggest going to something like Rust over C++ if you want a similar level of control.
>>
>>54589460
>C's is arguable worse
>If you need the compatibility of the millions of C compilers, then I definitely suggest C, but you most likely don't.
>C++ compilers are largely the same thing as the C compilers.

I could also suggest Rust but /dpt/ has an non-objective hatred towards that language.
>>
>>54588487
bump
!
>>
>>54587850
>correlation
>causation
Nice meme though.
>>
>>54589042
Inb4, some anon's 200 LOC paste is objectively better than GNU malloc
>>
>>54589528
I wasn't implying anything. I'm frustrated that such a powerful feature is being underutilized
>>
>>54589510
>I could also suggest Rust but /dpt/ has an non-objective hatred towards that language.
>go to print hello world
>compiler get's triggered and shuts down computer for safety
>>
File: galong.jpg (70KB, 960x1280px) Image search: [Google] [Yandex] [Bing]
galong.jpg
70KB, 960x1280px
>>54589488
>>54589510
I didn't want to mention it earlier but I'm actually using Go most of the time, /g/ seems to really hate Go. It's the language I learned after C, I made the decision to learn Go instead of D and Rust but I still consider going back and looking at those too. People are suggesting Rust more and more, I think the reason I opted for Go was that D and Rust were not stable yet, or something, I forget, maybe it was lack of documentation.

There are some features of C++ that I know about and seem helpful though. I don't want to spend all my time learning languages but there's no better way to decide if a language is fitting for your uses unless you at least skim the featurset and syntax.
>>
What is the point of hating a language for completely invented reasons?
>>
>>54587332
git add

with regex
>>
>>54589510
Binary interoperability is pretty important. It means that any libraries compiled with clang will not work with gcc and vice versa. It means that C++ FFI to other languages only work with certain compilers. It means that system utilities will never be written in C++.

And C++'s horrible syntax is absolutely unacceptable especially for a beginner.
>>
>>54589558
It's not so great, really. It's really nice how it allows the language to implement common operators in the standard library but it doesn't provide a lot of practicality beyond that. There's a reason APL never took off; obscure symbols only make your code more confusing. Brevity is not always a plus.

>>54589580
Point proven...
I like a lot of things about Rust but I also have a lot of concerns with Rust yet the only concern /g/ seems to have is just "my SJW! CoC!!"
I don't agree with the whole CoC thing either, but I think discrediting such an interesting language because of just that reason is helping noone.

>>54589607
I personally don't like Go because it doesn't have generics (as opposed to rust with the fucking amazing power of the iterator) and because of some other reasons, but I understand that people still find it incredibly useful, mainly due to its simplicity. I should try to write something in that language so I form a better opinion.

>>54589668
>And C++'s horrible syntax is absolutely unacceptable especially for a beginner.
I would never ever recommend C++ to an absolute beginner, but the anon in question seemed to understand pointers and memory well enough to be able to move to C++. I've never needed a strong FFI so I unfortunately can't judge how useful C is in this regard.
>>
>>54589718
>Point proven...

To be fair, Rust is agonizing to work in. I don't think I would use it for general purpose programming. It makes sense in the context of an extremely safe systems language, though.
>>
>>54589756
>an actually constructive comment about Rust
Thank you.
>>
>>54589785

You're very welcome, family.
>>
>>54589785
I also dislike the module/visibility system. Haskell's is pretty much perfect, they should have just used that.

Also, the fact you can't override move semantics. Yeah, I get that because of all the safety features, moves can OFTEN be a straight memcpy, but whenever you're working with unsafe stuff you're forced to put things on the heap unnecessarily as a result.

Don't really have any problems with it other than that.
>>
>>54589836
>I also dislike the module/visibility system.

What do you think is wrong with it?
>>
>>54589886
Private things are only visible in that same module, which is by definition the same file or an even smaller scope. Public things are visible anywhere the type is. There's no in between, so I can't, say, emulate "crate-level" visibility without writing a forwarding wrapper struct.

Whereas in Haskell, there's no public or private, but you can choose to re-export individual members, not just the entire type.
>>
>>54589975

I haven't ever needed that, but it now strikes me as a bit of an oversight.
>>
>>54589886
>>54589975
Basically, the consequences are that you're forced into using massive files because you can't split a file up without introducing new modules and thus barriers behind which private things aren't visible.
>>
>>54589995
I bet it's suppose to appeal to people used to Java's modifiers.
>>
>>54589718
>I personally don't like Go because it doesn't...
As a beginner I like it a lot, I've been using it over C in situations where I am doing something with the network, things regarding sockets or anything that involves HTML (frontends, web server, etc.). It's helped me learn a lot about how to design server/client software without having to know all the low level stuff right away, just to send packets from 1 tcp socket to another and not worry about marshalling, etc. myself just yet. I plan to take lessons learned from use with it and from the Go standard library back with me to C eventually.

It interoperates with C really well too which is nice, you can use cgo for compiling/linking C code at compile time or even the unsafe package to deal with systemcalls, etc. at run time.

The standard toolset and documentation is probably the biggest appeal to me though, it always works the same regardless of platform and makes cross compiling easy, so I can create some kind of network thing and still share it with Windows users no problem, even the source, there's no compiling issues or difference in tools across platforms. My small experience with sockets in C was kind of rough dealing with platform differences.

I'm not trying to endorse Go or anything but it's been a great learning tool for me personally, I'm not sure how useful it would be to others.

>>54589995
This reminds me, packages in Go have helped me learn about proper project structuring and scope restriction.
>>
>>54590235
I'm sure Go is absolutely excellent for beginners. I should learn more about it, I usually recommend Python to new programmers because it's fairly straightforward but for some reason I never have thought about recommending Go. My qualms with Go are entire non-issues for beginners and it isn't Java (I truly believe forced OOP is terrible for new programmers) or C++ (way too complicated for beginners).
>>
>>54590288
>recommending something for beginners because it's easy
I agree with your sentiments about Java and C++ though.
What's best for beginners is something like C with clean and clear error reporting, pretty much.
>>
>>54589180

minimax trees, pruning, logic/proof based AI, probability, decision trees, perceptrons.

bunch more shit but I only took an introductory AI course.
>>
>>54590235

I should learn Go. I've been putting it off.
>>
>>54590347
for what reason
>>
>>54590391

Learning is fun.
>>
>interviews with programmers that actually concerns their work
We need more of this.
https://www.youtube.com/watch?v=qWJpI2adCcs
>>
How can I convert HH:MM:SS into seconds, using batch script?
>>
>>54590479
Use bash to call a program written in a real language.
>>
>>54590479
fscanf(...);
h *= 60 * 60;
m *= 60;
return s + m + h;
>>
>>54590495
really? im just trying to make a really simple ffmpeg script that trims videos. that seems bloated.
>>
>>54590396
good reason
I always feel guilty when learning something for fun, like I'm wasting my time and stealing my future
>>
>>54590495
This is honestly the most comfortable option.
I suggest a C program. Because stuff like interpreters take too long to start to have it be comfy.
>>54590507
Suppose if you know bash like this guy that's fine.
>>
>>54590517
What a terrible attitude.
>>
>>54590468
>>>/v/
>>
>>54590347
learn the board game instead, its more useful and interesting
>>
>>54590507
>s + m + h

f + a + m.

>>54590510

You can do it pretty easily with powershell. Not so much with batch.
>>
>>54590538
I never realized how similar "batch" and "bash" sound. What a joke.
>>
>>54590535
>implying it's even about games
This is Mike Acton dude. Being so close minded about things will have you miss out on stuff.
>>
>>54590479
echo 00:01:00 | sed s/:/*60+/g | bc
>>
New thread now!

>>54590561
>>54590561
>>
>>54590517
>I always feel guilty when learning something for fun, like I'm wasting my time and stealing my future

I enjoy it. The more I learn, the more I realize how crazy this computer shit really is.
>>
>>54590571
B-but we're not autosaging yet, are we?
>>
>>54590479
>batch
Wait, are you using windows?

good fucking luck dude, lol.
>>
>>54590572
Yeah I agree with that; learning different langs helps with the whole "big picture perspective" thing too.
>>
>>54590288
>I truly believe forced OOP is terrible for new programmers
I agree so much. An intro class on programming shouldn't start with "ignore this public static void main(String args[] we'll get back to that in 2 weeks but you HAVE to have it exactly like that in your programs". The prospective programmers aren't going to learn what that shit means. Likewise, IDEs, which are extremely powerful tools, shouldn't be used in favor of just text editor and compiler when learning.
>>
>>54590584
We are now.
>>
>>54590603
>agrees with comment about forced OOP being bad
>complains about something specific to Java
top
>>
>>54590603
That has nothing to do with OOP.

I think anon is criticizing how whenever a new concept is taught, it's taught within the framework of OOP. Like not explaining what a list is and comparing it to other data structures, instead just saying that it's a class with these methods.
>>
>>54590617
Wait what the fuck is the post limit on this board then
Every other board I've seen is 750/500/300
Is /g/ like 310?
>>
>>54588836
>Python project

about 0 lines.
>>
>>54590646
yep

>>54590665
neat, what'd it do?
>>
>>54590670
>what'd it do

It's a clone of the 'true' command.
>>
>>54588836
About 3 pages arial 12pt
SLoC only
>>
>>54590682
heh
that's pretty clever
>>
python is for cucks
real men project fizzbuzzes in C
Thread replies: 320
Thread images: 30
[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.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK