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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 320
Thread images: 23

File: dpt_flat.png (102KB, 1000x1071px) Image search: [Google]
dpt_flat.png
102KB, 1000x1071px
Old thread: >>57826513

What are you working on /g/?
>>
I wrote a desktop app in C++ and Qt, I'd like to convert it to use on an Android phone. I never wrote anything for mobile. What do?
>>
trying to do day 3 of AoC in befunge98

99*:00"tupni"i$$>v  ;stack has number of lines left on top;
<v @k!`0:.:< ;valid tris=0; +-10
>&&&64p44p24p 24g44g64g v
v g44 g42g44g46 <
A B C 6 C + B < A
4 A + B < C
g A + C < B
2
4
g
+
`
!
^$$$$$$ _v
pop +
extra `
values !
^$$$ _v
+
`
!triangle checks out
^ _48*:1g1+:.0pv
^ <
for some reason ip never
reaches these last two options

there's an extra debug :. on line 2 of this file
(coord (1,16) and (1,15))

run like so:
$ cfunge advent03.bf < input
it requires that the input file be named "input"
as well as that the input file be redirected in on stdin


I'm at the point in debug hell where I think I just need to sleep on it.
>>
Anime /dpt/ is best
>>
Holy fuck, the network file is 52 megs haha, no wonder It can't load or something
>>
Daily reminder that Java and C# are the only relevant languages.
Don't fall for Haskell and C memes spreaded by NEETs.
>>
>>57834329

>relevant languages

I think you meant Javascript and Python, grandad
>>
material cancer
>>
>>57834329
I'm new. Is what this poster saying true?
>>
>>57834360
No, C is the only language you need. Everything else is a waste of time.
>>
>tfw paid to use OCaml
>>
>>57834360
If you want to get a job then yes, not many companies need C/Haskell experts while Java and C# are one of the most demanded languages.
>>
>>57834360
Well, to be honest, you should look/learn as many languages as you can.
After you've gone through some of them, just go with the one you feel like using/is the right one for the job.
>>
REPOSTIN FROM DEAD THREAD:
Would this be a worthwhile feature for an IRC bot "/dpt" would make the bot post a link to the most recently made dpt thread - no idea if I could make it but would it be worth investing my time into trying?
>>
>>57834366
Is this true?
>>
>>57834392
>job
If I don't care about that?
>>
>>57834360
Yes.

Particularly try to avoid C++ if you can. It'll ruin your life.
>>
>>57834442
How?
>>
>>57834442
Nah, it'll just ruin whatever project you decide to do in it...

>>57834416
Lisp. Definitely Lisp.
>>
what's the third best algorithm for image processing? i already have normalised correlation and sum of squared differences implemented
>>
Finishing a space invaders clone
In fucking MIPS
>>
>>57834454
>Nah, it'll just ruin whatever project you decide to do in it...
That and even in your 30s people will consider you a know nothing newfag.
>>
>>57834409
Yes, C is the only language conceived by people with actual understanding of computers.

Sill you should try to learn every languages and use what suits you most according to your current project or your tastes.
>>
>>57834329
Oh ok let me just program this microcontroller in C#

oh wait
>>
>>57834484

Oh ok let me just jerk my little dick with C

oh wait
>>
>>57834484
Why not. C# is just a language. You could have a compiler just for that.
>>
>>57834545
Are you saying C programmers have big dicks?

>>57834549
You could have. But there's a reason you don't. It's a too high level language to be useful for firmware
>>
>>57834549
Well, yes and no, since C# has garbage collection it requires a runtime, something most microprocessors (Going at ~20MHz) won't really be able to handle...
>>
>>57834566
>runtime
Do you understand the meanings of your own words, anon?
>>
>>57834566
You can use a subset of C# which is called almost-C. Yes I know it's stupid and more simple to use C.
>>
File: test3.jpg (10KB, 72x360px) Image search: [Google]
test3.jpg
10KB, 72x360px
Okay, I can see that my learning rate is a little high, but this is pretty cool, wow
>>
>>57834597
What library are you using?
>>
>>57834604

Torch7
>>
>>57834597

This is the network itself, if you're so inclined
>>
>>57834649
wtf i love neural networks now
>>
>>57834649
that looks like shit t.b.h
>>
>>57834673

what does?
>>
>>57834682
the syntax, the code. everything
>>
>>57834673
why are you trying to avoid 4chan filter? It's good desu
>>
>>57834696

Yeah, I could put in to a table first and then just feed the table indices to the network, but I'm being lazy rn.
>>
File: 1480277115220.jpg (118KB, 1024x1539px) Image search: [Google]
1480277115220.jpg
118KB, 1024x1539px
wtf have I done here?

#include <stdio.h>

int foo()
{
static int c = 0;
c++;
c++;
return c;
}

int main()
{
printf("%d,%d,%d,%d\n", foo(), foo(), foo(), foo());
return 0;
}


Output is 8,6,4,2. wtf?
>>
>>57834975
Order of execution for arguments is not defined in C
>>
>>57834263
Anyone ?
>>
>>57835006
learn java and read android sdk docs
>>
>>57834597

I think I went overboard with the latest training iteration, I went to take a shit and 30 minutes later it still aint done.

Whoops, it's roughly 35k iterations, let's hope it was worth it...
>>
For the anon who asked for the code of my shitpost detector, here you go:
http://pastebin.com/izNXZAsb

It's really disgusting, don't say I didn't warn you. I'll clean it up when I'll have some time.
Just so you know: 4chan has an API.
>>
>>57835027
        badWordCount += postList[i].lower().count('fuck')
badWordCount += postList[i].lower().count('shit')
badWordCount += postList[i].lower().count('tits')
badWordCount += postList[i].lower().count('fag')
badWordCount += postList[i].lower().count('nigger')
badWordCount += postList[i].lower().count('cunt')
badWordCount += postList[i].lower().count('kike')
badWordCount += postList[i].lower().count('kys')
badWordCount += postList[i].lower().count('cuck')
badWordCount += postList[i].lower().count('pajeet')
badWordCount += postList[i].lower().count('spic')
badWordCount += postList[i].lower().count('retard')
badWordCount += postList[i].lower().count('sperg')
badWordCount += postList[i].lower().count('autist')
badWordCount += postList[i].lower().count('shitskin')
badWordCount += postList[i].lower().count('newfag')
badWordCount += postList[i].lower().count('goy')


But anon, those are actually nice words...

Also, why aren't you using a list?
>>
File: test4.jpg (9KB, 72x360px) Image search: [Google]
test4.jpg
9KB, 72x360px
>>57835012

Holy fucking shit, this is actually incredible
>>
>>57834985
Right. So in this case it might first be executing the final call of foo() in the printf function, then working in reverse to the first call of foo() and printing it out in that reversed order. That makes sense, thanks.
>>
>>57835054
what's the point of this what does it do and hy are you making it?
>>
>>57835059
Yes, but don't depend on that, it's undefined behaviour. Once you compile your program with a different compiler or on a different platform (or even just different compiler settings), it might be different.
>>
>>57835006
http://doc.qt.io/qt-5/android-support.html

Read you dumb fucker
>>
>>57835006
Hello frenchy, I'm french too. Just wanted to tell you some faggots don't like unnecessary spaces before interrogation marks ("?"), you're warned.

Have fun on the internet! :)
>>
>>57835041
By a list, do you mean a list of curse word ? I guess i could do that, i'd be cleaner than this pile of shit.
As I've said, this is pretty shitty, i'm gonna refactor most of it anyway. Ultimately, you'd just give an it, and not some strings, and it would give you back a dictionnary of Grades.

Come to think of it, a dictionnary probably isn't really needed, I could use a list.
>>
>>57835071

It's a reversed CNN, usually a Convolutional Network takes an image and outputs what it thinks it is, here I am giving it what it should show me and it outputs an image.

Basically it's a network visualizing something from nothing (like dreams or imagination)

>why

Why not
>>
>>57834549
Some langs are harder to efficiently compile than others. C is pretty much all the way up there (C++ being somewhat of a close second), that's why we use it for microcontrollers. You can use C on MCUs running at less than 1MHz with 512 bytes of RAM, because every operation you write in C pretty much directly translates to one instruction of the CPU, an array created in C will correspond to a memory chunk in SRAM of exactly that size, etc. (there are some caveats, but generally you get the idea. on a 512 byte MCUs you wouldn't do anything off the stack.)

C# would require a huge runtime, since it has all kinds of extra features; exceptions, safe container datastructures, automatic memory management etc. The basic overhead of creating an empty ArrayList or string in C# probably already exceeds the memory capacity of some of the smaller MCUs. Not to even speak of garbage-collection, threads, JIT etc. Also the overhead of e.g. calling a method would probably end up being thousands of instructions.

You can remove a bunch of those language features to make it easier to compile C# to native code that more closely corresponds to what runs on the hardware (e.g. cython/rpython does this with python), but then, is it really C# anymore?

You would have to add language features C# doesn't have right now to make it useful. On MCUs, you often need to be able to set interrupts, write to specific memory regions and specific CPU registers to achieve certain things. For instance if the MCUs has a USB client device on it, you would typically write and read data through special registers. You would also probably not want to use e.g. the average numerical types available in C# (since C# probably guarantees e.g. certain overflow behaviours, has certain type sizes etc that your MCUs may not natively implement, meaning if you write something like "a*b", instead of emitting one instructions, you may end up with hundreds)
>>
Is C++ a bad language? Why is it hated here?
>>
File: test1.jpg (955B, 72x72px)
test1.jpg
955B, 72x72px
>>57835115

Also now I can trippily merge 2 images by changing the input weights like so
>>
>>57835131
Microsoft is currently developing a C#->native compiler/runtime. The executables have a couple of kilobytes/megabytes overhead of course, depending on how much of the framework/runtime you use. But still, it is possible.
>>
>>57835182
Because some C fizzbuzzers put <stdio.h> and <iostream> together.
>>
>>57835197
Anon, my autistic sensors are unusually high when processing your posts. I'm sorry...
>>
>>57835182
It's not even a language, just a bunch of plies of autism barely glued together.
>>
>>57835216

Basically I am making the computer dream up images from nothing, makes sense?
>>
>>57835182
It's a bloated abomination. People keep adding more and more features to a bad foundation, no matter if these features actually integrate neatly with the existing language.
>>
>>57835182
It's not a bad language, especially since C++11 it has improved drastically. But it is definitely a more advanced language that has been around for a long time and has accumulated a good deal of cruft (both in the language itself as well as in terms of bad/outdated tutorials/information out there).

It remains one of the more powerful and popular languages though. Few other languages can compete with it in the areas where it shines. Rust is probably the newest contender in that arena.
>>
>>57835200
Why can't Microsoft just die and go bankrupt? This cancer screwed computer science already enough.
>>
>>57834263
>>57835006
Xamarin compiler for visual studio has tools for this exact situation, no?
>>
>>57835200
Sure, and we've had things like that for java in the past as well. But that's still far far far away from what you'd need to run even on generously-sized microcontrollers. The output of those compilers still generally assumes you are running on an operating system that allows you to spawn threads, allocate memory on the heap dynamically, etc etc.
>>
>>57835231
>makes sense
Are you trying to avoid answering my post because you don't understand it by implying I don't understand yours?
>>
File: coefQR.jpg (71KB, 633x650px) Image search: [Google]
coefQR.jpg
71KB, 633x650px
What's a plot like this called?
Or what I'd it called when you fill in the regions like this (no gradient)?
What would the colors be based on? What do the colors represent normally?
>>
>>57835076
Case in point: http://rextester.com/ZPEC94872
>>
>>57835244
What exactly are you talking about? C#? .NET?
Both technologies are actually really good in my opinion, especially since they recently open sourced pretty much everything.
Don't get me wrong, I don't particularily like Microsoft either, but C#, .NET etc. are not the reason they should die.
>>
>>57835261

Then I'm not sure what you're talking about
>>
>>57835258
Sure, I know, I didn't want to prove C# is suited for Microcontrollers. I've worked a lot with really small Microcontrollers with just a couple of kilobytes of RAM.
I just wanted to point out that it might be possible to work with C# programs without having to install gigabytes of runtime and framework beforehand.
>>
>>57835262
contour plot but every time you change into a new region you use a different color

The colors are generally just auto-generated. If you plot with e.g. octave, matlab, matplotlib etc it just happens automatically. It uses a colorscheme (default or you can specify one) and then assigns each value a color, given it knows the range of all your values.

This one looks like the YlOrBr colorscheme from matlab, but the plot itself doesn't look like it was generated by matlab/octave (I don't recognize the font etc)
>>
>>57835262
Heat map or height map?
Colors are based on the result of a 2D function at the specific point.
>>
I'm trying to decide on the name for my first proper project, it's a raspi that sits on your desk, if you plug a usb into it all the contents of the usb are encrypted with a random 64 char password then deleted and replaced with normal non suspicious looking files
current name options
>usb blackhole
>one-time pi (name by an anon on dpt)
feedback on either name or new suggestions are very helpful
>>
>>57835306
>>57835316
Ok thanks.
>>
>>57835244
t. gentoo user
>>
>>57835328
>one-time pi
this
>>
What is the best language to write server side apps in? End user desktop apps? WHY?
>>
>>57835328

But anon, what's the fucking point
>>
>>57835262
looks like a contour-plot to me. useful if you want to plot a 3dimensional Surface - the lines represent points with the same height, an in this picture the lighter colors represent higher values (take a look at the numbers on the lines)
>>
>>57835340

Shellscript and Shellscript

Because fuck you.
>>
>>57835328
why not just dd if=/dev/urandom of=/dev/sdX
>>
>>57835342
None, just like 4chan.

>>57835328
MyIJPie_h
>>
>>57835306
>>57835316
>>57835329
Oh and would you consider this a nice plot for categorising? In this case the author wanted to simplify conditions by dividing ranges of the two variables into different regions to make analysis/presentation easier.

Is there something else I should look at aswell for that purpose?
>>
>>57835359
>would you consider this a nice plot
that highly depends on what you want to show the user.
>In this case the author wanted to simplify conditions by dividing ranges of the two variables into different regions to make analysis/presentation easier.
For this it makes sense I suppose.
>>
>>57835338
I thought this but it doesn't use one time pads (If I'm understanding what a one time pad is)
>>57835342
I have 10+ HDDs that need wiping and often wipe usbs in fits of paranoia
>>57835354
That won't kill as much time
>>57835356
>MyIJPie_h
I do not understand this name, I'm a retard can you explain it pls
>>
>>57835359
seems fine to me, but I don't know what you're doing exactly
>>
>>57835374
>That won't kill as much time
Why do you need it to kill time? What the fuck is the point of a device that wipes your drive and takes a lot of time doing so?
>>
>>57835390
just for the sake of it desu also by killing time I mean killing my time not making the device take longer (on purpose)
>>
>>57835387
>>57835370
I'm not doing anything specific. I just know this will come in handy though.
>>
We code together /dpt/:
http://rextester.com/live/UOFGM88429
>>
File: Capture.png (1MB, 1388x1000px) Image search: [Google]
Capture.png
1MB, 1388x1000px
>>57834252
I am working on a translation aggregator clone in WPF for translating visual novels. It uses Agth to get the text and then you can put your google translation API key into the configuration file to use their new translate machine learning end point. It also supports using Selenium to type into google translates website and then hides it's own UI so that you can just use the translate window like the main window but I dont want to distribute it with that because I am pretty sure that violates some type of a users aggrement. Also I am trying to do duplicate text removal better but since I am not doing any natural language recognition the approach is very naive.

My application still looks like dog shit but I am looking forward to digging deeper into WPF and getting it to look nice.
>>
>>57835425
why not https://codeshare.io/
>>
>>57835449
>https://codeshare.io/
Doesn't run the code?
>>
>>57835445
>machine translation with vns
kys you'reself
>>
If I have a lot of repos (20+) would separating them by year be a good idea? would it stop people on github being able to find them? plus it'd make it easy for people to track how much I've done in a given year...
>>
>>57835241
Why do people keep repeating this debunked meme about Rust being faster than C++? It runs slower and even compiles slower.
>>
>>57835553
>It runs slower and even compiles slower.
not if you compile and run the C++ on a rapsberry pi and compile and run the rust on a supercomputer
>>
>>57835584
Which is funny because Rust won't work on either of those
>>
>>57835553
that anon didn't say Rust was faster though
just that it competes with C++ on areas it shines on.
I assume what he meant was that Rust allows you to use OO patterns like C++ does, while being less wasteful than Java, like C++ is.
>>
>>57835608
>it competes with C++
If it isn't faster, then that isn't true. Don't be an inbred.
>>
how would I go about using the linux api with rust?
I want to use sockets and epoll
>>
>>57835553
I didn't say it was faster than C++ anywhere...?
>>
>>57835618
there are more reasons to use a programming language than it being fast.
C is faster than C++ and it compiles faster. why don't you use C for every project if abstraction patterns don't matter?
Why even bother getting a compiled language if you can write it all in the respective assembly languages of your target platforms? Dev time doesn't matter too, since execution speed is the only important thing.
>>
>>57835591
rust works on the raspberry pi. supercomputers are most of the time just a bunch of connected x86 nodes, so rust would work there too -- but with the caveat that the MPI bindings for rust look a bit immature, so if you want to use MPI across the cluster, you may run into issues there. But there are other ways to program supercomputers than with MPI, like with some MR framework, spark or what-have-you, and I see no reason why rust wouldn't work perfectly fine there.
>>
>>57835649
>Why even bother getting a compiled language if you can write it all in the respective assembly languages of your target platforms?
I bet this sounds real clever when you rehearse it in front of the mirror.
In reality you're just embarrassing yourself. You use C/C++ to keep your code portable across platforms without a total rewrite. Which, again, Rust doesn't help you with at all.
>>
>>57835618
That's not entirely true. For many applications where C++ is the prime choice nowadays, rust *could* be a good choice at some point.

There is a small minority of applications where performance is ABSOLUTELY crucial, and any step down from C++ would be unacceptable, but for a large number of applications there is at least SOME kind of tradeoff between safety/convenience/etc and speed.

For instance browser development is a pretty good example, I think. Speed is really important, but security & stability is also pretty critical. And rust was actually conceived with the intention of being used for browser-development.

Also, I'm not really deep into rust, but I don't see any particular reason why rust couldn't at some point in the future be as fast as C++ or at least come very very close. It has to a large degree the same kind of abstractions with the same kind of cost C++ does, plus it introduces (from what I've seen) a few new abstractions that are zero-overhead.
>>
>>57835692
>pulling the embarassing yourself meme
lmao the damage control
>>
>>57835532
>machine translation with vns
>kys you'reself
Why? Do you not like visual novels?
>>
>>57835699
>rust was actually conceived with the intention of being used for browser-development.
Then it is a failure.
>Also, I'm not really deep into rust, but I don't see any particular reason why rust couldn't at some point in the future be as fast as C++ or at least come very very close.
Haskell shills have been parroting the exact same line about their toy language for 10 or 15 years. If you're prepared to wait that long I have a bridge to sell you.
Face it, every "good feature" about Rust is vaporware.
>>
>>57835692
>I bet this sounds real clever when you rehearse it in front of the mirror.
it's a strawman argument, it's not meant to sound clever
the other anon said that execution speed is the only characteristic of a programming language that should be used to compare them to C++, which is bullshit as you rightfully realized in your post.
>>
>>57835728
I do, i don't use translations like a retard though.
>>
File: 1420500175412.jpg (438KB, 900x2134px) Image search: [Google]
1420500175412.jpg
438KB, 900x2134px
What order should I read these books in?
>>
>>57835734
> Then it is a failure.
why? it's a pretty young language, I think that isn't a judgement we should call before in a decade at least.

> Haskell

Haskell is so different that this comparison really makes absolutely no sense. Haskell has never had the goal or prospect of even getting close to e.g. C++ in terms of speed. It has never to any degree valued the concept of "zero overhead abstractions" or "you pay for what you use", unlike rust and C++.

Rust is a much much more realistic target to optimize, and the language itself is clearly designed with a "you pay for what you use"-mentality -- at least to some degree. And the compiler techniques needed to implement and optimize rust are pretty much the same used for C and C++, unlike haskell which is just batshit crazy with lazy evaluation, thunks, ...

Of course it'll take time regardless, I wouldn't expect rust to catch up to C++ performance in the next five years, at least. And it all depends on how much of an interest and push there ends up being for making it faster, of course.
>>
>>57835241
The old tutorials definitly are an issue. Every time I go to learn C++ I am spend the first 8-16 hours trying to determine what sources are valid examples and what are not. Even when looking for C++ 11 tutorials you still find outdates practices in many of the tutorials.
>>
>>57835734
>Then it is a failure.
but it's being used for browser development right now
where do you see failure?
>>
>>57835769

The Art of Killing Yourself

Is a pretty good first I'd say
>>
AoC 2016, Day 4, Part 1:
import re
from collections import Counter

def main():
data = []
with open('D4.txt') as f:
data = f.read().strip().split('\n')

def is_real_room(line):
match = re.match(r'([a-z\-]+)-(\d+)\[([a-z]+)\]', line)
room, id, checksum = match.group(1, 2, 3)

data = []
freq = Counter(room.replace('-', ''))
for (letter, count, ) in freq.items():
data.append([letter, count])

data.sort(key=lambda v: (-v[1], v[0], ))
return int(id) if ''.join([v[0] for v in data[:5]]) == checksum else 0

print('Result({})'.format(sum([is_real_room(line) for line in data])))

if __name__ == '__main__':
main()
>>
>>57835780
What's a good one?
>>
>>57835765
Ah yeah I haven't learned enough Japanese to read a complete VN yet. I got through Japanese 203 at University of Cincinnati and can understand most conversations between characters in eroge VN but I can't understand much of the narration. 3rd person dialogue is very hard for me to understand. Although I will say without Translation Aggregator and Agth around I don't know if I would be as good at reading Japanese as I am now.

Just curious, if machine translation was as good as human translation would you still be opposed to it?
>>
>>57835820
Also wanted to note I totally understand hating machine translations as they stand now because they are kind of a joke. They are certainly getting better but they still produce garbage alot of the time.
>>
File: DDD.png (23KB, 607x634px)
DDD.png
23KB, 607x634px
I want a modern version of DDD.
It just looks super convenient.
But https://sourceware.org/gdb/wiki/GDB%20Front%20Ends DDD is GNU depricated. Doesn't use modern GDB.
How should I do this? Is it an issue? Anyone here using it?
>>
>>57834985
I don't understand why it doesn't give 2,2,2,2.
>>
>>57835820
Well, you won't learn it by reading machine translations or by doing your uni program as they are absolute shit for learning languages.
>Ah yeah I haven't learned enough Japanese to read a complete VN yet.
Why do you think there is even something describable as "enough japanese for a vn"?
You learn by actually reading shit in the language, not by reading textbooks. The most basic understanding of grammar is already enough to start reading the simplest stuff with rikaisama.
>Just curious, if machine translation was as good as human translation would you still be opposed to it?
Depends on your goal, if your goal is learning Japanese then yeah.
>>
>>57835914
Because it's a static int.
https://en.wikipedia.org/wiki/Static_(keyword)
(See the 'lifetime':program execution)
It's basically a global variable but only accessible within the scope.
>>
>>57835858
the DDD site says it needs gdb 4.something OR LATER
so I assume you can build it with the latest gdb and be fine
>>
File: Capture.png (27KB, 839x488px) Image search: [Google]
Capture.png
27KB, 839x488px
Having some simple fun with NASA's api.

Maybe to create an android app in the future but i don't get a solid idea yet
>>
This should work right?

void print_tree(Tree *root) {
if (foot == NULL)
return;



print_tree(root->left);
printf("stuff");
print_tree(root->right);
}
>>
Why is cross-compiling any non-trivial project such an exercise in frustration?
>>
>>57836015
aren't you supposed to use tools to make it smooth ?
>>
>>57836004
>if (foot == NULL)
>>
>>57835962
>>57835858
it does indeed come with a relatively new version of GDB

why do you even ask such stupid questions before installing the software through your package manager
it's just 20MB for fucks sakes
>>
>>57836041
I am but they're not helping.
>>
>>57836015
GNU seems to think that simple cross-compiling is useless.
>>
>>57836048
shit fuck shit
i should go sleep I think


>and don't wake up
>>
What would I use Erlang for?
What's its purpose?
>>
>>57836093
Claiming you're a functional programmer if you don't know any real functional languages.
>>
>What would I use Erlang for?
nothing
>What's its purpose?
curiosity
>>
File: 1451271699062.jpg (28KB, 688x359px) Image search: [Google]
1451271699062.jpg
28KB, 688x359px
>What are you working on /g/?

Trying to write a small dll with Foobar2000's SDK which doesn't have any real documentation and is all in C++
>Don't know C++ but do know C
>no documentation
>relies on visual studio
>templates and factories
I'm signing myself up for a bad time.
>>
>>57836093
When you want concurrency for non-performance reasons.
>>
>>57836004
huh, I never realized how close the words root and foot are, and they mean pretty much the same thing

thanks for really making me think
>>
>>57836105
I could use Lisp as well
>>
how bad is it if valgrind says that a conditional jump depends on a uninitialised values, but it runs (outside a debugger as well)
>>
>>57836132
maybe you should initialize your variable before checking the condition of it
>>
>>57836132
Absolutely abhorrent. Fix your code, peasant.
>>
>>57836093
It's main point of uniqueness is that it supports preemptive scheduling of "greenthreads" (processes) across any number of cores.
This is opposed to e.g. go, which can also schedule greenthreads (goroutines) across any number of cores, but can only do so cooperatively.

There is a (relatively small) niche where this is valuable, which is in areas where you need high throughput with a non-trivial amount of CPU work done inside your own code (as opposed to e.g. C libraries or whatnot) but also really low latency (e.g. in go or nodejs you could clog up the scheduler queues here, if you're not careful.) Another aspect is that this preemptive scheduling behaviour can improve reliability somewhat (infinite loops won't bring down your server anymore, which they may in e.g. go or node.)

Two other aspects that are interesting are the way it handles failure (using supervisor trees) and the way it can handle hot code reloading.

It also comes with a bunch of functionality built-in that may be useful to you. Message passing, message queues, being able to persist to disk, etc etc.

The big drawbacks are its weird syntax, it's relatively slow performance and its lack of library ecosystem (compared to e.g. go, node, ...)
>>
>>57836132
that's very bad
>>
>>57835328
would like more feedback current names are
>usb blackhole
>one-time pi (IMO doesn't make sense since it'll probably be using RSA & PGP)
>gory wiper
>dead data
also open to new suggestions
>>
>>57835935
>Well, you won't learn it by reading machine translations or by doing your uni program as they are absolute shit for learning languages.
I graduated from my uni program and haven't done anything through a classroom with Japanese since 2011. The only reason my skills are where they are now is because of reading untranslate manga and using JParser with machine translations. I want to get JParser working as soon as possible in my tool so I can get back to learning characters more easily.

The way classes want you to pound vocabulary into your head is one of the worst ways I have experienced trying to pickup a language. I remembered more of the vocabulary for my classes by looking for it in Saki, Yotsuba and other untranslated material. Then after finding it in one of those source I can mentally tie it to a context, this process has had a much higher success rate for me than from blind memorization like the class room promotes.

>Why do you think there is even something describable as "enough japanese for a vn"?
I used "enough Japanese for a vn" because I don't know all the joyo-kanji. Since I don't meet the minimum requirements to read the news paper I used "enough Japanese". I don't know if joyo-kanji is highly regarded as a bench mark for literacy but it is the only benchmark I know.

>Depends on your goal, if your goal is learning Japanese then yeah.
Thanks for answering my question about your views on machine translation and I agree with your view of it depends on your goal.

I know this isn't quite the right board for questions about the Japanese language but when you were learning how did you deal with material that had multiple accents in it? Did you just avoid that material for learning purposes or did you just look up stuff specific to the accent? Saki and Yotsuba have probably built bad habbits for me because of the Kansai accent of some characters in Saki and Yotsuba is certainly not a model Japanese speaker.
>>
>>57836188
Go's scheduler actually is semi-preemptive. I don't know why.
>>
>>57836160
>>57836180
>>57836196
But I don't get it why is it saying that, it's a function that's going trough a tree, and the problematic line is when i check if the passed node is == NULL, and in theory every node was created with calloc
>>
>>57836394
>calloc
Well then you know valgrind is wrong. If that's what's going on.
>>
>>57836341
What do you mean by that? I'm pretty sure if you have an infinite loop in some goroutine, that goroutine will end up clogging one of your scheduler queues forever. So if you're in a scenario where you're spawning e.g. a goroutine for each request, and it can occasionally happen that one falls into an infinite loop (or otherwise takes a long time to complete, doing CPU-work, not I/O work) then eventually all your scheduler queues would be clogged up and the entire program stops doing any work.
>>
>>57836394
Then you're probably reading outside what was allocated.
>>
Should I put include guards on all headers just in case?
>>
>>57836438
Yes.
>>
>>57836438
Yes.
>>
>>57836288
>JParser with machine translations
Just drop that right away. You don't need anything but a starting book which explains basic grammar (Tae Kim is probably the best) and a dictionary (rikaisama). You can also use something like DoJG to look up new grammar.

Yeah, vocabulary is much better learned from actually reading/watching something meaningful.
>joyo-kanji.
Joyo is a shit benchmark if that's the only thing you know. You could learn 10k kanji and still not know a single word. Kanji alone aren't a really good benchmark, it's how many words you know which will naturally include a lot of kanji.

Just get exposed to a lot of different ones. It's already good if you can tell the different accents apart.
>>
>>57836419
When I tested this (two years ago at least), other goroutines were going hungry, but weren't entirely starved of CPU time.
>>
>>57836438
yes, or "#pragma once" which is supported by all compilers nowadays
>>
>>57836460
 P
NOT
R
T
A
B
L
E
>>
>>57836438
If writing public headers for a library, yes.

If writing pretty much anything else, NO.
>>
>>57836474
Don't listen to this guy. He evidently doesn't know much.
>>
>>57836394
calloc()ing a pointer to 0 is not well-defined behaviour in C.

C guarantees that if you cast the integer constant 0 to a pointer type, it will be a nullpointer. C does NOT require however that the nullpointer is actually all zero-bits. So that means calloc()ing a pointer and then expecting it to be a nullpointer is NOT guaranteed to be true.

That being said, that is probably unrelated to the issue valgrind is raising, since valgrind thinks you're reading from uninitialized memory (a pointer that is calloc()'d to 0 is not a valid nullpointer, but it is still initialized) -- so your issue is probably somewhere else.
>>
>>57836470
technically true, but there are only one or two extremely obscure compilers in existence that do not support it.
>>
>>57836454
Thanks for the advice, I have read about Tae Kim and Rikaisama from the daily japanese threads on /a/ but since I already had Genki I never got it. I will pickup Rikaisama though because I have been looking everything up by stroke count on wikipedia (forgive me) and it is rather unreliable. Not sure about picking up Tae Kim since I already have Genki and I have heard they are fairly close in quality just depends on whether I get more serious about learning or if it remains a hobby.

Thanks for your time.
>>
>>57836479
Stop including headers inside other headers you worthless faggot. You end up squeezing a big 50MB shit through the preprocessor unnecessarily as cascades of repeated includes happen every time you compile a compilation unit. In large projects the overhead can get extreme.
>>
Recommendations for a personal project for a fairly experienced programmer to get his feet wet in modern C++ practices?
I had an idea for a vidya gaem but it would take up far too much time and I would never complete it
>>
>>57836583
HTTP server
>>
>>57836583
Here's a nice project: don't use C++.
>>
>>57836583
Go for the video game. At least make a tile engine in something like SFML
>>
>>57836583
mandelbrot renderer
>>
>>57836583

do some basic physics simulations with eigen or armadillo. E.g. you could start with a 2D gravity simulator, implement various integrators, go to 3D (and make a 3D visualization for it in GL), look into the physics of distance smoothing factor, adaptive integration steps etc or if you're more interested in the visual side, there is a bunch of work you can do on the visualization and GPU side

If you're interested in optimizing, you can multithread the whole thing, port it to the GPU, OpenMP it, etc
>>
>>57836607
I really like the idea of starting with a tile engine. Getting that going wont be trivial but it will be a good learning experience. Plus if you ever want to make your game you might be able to reuse some code.
>>
>>57836583
>I had an idea for a vidya gaem but it would take up far too much time and I would never complete it
>it would take up far too much time and I would never complete it
Seems like a great introduction to modern C++ practices.
>>
>>57836594
Would be good except I just wrote an HTTP server in Lisp for my homepage.

>>57836596
Whatever. I know that Rust is a better systems language but its still really early in language developement. And I would rather be writing Lisp anyways but I want something to show that I am a competent C++ programmer.

>>57836607
>>57836674
I was going to make a cyberpunk roguelike but the more I thought about it the more I realized I don't actually know what that would look like.

>>57836633
Interesting, I'll look into that kind of thing.
>>
Where are pages like exhentai and similar hosted?

They store a lot of hentai, loli and whatnot that is downright illegal in most countries.
>>
>>57836687
>Rust
Go. Go's not early in language development. And before you bitch about systems and GC, Go's GC is realtime.

If you're still going to be a faggot, use C and show that you are a competent C programmer instead.
>>
>>57836687
> Interesting, I'll look into that kind of thing.

let me know if you want to have some code to look at, I've implemented basically all those things in a C++ project before and used it to simulate cluster collapses with 100-100k stars. I didn't get to porting it to the GPU though, but it has a nice 3D visualization that you can control with an xbox controller and whatnot, and it's multithreaded with std::thread.
>>
>>57836710
The ehentai@home project is what I'm guessing is their primary means of hosting.
>illegal
You're overestimating how illegal the stuff is.
>>
Then again, why Pascal is hated?
>>
>>57836710
Well I know they have a distributed network through their hosting at home program https://ehwiki.org/wiki/Hentai@Home but I am not aware of where they are hosting the bulk of the sites traphic from.
>>
>>57836717
Go to bed Rob Pike. Go and C both violate my personal code of ethics.

>>57836743
I'd love to see it anon. I don't know what kind of physics I'd simulate with that kind of thing though...
>>
>>57836794
What's your code of ethics -- use excruciating languages to write unreadable and unstable programs?
>>
>>57836794
https://github.com/Amadiro/cold-uniform-spherical-collapse
>>
>>57836818
(also here is an example of it running: https://youtu.be/StEkcO63-T8 )
>>
>>57836815
By those standards everything written at my work would violate his code of ethics. My work still uses VB6...
>>
I need to decide between:

Fast system that the user must manually disable after finishing.
Slow system that doesn't need to be disabled.

Decide /dpt/.
>>
>>57836878
that's very little info to go on
>>
>>57836755
>>57836761
>distributed hosting

I was looking into the hentai@home client source code. It looked damned simple to me, and I know Java well enough to implement such a feature. It's definitely on the roadmap, but for starters, there needs to be an absolute, secure base for the web page.

Any countries or cases we know of where the content wouldn't be a problem? I just want my records clean man.

>You're overestimating how illegal the stuff is.
Which I'm perfectly fine with doing. I don't want to take no chances. Is there a country with lax legislation regarding what can be hosted?
>>
Does anybody have a project they need a +1 on? I want to work in a team before my internship to get some group experience
>>
>>57836890
Fine. Here's some code for you.

class SlowSystem {
public void work() {
Resource r = ResourceManager.load(); // slow
r.work();
r.release(); // slow
}
}
class FastSystem {
private Resource r = null;
public void work() {
if (r == null) ResourceManager.load();
r.work();
}
public void disable() {
if (r != null) r.release;
r = null;
}
}
>>
>>57836922
Me
Does +1 imply +1 million US dollars?
Or it's only in Canadian dollars?
>>
>>57836957
That's fine, but the important questions are e.g. "how much does speed matter here"/"how much does the user value to have control over this", and e.g. "how likely is it that "Resource r" can and will be re-used as opposed to FastSystem being re-created each time.
>>
>>57836818
>>57836850
Holy shit that's pretty amazing
>>
>>57836568
Genki uses the standard teaching methods in classrooms aka it's absolute shit, just download Tae Kim. You can read through that in a really short time if you already know the basics. Also look into anki, it's great for making your own vocab lists from the stuff you read. Basically look into rikaisama anki integration.
Well, I don't really know how learning a language could be serious or not, I guess it could be serious if it's work related but the learning method shouldn't differ for that. It's a hobby for me but I've made a lot of progress compared to people I know who were studying it in uni. They for some reason think that knowing joyo is somehow a great milestone.
>>
>>57836993
also why can't you do the cleanup in e.g. the destructor
>>
>>57836964
Australian Dollarydoos
>>
>>57836993
You always have to assume library users are the dumbest creatures to ever write code.
If it was me, i'd definitely want to use the fast system though.
>>
File: test5.jpg (8KB, 72x288px) Image search: [Google]
test5.jpg
8KB, 72x288px
Impressed by just how much detail it captures from these more complex images.
>>
>>57837067
>java
>destructor
>>
>>57836957
You could provide methods like

system.loadResources()
system.doWork()
system.disable()

And then a convenience function

system.work()

or so that just does it all safely/cleanly in one go. Then put warnings around the "Unsafe" methods in the documentation.

(method names obv. subject to change, I'm sure you can think of something better here.)

If you wanna go full ham you could even encapsulate this into some sort of class hierachy, Where you have a SimpleSystem that just has a work() method and is a UnsafeManualSystem, and work() just calls the superclass loadResources(), doWork() and disable(). That way users won't even see the other methods in the documentation unless they go up the hierachy or (if you make them protected) themselves subclass your UnsafeManualSystem. But I think that's a bit over the top.
>>
>>57837083
>detail
Your brain fills it in.
>>
>>57836717
>Go's GC is realtime
AHAHAHAHAHA nigga like wtf that doesn't even make sense
>>
>>57837083
do I spy simon pegg
>>
File: 1480494689392.jpg (61KB, 801x801px) Image search: [Google]
1480494689392.jpg
61KB, 801x801px
What color of striped socks improves your programming skills the most?
>>
>>57837187
Miku socks with matching underwear.
>>
>>57837163

Well, but you can probably instantly decipher exactly what it has output, no?

It's just 'good enough' for the brain to fill in the blanks

>>57837177

That's actually him, pretty cool
>>
>>57837176
Go's GC pauses are bounded; it's always timely. Thus it is realtime.
>>
>>57836687
You not only don't know C++ but you can't figure out how to learn it on your own, so you don't _know_ Rust is anything as much as you _know_ C++ is anything. This is why /g/ fucking sucks
>>
>>57837242
Yes but it's not really to the credit of your program but rather your brain that you get all that detail.
Simon Pegg would be impossible to spot without having seen him before. We could probably not associate between that picture and him if we were to go in the other direction.

Nobody would look at Simon Pegg and be like "oh he looks like that image anon generated" without direct comparison. Similarly dogs cats and apples are well recognizable things. If you try and distance yourself from those memories and look at them more objectively you see that the apple in particular isn't particularly apple-like.
It has the defining silhouette but it could be a ball with a one bladed propeller.
>>
>>57837309
That still doesn't make it realtime.
>>
>>57837309
Wouldn't realtime imply that it doesn't pause the program at all? The fact that the pauses are short is just an implementation detail.
>>
>>57837309
That makes no sense because if it has to break its execution because it's running out of time it means it hasn't GC'd well enough. While not a major concern on modern machines you could potentially run into issues where the GC doesn't keep up with allocations.

Just in theory. I don't think Go's GC is particularly offensive because it's not intended to be a high performance language and it doesn't present itself as such, like Java does.
>>
>>57837335

I'm just impressed that it is a recognizable image at all, It starts out as a [1-5] array of floats with one of the floats being 1, rest being 0 then it goes through some linear layers and convolution and upscaling and finally it comes out like that, really makes you think about our brainboxes
>>
>>57837407
Yeah sure. I'm just saying detail is the wrong word for it. It's certainly impressive.
>>
>>57837363
There are a bunch of different definitions/strictnesses as to what constitutes "real-time", and also other terms like "soft real-time". It's really not that meaningful to talk about it (or to claim that gos GC is "realtime") without much more context.
>>
What is the proper way for iterating and removing elements from a C++ container?

for(auto e = vector.begin(); e != vector.end();) 
{
if(whatever) vector.erase(e);
else ++e;
}


This has always worked for me. Alternatively, swapping e with vector.back() and then popping the vector.

But with the standard library I can do this:

vector.erase( std::remove_if(vector.begin(), vector.end(), whatever) , vector.end() ); 


Which is preferable?
>>
>>57837340
Realtime means "program can reliably respond to events in a timely manner". For soft realtime, insert "usually".

>>57837363
Consider that execution of your code itself is a delay. As long as the response is timely and within forecasted bounds, the system is realtime. It doesn't matter whether the program was forced to relinquish the CPU, or performed a mark-and-sweep garbage collection phase, halfway between event and response.

>>57837373
That situation would mean you're running out of memory. Create less garbage.

Speed critical code is written to avoid heap allocations anyway. You can do that in Go just as you would in C, and there is a compiler switch that tells you which constructs are being put on the stack (which is a surprising amount, including growing objects you'd normally malloc in C just for convenience), and which on the GC'd heap.
>>
>>57837418

Well then excuse my poor choice of words, English isn't my first or even second language.
>>
>>57837446
If you don't need to perform any task on the element then use the latter, otherwise use the former.

Also the first one is technically not guaranteed to be alright because erase invalidates the iterators so you need to do:
e = vector.erase(e);
>>
>>57837446
Use standard algorithms. More readable and probably better performing, unless you spend a lot of time optimizing your code.
>>
#include <iostream>
#include <stdlib.h>
using namespace std;
void delay(){

//poor man's delay
for(int i = 0; i < 350; ++i){
for(int i = 0 ; i < 1488*88; ++i){}
}

}
void printDots(int a){
cout<<"|"<<flush;

for(int j = 0; j < a; j++){
delay();
cout<<"."<<flush;
}

cout<<"|\n"<<flush;
}
int main(int argc,char* argv[]){
int dotCount = atoi(argv[1]);

for(int i=0; i<4; ++i)
printDots(dotCount);

}
>>
>>57837461
>Create less garbage.
But it's a flaw in the GC, it should have stalled. If it does it's not realtime if it doesn't it's a problem with the GC. It's a problem with GC in general not just Go's GC.
GC's aren't realtime.
>>
>>57837461
removing heap allocations from go code takes quite a bit of effort, IMO, it's not nearly as straightforward as in C/C++. Not saying you're wrong, but it's the kind of optimization that I would apply after the fact and only if absolutely necessary. (Either way whether you're using C or go, if you want to apply this optimization to the fullest extend, you'll also additionally have to change the way functions work to a BYOB-style for instance, otherwise you're just trading heap allocations for potentially very large copying operations on the stack. So it's not exactly a very non-invasive optimization)
>>
>>57837461
>Realtime means "program can reliably respond to events in a timely manner". For soft realtime, insert "usually".
You're fucking stupid. GC's take an arbitrary amount of time. It doesn't mean shit if the GC is time constrained (which is a really bad thing) or not. The same goes for malloc. It's also not even soft realtime.
kys
>>
>>57837586
Why is it a bad thing that the GC is time-constrained

If you're not concerned with GC throughput, doing that does make GC pauses relatively predictable (at least in an upper-bound kinda sense).
>>
>>57837537
>>57837612
>Why is it a bad thing that the GC is time-constrained
It's not a bad thing. It's just not realtime.
>>
>>57837537
in go, when a goroutine allocates a lot of memory, there is something called "GC assist" where the goroutine "donates" time to the GC on allocation to make sure it finished the previous cycle (if I recall correctly). So essentially the GC does slow down the program when there is too much garbage.
>>
>>57837418

Also a problem with training is that the only real objective way I can train is just comparing pixels one by one, so the 'expected' outcome thanks to the way the training algorithms are programmed is loss of fine details but it should be getting the broad strokes, maybe I should try another criterion that's more top heavy.
>>
File: g_57834252.png (187KB, 1599x804px) Image search: [Google]
g_57834252.png
187KB, 1599x804px
Anon are you lost?

Here is a map.
http://korbo.ga/g/thread/57834252
>>
>>57837700
it's fucking slow
>>
>>57837494
>>57837506
Alright, thanks lads.
>>
>>57837612
>Why is it a bad thing that the GC is time-constrained
Guess what happens if the GC runs out of time... Ding ding ding, garbage starts accumulating and your system runs out of available RAM.
>If you're not concerned with GC throughput, doing that does make GC pauses relatively predictable (at least in an upper-bound kinda sense).
It's not even relatively predictable. GCs run when they feel like it and they will take a random amount of time to complete.
>>
>>57835692
>you write C++ to be portable
To the mild degree of not having to be instruction set specific.
And of course some write C++ to be platform independent but they're probably just better served by other languages usually.
>>
>>57837556
>removing heap allocations from go code takes quite a bit of effort
It doesn't, because you easily learn precisely what patterns of usage trigger a heap allocation. For example, returning a slice/array from a function's local scope will cause that object to "escape to heap". In truth, heap allocations in Go output are rare even in the most sloppily written code. They are not hard to avoid.

>>57837726
Just as you would not malloc in an event loop, nor would you write code that escapes to heap in such a situation.

>GCs run when they feel like
Which does not contravene real time.

>and they will take a random amount of time to complete
(a) it's not random and (b) the pause may be within your soft real time constraints, and a constrained pause phase may be within your hard real time constraints

Stop creating garbage.

>>57837586
>GC's take an arbitrary amount of time.
You're being a bellend because you can't be bothered to learn what realtime is and is not. You've got your own ideas and think you know better.

>>57837624
Yes it is.
>>
>>57837726
> what happens if the GC runs out of time
You will then just need to either generate less garbage or allow the GC more time. Still, on average you won't always be producing peak amounts of garbage all the time, so amortizing GC runs across time doesn't seem like a terrible idea to me. If the GC can't keep up with the produced garbage for a few seconds, that's okay as long as there is some period afterwards where you produce less garbage so that it can keep up. But ok, it's probably not the best choice for all kinds of applications. I think there is definitely a place for high-throughput GCs (and that's what java choses to use by default)

> take a random amount of time to complete
Well, if you schedule the gc just like any other greenthread in your system, it will run when it feels like it, but never stop your own greenthread for more than one timeslice worth of time. So while you don't know when it will complete, you do know that it won't slow down your thread much (any more than any other competing greenthread), both in terms of throughput and latency.
>>
>>57837446
>Alternatively, swapping e with vector.back() and then popping the vector.
Do this unless you need the order preserved, it's the fastest.
>>
>>57837798
>yes it is
We've clearly established the issues with it.
Stop trolling.
>>
>>57837798
But what are you going to replace the heap allocation with, e.g. for a function building a structure and returning it, etc -- a big-ass stack-to-stack copy? That doesn't buy you anything or could even be slower.
>>
The reason go's GC can be classified as real-time is that it guarantees a minimum amount of mutator running time as a ratio of GC pause time, over some arbitrary window.
>>
Can someone verify how functions work in ruby? Do they simply return the result of the last operation? Jumped into some code without reading any books on it.
>>
>>57837720
There are no optimizations right now
>>
I have bit strings of varying length, how could I concatenate them so they fit in one byte blocks, (bonus points if it's c, but I'm okay with pseudo code as well)
>>
File: umaruwp.jpg (112KB, 1920x1080px)
umaruwp.jpg
112KB, 1920x1080px
>automatic garbage collection
>RTOS

Pick one.
>>
>>57837837
Usually you move the problematic variable to a higher scope. This way, it is allocated at program start, or more commonly it lives in the executable's data segment.

>for a function building a structure and returning it
This would return the structure via the stack. If you instead returned a pointer to the structure you just built, it would escape to heap because it is a local object.
>>
>>57837800
>You will then just need to either generate less garbage or allow the GC more time.
Go used to be shilled as a systems programming language. Now it's being shilled as a high performance networking language. How can such a poor ass GC stand ground serving millions of requests? Oh wait, it cannot.
>>
>>57837911
https://en.wikipedia.org/wiki/Tracing_garbage_collection#Real-time_garbage_collection
whoa

>>57837926
>How can such a poor ass GC stand ground serving millions of requests? Oh wait, it cannot.
it's doing it right now you faggot, like on dl.google.com
>>
>>57837893
how big are the blocks?
>>
>>57837920
Yeah, that's my point. If you return a pointer to the structure, you get a heap allocation. If you return the structure, you get a huge stack-to-stack copy. So to really optimize the situation and not just trade GC time for stack-to-stack copy time, you'll actually have to modify the function signature to a C-style BYOB function.
>>
>>57837926
>How can such a poor ass GC stand ground serving millions of requests? Oh wait, it cannot.

It sort of can post 1.5. Before that Twitch Chat suffered from GC pauses making the system halt for a few seconds but it's down to tenths of a second nowadays while serving 1.5 mil concurrent users so it's not that bad but it's still far from ideal.
>>
>>57837933
>One obscure case
kek, with a rtos, you even have to avoid any memory allocation
>>
Just threw this together to log muh cpu temperature
#!/usr/bin/env ruby
require 'csv'

csv = CSV.open("/tmp/tempLog.csv", "a")

if not File.exists?("/tmp/tempLog.csv")
csv << (1..%x[sensors | grep Core].lines.count).map {|i| "c#{i}"}
end

loop do
csv << %x[sensors | grep Core].lines.map! {|e| e.split[2].to_i}
sleep 1
end
>>
>>57837893
Is bit strings value known?
>>
>>57837893
>>57837943
I completely misread what you said so ignore me
>>
>>57837933
I can run the fucking Google search engine with Flask and Python given infinite servers. Also, have fun with your segmented stacks.
>>
>>57837943
one byte, I want to save the string in disk, but without the padding
>>
File: image.jpg (48KB, 640x640px) Image search: [Google]
image.jpg
48KB, 640x640px
Does anybody know of god free written resources for starting programming in LUA? Please share any you know of.

I have never used a real programming language before and find the tables kind of confusing :(
>>
>>57837967
not at compile time, It's generated dynamically depending on the inputfile
>>
>>57837332
I know C++ I'm just looking for a project to get better at it

>mfw I accidentally started a huge debate about garbage collection
Well, you're right about /g/ sucking
>>
File: gobooks.jpg (152KB, 768x1024px) Image search: [Google]
gobooks.jpg
152KB, 768x1024px
>>57837945
>you get a huge stack-to-stack copy
That's not how stacks work. The runtime doesn't copy anything. All it does is increment (or decrement) an integer and set a register.

>>57837955
What?

>>57837954
Maybe Twitch Chat should use a pool and stop making so much garbage.
>>
>>57837992
Programming in Lua
Read the first page, then never call it LUA again
>>
>>57837992
Google ith thine friend
>>
>>57838020
How do you know if this or another bit string is valuable for you?
>>
>>57838052
>Maybe Twitch Chat should use a pool and stop making so much garbage.

Granted it's a Google owned product, they ought to know how to deal with it, no?
>>
>>57838052
when the integer is decremented, anything from the stackframe that just ended needs to be copied to the stackframe below, if it is to survive. That's the whole reason for BYOB-style programming in C, and why some people want to avoid e.g. returning large structs.
>>
>>57838054
I was just shouting is all, sry
>>57838055
Google is nonfree software :)
But seriously it is hard to find anything that is written(not video) and also aimed at beginners
>>
>>57838063
I don't entirely understand what are you thinking of, but if you mean how do I decode it, it's a prefix code
>>
>>57838052
>What?
you don't want a push onto an full arraylist while your plane is landing, trust me.
>>
>>57838099
So, you have some start combination of bits and some stop combination of bits?
>>
>>57838114
not exactly, it's generated based on a tree (i'm making a huffman coder), my problem is how to pack the bits into bytes
I probably have to shift depending on the the length of the given combination, but I don't really know how to deal with the overflow
>>
>>57838178
Is there some maximum size of bit fields?
>>
>tfw you learned the hard way that if you have 2 similar enough structs (ie. 2 separate linkedlist structs), and you free one and create the other within a small time span, you can end up with some values overlapping (ie. the next fields of the nodes), which can lead to great horror (ie. 2 corrupted linked list structures that are both mixed and infinitely looping), which can and fucking will cause you great pain (ie. a huge headache after wasting 3 hours working with debugger output that makes next to no sense)
>Moral of the story: When malloc-ing, always set the struct fields...
>>
>>57838217
worst case scenario is 8 bits
>>
>>57838094

https://www.lua.org/manual/5.1/

I reccomend you download an interpreter (sudo apt install luajit) and go from there.

Lua really isn't a very hard to grasp language
>>
>>57837988
>>57837893

the right way to do it would be to just use gzip
>>
>>57838227
don't you have to malloc it first before you can set the fields?
>>
>>57838227
i got to know this pain yesterday, I couldn't understand why does my function gets in an infinite loop, changed every malloc to calloc after that
>>
>>57838227
Also note that valgrind and some sanitizers of some compilers can catch this (definitely clangs MemorySanitizer, maybe AddressSanitizer of gcc/clang, not sure) and sometimes the compiler can just outright generate a warning for it, if it can easily deduce that you're using uninitialized memory (use -Wuninitialized and -Wmaybe-uninitialized with gcc, for instance)
>>
>>57838244
oh fug

What's the way to find the length of the combination?
>>
>>57838259
ok, I'll just send the gzip source to my TA

>>57838275
I can do that, pretty easily while traversing the the tree
>>
>>57838256
Thx what is the advantage to luajit over just the package "lua[version.number]". That came with an interpreter
>>
>>57838299
luajit:
+ faster
+ has some extra functionality
- only supports older lua version (2 minor version numbers behind)
>>
>>57838316
I am wanting to learn love2d which i think has just the regular lua imbedded, so i think it would be a good ida to stick with the regular lua for now. I will for sure look into luajit if i start doing my own programs from scratch
>>
Why is garbage collection named so offensively? Does it assume I have garbage in my code?
>>
>>57838353
love2d has luajit embedded

but it really doesn't matter much, you won't run into any issues because of the differences.
>>
>>57838298
I have an idea (probably bad).
Use 7 bits per byte.
If there's something more up to seventh bit, set the last bit to one.
>>
>>57838353

Since 0.9 or 0.8 Love is using LuaJIT
>>
>>57838354
It depends on the language - if the language is garbage, it has garbage collection.
>>
>>57838379
how come it doesn't collect itself?
>>
>>57838394
all the languages that could have, so they don't exist anymore, hence why you don't know about them. The ones we're left with are the ones that failed at doing that.
>>
>>57838316

Aren't the newer Lua versions generally viewed as inferior to 5.1 or something?
>>
>>57838371
I'm think about smth like this
k := code
l := length of code
n := 8
if n-l >= 0:
k &= k << n-l)
n -= l
else:
k &= k >> abs(n-l)


then loop this somehow, save the overflow and get a new byte, that's not exactly clear as of yet
>>
>>57838316
>luajit
more like luajeet
kek
>>
>>57838417
no idea about that, I don't use lua that much. but newer versions introduced integer and bitops, I think, which can be pretty useful.
>>
>>57838394
Because it's trash?
>>
>>57838432
then why didn't anyone invent trash collection yet?
>>
>>57838418
But 8 to 0 gives 9 iterations
>>
File: Screenshot_4.png (23KB, 938x353px) Image search: [Google]
Screenshot_4.png
23KB, 938x353px
>>57838274
Hm... thanks for the heads up, but something tells me I won't really be able to use valgrind all that well...
It's hard enough tolerating that stuff when gdb does it...
>>
>>57838464
you can attach both valgrind and GDB to a process from a completely separate terminal. Or just re-direct the valgrind output (stderr) to a file.
>>
>>57838461
what 8 iteration, I'd use n only for shifting
also I realized I need or not and
>>
>>57833152
>So, there's no other non-memous language to write native code with high-level abstractions?
Exactly.
>>
File: meme overload.jpg (42KB, 480x463px) Image search: [Google]
meme overload.jpg
42KB, 480x463px
>advent of code is up again
I started programming exactly a year ago and I had to give up around day 10 of AoC 2015 because shit was getting too hard.

I've improved a lot since then, maybe I should try it again.
>>
>>57838543
What was the problem of AoC2015?
>>
>>57838543
Do it, the tasks are slightly harder this year but nothing too fancy so far.
>>
Why people insist on rewriting everything in C?
>>
>>57838471
Oh, first time hearing you could send the output to a different terminal, thanks.
>>
>>57838611
they usually don't
>>
>>57838620
you can even combine valgrind and gdb into vgdb, which lets you e.g. set a breakpoint on an uninitialized memory read, or a breakpoint on memory being lost. it's the bees knees
>>
NEW THREAD:

>>57838637
>>57838637
>>57838637
>>
>>57838611
Because then you can, generally speaking, use the code in almost any other language.
>>
>>57838650
Why so?
>>
>>57838662
Well, you can use it in C or C++ code, for obvious reasons. You can compile it to asm.js and use it in js. Ruby/Python/Lua/Rust/Some lisps/etc. all have systems that let you use C code.
I think you can even get Java to run C code, too lazy to check though.
>>
>>57838662
because basically every language has a mechanism to bind to C code; python, ruby, erlang, javascript, java, lua, go, rust, C++

in some languages it's easier (e.g. in C++, all you need may be "extern C"), in some it's not as easy (erlang, you may have to e.g. write an asynchronous driver).

Some languages have different ways of doing it, e.g. python has ffi, the python c api itself and e.g. cython (which you can use to create a bridge between C and python relatively easily)

If your code is written in, say, javascript, python or go, it is pretty hard to use from other languages. You can embed javascript relatively easily, you can embed python (but it sucks), and with go, your probably only option is to expose it as a service and then talk to the service.
>>
>>57838707
Also, I think it should be mentioned that a big part of the reason why C is the "lingua franca" (and not some other language) that everyone supports binding to is because it has a pretty stable ABI (unlike C++) which makes the process generally much more pleasant. Of course it's also just a popularity thing. Binding to C is pretty easy when e.g. your interpreter is already written in C anyway.
>>
I'm trying to create an object with the following constructor:

Processor::Processor(const std::string & record, std::function<Task::Quality(int)> qual) : Task(record){ //code goes here }


but when I try to create it with the following line

Processor a("record", 0);


I get the error:

"Error C2893: Failed to specialize function template"

What am I doing wrong?
>>
File: 4868.png (20KB, 480x480px) Image search: [Google]
4868.png
20KB, 480x480px
> 0xbeefc0ffee

s m h
Thread posts: 320
Thread images: 23


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.