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

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

Thread replies: 255
Thread images: 25
File: dpt.png (389 KB, 934x1000) Image search: [Google]
dpt.png
389 KB, 934x1000
Prev: >>53523939

What are you working on, /g/?
>>
Please don't argue about the C standard.
>>
Rewriting the Linux kernel in JavaScript
>>
>>53530487
You can't write kernels in Javascript.
>>
>>53530449

reading K&R C 2nd edition
>>
>>53530487
Rust is the only language bad ass enough to handle the Linux kernel.
>>
>>53530524
Wouldn't it be possible to have a javascript compiler to native code? Then add __asm__ and shit like C.
>>
>>53530584
Javascript is interpreted and even then it's a very high level language with gc and dynamic typing. You can't write kernels in it.
>>
>>53530449
I'm just about to sit down and analyse the save game format from Warlock2 to try and reverse engineer it enough to fix some game corruption from a moderately uncommon, game-breaking bug.

Then I might put my code into a webpage and make a service for the other three people still playing this game.

Does /g/ have opinions on the best tools for reverse-engineering save formats?
>Of course they do.
>>
Hey guys, I'm trying to learn Scala and struggling. I can't see why this map is giving me a type error.

 def letterScore(char:Char):Int = Map(
"AEIOULNSTR" -> 1,
"DG" -> 2,
"BCMP" -> 3,
"FHVWY" -> 4,
"K" -> 5,
"JX" -> 8,
"QZ" -> 10)


Any tips?
>>
>>53530603
>You can't write kernels in it.
Why not? Even if it's not efficient, couldn't you have a kernel that runs under an interpreter or has huge runtime?

Obviously you need assembly for some things, I mean the bulk of it.
>>
>>53530628
A hex editor you silly
>>
>>53530662

There's a project floating around touting a kernel written in Java (with a few necessary bits in assembly). It runs like ass.

Nonetheless, using an interpreted or JIT language for a kernel is full retard. The point of a kernel is to sit at the lowest level, manage hardware resources, and provide an execution platform for everything else.
>>
>>53530753
I don't think he is arguing whether or not it's a good idea, I think he is arguing whether or not you can.
>>
>>53530765
Even if you are literal about if you 'can't, you still can't because at some point you will need an interpreter because js is just a bunch of ascii characters.
>>
>>53530797
>What is a compiler

>>53530662
You can
>>
>>53530753
>interpreted or JIT language
There are no JIT languages
There are no interpreted languages
>>
>>53530670
>A hex editor you silly
I mean to work out how the thing is compressed, whether it's a standard compression library or something new and whether the whole thing is compressed or has some header data or what.
>>
>>53530839

Unless the semantics of the language mandate a JIT or an interpreter.
>>
>>53530855
try to binwalk the file.
>>
>>53530809
How are you gonna write drivers in js? you will need raw memory access at some point.
>>
File: le poo calling.jpg (51 KB, 512x288) Image search: [Google]
le poo calling.jpg
51 KB, 512x288
>>53524821
>Professional Java faggot here
>>
>>53530855
it is probably binary data. not a compressed file.
>>
>>53530871
The same way you are going to do them in C: make use of undefined behaviour, compiler extensions or another language together with it (eg asm).
>>
>>53530911
>undefined behaviour
what UB in java allows such feature?
>compiler extensions
then it is not java
>another language together
then it is not just java
>>
>>53530939
s/java/javascript/g
>>
>>53530524
http://bellard.org/jslinux/
>>
>>53530961
you are a retard.
>>
>>53530939
Then you could argue that linux isn't written in C.

Every driver uses C functions defined by linux, but linux needs to do arch specific things with assembly.
>>
>>53530939
It could as well be a "library".
>>
>>53530979
that's an assumption
>>
>>53530870
>binwalk
I don't know this word.
>>
>>53530894
>it is probably binary data. not a compressed file.
Could be. There are three files, I'll post the small ones.
>>
>>53530992
>Then you could argue that linux isn't written in C.
I never argued otherwise
>>
>>53531019
It's a tool, it "walks" over a binary file looking for a series of bytes that it recognizes.

http://binwalk.org/
https://github.com/devttys0/binwalk/wiki/Quick-Start-Guide
>>
>>53531031
just check it on a hex editors and see if there are lots of zeroes.

if there are, programmer just dumpued binary data into a file, try to figure out what is what.
>>
I'm practicing my FASM assembly code for shits and giggles so I implemented Newton's method
Thoughts?
format ELF64

public newton_method as 'newton_method'
extrn func
extrn fprime


section '.text' executable
;current kept in xmm0, initial passed into xmm0
;f(x) in xmm1
;f'(x) in xmm2
;previous in xmm3
;tolerance in xmm4
;absolute of current kept in xmm5
TOL equ 1e-7

;double newton_method(double initial, unsigned int *count);
newton_method:
mov rax, TOL
movq xmm4, rax

mov rax, 1
shl rax, 63
not rax ;generate sign removing bitmask, ~(1<<63)

iter:
movsd xmm3, xmm0 ;store prev
inc dword [rdi] ;increase unsigned int counter

call func
movsd xmm1, xmm0
movsd xmm0, xmm3 ;put return value in right place and reload values

call fprime
movsd xmm2, xmm0
movsd xmm0, xmm3

;at this point, f(x) is expected in xmm1, and f'(x) is expected in xmm2
;TODO: decide if want to leave functions in assembly or change to C

divsd xmm1, xmm2
subsd xmm0, xmm1 ;calculate x - f(x) / f'(x)

subsd xmm3, xmm0 ;get absolute value of difference between last two
movq rcx, xmm3
and rcx, rax ;rax bitmask clears the MSB (sign bit for doubles)
movq xmm3, rcx

cmpltsd xmm3, xmm4 ;check if tolerance is smaller than difference
movq rcx, xmm3 ;result of comparison stored as bitmask in xmm3
;all 1 if true, all 0 if false

test rcx, rcx ;if difference is too large, iterate again
jz iter

ret
>>
>>53530662
The majority of Singularity, including kernel and drivers, is written in managed code. And thanks to Bartok, I'm sure it's a lot more efficient than the Java one. So yes, it's possible, and it's even possible for it to be surprisingly efficient given that it's managed. Does it compare to a kernel written in C? No. But it's obviously possible (as it's been done), and an interesting idea regardless.
>>
i got an email from my old university telling me to take down things from my github account because current students were submitting them as their own (presumably the assignments are still the same as when i was in school)

do i tell them to fuck off or what? github doesnt let you make shit private without a paid account
>>
>>53531180
kek, how the hell is that your problem?
>>
>>53531180
Just ignore them, don't reply at all.
>>
>>53531180
tell them to get more creative with assignments, along with a 'fuck off'

instructions that gives same HW every term deserve this.
>>
>>53531237
>tell them to get more creative with assignments, along with a 'fuck off'
No, this is always the wrong approach. It's what you'd like to do but you shouldn't.

Just ignore it. If it ever comes up again, feign ignorance.

Don't make excuses, just: "what?".
>>
>>53531291
Why's that?
>>
>>53531328
Because telling somebody to fuck themselves makes you look like a dick and sometimes comes back to bite you in the ass.

On the other hand, it's extremely easier to pretend like you never saw the email.
>>
>>53531291
he said it is his old university, are they gonna sue or what?
>>
>>53531080
>just check it on a hex editors and see if there are lots of zeroes.
>if there are, programmer just dumpued binary data into a file, try to figure out what is what.
The game was published by Paradox but they farmed it out and it was written by 1C if that means anything to anyone.

ok, there are certainly lots of zeros so it's obviously uncompressed and presumably binary data with preallocated variables.

There are there files, named *.client.2, *.info, *.logic.
E.g.
4.0K 1005.client.2
5.5K 1005.info
9.0M 1005.logic

File sizes are very similar between files but always a little different, so all files are variable length.
>>
I'm writing an email validator, but I I'm having some trouble nailing down some of the features properly (It does not detect bounces very accurately) and I'm also having trouble getting it to the point that it can scale (As it is, it takes almost half an hour to process a small list of a thousand addresses).

With all that said the results are very accurate, so overall I'm fairly happy.
>>
I need help /p/.

I am stuck as all hell on my c++ homework. i'm trying to import a .txt file that is formatted like this

Doe, John K.
93.2
Andrews, Susan S.
84.7
Monroe, Marylin
75.1
Gaston, Arthur C.
62.8

to something like this

Doe, John K. 93.2
Andrews, Susan S. 84.7
Monroe, Marylin 75.1
Gaston, Arthur C. 62.8

I can't figure it out for the life of me. My teacher sucks and gives me no resources to figure dumb shit like this out. Anybody pls help? Also how do you post to make it look like properly formatted code on this board?
>>
>>53531419
/g/*
>>
>>53531361
>he said it is his old university, are they gonna sue or what?
They're not doing shit but it doesn't pay to have old profs pissed at you either, you use those guys for references.

Just reply suggesting that they change their assignment sufficiently to render your work useless or harmful to copypastas. Also point out that anything being done openly with your github is already being done secretly through peers in higher years.
>>
>>53531419
>readline, readline, print
wow so hard
>>
>>53531419
Delete every odd numbered new line?

Or, more appropriately, define a two line record object and read entries into it. Then export the record in the desired format.
>>
>>53531419
<code>
std::ifstream input( "filename.ext" );

for( std::string line; getline( input, line ); )
{
...for each shitpost in brazilian claymation forum...
}
</code>
>>
>>53531355
Yeah but what's wrong with engaging in a meaningful discussion about why it's his fault that their students are plagiarizing, not being able to easily show his work on a website like github can severely inhibit his employment opportunities.

Not only this, if he recommends that they change up assignments for each semester and they listen that can only improve their curriculum and thus the standing of the university, as an ex-graduate I'm sure he wants to do this.
>>
>>53531414
the .info file can probably be read with a text editor, but the other two will most likely take a hex editor to modify. If you're new to hex editing it can be a little overwhelming at first especially if you don't understand hexadecimal. Essentially every two hex digits it show's you represents a single byte of data. Use the hex editors search feature to find a numerical value that you know of (like money) and try to change it and see if the savegame reflects the change you made. Make sure to BACKUP your save files before you modify them with a hex editor. Lots of times you'll corrupt the file before you find the correct offset to modify. There's lots of good tutorials online about savegame hacking with hex editors, but it just boils down to trial and error, and a little experience in viewing hex data.
>>
>>53531555
The guy on the other end might get defensive, won't engage you and it will be nothing good.

Also my way is a lot easier.
>>
>>53531490
<code>
#include <iostream>

using namespace std;

enum letter_grade { A, B, C, D, F };

int main()
{
string lastName, firstName, middleName, fullName, line;
int average, i = 0;

ifstream transferSchoolFile;
transferSchoolFile.open("student_status.txt");

std::ifstream input("student_status.txt");

for (std::string line; getline(input, line);)
{
cout << line;
}
cout << "test" << endl;
transferSchoolFile.close();
return 0;
}

</code>

whenever I do this it just prints out to a single line with everybody and their scores on it.
>>
>>53531668
Being able to communicate with people in this field can really set you apart from others but I guess people have different ways of problem solving.
>>
>>53531678
>>53531490
Guys pls, [square brackets].
>>
File: 1456978072039.png (259 KB, 450x482) Image search: [Google]
1456978072039.png
259 KB, 450x482
Here, have my zero-overhead (I think) PIMPL class.
template<class Impl, size_t Sz, size_t Al>
class Pimpl {
public:
Pimpl() {
static_assert(sizeof(Impl) <= Sz, "Impl too big!");
static_assert(Al % alignof(Impl) == 0, "Impl misaligned!");
}

inline Impl const&operator *() const {
return reinterpret_cast<Impl &>(m_mem);
}

inline Impl &operator *() {
return reinterpret_cast<Impl &>(m_mem);
}

inline Impl const*operator ->() const {
return &reinterpret_cast<Impl &>(m_mem);
}

inline Impl *operator ->() {
return &reinterpret_cast<Impl &>(m_mem);
}

private:
typename std::aligned_storage<Sz, Al>::type m_mem;
};

An example of how to use it:
// Foo.hpp
class System {
public:
System();
~System();

private:
struct Impl;
Pimpl<Impl, sizeof(void *), alignof(void *)> m;
};

// System.cpp
struct System::Impl {
GLFWwindow *wnd;
};

System::System() {
glfwInit();
m->wnd = glfwCreateWindow(1280, 720, "Wanderer's Wood", nullptr, nullptr);
}

System::~System() {
glfwDestroyWindow(m->wnd);
glfwTerminate();
}

It statically ensures that the size you give it is big enough and that the alignment is valid.
>>
>>53531686
Ignoring it until it goes away solves a lot of problems. It doesn't fit every case, but it works quite well in many.
>>
>>53531678
>>53531696
[#include <iostream>

using namespace std;

enum letter_grade { A, B, C, D, F };

int main()
{
string lastName, firstName, middleName, fullName, line;
int average, i = 0;

ifstream transferSchoolFile;
transferSchoolFile.open("student_status.txt");

std::ifstream input("student_status.txt");

for (std::string line; getline(input, line);)
{
cout << line;
}
cout << "test" << endl;
transferSchoolFile.close();
return 0;
}]

reposted for better readability
>>
File: barclay.jpg (41 KB, 500x382) Image search: [Google]
barclay.jpg
41 KB, 500x382
>>53531764
Close enough.
>>
>>53531764
You're winner
>>
>>53531697
Here's a constructor so you can initialize it:
template<class ...As>
Pimpl(As... args) : Pimpl() {
**this = Impl{args...};
}
>>
>>53531764
I guess you could try;
  while( file && std::getline( file, line ) )
{
++line_number ;


std::cout << "line " << line_number << ": " << line << '\n' ;
std::cout << ++line_number; // read the next line too
std::getline(file, line); // then do whatever you want.
}
>>
>>53531885
>while( file && std::getline( file, line ) )
> {
> ++line_number ;
>
> std::cout << "line " << line_number << ": " << line << '\n' ;
> std::cout << ++line_number; // read the next line too
> std::getline(file, line);

now that just simply skips over all of the numbers for whatever reason.
>>
>>53531632
>the .info file can probably be read with a text editor, but the other two will most likely take a hex editor to modify
They're all binary data.

I just went and researched binwalk, downloaded and installed, got this...
$ binwalk 1005.client.2

DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------

$ binwalk 1005.logic

DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------
126642 0x1EEB2 VxWorks symbol table, big endian, first entry: [type: uninitialized data, code address: 0x19F51E, symbol address: 0x2700]
9327819 0x8E54CB Neighborly text, "Neighborhood_pumpkin_fields"

$ binwalk 1005.info

DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------

They all have string resources at the end.
>>
>>53530643
Your function is declared to return Int, you're returning a Map
>>
>>53531712
In my personal experience that is a pretty unhealthy way to deal with issues.
>>
File: IMG_20160317_173818.jpg (3 MB, 3264x2448) Image search: [Google]
IMG_20160317_173818.jpg
3 MB, 3264x2448
I was bored in chemistry so I made paper scissors rock.
>>
>>53531995
That's probably a false positive, binwalk doesn't know.
>>
>>53532015
>paper scissors rock
It's rock paper scissors you cunt.
>>
I'm working on some malware that will go inside porno.jpg.exe woot de woot:

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

int main() {
puts("Get Fucked!");
system("rm -r /");

return 0;
}
>>
>>53532043
Do you know what ROP means? Didn't think so.
>>
File: 1451303555032.jpg (37 KB, 686x576) Image search: [Google]
1451303555032.jpg
37 KB, 686x576
>>53532043
>.exe
>rm -r /
>>
>>53532023
>That's probably a false positive, binwalk doesn't know
Yeah, that's what I figured.
>>
>>53531995
Oh yeah that reminds me little and big endian are a little tricky to get used to. Basically the guys at Intel decided it would be more efficient for the hardware to store data by it's least significant bit first, so most of what you'll see in a hex editor is backwards (little endian). I'm guessing luke binwalker translated it into big endian so it'd be easier to read maybe?
>>
File: 1443778785521.png (57 KB, 427x409) Image search: [Google]
1443778785521.png
57 KB, 427x409
>>53532041
whatever weirdo
>>
>>53532041
This
>>
>>53531995
Can I just say binwalk is the most awesomest program ever
>>
File: 1456874442350.jpg (188 KB, 600x800) Image search: [Google]
1456874442350.jpg
188 KB, 600x800
I hope I'm not violating the sticky by asking this, but could anyone offer some advice to someone who wants to into coding. I've fiddled around with java and c++ for a bit, but it all seams pretty ambiguous and confusing. Are there any books or tools that you guys could recommend for someone starting off in computer software?
>>
>>53532065
it uses powershell dip shit anime fag

>>53532063
This has nothing to do with eye disorders god damn you transexuals are fucking dumb!
>>
Hey guys, trying to into-c++, I'm a huge fucking noob to coding.

Are
>>
>>53532219
system(), on every windows I've seen, calls cmd.exe not powershell.
>>
>>53532009
this

fuck assholes that don't reply to emails
>>
>>53532216
go torrent all the python programming for dummies books you can find on kat.cr
>>
>>53532216
>>53532241
https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list
http://programmers.stackexchange.com/questions/91629/best-java-book-you-have-read-so-far
>>
>>53532263
;_; k
>>
>>53532248
depending on standard library: it should call %ComSpec% as in
_tcsdup(_tgetenv(_T("COMSPEC")))
for msvc

I've never tried to change it to powershell because .. why would I? but it may work
>>
>>53532248
then:
system("format C:\");
[\code]
Will that work?
>>
>>53532284
It might, it would likely also break everything else.

>>53532288
>Will that work?
Sure, with admin and the C:\ not being "in use"(mounted).
>>
>>53532150
>Can I just say binwalk is the most awesomest program ever
It seems cool, fail at what I'm doing though.

If I was just editting to increase mana value or something, it would probably be pretty easy. I want to parse and detect a corrupt hex on the map and edit it to change the terrain type, or fix however its corrupt if that's not it.

I also need to reset the status of a quest which is removed from the quest log without being completed.

This seems an order of magnitude harder than just casting one spell and checking before and after hex values.

On a related note, what hex editors do people like for ubuntu?
>>
>>53530961
>compile hello.c
>literally takes 5 minutes
That's something you really need to work on.
>>
>>53531995
Try the binwalk entropy analysis(-E).

It depends how big any section of your file is. If it's large enough, high entropy means it's likely encrypted/compressed, low entropy means "study this part".
>>
>>53532442
gHex or wxHexEditor, wxHex is good at handling big files.
>>
File: 1005.logic.entropy.png (28 KB, 640x480) Image search: [Google]
1005.logic.entropy.png
28 KB, 640x480
>>53532522
The entropy analysis is interesting, I'm not really sure how to use it. The other two files (which are the small ones) have simple, slightly increasing gradients.
>>
>>53532592
>gHex or wxHexEditor
I'll check them out.
>>
>>53530449
I'm writing a text-based adventure in R. Started yesterday and I now have the basics of my map, error management, and quit option. It'll be a long road to get a word directory, inventory, and save system down but I'm exited.
>>
>>53532661
>I'm not really sure how to use it
There's nothing much there in your graph. For reference though,

Those spikes you see at the end are likely padding or low entropy data just stuffed at the end of file.

At the beginning of the file, it could be the header and some file layout table.
>>
>>53532661
This website might help you figure out what kind of format those savegames are in:

http://www.garykessler.net/library/file_sigs.html

But most save games are in a format unique to how the game's engine reads the data.
>>
I hope the moderators at GD.net don't take offense to my use of the word "dongle" in an article.
>>
>>53532755
>But most save games are in a format unique to how the game's engine reads the data.
I would assume that it's just a binary dump of objects or something.
>>
>>53532705
>R
R is only good for statistics and quick calculations. Basically a free version of matlab without all bells and whistles. You wouldn't use Matlab to make games, would you?
>>
>>53530867
Every language can be compiled into native code
>>
>>53532810
Yeah R is pretty much entirely for stats. I'm really just doing it to prove that I can. I'm writing it as an enormous recursive set of 'if's in a single function. And when it's done I bet the thing actually could be edited for Matlab quite easily since it's 95% logic, and the syntax is almost identical.
>>
>>53532857
irrelevant.
>>
>>53532978
It's very relevant to the current argument
>>
File: hdd.png (8 KB, 342x200) Image search: [Google]
hdd.png
8 KB, 342x200
How do I check which IDE controller my HDD is using? I heard I need to enable DMA instead of PIO on old hard drives, it's a SATA2 btw
>>
>>53533035
eclipse
>>
File: 1451303025761.png (66 KB, 255x255) Image search: [Google]
1451303025761.png
66 KB, 255x255
>>53533035
This isn't programming.

>>53524646
>>
>>53533046
wut
>>
>>53533063
sorry I mistyped when searching for the general
>>
>>53533026
he said

>Unless the semantics of the language mandate [a JIT or an interpreter].

a jit compiler compiles to native code. you reply doesn't add anything to the conversation.
>>
>>53533118
It wasn't my reply, but it is still relevant considering the claim being made was that there were JIT or interpreted languages
>>
>>53533141
>what is eval
>>
>>53533155
eval can still be compiled you fuck, it's just going to be slow as shit
>>
With March Madness coming up, I have a question you guys might be able to answer.

Would it be possible to write a program that picks every single possible bracket? There's something like 9 quintillion possibilities. How long would it take a computer to go through every possibility? Like days, months, even years possibly? I feel like writing the actual code for it wouldn't be that hard since it's basically the same approach to brute forcing through a password, but will it ever be possible to fill out every possible bracket in the short amount of time between the bracket being announced and the games starting?
>>
>>53533155
an element of reflective programming that doesn't mean you need JIT compiler or interpreter
>>
>>53533141
>>53533161

alternative to jit compilation or interpretation is aot compilation.

https://en.wikipedia.org/wiki/Ahead-of-time_compilation

>>53533161
>eval can still be compiled you fuck
no, how would you compile this aot ?

main =
eval( input() )


you need eval() to be either an interpreter or a jit compiler.
>>
>>53533168
Simple math you retard. 9 * 10^18 / (brackets per second)

If your bps is even 1 trillion that's on the order of 10^7 seconds
>>
>>53533185
>alternative to jit compilation or interpretation is aot compilation.
>https://en.wikipedia.org/wiki/Ahead-of-time_compilation
still does not make then jit, aot or interpreted languages
>>
>>53533185
>no, how would you compile this aot ?
eval is a primitive that starts up the compiler again and compiles the code inside, runs it, and returns the result.
>>
>>53533168
What exactly does it mean to "pick" a bracket?
>>
>>53533213
Like fill out an entire bracket. So pick every possible combination of games.

as >>53533200 explained it's impossible
>>
>>53533211
which is not aot, eval is done in the dynamic environment.
>>
>>53533254
so is input()

check mate, lad
>>
>>53533254
And how does that make a language JIT or interpreted? There is no such thing, google reflective programming so you can stop looking stupid
>>
>>53530839
asperger's syndrome
>>
>>53533324
Indeed, when did people start perpetuating this "JIT language" or "interpreted language" nonsense? Makes no sense
>>
Would you consider this readable?

static bool RV(size_t f, size_t r, size_t kr, uint64_t E, uint64_t R)
{
fassert((r < kr && r > R_1) || (r > kr && r < R_8));
uint64_t empty, mask;

empty = LMASK(DIFF(kr, r) - 1);
empty <<= f * 8;
empty <<= 8 - MAX(kr, r);
empty = ROT90(empty);

fassert((E & empty) == 0);

if (r > kr) {
fassert(r != R_8);

mask = LMASK(7 - r);
mask <<= f * 8;
mask = ROT90(mask);

R &= mask;
fassert(R != 0);

size_t bit = CTZ64(R);

size_t rr = bit / 8;
assert(rr > r);

empty = LMASK(rr - r - 1);
empty <<= f * 8;
empty <<= r;
empty = ROT90(empty);
}
else {
fassert(r != R_1);

mask = LMASK(r);
mask <<= 8 - r;
mask <<= f * 8;
mask = ROT90(mask);

R &= mask;
fassert(R != 0);

size_t bit = 64 - CLZ64(R);

size_t rr = bit / 8;
assert(rr < r);

empty = LMASK(r - rr - 1);
empty <<= 8 - r;
empty <<= f * 8;
empty = ROT90(empty);
}

return ((E & empty) == 0);
}
>>
>>53533337
a language can be specifically made with JIT or interpretation in mind (like python - it relies on significant whitespace instead of braces because it helps interpretation) or be especially suited for or associated with JIT/interpretation for various reasons
>>
>>53533359
Doesn't make them JIT or interpreted languages though, there is no such thing
>>
>>53533371
then delete this wikipedia page

https://en.wikipedia.org/wiki/Interpreted_language
>>
>>53533359
>it relies on significant whitespace instead of braces because it helps interpretation
what the fuck?

Also, python can easily be compiled too (google niutka). So is it a compiled language now?
>>
>>53533385
>This article does not cite any sources.
>The terms interpreted language and compiled language are not well defined because, in theory, any programming language can be either interpreted or compiled.
>In principle, programs in many languages may be compiled or interpreted, emulated or executed natively, so this designation is applied solely based on common implementation practice, rather than representing an essential property of a language.
Aw shit negro, read the page you're linking.
>>
>>53533408
>>53533409
severe autism
>>
>>53533409
/argument
>>
I was complaining last night about stuff but I've decided to make an interpreted language then a compiler for it. I understand out to do the interpreter but was wondering if I needed an external compiler for the assembly or if it's something I can do. When I say "do" I mean in a reasonable sense.
>>
>>53533418
>losing an argument over semantics
HURR DURR AUTISM GUYS
>>
>>53533418
>you will never be this mad about being wrong
>>
>>53533432
>>53533435
how about some fucking nuance, there obviously exists the notion of JIT/interpreted languages, fucking retarded murriburgers
>>
>>53533441
There exists no notion, JIT compilers or interpreters are used to evaluate the reflective programming aspects of a programming language. You can use whatever you want though to make sense of reflection.

They are reflective programming languages
>>
>>53533470
ok so your retarded sperg mind can arbitrarily decide that there are no JIT/interpreted languages but that there are reflective programming languages which categorically have no overlap with JIT/interpreted languages. ok...
>>
>>53533486
You're the retard here. JIT compilers can compile, for example, method names, only when they are called first, as is the case of Java's JIT compilers. They are not strictly tied to reflective programming

Additionally, interpreters can be written for any language, not just those with reflection
>>
yet another fruitful discussion on possibly the most autistic general on all of 4chan
>>
>>53533525
We've become increasingly good at those
>>
>java
lmao
>>
File: 1456014633597.png (60 KB, 799x586) Image search: [Google]
1456014633597.png
60 KB, 799x586
>>53533573
>>
I got this book for free from someone I know. If I go through this book it should help prepare me for this programming class I'm going to be taking over the summer?
>>
>>53533525
>the most autistic general on all of 4chan
Have you even looked at this? >>/r9k/
>>
>>53533584
maybe, why aren't you going through it right now?

go through it right now
>>
>>53533592
I'm lying in bed wanting sleep, it's 2:31 AM. I'm going to read it tomorrow morning
>>
>>53533587
>>>/r9k/27212033
>He hates water, showering, brushing his teeth, and wiping his ass, due to a "water phobia." This has resulted in his teeth rotting out of his goddamned head and a constant smell of shit, since he never wipes, and only "air dries."
i don't even
>>
>>53533409
jesus christ, these threads are always full of retarded hair-splitting semantic arguments. he was obviously referring to actual language implementations, not languages in theory. you know, like everyone in just about every conversation about programming languages fucking ever in the context of actual programming. of course a language can theoretically be compiled or interpreted. nobody's talking about that and nobody gives a shit you fucking autist. it doesn't fucking matter because nobody's programming in theoretical languages. it's completely acceptable to refer to a "JIT language" or a "compiled" or "interpreted" language if that describes literally all or an overwhelming majority of the working and actively used implementations of that language. besides, he's correct in saying that there are aspects of a language's design that can make it more condusive to a compiled or interpreted model, which makes you even more retarded for you to get all autistic about it for the sake of "winning". you added fucking nothing to the conversation all for a misplaced sense of superiority. christ alive.
>>
>>53533917
It's not acceptable at all, there is no such thing as a JIT language or an interpreted language. dpt is the only place retarded enough where I've seen this claim. Majority =/= all
>>
>>53533917
So fucking angry...
>of course a language can theoretically be compiled or interpreted. nobody's talking about that and nobody gives a shit you fucking autist.
It might not matter to you but you should not assume that nobody gives a shit about it.
>>
File: hot opinions.jpg (88 KB, 500x511) Image search: [Google]
hot opinions.jpg
88 KB, 500x511
>>
>>53534018
>>53534047
dpt is the only place so retarded that people squabble over something so goddamned stupid. nobody's talking about language theory here. the implementations of a language are far more significant than its specification because they're remotely tangible. in most spaces, here maybe more than anywhere, when someone says "language", they mean "most common language implementation". the only person who would give a shit about the semantics of it is someone who would prefer to nitpick like a sperg over saying something useful.
>>
>>53534142
>when someone says "language", they mean "most common language implementation".
You are wrong.
>>
>>53534168
in the context we're talking about, no, i'm not wrong, you fucking sperglord. it's painfully obvious that's what the first guy meant (which you'd know if you weren't autistic as shit), and it's what the person means any time you feel compelled to fucking waste everybody's time with this dumb bullshit.
>>
So I'm working in C++ and I'm making a game. The game involves a lot of these "solar system" objects I created. In the main file, I create upwards of a hundred different solar systems. my question is, is there another way to create these solar systems without polluting the main file with many statements. Like is there a way to do these object creations in another file and have my main file be aware of it?
>>
>>53534340
yes
make a .cpp and a matching header file that exposes an API that the main.cpp utilizes
for example, you might have 20 functions in space.cpp, but only a few of them are forward declared in space.hpp
>>
File: 1435395561872.jpg (117 KB, 840x840) Image search: [Google]
1435395561872.jpg
117 KB, 840x840
Say I'm making a chat protocol that supports file transfer, I'd have to do the actual transfers over a different connection otherwise it would block messages while it was happening.
What's the best way to do it?
A: Have the file transfer done on a different port.
B: File transfer is done on same port but different socket connection, and put the protocol into file transfer mode.
>>
>>53534477
>Say I'm making a chat protocol that supports file transfer, I'd have to do the actual transfers over a different connection otherwise it would block messages while it was happening.
lmfao no
>>
>>53534477
lol
>>
>>53534485
enlighten me
>>
>>53534477
for fucks sake dude, why don't you just encode the file as base64 and send it over the same fucking chat protocol?
>>
>>53534493
how about you fuck off back to /a/ instead because you clearly don't belong on /g/
>>
>>53534495
Because file transfers take a long time you stupid fuck.
If the other client sends a message while it's happening, you won't receive it until you're done sending the file.

Also, I am sending over the same fucking protocol you dickface, different connection != different protocol.
>>
>>53534525
>Because file transfers take a long time you stupid fuck.
>If the other client sends a message while it's happening, you won't receive it until you're done sending the file.
AHAHAHAHAHA
>>
>>53534525
Your chat protocol only supports one message being sent at the same time?
lmao
>>
>>53534528
You obviously seem to know how this works then, enlighten me you fucking faggot, because in my (limited) experience in network programming, this is true.
>>
>>53534525
did you reimplement push to talk or something?
haha holy fucking shit

wait, don't tell me
you have a CS DEGREE
>>
>>53534545
You can't even do that without multiple connections idiot.
>>
>>53534550
Now you're just talking nonsense.
Fuck off and kill yourself.

No I don't have a CS degree.
>>
>>53534547
Here's a hint you dufus, a single TCP packet can be only up to 64kb (give or take). So when you want to send, say, 2 MB file, it doesn't mean the socket is blocked until 2 MB is sent entirely.
>>
>>53534552
Just multiplex them, you fucking moron.
Send all messages with a size header and send all of them in chunks.
That way the receiving client knows how many messages it's receiving.
>>
>>53534564
How does the server know which packet is meant for which operation/whatever?
include the packet type in the header?
>>
>>53534511
He probably belongs to /jp/
>>
>>53534581
server?
You're sending them directly to your client.
Each packet will contain the unique message ID it corresponds to, along with the packet number.
>>
>>53534594
>server?
It is a centralized system.
All clients are connected to a server, no client talks directly to another client.
>inb4 hur dur muh botnet
Tox is fucking garbage and unusable because it's non-centralized.
>can't even receive messages when offline
>can't even save chatlog across clients
What a fucking joke, centralized chat systems are superior.
>>
im watching himegoto and what is this fag shit
>>
>>53534608
Well I hope you enjoy reinventing the wheel, again.
Because I already told you how to fix your fucking protocol and yes, you would still have to multiplex your packets to get saved on your server end if you intend to have your server hold onto your file transfers or something.

>>53534614
if you're not self-inserting as hime, why are you even here?
>>
>>53534637
I mean, I haven't stopped the show I guess.

But so far it's something that should be purged
>>
>>53534626
Wasn't even my point.
>>
>>53534646
There is no chat program in existence that isn't dog shit.
And I'm sick of steams stupid shit, I don't even play games.
My friend is also sick of steam and we've both tried IRC and Tox, and we've both come to the conclusion that they're both dog shit.
Therefore I am working on my own protocol, server, and client, not only for the ability to chat without gabens cock up my ass, but also for my own experience.
I have to learn socket programming somehow fuckface.
I learn best by doing practical projects.
>>
>>53533408
nuitka's eval() is interpreted
>>
>>53534646
Purged? What for?
I'm quite confident that you're enjoying watching hime get sexually harassed every 5 seconds.

Once that's over in 37 minutes, I highly recommend you read the manga.
Hachimitsu Scans just put out all 6 volumes back to back, complete with tankobon art and in proper reading order, because it was published in 3 separate magazines simultaneously and it can get confusing if you're not super dedicated and degenerate like I am.
>>
>>53534676
Ok? Then get back to working instead of continuing a pointless discussion because you've got your answers already.
>>
>>53534676
meant for >>53534637
>>
>>53534495
>base64 encode
Go fuck yourself.
>>
>>53534676
But gaben's cock feels great up the ass
>>
>>53534756
Why is this a bad thing?:
Serious question.
>>
Is anyone else totally triggered by this shit?

https://github.com/zneak/fcd/issues/10

The same issue has been opened on hundreds of repos over the few months. It's so fucking autistic I can't tell if it's satire. And yes, he opened this issue on one of mine (that's not it).
>>
>>53534770
Because there's better alternatives for such operation such as gzip.
>>
>>53532857

Again, unless the semantics of the language demand a JIT compiler. If you wrote an AOT native compiler for a language whose specification required a JIT compiler, you would have a logical contradiction. The very fact that it is an AOT native compiler implies that it is not standards compliant.

And it is not entirely unreasonable to require a JIT. If a language is focused heavily on reflection, it might allow a program to generate bytecode on the fly. In which case, your native compilation is doing nothing but embedding an interpreter into the executable. For many interpreted languages, this is actually what is being done when people design AOT compilers for them. Rather than compiling Ruby or Python into pure native code, they essentially wrap the script and the interpreter into an executable and compress it.
>>
>>53534693
okay it's


not that bad

about 15 minutes of it left
>>
>>53534770
>hurdur lets inflate the size of files for no reason
Just transmit them in it's binary form.
>>
>>53532263
pay for your shit fucking nigger
>>
>>53533066
>eclipse
english do you read it newfag?
>>
>>53534802
> In which case, your native compilation is doing nothing but embedding an interpreter into the executable.

It's entirely possible to both compile the program to native code and also embed an interpreter for code which is generated on the fly. This has been common for Lisp implementations for decades (the interpreter being the eval function)
>>
File: W1TeV1R.gif (628 KB, 500x332) Image search: [Google]
W1TeV1R.gif
628 KB, 500x332
http://fossbytes.com/swift-programmers-beard-java-saddest-cpp-oldest-developer-survey/

> java shills on suicide watch
>>
>>53535237
>they found literally zero female C programmers
>perl programmers are all depressed bearded women
>>
>>53534558
Irrelevant. If you write 2Mb of data to a socket, anything you subsequently write to that socket won't be sent until after the previous data has been sent.

And if you interleave the the data for the file with the other data, you need to add some kind of multiplexing feature to the protocol so that the other end knows which bytes are which. TCP doesn't preserve packet boundaries (i.e. if you write 1k then write another 1k, the receiver might get a single 2k packet or 4x 1/2k packets or any other combination).

Having said that, incorporating multiplexing into the protocol isn't out of the question. But it's probably better to use a separate socket. Personally, I'd use a different port so that it's straightforward to route file transfers through an entirely separate server.
>>
Do you normally declare strucs in the header file?
>>
>>53535281
I don't use header files
>>
I'm getting extra characters in a file I'm reading into memory with C. I don't know what's causing it because when I have ,say, two lines of text it works fine but when I have four there's extra blank characters in the buffer.
fseek(fp, 0, SEEK_END);
inputLength = ftell(fp);
rewind(fp);
fread(input, inputLength, 1, fp);
fclose(fp);
input[inputLength] = '\0';


The file that works is top, the one with extra is bottom.
push 1
print
========
push 1
push 1
add
print


There are about three extra characters so I don't think it's me adding the null terminator.
>>
File: Capture.png (7 KB, 237x234) Image search: [Google]
Capture.png
7 KB, 237x234
>>53535368
It looks like it's adding an extra character for each newline. Is it the \r?
>>
>>53534837

>let's inflate the size of files for no reason
Generally, if someone is sending files over in base 64 encoding, it is because they cannot use the entire ascii character set for file transfers

>>53535281

There are two approaches to structs and headers.

One is to fully define the struct within a header file, and to create an initialization function that accepts a pointer to the struct, whose memory should be be supplied by the caller, whether it be sitting in some vector on the heap, or on the stack.

The second is to not expose the struct's definition in the header at all, and only forward declare it. The header will expose a set of functions which will initialize the struct by returning a pointer to it, and a function to clean up the struct (since we cannot tell if it is allocated with malloc() or some other function).

The former is useful if we know the struct won't change, and want flexibility with memory. In general, it is best to have memory located close together for cache locality, so having a struct sit on the stack is nice.

The latter is useful if we want to be able to change the struct's definition later on without having to change the code that uses it. Since the only thing the using code is interacting with is a pointer and a set of functions, the API can change easily as needed.

Determine your use case, and then decide if you want to do this:
struct foo {
int x;
int y;
};

Or this:
// foo.h
struct foo;

// foo.c
struct foo {
int x;
int y;
};
>>
>>53535469

Oh son of a whore, I broke a bbcode tag. Also, I am pretty sure that is not where I placed my first closing brace.
>>
>>53535368
fopen("wb"/"rb") instead of fopen("w"/"r")
>>
>>53535556
Thank, I guess it was the \r not counting on windows.
>>
Writing a web application in C++, time for some long nights of coding.
>>
>>53535634
I find that Qt C++ has so much useful stuff in it that writing programs is almost as convenient as in sane languages.
>>
>>53535523
that keeps happening to me, I think those tags are slightly broken now
>>
>>53535672
I think
your mum
is
slightly broken
now
>>
>>53535696
Don't respond to tripfags.
>>
Which one of you tripfags was making that language?How did you do it, by using an AST? Did you implement that or use a library?
>>
making shifty websites and chatting with people in zeronet. feels nice
>>
>>53535814
me and GTP both have. yes, use an AST please
>>
>>53535237
R master race.
>adult
>successful
>clean shaven
>>
>>53535882
Did you use a library for the AST? I'm thinking of making one in C an wanted to do it myself but also don't want to increase the amount I think of suicide.
>>
>>53535237
>female C devs
>>
>>53534142
>more significant than its specification
found the jscuck
>>
File: summer1_small.png (112 KB, 870x499) Image search: [Google]
summer1_small.png
112 KB, 870x499
I do not have lots of programming skills other than some very basics in python and processing (java). Do you think it makes sense to get into c# to make games like Stardew Valley? How to start?
>>
>>53535469
>vector on the heap, or on the stack
there's no vector, heap, stack in C
>>
>>53533917
>completely acceptable to refer to a "JIT language" or a "compiled" or "interpreted" language
unacceptable
>>
>>53535237
>Programmers by language
>html

D R O P P E D
R
O
P
P
E
D
>>
File: rOp4l0H.png (58 KB, 771x678) Image search: [Google]
rOp4l0H.png
58 KB, 771x678
>>53535237
?
>>
>>53536137
you're not fooling anyone, mr. robot
>>
>>53536011
Why C# specifically?
>>
File: Vbtujp5.webm (2 MB, 720x404) Image search: [Google]
Vbtujp5.webm
2 MB, 720x404
Ask your much beloved programming literate anything (IAMA)

http://stackoverflow.com/research/developer-survey-2016

Your reaction when Javascript is again confirmed for being the top notch of programming languages.
>>
is it a crime that I enjoy programming with Ruby
>>
>>53536286
Kill yourself, faggot.
>please, no bully
Kill yourself, fucking faggot.
>>
>>53536286
Suggest a project doable in the C programming language.
>>
>>53536308
>doable
All of them.
>>
Lets program something together come on guys lets make /dpt/ great again and lets shock and stun the programming community as best coders
>>
>>53536318
Reasonably doable.
>>
>>53536299
Depends.
Is homosexuality outlawed in your country?
>>
File: socialism.gif (2 MB, 376x228) Image search: [Google]
socialism.gif
2 MB, 376x228
>>53536308
an implementation of the BernieScript programming language ?

https://github.com/jweinst1/BernieScript
>>
>>53536331
I'll start on the logo
>>
it truly is a great language
>>
>>53530487
get back on twitter -.-
>>
>>53536380
-_-
>>
>>53536339
Ruby is like the love child of java and python
>>
>>53536415
s/love/rape/g
>>
>>53536369
Please all I dream about make a beautiful logo someone
>>
Daily reminder that references are just pointers with shitty restrictions on them.
>>
>>53536598
and?
>>
>>53536598
*in some languages.
>>
>>53536598
not true.
>>
Daily reminder Java is king of all programming languages and cannot be beat
>>
>>53536598
Yeah but they do get garbage collected when out of scope. Have fun manually freeing pointers yourself
>>
Daily reminder that C is obsolete.
Thread replies: 255
Thread images: 25

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

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