[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: 343
Thread images: 13

File: 1497305697332.png (40KB, 1620x774px) Image search: [Google]
1497305697332.png
40KB, 1620x774px
What are you working on, /g/?
Previous thread: >>61484482
>>
Do they plan to fix this or is it nailed to D's coffin? Because I'd really love D without a STW GC
>>
First for COBOLT
>>
>>61490102
Cobalt*
>>
>>61490101
You can use D without GC right now.
>>
>>61490101
60/40 want the GC gone.
Also /dpt/ wildly overreacts about GC's obtrusiveness.
But as the other anon said, @nogc is your friend.
>>
>>61490101
Think they're working on switching it out for Sociomantic's GC, which runs in a separate thread
>>
>>61490135
How practical is it really?
>>
>>61490148
It's as easy as malloc and free
>>
>>61490140
Anon, I don't have anything much against the GC.
Well if D goes full RAII it'd be even better but how about making the GC better?
>60/40 want the GC gone.
what?
>>
>>61490101
What always puzzles me is:
>Go is great! <munches on Rob Pike's dick>
>D sucks because of GC!
>>
>>61490183
Please, Gotards are the official laughing stalk of /dpt/
>>
Fucking parameter packs in c++ templates drive me nuts.
Please tell me this can be implemented better:
#pragma once
#include <array>
#include <numeric>

template <typename T, size_t Rank>
class test_array {
public:
template <typename ...Args, std::enable_if_t<sizeof...(Args) == Rank>* = nullptr>
explicit test_array(Args&& ...args) : sizes{std::forward<Args>(args)...}, data{size() ? new T[size()]{} : nullptr}
{
}

template <typename ...Args, std::enable_if_t<sizeof...(Args) == Rank>* = nullptr>
size_t ix(Args&& ...arguments) {
std::array<size_t, Rank> args{std::forward<Args>(arguments)...};

size_t index{};
for (size_t i = 0; i < Rank; i++) {
index += args[i] * std::accumulate(sizes.cbegin(), sizes.cbegin() + i, size_t{1}, std::multiplies<>());
}
return index;
}

size_t size() const {
return std::accumulate(sizes.begin(), sizes.end(), size_t(1), std::multiplies<>());
}

std::array<size_t, Rank> sizes;
T* data;
};
>>
>>61490160
>but how about making the GC better?
Thats counter-productive when the community is leaning towards a nogc future.

But the GC isnt even bad, even for being STW.
You can also do GC.disable/enable anytime you want. Or just use malloc/free and std.container.array
>>
>>61490203
>Some people read these
>>
>>61490183
this is why C is never going away

>>61490203
just kill yourself instead. it's easier than trying to finish that.
>>
File: 1475997497444.jpg (374KB, 1180x664px) Image search: [Google]
1475997497444.jpg
374KB, 1180x664px
im building shared libraries using cmake and gcc, is there any way to disable generating .a files? i dont need them and they just take my screen space when browsing output directory
>>
>>61490207
>enable GC back
>Immediate stw
>>
>>61490219
>this is why C is never going away
No. C will never go away because all language can interface to C
>>
>>61490203
variadic templates are not for humans, give up.
>>
>>61490225
>dont .enable on performance critical sections
>never have an issue
with concurrency and parallelism it shouldnt be a problem though.
But if youre that apprehensive then just stick with c/++, desu.
>>
>>61490249
>C++
I'd rather kill myself or stop programming.
>>
File: c.png (77KB, 1200x1276px) Image search: [Google]
c.png
77KB, 1200x1276px
>>61490105
Sounds complicated, I won't optimize it before switching to A* from BFS and seeing that I really need it. Premature optimization is the root of all evil.

Also, seeing that you're much more experienced Python programmer, and I'm way more familiar with C, in your opinion, how much Python is bigger, harder to master than C is? Currently, I have the C standard and I like reading it from time to time, I think that combined with the C puzzle book (1982) I will become quite deeply familiar with the language.
>>
>>61490220
the command to generate a shared library is
gcc -shared -o libfoo.so inputfile1.c inputfile2.c inputfile3.c obj1.o staticlib1.a # etc

chances are for a small project you probably don't need cmake. just specify your source dependencies manually with a regular makefile, it'll be way faster
>>
>>61490260
Then i guess if you really wanted to you could just use it as a better C environment with UFCS and functional support.
>>
>>61490293
C++ has UFCS?
>>
>>61490293
>better C
Is thare any guide/website for that.
>>
>>61490270
>the command to generate a shared library is
>gcc -shared
it's that easy? holy shit
>>
There's literally no reason to learn programming.
>>
>>61490195
> laughing stalk
>>
>>61490247
>>61490219
>>61490213
I have never liked c++ but I just wanted to program multi dimensional array in c++.

>>61490299
I think he was talking about D.
>>
Clojure, Haskell, or Elixir tonight, lads?
>>
>>61490330
point stands irregardless :^)
>>
>>61490320
???
To avoid being a jobless neet?
>>
>>61490347
>tonight
A 30 minute intense masterbation session about pure languages
>>
>>61490270
thats not what i was asking for, i want gcc to not generate that .a file, whenever i create dll/so file theres always an .a, i dont want it
>>
>>61490358
I should probably add 'after the masturbation'.

I just wish Clojure had pattern matching...
>>
>>61490388
Rust doesn't have this problem
>>
File: cpuzzles.jpg (193KB, 1029x728px) Image search: [Google]
cpuzzles.jpg
193KB, 1029x728px
Anybody tried this? Will it make me a better programmer?
>>
>>61490396
No, but striped socks will
>>
>>61490394
> imperative language
> twenty fucking seventeen
>>
>>61490351
If you're a programmer, you're on a fast track to become a jobless neet.
>>
>>61490378
it doesn't generate a .a file

$ cat testlib.c
int important_function(int a)
{
return a*2;
}
$ gcc -fPIC -shared -o libtest.so testlib.c
$ ls libtest.*
libtest.so
$ ls *.a
ls: cannot access '*.a': No such file or directory
>>
test
>>
What if there was a Rust based language that doesn't have stupid shil like borrow checker? It'd use RAII and have zero cost itererators etc
>>
>>61490077
>What are you working on, /g/?

Going back and trying to understand Prolog a bit more
>>
>>61490439
it's called unsafe
>>
>>61490445
> Prolog
I still have nightmares.
>>
>>61490439
itd still be a half-breed monstrosity
>>
>>61490466
Can't be worse than C++
>>
File: 59479681986132181.png (5KB, 247x204px) Image search: [Google]
59479681986132181.png
5KB, 247x204px
>>61490422
it must be fucking cmake, but im not gonna write makefile for 250 cpp files tho
>>
>>61490480
It unironically is though.
>>
File: 1500232934506.jpg (100KB, 600x800px) Image search: [Google]
1500232934506.jpg
100KB, 600x800px
>>61490495
Nice try, herb sutter
>>
(Reposting)

>>61489518 (You)
I caught it turning null literally immediately after object construction:
RamfsFile ctor 2, vtable: 0xc01145bc
alloc_inode 0xc0911020 vtable: 0x00000000


RamfsFile ctor:
RamfsFile::RamfsFile(u64 ino, RamfsInstance *instance) : RamfsInode(ino, instance) {
printk << "RamfsFile ctor " << ino << ", vtable: " << *reinterpret_cast<void**>(this) << '\n';
}


Code that calls above ctor (T is RamfsFile):
auto *inode = new T(ino, this);
// objects vtable pointer and surrounding content get mysteriously zero'd between the above line and the below line
printk << "alloc_inode " << inode << " vtable: " << *reinterpret_cast<void**>(inode) << '\n';



The vtable pointer was valid in the constructor, and then immediately after the constructor I print it out again and it's null. Keep in mind that it gets zero'd like this at random points, I just happened to catch it here this time.
What could be causing this? This is fucking weird.
>>
>>61490513
Enterprise incompetence/laziness is amazing.
>>
>>61490513
>Current state of C++
>>
>>61490513
kek this is sad
>>
File: _tnkNT.png (29KB, 1373x433px) Image search: [Google]
_tnkNT.png
29KB, 1373x433px
>>61490482
if your code is properly modularized, writing makefiles will be super easy

if it isn't modularized to the point where you could shit out working makefiles in 10 minutes or less, it means your code sucks
>>
>>61490534
>Current
>>
>>61490518
why are you writing a kernel in c++?

set an early write watchpoint for the address then continue the debugger

it'll trap whenever it gets zeroed
>>
>>61490263
Well, C is a lot more nuanced than Python, which be tricky to learn. However, Python has a lot more concepts to learn. All in all Python is probably much easier to master than C, simply because is more primitive than Python and thus requires a lot more experience to handle things, especially if the program gets large.

It is not really hard to switch to A* from BFS if you see out your code correctly. A general program structure would be.
# node.py
class Node:
# Used for handling nodes in a tree
def __init___(self, element):
# Set g, h, f, parent and children to default values
def addchild(self, node):
# Add child to node
def setParent(self, parent):
# Set parent for node

# tree.py
class Tree:
# Used to store the actual tree and nodes
def __init__(self, root):
# Set root node of the tree

def __contains___(self, item):
return self.contains_aux(self.root, item)

def contains_aux(self, node, item):
# Use recursive algorithm to find element in the tree

# tree_search.py
class TreeSearch:
def __init__(self, puzzle_initial_state):
# Set the currently selected node (for expansion) of the tree to an initial state
# Create a tree object to store all the states
# Create a variable to store open and closed states
def solve(self):
# Expand each element in open to check if the puzzle is solved


Now it is a matter of creating a class for your BFS or A* to inherit from TreeSearch and defining a method expand_node to calculate the f, g and h values of each node and ordering it so that solve will get the smallest f value.
>>
D atleast did this better than c/c++ does:
int x,y;   // x and y are ints
int* x,y; // x and y are pointers to ints
int x,*y; // error, multiple types
int[] x,y; // x and y are arrays of ints
int x[],y; // error, multiple types
>>
>>61490396
I've never seen that book so I can't comment on how good it is. What do you mean by "better programmer"? That could mean a few things. I recommend The Pragmatic Programmer, but that focuses on the more software engineering side of things. The Practice of Programming by Kernighan and Pike is very good, it focuses on general programming techniques but it does a lot on C since C has a lot of unique features about it. If you are extremely lucky you could find a copy of Elements of Programming Style by Kernighan and Plauger which mainly a predecessor to The Practice of Programming and makes a lot of comments on Fortran and PL/I, but later chapters are more general. And there is also Expert C Programming, but my copy of the book has not been delivered to me yet, so I don't have it or know much about it.

>>61490263
As said here >>61490574 C is very basic and making large projects can be difficult, that's why a lot of people C++ instead of C since C++ provides a lot more abstractions to make programming easier.
>>
>>61490605
On one hand yes, on the other everyone is used to the trap that the syntax is in C++ and C and it might be confusing for newcommers.
>>
>>61490605

It's an improvement, but it's not the best way things could be.
int[3][6] arr;
arr[5][2]; // final element of array - confusing

The only style I haven't seen played with in any language is this, you could consider it a variant of "declaration follows usage".
int x;
*int ptr1, ptr2;
int[3][6] arr2d; // arr[2][5]
>>
>>61490569
>why are you writing a kernel in c++?
Why not?

I have tried setting a watchpoint, but the problem is that when I connect gdb to qemu to set the watchpoint, the bug vanishes! Even though nothing changed except now I just have a debugger attached.
And of course the bug comes back when I don't attach a debugger.
It also vanishes when I disable KVM, and it doesn't happen in bochs at all.

Is this a qemu bug? I'm not sure if it is, because removing a function call in my code causes the bug to also disappear without changing the address that the object resides at (0xc0911020), and of course I've spent hours investigating why the existence of the somewhat unrelated function call causes the bug to arise, and can't find anything.

But what I've caught here >>61490518 is pretty weird.
>>
>>61490605
You can also do:
int x = 4,y, z = 9;
>>
>>61490102
>>61490108
COBOL
niggers
>>
>>61490670
then compile in a write trap into your kernel, do the debugger's job for it

http://www.sandpile.org/x86/drx.htm
http://wiki.osdev.org/CPU_Registers_x86#Debug_Registers
>>
>>61490670
I don't know how it relates to your bug but everytime I had a bug that vanished under a debugger it turned out to be an uninitialized variable which the debugger was zeroing out.
>>
File: Tcl-powered.svg.png (17KB, 179x280px) Image search: [Google]
Tcl-powered.svg.png
17KB, 179x280px
>>61490077
Last night I read about this language called Tcl. It looks pretty comfy and powerful, should I learn it /dpt/?
>>
>>61490203
This is why I prefer C.
>>
>>61490724
Demonstrate an implementation in C then.
>>
>>61490718
Why would the debugger zero anything out?
>>
>>61490723
No. Learn guile instead or Stallman will come to rape you while you are sleeping, just like he did with the gdb developers.
>>
>>61490724
because C variadic macros are so elegant, right?
>>
>>61490747
Yeah, variadic macros are the best. Fuck sepples.
>>
>>61490724
Well I use C and c++ for different things, c++ for pc and C mostly for embedded stuff.
>>
>>61490203
What is that supposed to be and what is Rank
>>
>>61490737
I don't know but gdb does that for uninitialized variables, that's why I had the bugs occur without a debugger but the moment I attached gdb the bug would vanish. Again, I don't know how that related to your program other than the bug vanishes under gdb but perhaps it's worth looking into.
>>
>>61490513
If you're going to write a shitty implementation of something and then put in a comment telling others to fix it, its better not to write anything at all.
>>
>>61490734
struct array {
void *contents;
size_t size_in_bytes;
};
>>
>>61491011
heheheheheheheeh
>>
>>61491011
hahahaha
>>
>>61490770
It's supposed to be a multi dimensional array.
So you can do stuff like.
#include "multi_array.h"
int main(int argv, char** argc) {
multi_array<int*, 4> ma_4d(3u, 5u, 3u, 2u); // Create an array of size 90
multi_array<int, 3> ma_3d(2u, 4u, 3u); // Create an array of size 24
multi_array<double, 2> ma_2d(5u, 5u); // Create an array of size 25

// ma_3d.ix(0u, 2u, 1u) == 12
// ma_4d.size<0>() == 3u
// ma_4d.size<3>() == 2u
// ma_2d.size<2>() gives a compiler error
}


>>61491011
your struct does something completely different though.
>>
>>61491011
>>61491024
>>61491034
(You)
>>
>>61490670
>but the problem is that when I connect gdb to qemu to set the watchpoint, the bug vanishes!


Haven't read your posts because TLDR so don't know if this applies but this is a classic symptom of a race condition. Is something yanking the object away from elsewhere?

>it doesn't happen when I have a debugger attached!
>it doesn't happen in release builds!
>it doesn't happen on my machine!
etc.
>>
>>61491042
why do you need a variadic template for something with always two template arguments? I don't get it
>>
>>61491100
The variadic arguments apply to the constructor arguments, not the class template.
>>
>>61491089
It is a multithreaded kernel, but I don't have any other threads running, nor are there more than one thread touching the code where the bug resides.
I've even tried disabling the scheduler alltogether and just ran the test code in the boot thread and the bug still arises.
>>
databases are pretty neat.
>>
>>61491042
struct array multiarray;
multiarray.size_in_bytes = sizeof(int *)*3*5*3*2;
multiarray.contents = malloc(multiarray.size_in_bytes);
// Create an array of size 90
// And here is how to treat it as a 4D array:
multiarray.contents[1*3*2*1] = malloc(sizeof(int));
>>
>>61491042
Add uint8_t dimension to struct. Problem solved
>>
>>61490739
How bad can it be?
My dad did it and I survived that.
>>
>>61491138
again, register a debug ISR and set up the debug registers to trap on write to the vtable address

that should catch your bug as it occurs
>>
>>61491176
I think I will do that.
>>
what's the recommended IDE for Rust?
>>
>>61491211
firefox
>>
>>61491211
The same as every other language: Emacs.
>>
File: 1497578481684.jpg (210KB, 1600x1067px) Image search: [Google]
1497578481684.jpg
210KB, 1600x1067px
I will unironically ditch C++ for Jai when it comes out.
>>
>>61491289
>when it comes out.
What are you going to do until 2068?
>>
>>61491233
>>61491217
does Rust not have a good IDE that can parse the code?
>>
>>61491310
>he doesn't know
>>
How do I into C++? Goddamn, I can read the Linux source code with ease, but reading even the simplest snippets of modern C++ (std::function, mutex, templates, etc.) gives me a headache. And the language is so fucking huge that I don't know where to start.
>>
>>61491321
Noone knows because nobody has ever programmed in Rust, not even rust programmers.
>>
>>61491346
use a sane subset of C++.
C + lambda funcs + constexpr + raw strings + auto + whatever else you actually find useful
>>
>>61491346
Same as most other languages...
1. Decide on something to do
2. Set off to do it. Look everything up as you go
>>
Making game utility library(engineish) in C and I want to make it modular. By that I mean the engine will be running and manage resources and modules. It will provide interface to load and unload modules.

Is there some small engine that does this or some documentation on the subject?
Not sure what all my library should provide, like do I want the rendering stuff be inbuild with the engine or load it as module...
>>
>>61491369
>use subset of C++.
No you dumb fuck. Either you use sepples or you should fuck off, nobody wants your """orthodox c++""" because it just makes using your shit harder.
>>
>>61491422
if you actually use the awful abomination that is C++ as it was intended you are a gullible, simple-minded lemming. Thus you are the perfect candidate for churning out "clean" C++ code, carry on.
>>
>>61491408
Make a game and the engine.Not just the engine.
>>
61491335
(You)
>>
>>61491461
sure but I need to make platform for testing to create that game which will be the library.
>>
>>61491462
>he STILL doesn't know
>>
>>61491489
Jai's probably at 0.0.9 right now.
>>
>>61490417

>program now
>expert sales when outsourced
>>
Under what circumstances might you want to do arithmetic on a void*?
>>
>>61491501
who cares? I was talking about when the compiler actually gets released to the public
>>
>>61491515
thats what i meant.
He still doesnt have a lot of basic features and on top of that he wants to basically do a re-write once its feature complete. Youre bettor off learning Nim.
>>
>>61491507
In the context that it's not an opaque pointer to memory, and actually means something.
>>
>>61491551
Surely you'd cast it first if you know what it's pointing to.
>>
>>61491507
Never. It is undefined behavior.
>>
>>61491539
it will be out by the end of the year screenshot this
>>
>>61491570
Just because something is classified as having undefined behavior doesn't mean its actual behavior is undefined
>>
>>61491596
>it will be out by the end of the year
If he gives in to his twitch brainlets and releases a half-finished mess.

I dont see a beta release until earliest this time next year.
>>
>>61491604
It means what it means. You can't rely on undefined behavior.
>>
>>61491642
For the most part, you absolutely can. You just can't rely on it being portable.
>>
>>61490077
Just got a programming job. How can I distinguish myself and become a better programmer? Went to a meh school with tons of pajeets so I was top of my class without being that good or learning all that much.
>>
>>61491176
No luck.
The watchpoint gets triggered in the constructor, so it definitely works, but then when the vtable ptr mysteriously gets nulled, the watchpoint never gets triggered.
Is it even possible to write to memory without triggering watchpoints? I did make sure to set a write watchpoint.

Relevant log:
RamfsDir: mkfile `lol`
DEBUG EXCEPTION! eip: 0xc010b97b, vtable: 0xc01148cc
DEBUG EXCEPTION! eip: 0xc010b9af, vtable: 0xc0114860
DEBUG EXCEPTION! eip: 0xc010715a, vtable: 0xc011481c // ctor triggers watchpoint
RamfsFile ctor 2, vtable: 0xc011481c
alloc_inode 0xc0911020 vtable: 0xc011481c
RamfsInstance: lookupInode 2
Inode table:
1: 0xc0891020, vtable: 0xc01147d8
2: 0xc0911020, vtable: 0xc011481c // The object we are watching
RamfsInstance: releaseInode 1
Inode table:
1: 0xc0891020, vtable: 0xc01147d8
2: 0xc0911020, vtable: 0x00000000 // Suddenly it's null, and our watchpoint never got triggered. Wtf?!
...


This is the code I used to setup the debug registers, in case I did it wrong:
        asm volatile (
"mov eax, 0xc0911020\n"
"mov dr0, eax\n"
"mov eax, 0\n"
"or eax, (1 << 1)\n"
"or eax, (1 << 16)\n"
"or eax, (4 << 18)\n"
"mov dr7, eax"
:
:
: "eax", "memory"
);


...

I just ran it again and got this:
RamfsDir: mkfile `lol`
DEBUG EXCEPTION! eip: 0xc010b97b, vtable: 0xc01148cc // Inode ctor
DEBUG EXCEPTION! eip: 0xc010b9af, vtable: 0xc0114860 // RamfsInode ctor
DEBUG EXCEPTION! eip: 0xc010715a, vtable: 0x00000000 // RamfsFile ctor
RamfsFile ctor 2, vtable: 0x00000000
alloc_inode 0xc0911020 vtable: 0x00000000
...

This has to be a qemu bug.
>>
>>61491826
Practice, particularly with the languages or framworks your company uses. Ask a nicer senior-level guy once you get to know everyone a little better.

>Went to a meh school with a tons of pajeets
iktf, now i'm headed to graduate school ready to get my shit kicked in
>>
>>61491874
Wish i had saved some screencaps of code and diagrams pajeets sent me. Holy fuck it was indecipherable. Even reading their texts was a master class in cryptography
>>
to code in Java is to touch the sublime
>>
Do you make a few but large commits or do you make small but a lot of commits?
>>
I'd like to make a voxel game. What should I use?

1. I thought I would go with C/C++, SDL or FLTK and OpenGL for the client (and maybe emscripten/WebAssembly for a browser version, that would be nice).
What about Rust instead of C++? I know nothing about Rust but /g/ memes about it all the time. It's maybe a shit idea but worth asking you anyways.

2. Server needs to be faster and more stable, obviously, so I thought I'd go with pure C because I know C the best. Or should I go with Erlang and only write computationally heavy parts in C? I've heard of the stability of Erlang but I'm worried it would be too slow.

3. I know nothing about networking. There will be lots of data sent between server and clients and I can't lose packets or anything.

4. I made up a format of storing the voxels. The world would be split into chunks, each of 16x64x16 nodes, each chunk would store a serialized BLOB listing all nodes that differ to the ones generated with the map's seed. It would be stored as a list of structures defined like this:
int16 node_type; //this gives 65536 different types of nodes which should be enough IMO
list of int16 position; //4 bits for x coordinate, 4 bits for z coordinate, 6 bits for y coordinate, 2 auxiliary bits that I'll explain in next post

I saw one game that stored the chunks in a database (SQLite). I think I'll do the same.

5. I'd like to make a mod API for this. Mods would be just dynamically loaded libraries. I need a way to let the system find mods in a directory to load them.
>>
>>61492059
small and many
>>
>>61492064
Rust gamedev is still pretty immature, outside of sdl2 i found it to be difficult.
>>
File: Freakenstein.jpg (57KB, 1000x1005px) Image search: [Google]
Freakenstein.jpg
57KB, 1000x1005px
Post a picture representing a language and others guess what the language is.
>>
File: idort titties.jpg (204KB, 927x1137px) Image search: [Google]
idort titties.jpg
204KB, 927x1137px
>>61492234
sepples
>>
>>61492234
Java
>>
>>61492234
Dutch?
>>
>>61492276
Dutch is a lovely language though.
>>
>>61491849
What had to have happened, I think, is that a different page of memory got mapped over the region.

Can you run it on actual hardware to confirm that qemu is being weird?
>>
>>61490077
I'm writing a script in python to check whether a combination of words is valid by submitting it to a remote website and parsing the reply

problem is, I can only check one combination of words at a time using loops, I'd like to make the script faster

What should I use to run 5 or more checks at a time? Multiprocessing, multithreading, Parallel processing?
>>
>>61492234
C++ for sure
>>
>>61490203
why do most people posting c++ code snippets don't use namespace std instead of having to write it out.
If it's for performance reasons I can understand but if not I usually find it more legible using namespace.
>>
>>61490482
lib250tho.so: $(wildcard *.c)
$(CC) -o $@ -shared -fPIC $^

wew, so hard
>>
>>61492064
golang is the only viable answer
>>
>>61492385
It was because I copied it over from the full container.
>>
>>61492234
rust
>>
>>61492234
>>61490077
>>
>>61492064
WebGL for the client and Node.js for the server if you want a working prototype in days.

What you said if you want one in months.
>>
No reason to use c or c++ anymore now .net runs on multiple platforms.
>>
>>61492414
>lib250tho.so: $(wildcard *.c)
> $(CC) -o $@ -shared -fPIC $^
>$@ hurr
>$^ durr
The fuck is that trying to be regexp?
Then they make fucking macros for everything, why not make descriptive macros for your fucking parameter handling shit?
fuck make is so fucking retarded.
>>
>>61492327
>Can you run it on actual hardware to confirm that qemu is being weird?
No.
But as I said, the bug doesn't happen if I disable KVM or run it in bochs.

>What had to have happened, I think, is that a different page of memory got mapped over the region.
Could be, but shouldn't be. I'll look into it.
>>
Not sure if this is possible but maybe it is or maybe someone can point me to something similar to it -

I'm writing some code in C++ and have a class with some variables in it that I'd like to access with getter and setter functions. My question is, do I need a getter and setter for each variable, or is it possible to have a generic one where I pass the name of the variable in as 'x' and then have the function simply return 'this.x'?
>>
>>61492571
it doesn't
>>
>>61492593
>do I need a getter and setter for each variable, or is it possible to have a generic one where I pass the name of the variable in as 'x' and then have the function simply return 'this.x'?
holy shit, anon

Just write your getters and setters. Doesn't C++ have auto-properties these days?
>>
>>61492599
Yes it does. It's called .net core.
>>
>>61492593
Why do you want to write getters and setters? Just make your fucking variable public
>>
>>61492593
If only C++ has mixins
>>
>>61492593
>is it possible to have a generic one where I pass the name of the variable in as 'x'
it's usually automated for you anyway so nobody does that shit
>>
>>61492599
>it doesn't
Can you elaborate?

Mono and .NET Core are both FOSS, and between them (and the .NET Framework) they cover pretty much everything.
>>
>>61492571
>No reason to use c or c++ anymore now .net runs on multiple platforms.
While it's great that .NET Core/Mono is FOSS and works on all the major platforms, it hasn't replace C or C++ at all.

You could make the argument that some C++ things can be replaced now, but it certainly isn't obsolete.

C isn't even comparable to either.
>>
I made a basic search engine for uni in c++. Basically tokenize words, index documents and search.
Any project i can do along the same lines?
>>
>>61492744
>Bu.. Bu. But Muh Bill Gates Dick IN MY ANUS
Fuking #c shiller
>>
>>61492759
Elasticsearch
>>
>>61492759
you're only 20 years late
>>
>>61492775
>>61492834
I know. I'm just looking for projects where optimization is important. I remember for the part on tokenization a friend used regex and it took him 40 seconds to process a bunch of files the teacher gave us. I used a finite state machine and it took 10. I had a blast just looking for stuff i could optimize in my code and seeing the time go down.
>>
>>61492875
Again, Elasticsearch. Having a fast search is critical for this project.
>>
>>61492887
>>61492775
He's asking for a project he can enjoy optimizing not a project that's been done in search
>>
>>61493056
For what purpose?

Why reinvent the wheel? Just build upon the work that's been done.
>>
>>61493166
>brainlet literally can't comprehend doing a project to learn
hello rajesh
>>
>>61493209
That's pretty racist, and the accusation that I'm Indian isn't correct.
>>
>>61493166
he said he enjoyed optimizing it
so presumably for entertainment
>>
>>61493225
>That's pretty racist, and the accusation that I'm Indian isn't correct.
r u nu?
>>
>>61493225
Back to your shitting street
>>
>>61492327
Nope, page isn't being remapped.
>>
hey /dpt/ I need help. I really want to learn how to program, but i seriously dont know what the fuck to do. Do i need a text editor? Do I need linux? I don't wanna use Windows but Vim seems hard to use and i dont understand it. I'm just a brainlet trying to get a job, please help
>>
>>61493386
>I'm just a brainlet trying to get a job, please help
don't bother than
you don't have the necessary autism for this field
>>
>>61493386
>I'm just a brainlet trying to get a job
go to a coding bootcamp, they will teach you to make websites and you'll be all set
>>
>>61490203
std::unique_ptr instead of raw pointer
>>
>>61493386
I'd just like to interject for moment. What you're refering to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.

Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called Linux, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project.

There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux!
>>
>>61493439
No, Richard, it's 'Linux', not 'GNU/Linux'. The most important contributions that the FSF made to Linux were the creation of the GPL and the GCC compiler. Those are fine and inspired products. GCC is a monumental achievement and has earned you, RMS, and the Free Software Foundation countless kudos and much appreciation.

Following are some reasons for you to mull over, including some already answered in your FAQ.

One guy, Linus Torvalds, used GCC to make his operating system (yes, Linux is an OS -- more on this later). He named it 'Linux' with a little help from his friends. Why doesn't he call it GNU/Linux? Because he wrote it, with more help from his friends, not you. You named your stuff, I named my stuff -- including the software I wrote using GCC -- and Linus named his stuff. The proper name is Linux because Linus Torvalds says so. Linus has spoken. Accept his authority. To do otherwise is to become a nag. You don't want to be known as a nag, do you?

(An operating system) != (a distribution). Linux is an operating system. By my definition, an operating system is that software which provides and limits access to hardware resources on a computer. That definition applies whereever you see Linux in use. However, Linux is usually distributed with a collection of utilities and applications to make it easily configurable as a desktop system, a server, a development box, or a graphics workstation, or whatever the user needs. In such a configuration, we have a Linux (based) distribution. Therein lies your strongest argument for the unwieldy title 'GNU/Linux' (when said bundled software is largely from the FSF). Go bug the distribution makers on that one. Take your beef to Red Hat, Mandrake, and Slackware. At least there you have an argument. Linux alone is an operating system that can be used in various applications without any GNU software whatsoever. Embedded applications come to mind as an obvious example.
>>
>>61493386
>Do i need a text editor?
source code is text, and you'll be editing that. so gee I sure do wonder if you will
>Do I need linux?
if you're smart youll use it
windows development is worse than death
> I don't wanna use Windows but Vim seems hard to use and i dont understand it.
why do you need to use vim on linux
use kate, or some other graphical text editor if you don't like vim/emacs
>>
>>61493474
> GCC is a monumental achievement

yep, llvm is still shit for performance despite Apple cash
>>
>>61493520
Both can be better than the other in different cases
>>
>>61493386
https://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_3
Disclaimer: I hate python because its not strictly typed but this will tell you how to get started.
>>
>>61491042
The multidimensional array be implemented as this:

#include <array>

template<typename T, size_t Rank>
using multi_type = std::array<T, Rank>;

template<size_t N, int... Rest>
struct rank {
static size_t const value = rank<Rest...>::value * N;
};

template<size_t N>
struct rank<N> {
static size_t const value = N;
};

template<typename T, size_t ...Args>
using multi_array = multi_type<T, rank<Args...>::value>;

int main()
{
multi_array<int, 3, 3, 3> m;
return m.size();
}


Will try to figure out how to query for each dimension's size.
>>
>>61493541
No. I write software you know and regularly compile and test with both because it's a trivial change.
>>
>>61493351
Is the memory still accessible at the point the vtable becomes null if you stick a pointer to it in a global? Maybe accessing it then will cause a fault?
>>
>>61493386
>Do i need a text editor?
You need something that has a text editor. Choose the primary IDE made to work with your preferred language. You can also use "totally-not-IDEs" that people call "text editors", but you'll be spending lots of time adding on features that are otherwise built-in to a proper IDE.

>Do I need linux?
Of course not.

>I'm just a brainlet trying to get a job, please help
It's possible that you literally do not have the correct thought patterns to program. There are multiple studies that show distinct groups of people and whether they are capable of programming based on their problem-solving patterns.
>>
>>61493619
what are the non-programing thought patterns?
>>
>>61493614
You mean keep a pointer to the actual vtable? Pretty sure it's in static memory and it doesn't matter anyway.
The issue is that the vtable pointer gets zeroed by something which causes a fault when trying to call a virtual method.
The memory that the pointer resides in is still accessible, that's how I'm able to even print the value of the vtable pointer.
>>
>>61493668
Oh and it's not just the vtable pointer that gets zeroed, the surrounding area gets zeroed too.
I don't know exactly how large that area is though.
>>
>>61493583
Using your method the sizes are fixed on compile time while in my implementation they aren't. I might change mine to not be fixed during compile time at all and just have everything be runtime.
>>
>>61493662
Lack of intuition. See http://www.myersbriggs.org/my-mbti-personality-type/mbti-basics/sensing-or-intuition.htm?bhcp=1
>>
>>61493662
It's mostly based around your ability to form consistent mental models on how a system(in the abstract sense) works. It actually doesn't matter at all if your mental models are right; the only major distinction is if you can form a consistent model in your mind based on observable behavior of the output from things you can manipulate.

This is usually tested with showing those who have never programmed simple variable assignments and control flow. Even if the tester misunderstands how assignment/comparison works, if they continue to answer in a consistent way, they can likely learn the proper way. Unfortunately, this is usually only about 35-40% of the population.
>>
>>61493717
>drawing conclusions from MBTI tests
this is why people think MBTI is a joke
>>
>>61493719
are these people just stupid or is there another set of problems they excel at?
>>
>>61493735
If you can't draw conclusions then it is useless.

You already thought it is a joke and you're trying to imply treating it as something other than a joke makes it a joke. You're thinking backwards.
>>
is making programs with HTML, CSS UIs a thing?
>>
>>61493735
Also >>61493719 says there's 35-40% programming compatible people, and about 25% of the population is nominally intuitively typed. Considering that some people are well balanced humans and have well developed tertiary and inferior functions, that makes sense.
>>
#include <iostream>

int getLength(int x)
{
int count = 0;
while (x > 0)
{
count++;
x = x / 10;
}

return count;
}

int main ()
{
int champernowne[1000100];
int n = 1;
int initial_pos = 0;

while(initial_pos <= 1000000)
{
int nlength = getLength(n);
int end_pos = initial_pos + nlength - 1;
int ntemp = n;

for(int i = end_pos; i >= initial_pos; i--)
{
champernowne[i] = ntemp % 10;
ntemp /= 10;
}

n ++;
initial_pos = end_pos + 1;
}

int product = 1;

for(int i = 1; i <= 1000000; i *= 10)
{
product *= champernowne[i-1];
//std::cout << product << "\n";
}

std::cout << product << "\n";

return 0;
}


I got this solution for problem 40 of project euler. Tell me why I'm retarded/what I could have done better.
>>
>>61493842

project euler has nothing to do with programming

consult a math forum
>>
>>61493772
>Are the majority of all humans stupid?
The answer is a resounding "Yes", as fedora-core as that sounds.

I can't comment on excelling at other areas from this one particular test, but generally speaking, anyone who is successful in their endeavors are able to form consistent models of any aspect of their life, and also especially adjust those models when reality directly contradicts assumptions they've made about a particular system.

>>61493808
Personally, I don't think the MBTI "Intuitive" type would show a strong correlation of all gainfully employed programmers, but more likely be correlated to language designers and higher-level software architects.

I wouldn't claim that you need to be either of these to be considered a successful programmer.
>>
>>61493842
you could have used haskell
>>
>>61493701
If it is not compile-time, then it is a bit pointless to use templates. Just have a vector of vectors (...of vectors, etc...) and call it a day.
>>
the NSA's internship programs only explicitly want C, assembly, and OOP experience. what OOP language should i focus on? i like C++ because it's common on linux but not much otherwise
>>
>>61493774
>you already thought it is a joke
no, I don't, I like MBTI
but to act like it's anything other than a systematic way to describe people is foolish
MBTI should only be used to describe people based on prior actions and statement, using it to guess what a person is like is dumb.

I don't think I'm succeeding in describing where I stand on MBTI, but hopefully you understand
>>
>>61493668
>>61493688

I'm pretty stumped, then. Code?
>>
>>61493891
>what OOP language should i focus on
java unironically, that said, C++ is better
>>
>>61493842
You precomputed all these digits of that irrational number when you didn't have to.

I'll give you a push in the right direction. Imagine we have a rational number consisting of all the 3 digit numbers glued together, and for simplicity's sake, if it's less than 3 digits, we add a zero to the front.

.0000001002..........997998999

Zero indexed, digit 100 is the 1st digit of 99th number.

So you'd read it with
sprintf(s, "%03i", 99);
s[1];
>>
>>61493891
Java is the easiest way to learn OOP if you don't know it already
>>
Why should I bother with header files?
Can't I just wrap my implementation file in a guard and include it?
>>
>>61493956
>>61493945
i've had to use both java and C++ for class projects already, i'm going to be a senior this fall. i want to pick one language to master as in by becoming familiar with most of its ins and outs, although brushing up on OOP principles wouldn't hurt me
>>
>>61493976
You'll get duplicate definition errors

If you force everything to inline, your link times will go to shit

Best solution is a precompiled header
>>
>>61494026
C++ is the language that takes a lot of time to master. The basics of Java can be refreshed in a week or two, and from there it's just a case of knowing the libraries.
>>
>>61494026
in that case C++
it is by far the more expansive language
being a master C++ programmer is alot more impressive than being a master java programmer
>>
>>61493857
Well "can learn how to program" is different from
"gainfully employed." And it wouldn't show a super strong correlation.

First, I acknowledged myself that some people are just ubermenschen with well developed tertiary and inferior functions.

Secondly, not all programming actually requires logical thinking. I know a lot of people who graduated with a CS degree and spend their days milling out GUIs. You're definitely right that choosing subsets of the programming field would have a stronger correlation.

You shouldn't preclude someone from a programming job based on a personality test when you can just, you know, instead of giving them a personality test, give them a programming potential test.

It's actually illegal if you're an employer with more than 20 employees.
>>
>>61494031
>You'll get duplicate definition errors
Even if I use an include guard?
>>
>>61494046
>>61494038
thanks
>>
>>61494055
Yes, because that only stops you from including the definitions more than once per object file (the unit of compilation).

When you link the object files together at the end, the linker will complain if there are duplicate definitions of anything that wasn't inlined or differently cv-qualified.

If you don't get what I mean from reading it, try it yourself with a couple of really basic .c files.
>>
>>61494047
>It's actually illegal if you're an employer with more than 20 employees.
anon I don't think personality tests fall under discrimination laws
>>
>>61494086
If every single file is included fully, there's only one compilation unit and nothing for the linker to do.
>>
Fuck it. I'm going to read trought rust book and learn rust,
>>
>>61494109
That's if you only have one output object file, which is a really dumb idea if you have any plans for your code to expand.
>>
>>61494088
Huh you're right. It's just IQ tests that are illegal.

That's really messed up.
>>
if javascript variables are global then how the fuck do I find out where it was declared?
>>
>>61494150
>IQ tests are illegal
wtf?
>>
>>61494156
Dunno lol.

Variables declared with let and var are not global btw
>>
>>61494127
>which is a really dumb idea if you have any plans for your code to expand.
Because big projects will take too long to compile, or something else?
>>
>>61494170

what? a variable declared outside a function is always global
>>
>>61494167
Yeah they're illegal to use for job interviews because IQ is generalized so therefore it's not applicable to your job, and you're discriminating against theoretical savants. You're allowed to use domain specific tests though.
>>
>>61494202
No shit.
>>
>>61494213
https://www.youtube.com/watch?v=fjs2gPa5sD0
>>
>>61493854
So what's a good project euler for programming?
>>
>>61494156
The best you can do, to my knowledge, is to enable strict mode by putting 'use strict' at the top of the file. Implicit globals will then error, but unfortunately globals created with var will not. I don't think SpiderMonkey or V8 store any information about variable declaration location anymore.

>>61494188
Because each time you change one piece of your implementation, you have to recompile every other piece along with it. If you use separate object files and just include headers, you only have to recompile the object files that get changed.
However, you'll always be linking the full set of object files, so using C instead of C++ and keeping LTO off is an easy way to reduce the amount of work the linker has to do each time.
>>
>>61494261
So it's simply about maintaining acceptable compile times?
>>
>>61494279
Yes.

If you use a precompiled header as part of your build process, you get many of the benefits of a module system too.
>>
>>61494311
>If you use a precompiled header as part of your build process, you get many of the benefits of a module system too.
You've completely lost me. I don't know what that is or how it would help.
>>
>>61490077
DELET THIS
>>
>>61494311
How do you do precompiled headers?
>>
>>61494256
Back in the day we used SPOJ and old TopCoder competitions
>>
>>61494333
Make a header file (e.g. "all.h") that has #includes in it that are common to all your files or that change the most frequently. Change all your files to include this header. In the Makefile, run the compiler on the header to produce all.h.pcx, and set its dependencies. Now repeated compiles will be much faster.
>>
>>61494419
Umm... how does this make compiling faster?
You're producing separate object files from the headers themselves that depend on other translation units?
And then you're gonna create new translation units from already compiled object files?
This sounds like a goddamn mess.
>>
>>61494443
It makes it faster because compiling the headers is the single longest part of compiling C and C++. By using a single precompiled header and just a few file-specific includes per actual object file, you eliminate the vast majority of the overhead needed to compile a file.

The precompiled header is not itself an object file. It just contains definitions in a format that doesn't require the compiler to do expensive source compilation.
>>
>>61494474
c preprocessor was a mistake
>>
>>61494474
Is this compiler specific behavior?
This has unportability written all over it.
>>
>>61494490
Yes, it's compiler specific. msvc and gcc do it differently (clang does it the same as gcc). Just feature-detect for them.

If portability is all that matters to you then you may have picked the wrong language. C/C++ are not portable between OSes at all.
>>
>>61494490
I think you don't need portability for local compiling.
>>
>>61493701
Here's a simple alternative using vectors:

#include <vector>
#include <cstdio>

template<typename T, int t, int ...Args>
struct multi_vec {
multi_vec() : m(t) {}
std::vector<multi_vec<T, Args...>> m;
};

template <typename T, int t>
struct multi_vec<T, t> {
multi_vec() : m(t) {}
std::vector<T> m;
};

int main()
{
multi_vec<int, 2, 2, 3> v;
int x = 0;
for (auto& i : v.m) {
for (auto& j : i.m) {
for (auto& k : j.m) {
printf("%d \t%p\n", x, &k);
k = x++;

}
}
}
return 0;
}


You also win cache locality, since keeping your data in a series of contiguous containers is more efficient.
>>
>>61494515
It is portable. Have you heard of #ifdef?
>>
>>61490077
I cannot for the life of my figure out how to declare or allocate an fpos_t object in c, and cannot find any tutorial that will tell me how. Can anyone just tell me what line I need to type?
>>
>>61494530
My data is already contiguous though, I save it all in T* data;
>>
>>61494531
Does your C compile unmodified on Plan9?

Language portability is about writing the same code and having it work everywhere. Unless your program does nothing useful, C on win32, C on linux, and C on netbsd are all dramatically different and require a good bit of #ifdef'ing to make work.

>>61494530
This is useless
>>
What was the biggest mistake of C++?
>>
>>61494607
Existing
>>
>>61494607
Retaining C89 compatibility and then disallowing features from C99 and C11 and soon to be C22.
>>
>>61494607
Easy. Not standardizing name mangling. C++ would probably have replaced C if it was standardized.
>>
>>61494607
Its existence.
>>
>>61494607
Operator and function overloading have done more damage than anything else in the language.
>>
>>61494607
Try to be an extension of glorious C but with an opposite paradigm. That was a stupid idea.
>>
>>61494582
Yes, the problem only comes when you want to resize at runtime.
>>
>>61493933
There's a lot of code, and I'm not willing to post it all here.
But here's some code snippets that I think are most relevant to the bug (some of the code is old, that's why the style is inconsistent, because I changed styles since then):
Snippets from VFS: https://pastebin.com/VKSLkYSS
Inode definition: https://pastebin.com/KFQjM6WW
Snippets from RamFS: https://pastebin.com/neYMEgCh
Vector implementation: https://pastebin.com/vnYH1w4d
List implementation: https://pastebin.com/BP1h1j1B (Old code)

I suspect that my List implementation could be responsible or at least related to the bug.
I swapped out a List for a Vector (line 8 of the first pastebin) and refactored openInodesRemove and that seemed to stop the page faults (because the object got allocated somewhere else, by chance), so I allocated some dummy memory at the area that was being zeroed and inserted some print statements at key points to watch it's value, it stopped being zeroed, and I wasn't getting page faults anywhere else.
Watchpoint got triggered only once from the allocator putting it's header magic there, which is the value I watched above, it didn't change or get zeroed.

I still have no idea what was causing the zeroing and whether it was my fault or qemu's, and I suspect that I might've just simply moved the bug out of the way to be triggered again sometime in the future, but for now, it doesn't seem to be a problem anymore, hopefully.
Implementing a linked list in the first place was a mistake, so I'm just going to throw that code out.
>>
(You)
>>
>>61494631
/thread
>>
>>61494607
Maintaining compatibility with C.
>>
The other day some anon posted Rust generic programming examples. It's a worse mess than C++ and Java :(
>>
How are Scala compile times in 2017?
>>
>>61494779
I was hoping for something that I could compile and debug for myself. I read through all of that and at a glance there's nothing I saw that was wrong with it.
The one thing I might feel comfortable about mentioning is that your source files have too much whitespace and spread out the actual logic too thinly to be able to coherently follow it.
But other than that, I can't do much else.

What version of qemu are you using?
>>
>>61490077
I'm thinking about a command system for my super snowflake WM in Haskell. The current idea is to keep a stack of values on which the user can operate so they would essentially input the commands in postfix notation. I'm wondering if it would make sense to allow the user to put functions onto the stack and apply them manually and if it's possible to push polymorphic values (since it all has to be done dynamically). I've made a simple almost-calculator to check the idea, but it still doesn't have enough functionality to say for sure if it's comfy. Next I'll make an interactive tree zipper as an experiment.
>>
>>61494942
2.9.0
>>
>>61494968
It's possible that you found a bug in qemu. I would try to make a minimal reproduction, and send it privately to a qemu developer. If it's an exploitable bug, you want to do responsible disclosure.
>>
What's a good book to start with android programming? I just spent the last 3 months getting the hang of Java
>>
>>61495016
If the bug ever pops up again, I'll look into doing that.
>>
>>61492571

Well jeez, what language am I supposed to use if I want to compile .NET?
>>
>>61495058
(totally speaking out of my ass) but I wouldn't try to learn that from books
>>
>>61495078
And the fact that the bug disappears when I disable KVM (which shouldn't affect anything other than performance, correct me of I'm wrong), makes me think that it's most likely a Qemu bug.
I'm going to go and install older versions of qemu and see if I get the bug.
>>
>>61494925
Re: all the shitting on C++ and desperately wanting saner alternatives
>>
>>61494925
Java is without a doubt the best modern programing language.
>>
>>61493717

Eh, I'm ISTP and I can program just fine.

>>61493774

>If you can't draw conclusions then it is useless.
Well here's a conclusion: MBTI is useless. It reduces the broad scope of human personality into 16 different types. It couldn't be anything BUT useless.
>>
>>61495220
Still happens with older qemu versions.
Maybe it's a KVM or Linux kernel bug.
>>
>>61494633
no one uses anything but C89 tho
>>
>>61495143
>but I wouldn't try to learn that from books
what then?
>>
>>61495360
lmao
>>
>>61494940

I don't really use Scala, so I decided to search a bit. First article I get for googling "Scala compile times"

https://jobs.zalando.com/tech/blog/achieving-3.2x-faster-scala-compile-time/?gh_src=4n3gxh1

Seems like they're improving in the current year.
>>
>>61495371
they don't tho
I wish it weren't the case, but that's just how it is
besides C compatibility doesn't matter in this stage of C++'s development
C++ had compatibility with early C because they wanted people to move from C to C++
if a person made a conscience decision to move to C99 or something later it's highly unlikely they'll be moving to C++ ever
>>
>>61490347
OCaml
>>
>>61495360
I use C11.
>>
>>61490448
unsafe still does borrow checking

Literally the entire point of Rust is the borrow checker. Maybe you should actually learn how it works before trying the language. The biggest restriction it imposes is forcing you to design you data structures strictly top-down (consider your data structure as a tree; you cant reach from nodes to their parents). This can be avoided with reference counting, but then that makes mutation a lot more cumbersome.
As a functional programmer I think this is how you should be designing your programs anyways, in which case Rust just requires you to be more explicit about how you structure your data, but after that there isnt much borrow checking to fight with once you understand the rules.
>>
>>61495418
>no native threads
>no unsigned type
>>
>>61494633
I'm quite happy I can use C99 to shut large amounts of sepples programmers out.
More languages should have features like these. Maybe we should just make an large database of sepples programmers so we can ostracize them from society. We can't make it illegal but nobody can blame you from wanting to distance yourself from this degenerate behavior
>>
Optional<Integer> mabeInt = null;
>>
>>61495830
>lowercase null
Tell me sepples didn't define this.
>>
>>61495830
std::optional<int> maybe;
>>
>>61495830
What language is this?
>>
>>61495846
void *something = nullptr;
>>
>>61495475
Me too.
>>
>>61495846
sepples has the NULL macro but discourages it in favour of nullptr
>>
>>61490077
Is it meant to look like Billy Mays?
>>
>>61495919
I'm aware but lowercase null would just be retarded.
>>
>>61495823
I program in Lisp and C but I would prefer C to accept some modern stuff in to the language.
Mainly the stuff that should also be in the Lisp standard, sockets and threads.
POSIX is nice but windows is still big platform so having "optional standard" for necessary stuff would be nice. So if you come up with new platform you could design you C API to follow the the standard. No need for 10 different library with totally different function names and semantics.
Also having lambdas would be nice if they can keep them out of headers.
>>
>>61495939
looks like Java to me anyway
but I have no idea what use an Optional is in Java.
>>
>>61495954
>threads
Already there since C11. Talking about implementations though... I know there are definitely some commercial ones. like http://www.dinkumware.com/. Don't know about free ones, though.
>>
as a person who is an amateur at C++ and has most of their programming experience in C++ (and therefore lack any thing to really compare it to) what does C++ do wrong in a way that I might notice
>>
Is there a list of projects ranging in difficulty i can go through to git gud at programming?
>>
>>61495987
glibc doesn't provide C11 threads.
I don't know, I undertand that C exists because we need language that is so easy to implement compiler for but I would like some modern features like the lambdas and maybe type inferense. We will never have those and we will never have new C like language that doesn't go fully overboard.
We can never have anything nice and we always have to implement the wheel again in conditional macros.
>>
>>61496031
almost any book on programming will have exercises to go through

do them
>>
>>61496023
Use it for a while and just form your own opinion.
>>
>>61496074
I haven't noticed anything wrong with it yet tho
seems pretty reasonable
>>
>>61496035
I don't know about lambdas. In assembly, how would they be different from inline functions?

Type inference could be done with auto (like in C++11) but I doubt it will ever be done.
>>
>>61496023
Lots of implicit behavior.
For example if you call f(x) you have no idea if f is being deep-copied, passed as a reference, or implicitly converted to another type. Also, the function may be overloaded numerous times, which adds to the complexity, slows down compilation, and produces gigantic error messages (try this: struct a {}; std::cout << a(); and look at the error). This saves keystrokes but introduces a lot of mental overhead in understanding systems with lots of complex types.
Also, header files and forward declarations are artifacts of C, modern languages should be able to determine the available types, work out function dependecies and module dependencies, where as C++ has you using shitty makefiles, forces you to basically splice in GIGANTIC c++ headers (have you ever looked at the source of, say, <vector>?) which contributes to horrible build times and makes optimization more difficult.
>>
>>61496084
there are lots of little gotchas
Even OOP is error prone, watch out for object slicing
>>
>>61496084
Broaden your spectrum. Try out different languages. You will like some features and dislike the others. You will start looking at languages as the tools they really are and maybe become less engaged in language flame wars. Just focus on good programming with whatever works for you. That's how it worked for me.
>>
>>61496117
*you have no idea if *x* is being deep-copied
>>
>>61496140
>Broaden your spectrum. Try out different languages.
I am
I'm learning guile Scheme, so far the syntax seems odd and un-intuitive, but it also seems alot clearer what's going on from a programming structure standpoint

clojures in particular also make no sense to me

>>61496117
>Also, header files and forward declarations are artifacts of C, modern languages should be able to determine the available types, work out function dependecies and module dependencies, where as C++ has you using shitty makefiles, forces you to basically splice in GIGANTIC c++ headers (have you ever looked at the source of, say, <vector>?) which contributes to horrible build times and makes optimization more difficult.
ah, so it's just C++ and C that have to deal with the
Cmake/configure/whateverthefuckelse -> make -> make install
Bullshit?
>>
>>61496035
why don't you just use a language like scheme
>>
>>61496085
>I don't know about lambdas. In assembly, how would they be different from inline functions?
Sure now that I think about it lambdas are nice but function pointer + function just provide the same, it's just matter where you type it and adding new parameter with stuff if you want to something like closures.

>Type inference could be done with auto (like in C++11) but I doubt it will ever be done.
That would be poor choice, but I don't think it will never come to C. I would just like to have "modern syntax C" with type inference like
x = printf("test"); // x is type of int
printf("%d\n", x);

But I don't really want to implement new compiler. The language could be easier to use while keeping the same semantics. Might be just because of I have used Lisp so much, too bad there's no statically typed lisp standard.
>>
>>61496203
>Bullshit
Yes, most other languages have just 1 or 2 standard build tools which always work and do all sort of dependency management for you. Build systems are still a rough spot for most languages, because developers cant be trusted to version their libraries correctly, but its generally a much nicer picture outside of C++
>>
>>61496125
>object slicing
just looked this up, and while the compiler should output a warning or just refuse to compile for that, it seems like it's also easily avoidable
>>
>>61496257
I make a habit of explicitly deleting copy constructors for polymorphic classes. It's easy to avoid once you know about it, but it's still an easy trap for beginners to fall into.
>>
>>61491217
vscode
>>
>>61491211
IntelliJ
>>
>have to use windows for development at work
>have unholy combination of emacs, git bash, and MSYS2 to get as close to a linux-like environment as possible
>works well enough, but just barely

who /have to use windows but comfy/ here?
>>
>>61496383
can you run a linux vm?
>>
>>61496389
Nope
That was my first thought, but I'm not allowed to
>>
>>61496408
lmao why not
>>
>>61496443
IT department says so :(
>>
>>61496458
>tfw IT department wants to control you
>>
New thread:

>>61496524
>>61496524
>>61496524
>>
Is it possible to code an "app" that will screenshot a selected 4chan post and, if desired, save it to my computer? I'd a web designer so I guess my fort is the more creative side of technology and I'm not sure what's possible and what's not. I guess my ideas sometimes exceed reality in a sense? Haha
>>
>>61496482
you must subject the IT department anon
this is a game of political will; you either win or you die
>>
>>61496533
yes, such a thing is possible.
>>
>>61495368
videos desu
>>
>>61494167
IQ is not an indicator of suitability for a specific job in the slightest, nor is it even a particularly good indicator of intelligence. It's just something teenagers use to jerk themselves off with.
>>
>>61496374
>installing russian botnet on your system
shygddty
>>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[])
{

FILE *file = fopen("doc.txt", "w");

char* input;
scanf("%s ", input);

if(file == NULL)
{
printf("ERROR: Could not write file...\n");
return 1;
}

fprintf(file,"%s\n", input);

free(input);

system("PAUSE");
return 0;
}

can someone tell me why it gives me an error when I want to write the input in from scanf? I really don't understand why the char* can't simply act as if it were just a plain string
>>
>>61496706
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[])
{

FILE *file = fopen("doc.txt", "w");

char* input;
input = malloc(100 * sizeof(char));
scanf("%c ", input);

if(file == NULL)
{
printf("ERROR: Could not write file...\n");
return 1;
}

fprintf(file,"%s\n", input);

fclose(input);
free(input);

system("PAUSE");
return 0;
}


changed it to this but still does not work, idk what to do :(
>>
>IQ isn't real
>psychological tests aren't real
>statistics don't exist
>let me explain how monads work
lmfao the state of /dpt/. Could this place get any more plebbit
>>
>>61497179
they're just faggots anon, ignore them
this breads un-ironically the best general if you can get past all the dumb
>>
Doing Haskell. I wanted to find some comfier approach to making Zipper than containing Zippers for each data structure in a separate module. Then I found type families. However, it doesn't make much sense to define generic Zipper like they do in the example for Map in Haskell wiki. Is it okay to just ignore the generic part and use type families for really overloaded functions? Would it make you upset if you encountered it in your codebase?
>>
>>61491507
I'll bite. You can write code that's generic to memory layouts without first knowing any types. Void arithmetic comes in when you index it.
>>
>been interested in programming as a kid
>always wanted to grow up to be software developer
>study CS at university, ace all classes
>about to graduate
>realize that pajeets will take over the industry within a decade
>no future for americans in programming

did i just get a useless piece of paper?
what the fuck can i do now? is it even worth going into a junior dev role when the title "Software Developer" won't even exist for americans in a few years?
Thread posts: 343
Thread images: 13


[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.