[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: 338
Thread images: 41

File: 1495684064452.jpg (98KB, 640x640px) Image search: [Google]
1495684064452.jpg
98KB, 640x640px
Old thread: >>61776941


What are you working on, /g/?
>>
>>61784776
Dumb cat
>>
>>61784776
getting a job
>>
>>61784776
Smart cat
>>
>>61784776
cat
>>
>>61784892
Oh Shit Got To Poop
>>
>>61784776
/dpt/ - Daily pooinloo thread
>>
File: superthumb.jpg (29KB, 300x250px) Image search: [Google]
superthumb.jpg
29KB, 300x250px
After learning several languages and not liking them, I am overcome with the desire to make my own language.
How do I overcome this common malaise?

well, I don't know shit about compilers or machine logic anyway, my gripes are mostly syntactical ones.

Why couldn't early programmers do a sensible thing and leave all the performance features a programming language in the machine code domain, with syntax being a parser/interpreter layer of abstraction for the end programmer? All languages would just compile to intermediate binary code, which then would be optimized and compiled into machine code by a unified compiler.
Then we could even do freaky shit like syntax being defined by the local settings of the IDE, so every programmer could use his own syntax, even within the same project on the same codebase.

I guess you could still make a syntactical wrapper around C or something.
>>
what lightweight laptop would you recommend for some 2d and low poly 3d gamedev?
as long as it can run ide/blender/unity/ue4 that would be great.
>>
File: 1499819727053.jpg (1MB, 2048x1536px) Image search: [Google]
1499819727053.jpg
1MB, 2048x1536px
Discuss.
>>
File: aaaa.jpg (35KB, 317x344px) Image search: [Google]
aaaa.jpg
35KB, 317x344px
(reposting from last thread)
I FUCKING HATE WEB DEV AKA WEBSHIT REEEEEEEEEEEEE

BUT IT'S THE ONLY VIABLE PLATFORM TO ACTUALLY MAKE SHIT ON OTHER THAN MOBILE WHICH IS EVEN GAYER REEEEEEEE
>>
>>61785000
Not enough
>>
>>61784986
>After learning several languages and not liking them
Which languages?
>>
>>61785011
C/C++ and Python, mainly
>>
>>61784902

rude
>>
>>61785000
No one can beat Stroustroup in book thikkness. That's why he's the king.
>>
Common Lisp is the only good language.
Too it's dynamically typed and there's no good implementation.
>>
>>61785000
You can only write so much about something as featureless as C
>>
>>61785011
I've written in C, Python, Pascal, JS, ADA and C#.

As weird as it sounds, I liked Pascal the best, but it has lots of problems of its own. I think the way it internally uses pointers, but abstracts the mess away with function parameter flags is great. But the way it treats arrays and loops is clunky as fuck.
ADA was hell to work with, I think they went too far in a few places with the safety and verbosity. But unique closing blocks for each type of block such as (endif, endfor, etc) is also a great idea.
>>
>>61785103
>unique closing blocks for each type of block such as (endif, endfor, etc)
Worst idea ever
>>
>>61784988
please respond dev-kuns
>>
>>61784988
maybe try agdg?
>>
File: 15008766077630.jpg (26KB, 190x200px) Image search: [Google]
15008766077630.jpg
26KB, 190x200px
Can one just fork GCC and modify the parser only as to change the syntax without altering the inner workings of the language itself?
>>
>>61784776
That's a cute kitty
>>
File: 1499496082605.jpg (18KB, 284x339px) Image search: [Google]
1499496082605.jpg
18KB, 284x339px
I think Rust made a mistake by abandoning many C/C++ conventions for no reason. Is it hard for people to start using a new syntax? Yes, very hard.
>>
I've been wondering about ways to hide audio messages in innocent music clip videos.
Basically I'd like to merge two audio streams A and B in such a way that a youtube viewer would hear a lightly distorted stream A, and a program could decode it to stream B in realtime. And this method would have to survive youtube's reencoding, so it should be signal methods and not bit based methods.
I have found some papers which I find relevant.
A WAVELET DOMAIN LSB INSERTION ALGORITHM FOR HIGH
CAPACITY AUDIO STEGANOGRAPHY
http://ieeexplore.ieee.org.sci-hub.io/abstract/document/1231075/
Any particular ideas on this?
>>
>>61785184
GCC can compile many languages and has many targets.
You should see how to add new GCC frontend, might not even require modyfing GCC itself.
>>
>>61785103
These are all Algol-type languages. Try ML-like (Ocaml or F#), Haskell and Lisp (Racket or CL).
>>
>>61785001
>>>/g/wdg
>>
damn... i just did and they sent me to g
>>
>>61785184
you can't do anything with GCC's source except for compiling it
>>
File: Doc#1.png (235KB, 1804x891px) Image search: [Google]
Doc#1.png
235KB, 1804x891px
Started learning Python today as my first scripting language. This is surprisingly fun and rewarding.
>>
>>61785193

It is not very hard to learn a new syntax. You're just retarded.
>>
>>61784289
Its not off the shelf, its a cheap Chinese knockoff
What would you suggest learning with? I have a lot of time soon
>>
Trying to get the hang of it before starting a programming course in September.

Today I realized that in C# 'Console' is the same class as any other and WriteLine is a method like any other.

Believe it or not, it makes things (i.e. understanding the concept of classes and methods) much clearer for me.
>>
>>61785386
cool
>>
>>61785184
It's possible, you can modify the parser so that *your* concrete syntax would generate the same AST as the correspondent standard C's syntax. After that you can just reuse all the immediate code generations and backends of GCC.
But of course it's not practical especially if you just have silly gripes with an ancient language's syntactic quirks. You'd have an easier time defining new CPP's macros to implement your own """syntax""". That was how Stroustroup originally implemented C++ and that was why C++ started out shit and only gets worse as time goes by, because its originator is a fucking hack.
>>
>>61785386
Yeah, but keep in mind that you're typically using static methods on Console, like Write, which allows you to call a method that belongs to a class without creating an instance of that class to use. Those are going to work a little differently, and be designed differently, than non-static methods made to work on a unique instance.
>>
>>61785193
Rust's syntax borrows a lot from ML's family, so yeah it's easy for me. But if you can't even handle something as trivial as the syntax differences how could you handle its completely different type system? Just man the fuck up my anon-kun.
>>
>>61785563
I rather have problems with the user interface design that the syntax encapsulates. It seems most syntax is the way it is to appease the parser and the compiler, not to appease the programmer or achieve some kind of usability goals.

It's just poor interface design and I don't like it aesthetically. My idea is that the syntax should be a concise and internally consistent design language for controlling the compiler behavior.
>>
>>61785619
perhaps he's fine with it but is worried that these choices will restrict its popularity
>>
>>61785169
It's easier for the parser though, as silly as it sounds the ``dangling ifs'' was an actual parser implementing problem.
>>61785651
Nah, beside the lexer, the parser is just the tiniest and most trivial part for pretty much every compiler (even toy ones) in existence. C's syntax being this way is just solely of historical reason.
>>
>>61785651
>controlling the compiler behavior
You don't control the compiler behavior with syntax though. Most of the code generation, static analysis, IR rearrangement and optimization, backend code generator's interfacing and linking have nothing to do with the language's syntax.
Syntax is not anything complicated, it's just that once you defined a concrete syntax it's really hard to make posthoc changes. That's why languages like Scheme and Lisp are so valuable.
>>
>>61785721
>>61785770
Question is, why is something so superficial also so tightly embedded into the language that it can't just be changed on the fly.
Why isn't there an intermediate parser output or something.
Damn, I'm so smart with my hindsight.
>>
>>61785822
>Why isn't there an intermediate parser output or something
There are, they are call abstract syntax tree, IR code and backend code. The problem is there are already a fuckload of softwares written in the old ``surface'' syntax that wouldn't build anymore if you just nonchalantly changed it.
In languages where you can directly access and modify ASTs like the Lisp languages, you can change the syntax to suit your taste, especially if you have reader macros like in Common Lisp.
>>
>>61785619
I'm skeptical that Rust will be the next big thing. So like others I think I won't make that huge time investment. It would be easier if the syntax was C/C++/Java like.
>>
>>61785992
stay left behind then punk
>>
>>61785898
Hol up, what if you like, build your codebase into the intermediate language and store it as that, with IDEs or whatever interface just decoding it into your syntax of choice?
Damm, I'm so smartta
>>
inheratance is a worse form of composition
>>
>>61785822
A lot of bigshot compiler implementations of other languages reuse GCC's and LLVM's code generation as their backend, so yeah alternatively you could make your own language and do just that.
>>61786078
It's called decompilation and if you have ever looked at a decompiler's output, you'll realize you aren't that smart after all.
To be honest I feel like I'm talking with a clueless sophomore with too much confident in himself or something. Just learn that damn undergrad compiler course before trying to reinventing the wheel for the 2^64th time ``please''.
>>
>>61786121
>clueless sophomore with too much confident in himself
Unironically the correct description of 90% of /dpt/fags
>>
File: d20.jpg (20KB, 420x420px) Image search: [Google]
d20.jpg
20KB, 420x420px
>>61786121
lmao I bet decompilation is just a problem of implementation, especially from an intermediate binary stage
it's just that nobody was smart enough to do it right
before me

my iq is one of the hifhest
>>
File: kimochi warui.jpg (35KB, 450x384px) Image search: [Google]
kimochi warui.jpg
35KB, 450x384px
>>61786190
Ok.
>>
File: 13903333.jpg (36KB, 478x640px) Image search: [Google]
13903333.jpg
36KB, 478x640px
https://www.reddit.com/r/rust/comments/6s7c3d/rrust_hit_100000_uniques_and_1000000_pageviews_in/
:^)
>>
File: re.png (191KB, 1765x1006px) Image search: [Google]
re.png
191KB, 1765x1006px
I have just found out there existed sanic hegehog videos games on android, and I couldn't resist looking inside since android reverse engineering is easy and fun.
So it's implemented in a x86 library on top of openGL ES, symbols are present, and java decompilation gives signatures of JNI entry points.
So I'm sure a sufficiently dedicated autist could dlopen that library and wrap that into a Linux desktop game without great difficulty.
>>
What is the Klossiest programming language/ framework?
>>
>>61786307
Probably Ruby!
>>
>>61786307
I just saw her in a youtube ad selling some premade webshit app.
I think she gave up programming because it's too hard.
>>
>>61786307
Must be this http://samshadwell.me/TrumpScript/
>>
>>61786361
>I think she gave up programming
she never started. its just propaganda.
>>
>>61785037

Read SCIP, if you find scheme boring you need another profession.
>>
>>61786361
>>61786373
Kut her some fucking slack, she's not even 25 yet.
>>
>>61785011
Try Rust!
>inb4 HURR DURR SJW
It's open source, no SJWs control it.
>>
I've misjudged Python like so many others
>>
>>61786526
in what way?
>>
>>61786502
>It's open source
/g/ should fork it and make it not shit then
Call it /g/ust
>>
>>61786538
Let's call it /g/arbage then, for the lack of a garbage collector means its eternal reign as the shittiest language in existence!
>>
>>61786421
She is 25 and some days.
>>
>>61786267
Hello Christian.
>>
I am garbage collector pilled now.

Trying to manually manage your memory is like trying to manually optimize your code. Why bother if the compiler/GC is going to do it a million times more efficient than you? Wasted effort.
>>
>>61786612
Use Rust and have the compiler do it for you at compile time without any overhead!
>>
>>61786533
nah jk
>>
File: 1501958812871.png (314KB, 500x684px) Image search: [Google]
1501958812871.png
314KB, 500x684px
>>61786586
>make it not shit
Why are you on 4chan when you lack the reading comprehension of a 12 year old
Underaged b&
>>
>>61786656
>make it not shit
Because it's impossible for /g/ to make anything equally or less shitty.
>>
>>61786598
>i missed karlie's birthday

I really fucked up, /g/.
>>
>>61786653
based
>>
Is there a way to automatically organize source files in VS?
Like when my function definitions are not in the same order as the header declarations?
No spectrum comments.
>>
>>61786370

The fruits of liberal faggotry.
>>
File: 1448868602454.png (24KB, 850x400px) Image search: [Google]
1448868602454.png
24KB, 850x400px
Why is it bad to sizeof() a char?
>>
>>61785274
Keep at it
>>
>>61786927
it's always 1, i do it anyway because it's more readable
>>
File: 9yQkEL8.jpg (51KB, 374x626px) Image search: [Google]
9yQkEL8.jpg
51KB, 374x626px
>>61785274
Good for you anon, have fun with snek
>>
>>61786927
Is guaranteed to be 1, so it's pointless. It just clutters up code.
>>
Trying to write some I2C bare-metal code for an STM32 platform. I'm really considering switching to an OS, does anyone know an extra lightweight one who's been ported to Cortex-M ?
>>
>>61786983
Why? Making a special condition check for char will clutter up your code
>>
File: yessir.png (126KB, 1896x679px) Image search: [Google]
yessir.png
126KB, 1896x679px
>>61786930
>>61786978
Day 1 of self-study, burned through 2 chapters of Matthes' book on Python. At page 70 of 562. Going to take a break for a while, then get at least one more chapter in today. This is going swimmingly. If I keep up this solid pace, I'll be done before the month is over!

Thanks for the well-wishes!
>>
>>61787033
>special condition check for char
What special condition?
It's almost always blatantly obvious that what you're allocating is a string, even without the sizeof(char).
Typical uses would be
// Functionally equivalent to strdup
char *dup = malloc(strlen(str) + 1);
strcpy(dup, str);

// Functionally equivalent to asprintf
int len = snprintf(NULL, 0, "%d%d%d", a, b, c);
char *str = malloc(len + 1);
sprintf(str, "%d%d%d", a, b, c);

A sizeof(char) doesn't add anything meaningful.
>>
File: klossy.png (1MB, 1550x1048px) Image search: [Google]
klossy.png
1MB, 1550x1048px
>>61784986
>Then we could even do freaky shit like syntax being defined by the local settings of the IDE, so every programmer could use his own syntax, even within the same project on the same codebase.

Sounds cool at first, but do you trust pajeet to come up with his own syntax that makes sense to others? It would make collaborative programming an absolute clusterfuck.

>>61784988
Maybe check out an X or T-series Thinkpad. As long as you get an i3 or higher, it should do the job.

>>61785274
You picked a good choice, anon.

>>61786307
>>61786316
The banner on her coding camp's website has a Ruby extension. Good guess.
>>
>>61787157
>Sounds cool at first, but do you trust pajeet to come up with his own syntax that makes sense to others? It would make collaborative programming an absolute clusterfuck.
Well, it wouldn't matter, since the actual source code would be in binary, displaying it in a given syntax would just be a local user decompilation stage. You just open the binary source and your IDE translates it to the syntax of your choice.
>>
>>61787214
LLVM :)
>>
>>61787234
LLVM has the Fatal Flaw of not being invented by me.
>>
>>61787256
Just fork LLVM then? That's the point of FOSS, just take credit for it.
>>
>>61787119
>What special condition?
For getting the byte size of an arbitrary variable, which is the whole point of sizeof. The whole point is that sizeof works with any object. If I'm writing a function to validate an arbitrary variable, I'm not going to write a break case just for a char type.
>>
>>61787214
So the Git repo or whatever source control would have a preset syntax too, but could then be decompiled when it's cloned to the user's local? Might be an interesting way to add my own syntactic sugar to the language. Or could a Java programmer use this to make C# "look like" Java, assuming someone takes the time to make a syntax tree for them.
>>
>>61784776
I have to use some baby IDE called BlueJ for a dumb intro to programming course.
Now I not only have to program in Java, but I have to program clicking on stuff.
It's so fucking braindead.
>>
>>61787408
See no reason the Git repo wouldn't contain the intermediate binaries, with each user just choosing a pre-set or user-defined display syntax like one would choose a color scheme on a website.
>>
>>61787363
>size of an arbitrary variable
Keep doing that then. You're taking this argument out of proportion. It's not a case of "Don't ever do this, it's completely terrible and can break everything", it's just a preferred style thing because it could be pointless. If a sizeof(char) or something gets generated by a macro or whatever, it's not anything to even be bothered about.
I think taking the size of a variable directly is always appropriate (and preferable to taking the size of a type directly), even if the variable is a char. It allows you to change things later, like changing the string a wide string or something easily later.

The argument is really against cases where you're allocating a string or "raw" data in terms of bytes and putting a sizeof(char) in the malloc expression.
>>
>>61787489
Or if there's a problem of browser bloat or PC performance, store several decompiled versions in most common syntaxes or whatever.

Wait, this is getting dumb.
>>
>>61785037
Try Go or Ruby!
>>
File: 1500849375801.jpg (55KB, 600x413px) Image search: [Google]
1500849375801.jpg
55KB, 600x413px
What's a good IDE for learning C? I don't want it to autocomplete, just to run stuff without having to go into terminal/commandline and use gcc
I already know Java and Python, so it's more specifically learning C and lower level language material than learning to program, to be clear.
>>
Gonna learn nodeJS so I can get a memejob and hopefully escape the pajeets of my javashop. What's a good free html editor? Or at least a cheap one?
>>
>>61787595
>without having to go into terminal/commandline and use gcc
The command line is honestly the best way.
Just set up a simple build system (plain makefiles work fine), and compiling your program is as simple as typing 'make'.
>>
>>61787630
vim
>>
>>61785193
I don't understand how Rust syntax is different? I've only learnt a bit of Rust and it doesn't seem to be much different at all. I actually like Rust because it has a lot of my favourite features which appear in other languages.
>>
>>61787630
Literally any text editor. Sublime will do fine, Atom or VSCode if you don't mind a heavier editor that looks better out of the box.
>>
>>61787055
what IDE is that?
>>
>>61787673
I meant more like a modern GUI builder. Surely we must have moved on from the mid 2000s?
>>
For higher level languages like python, is it bad practice to change a variable's type
for example
a = 1
a = "text"
>>
>>61787595

If you absolutely need an IDE, then Code::Blocks or Qt Creator will do okay.

Otherwise, I highly recommend learning with the command line. I remember when I was working on my Bachelor's being in a networking class where we had to write a program that would snoop on connections passing through it and filtering the data, and displaying results in a TUI using curses. At least a few of the students had no clue why it was that they were running into errors not finding certain symbols from curses when "they included the right header files." They were apparently unaware of the role of the linker and how to link a third party library.

I honestly can't find the ability to respect people who neither understand nor desire to understand their build process. If you want to be a C programmer, you should know the basics of how your compiler and linker work, and know how to use a build tool. Once you understand how everything works, it's really as simple as just typing make all the time.
>>
>>61787426
what college?
>>
>>61787873
It's bad practice for any programming language to do that.
>>
>>61787942
>>61787873
Dynamic typing was a mistake.
>>
>>61787992
What's the idea behind dynamic typing?
Is it really that hard to declare your variables before using them?
>>
File: defensive.jpg (34KB, 710x720px) Image search: [Google]
defensive.jpg
34KB, 710x720px
>>61787899
R-Ruby senpai, .... why d-don't you learn .... R-Rust! I-I started l-learning it and i-it is .... v-very comfy!
>>
>>61787740
It's Geany.

http://www.geany.org/

Very pleasant experience so far. Looking forward to continuing with it.
>>
>>61788067

I have actually learned a bit of it. It's a nice language, though it is missing a few features I'd like to see in it as a systems language. But given that they just added untagged unions, I'd say they're probably not done adding features. I'm not sure if I'd use it as a primary programming language, but I've been keeping tabs on it and watching its development.
>>
>>61788032
I will never understand why in javascript you have to define a variable with var instead of a real data type or just omit var entirely
>>
>>61787873

Please don't do that.
>>
>>61788190

Well, I would imagine it would help with scope. Say we declare some variable foo in global scope. Now we assign foo to something else in a function scope. Are we mutating the global variable or starting a new variable? If we declared it with var, we'd be making explicit that this is a new scope, would we not?

That said, I'm not JavaScript expert. I've played around with it, but never used it for much and never delved deep into the language. Web programming isn't my thing.
>>
File: 1501379009864.jpg (122KB, 962x640px) Image search: [Google]
1501379009864.jpg
122KB, 962x640px
>>61788190
All data is data, just ones and zeros that can't be distinguished without knowing what it is already. Assembly itself has no data types either.
JS, in it's shitty introduction to the world, never had the bright idea to allow easy use of data types like int or double, despite almost every other language already having that feature.
For why you need var itself, i assume >>61788233 is probably correct, since it still needs to be called for scope reasons.
>>
Found this little snippet on Stack Overflow.

// These are both globals
var foo = 1;
bar = 2;

function()
{
var foo = 1; // Local
bar = 2; // Global

// Execute an anonymous function
(function()
{
var wibble = 1; // Local
foo = 2; // Inherits from scope above (creating a closure)
moo = 3; // Global
}())
}


https://stackoverflow.com/questions/1470488/what-is-the-purpose-of-the-var-keyword-and-when-to-use-it-or-omit-it

Looks like I was right.
>>
>>61788256

>despite almost every other language already having that feature.
Yes, well, its creator was a big fan of Lisp, the father of dynamic typing.
>>
>>61788419
>
globals

absolutely disgusting.
>>
>>61787426
Like clicking on your majestic cherry blue keyboard
>>
>>61788436

They have their purpose, but should be used sparingly. Personally, I like Ruby's approach: using symbols on the variable name to indicate the scope. $foo is a global, @foo is an instance variable, and foo is a local variable. @@foo should be avoided in favor of a class level instance variable.
>>
>>61788478
>They have their purpose,
no they dont.
>>
File: file.png (90KB, 250x367px) Image search: [Google]
file.png
90KB, 250x367px
What is a good way too learn Python? I bought "Learn Python the Hard Way" but a friend said the author's a hack for making me use Python 2 and Notepad++
>>
>>61788497

I take it you've never done concurrent programming?
>>
>>61788497
You're right instead of globals you should use the singleton pattern (TM) or alternatively pass a handler to every single class.
>>
>>61788553

Pearson Publishers, Starting out with python is the best if you have never programmed before. Yes, Zed Shaw is a cunt.

Mark Lultz learning python is okay but lacks substantial exercises, so maybe give that a miss.
>>
>>61788553
Literally just start writing shit in your spare time for the purpose of learning the language. Read the hitchhikers guide to python, and effective python, and really any book. Nothing wrong with learning 2.7 but you should save yourself the trouble and just skip to 3.x
>>
>>61788606
>you need globals for concurrency
wow ruby, you become more of a baka every day
>>
>>61788630

It's not that one NEEDs it, it's just that it makes the problem of sharing data a lot easier.
>>
>>61788691
use a language with modules.
>>
>>61788629

Listen to this. Python 2 is just not worth learning anymore unless you have to for work. Generator functions introduced in 3 are so useful.
>>
Learning linear regression with python. I ended up wasting a lot of time on an aside in matplotlib: you can draw a line of best fit pretty easily for 1D linear regression by just running
plot(X, Yhat)
, but a drawing a plane of best fit for a 2D linear regression is more challenging, since
plot_surface(X1, X2, Yhat)
for mplot3D takes data in as 2D coordinate matrices instead of just a list of points.
>>
>>61788695
what's that?
>>
>>61788843
whats what?
>>
File: 1457576176147.jpg (409KB, 770x1100px) Image search: [Google]
1457576176147.jpg
409KB, 770x1100px
Realistically speaking, if someone with a great github portfolio has an anime avatar, are they automatically unemployable?
>>
>>61788843
Nothing really desu. Basically a language where static is default.

Modules are a pain in the ass and don't really add any value. They just end up discouraging you from making new files.
>>
>>61788860
modules in languages
>>
>>61788130
I've been using Geany for a couple years. I like it.
>>
>>61788695

Namespacing data doesn't make it any less global in practice. Incidentally, Ruby does have modules. Nonetheless, there are still some times when it might make sense to make a global, and it would honestly be silly just to make a module to act as a container for it.
>>
File: aya_happy.jpg (16KB, 190x188px) Image search: [Google]
aya_happy.jpg
16KB, 190x188px
>>61788868
Only if the avatar is cute.
>>
Is this a linked list in Rust?
use IntList::{Node, Empty};

// This program defines a recursive data structure and implements methods upon it.
// Recursive data structures require a layer of indirection, which is provided here
// by a unique pointer, constructed via the `Box::new` constructor. These are
// analogous to the C++ library type `std::unique_ptr`, though with more static
// safety guarantees.
fn main() {
let list = IntList::new().prepend(3).prepend(2).prepend(1);
println!("Sum of all values in the list: {}.", list.sum());
println!("Sum of all doubled values in the list: {}.", list.multiply_by(2).sum());
}

// `enum` defines a tagged union that may be one of several different kinds of values at runtime.
// The type here will either contain no value, or a value and a pointer to another `IntList`.
enum IntList {
Node(i32, Box<IntList>),
Empty
}

// An `impl` block allows methods to be defined on a type.
impl IntList {
fn new() -> Box<IntList> {
Box::new(Empty)
}

fn prepend(self, value: i32) -> Box<IntList> {
Box::new(Node(value, Box::new(self)))
}

fn sum(&self) -> i32 {
// `match` expressions are the typical way of employing pattern-matching,
// and are somewhat analogous to the `switch` statement from C and C++.
match *self {
Node(value, ref next) => value + next.sum(),
Empty => 0
}
}

fn multiply_by(&self, n: i32) -> Box<IntList> {
match *self {
Node(value, ref next) => Box::new(Node(value * n, next.multiply_by(n))),
Empty => Box::new(Empty)
}
}
}
>>
>>61788909
So I'm fine with an ugly grandma avatar?
>>
>>61788890
>modules and globals are the same things
Alright, heres your last (you)
>>
File: 1149047.png (80KB, 400x400px) Image search: [Google]
1149047.png
80KB, 400x400px
>>61788909
there was a guy who used to post here that is programmer god
and his github has this picture
>>
File: excited.png (901KB, 1037x1056px) Image search: [Google]
excited.png
901KB, 1037x1056px
>>61788936
No, you are only employable if your avatar is cute!
>>
File: Screenshot_2017-08-07_20-25-19.png (767KB, 1599x899px) Image search: [Google]
Screenshot_2017-08-07_20-25-19.png
767KB, 1599x899px
Cleaned up my pretty printer a bit. Next step is adding unions.
>>
File: 1494544017286.jpg (34KB, 640x427px) Image search: [Google]
1494544017286.jpg
34KB, 640x427px
>>61788868
All you have to do is
>Dye your hair any tone of cool colors
>Identify as a pneumosexual unsigned turboxir
>Have a github that does pull requests on random projects
>Your only contribution should exclusively be renaming "problematic" variable names or comment into safe space mellow words
Now you're hired by Google, all you have to do to keep your free allowance is pretend to do something twice a year
>>
>>61788982
when i wrote my compiler i printed my AST with dots
like
root
..program
....class
.......id(gcd)
>>
>Senior / Lead NodeJS Developer
>£100,000 - £120,000 per annum
>>
This is modern C++

    constexpr auto x =*
(f1 | f2)--[1_p - U - 6_p]--(f3)
(f4)--[2_p , 5_p]--(f5)
(f6)--[3_p - _ - 4_p]--(f7);


If you don't know what this does then you don't know C++
>>
>>61789092
>If you don't know what this does then you don't know C++
I'm not sure I want to
>>
>>61789092
Pattern matching on a bunch of functions?
>>
>>61789092
why would anyone want to know what this garbage does
>>
>>61789092
I'm glad I don't desu.

I feel dirty when I write a quasiquote, let alone doing shit like that.
>>
>>61789092
>If you don't know what this does then you don't know C++
Like everything else in that godforsaken language, some feature some other language had that somebody somewhere wanted so they implemented a half-functional, never-going-to-be-used version of it so they can say "YEAH BUT SEPPLES CAN DO IT TOO!!!!!!" no matter how arcane or hacked together it is.
>>
>>61788944

A module's name is globally accessible, and typically its members are too. A variable kept in a module might not be called a global variable, but for all practical purposes, it is one. Using a singleton has the same effect. All you're doing is adding an extra step to accessing a variable that is accessible from any function with a shared state.
>>
>>61788925
http://cglab.ca/~abeinges/blah/too-many-lists/book/
>>
>>61788982
Post your other monitor
>>
>>61789092

Not knowing the types of any of these variables, nor knowing the definition of the _p user defined literal, it is impossible for anyone to know what that code does from just that snippet.
>>
File: Screenshot_2017-08-07_20-50-59.png (3MB, 1918x1079px) Image search: [Google]
Screenshot_2017-08-07_20-50-59.png
3MB, 1918x1079px
>>61789292
Well if you insist
>>
File: frongshot.jpg (401KB, 1948x1127px) Image search: [Google]
frongshot.jpg
401KB, 1948x1127px

⣰⣾⣿⣾⣶⣶⣷⣷⡄
⢠⣸⣿⣿⣿⣿⣿⣼⣻⣯⠷⣕⡄
⢰⣿⣿⣿⣿⣿⣧⡵⣝⣿⣽⣵⡼⠰
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦
⢻⣿⣿⣿⣻⣻⣻⣻⡿⡿⡿⣿⡰⠐
⢀⣬⣿⣿⣿⣿⣿⣿⣿⣿⠛⢐⠐
⣾⣿⣿⣶⣦⣿⣿⣿⣿⣿⣿⣿⣿⣿⣰
⢤⣽⢿⣻⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣷⣧⡀
⢠⡠⣖⣶⣶⣿⣾⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣿⣿⣿⣦⡀
⣜⢮⣿⣿⣿⣿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡻⣿⣾⣿⡿⡿⣠
⢐⢗⣿⣿⣿⣿⡿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⠶⣕⠦⢀
⢂⣿⣿⣿⣿⣿⡺⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠐
⢢⣻⣿⣿⣿⡧⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠐
⡳⣿⣿⣿⣇⢯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠐
⠘⢮⢻⢿⣿⡜⣞⡿⣿⣿⣿⣿⣿⣿⣿⣟⡰
⠑⡳⣶⣳⡣⠒⠩⣐⣰⢛⡛⣿⣿⣿⠰
⢈⣞⡿⡁⢀⠪⢻⣿⡯⡀
⠐⠦⠮⢨⢨⡑⡈⡂⡑⠡⠡⡁⡃⢅⣑⡩⡩⠭⠫⠫⠣⠦
⠰⣀⠒⠒⢠⢠⢀⠐⢐
>>
File: question.jpg (37KB, 1024x576px) Image search: [Google]
question.jpg
37KB, 1024x576px
Is this valid C? Because I tested it and it works.
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
int i;
int *arr = malloc(sizeof(int) * 10);
int *d = arr;

for (i = 0; i < 10; i++)
*(arr++) = i;

for (i = 0; i < 10; i++)
printf("%d\n", d[i]);
return 0;
}
>>
>>61789456
dumb karenposter
>>
>>61789456
No. You're writing out of the bounds of the memory allocated to you. Your code isn't segfaulting out of luck. Malloc could theoretically return a region close to a page boundary where you'd get burned.
>>
>>61789456
looks about right, but you forgot to free arr
>>
>>61789501
How is it allocating to out of bounds memory?
>>
>>61789501
not him, but how so? arr is only incremented after writing i, so there's never an out of bounds write
>>
>>61789456

Looks like valid C to me.
>>
>>61784776
>jquery
>>
>>61789521
t. NEET
>>
>>61789521

It's a cat; it doesn't know any better.
>>
>>61784776
>setTimeout
>hard coded URLs
>setting height in JS
>ES5
>>
>>61789501
dumb rustposter.
>>
>>61787055
Consider this:
# every time you "add" strings, they get copied, so this is a big waste of resources and time. BUT, this
message = person.title() + " " + "has" + " " + str(beans) + "beans!"
# is the same as this
message = " ".join((person.title(), "has", str(beans), "beans!"))
# or this, if you like C syntax
message = "%s has %s beans!" % (person.title(), beans)
# there's also str.format, but if you're running a newish version it's basically obsoleted by these (also called format strings)
message = f"{person.title()} has {beans} beans!"
>>
File: qq.jpg (158KB, 1080x1080px) Image search: [Google]
qq.jpg
158KB, 1080x1080px
>>61789521
>>61789537
what's wrong about that?
>>
>>61789514
>>61789513
Oh fuck I misread. Yeah it's fine.
>>
>>61789501

>Malloc could theoretically return a region close to a page boundary where you'd get burned.
Could it give you a region close to a page boundary? Yes. Would it burn you? No. You likely wouldn't even notice the performance hit from the kernel having to swap pages in and out.
>>
>>61789619
I'm pretty sure he was implying that the page won't be mapped to anything.
>>
>>61789619
I thought he was moving down the array twice desu.

I almost always use array syntax for pointers so I saw 2 ++'s and alarm bells started ringing desu. 10 elements is also small enough that if there was the error I imagined there being, it probably wouldn't crash.

Also page boundary crossings are so overblown. God forbid if I get a cache miss there's a little more indirection once every 4096 bytes.
>>
>>61789591
jquery is a big download you'll use 5% of (check axios for ajax)

setTimeout will make a nightmare of your application state when used with animations - if you have to do that, use Promises so you know when they're done

Hard coded URLs are sloppy and create a surface to introduce 404s (that code would break if the site was deployed to /asdf/ instead of /)

Use flexbox instead of setting height in JS, or at least add a window resize hook

ES5 is high school tier
>>
>>61784776
Where does /g/ go to look for part time work?
>>
>>61789721
There's a good bridge near me I beg/hook under
>>
>>61789721
the grocery store
>>
>>61789721
>inviting 60 more people to your gold mine
>>
c++ or python better
>>
>>61789765
Totally different uses. Python is scientists and C++ is video game devs.
>>
>>61789456
You probably already know this, but in the general case, if you write the first loop like this
for (i = 0; i < 10; i++)
arr[i] = i;

it will be easier for the compiler to optimize.
>>
>>61789778
It also has less mutation going on so retards like me are less likely to misread it.
>>
>>61789775
so which one is better
>>
>>61789862
Totally different uses. Python is scientists and C++ is video game devs.
>>
>>61789878
so which one is better
>>
Guys how do I convince my boss to move back to Java after he decided to move to Scala? The compile times are killing us
>>
>>61789892
Totally different uses. Python is scientists and C++ is video game devs.
>>
>>61789775
Python, since it can do everything it's intended to do just fine with a okay syntax and no real major fuckups
C++ can do only half of each of those.
>>
>>61789905
pooe on his chair
>>
>>61789905
>The compile times are killing us
explain
>>
>>61789905
tell him the compile times are killing you
>>
File: c-baby.jpg (248KB, 808x805px) Image search: [Google]
c-baby.jpg
248KB, 808x805px
STOP ABANDONING MEEEEEEE
>>
>>61789946
I have done, he just says they won't be so bad in the next version of the language

>>61789928
It was a metaphor
>>
>>61789974
do people here actually use c or is it a meme like gentoo
>>
ok, say I want my job to be something like this:
i like to solve difficult problems and learn skills, but I'm not an entrepreneur with original ideas. I'd like to realize someone's idea for an application with my own skills (which I don't have yet but you get what I mean). that's what a programmer/"software engineer" does, right? also what language would you learn for this type of programming job?
>>
>>61789989
I use C
>>
File: fed2.jpg (8KB, 480x360px) Image search: [Google]
fed2.jpg
8KB, 480x360px
>>61789989
It's part of /g/ fedoracore.
>>
>>61790010
i see
>>
>>61785213
Why
>>
>>61789913
Oh yeah I agree. Getting a job in the game dev industry is retarded. And you shouldn't use C++ if you're indie; C++ is used because "industry standard" not because it's the right tool for the job. You can really feel the resentment game engine designers like Mike Acton have for C++.
>>
>>61789990
>that's what a programmer/"software engineer" does, right?
Most software engineer roles are very tedious. You are expected to do the same frontend/backend/sql shit every day for the rest of your employment.

I think you are looking for more of a "research assistant" position. If you land an intellectually-stimulating job with only a bachelor's degree, you've hit the jackpot.
>>
please make your next app a cli app and help put an end to gui tyranny
>>
>>61790039
>tinder app in the terminal
>>
>>61789989
I'm learning it right now to do some linux stuff
>>
>>61790010
As far as I'm concerned, C *is* programming.
>>
>>61790039
>wanting to be limited by cli
>>
>>61790084
Writing a compiler in assembly is programming
>>
I have now begun the process of reprogramming my taste buds.
>>
>>61790087
I'd prefer everything to run in emacs but I don't think most people are ready for that yet.
>>
>>61789975
So be rational. If it's amounting to like 15 minutes of your day, time your coffee run with a build. If it's taking a lot more, then tell your boss it's going to affect how productive your team is until that next version addresses your concern.
>>
>>61790117
d-do you have a test case for semen? I can provide the sample~
>>
>>61790029
Well, that's disappointing if true...
>>
>>61789801
Retards like this? >>61789501
>>
>>61790295
No that guy eats paint I'm not that retarded anon.
>>
What is the programming equivalent of this?

https://www.youtube.com/watch?v=9JDzlhW3XTM
>>
>>61790361
C#

somebody please post the "Microsoft Certified Solutions Expert" image
>>
>>61790156

If I needed that, I am more than capable of producing it myself. Anyways, the whole idea is to get myself used to not drinking something super sweet with every meal, like soda or fruit juice. And I'm going to try and replace it with possible bitter things like black coffee and unsweetened tea.

>>61790123

Emacs hurts my hands.
>>
>>61790376
try tap water, it's still a little sweet
>>
>>61790376
>Emacs hurts my hands.
Have you tried using a more ergonomic keyboard and/or evil mode?
>>
>>61790361
>monkeys
It's Java, no doubt about it.
>>
>>61790417
Jaba dev, can confirm.
>>
>>61790376
why do americans always drink so much sugar water?
>>
>>61790027
If you're an indie developer, the best language to learn now is Java.
>>
Can someone explain to me why callbacks are considered asynchronous in various javascript frameworks? I keep seeing them say the meme catchphrase "functional programming" and I don't remember lisp being considered an innately asynchronous or parallel language.
>>
>>61790393

Honestly, tap water has not much real taste. Although if you freeze it into a solid bottle of ice and let it slowly melt, it's pretty delicious.

>>61790399

>different keyboard
I use a laptop. I'd rather not use a USB keyboard, and I don't want to add another criterion on for my already picky needs for laptops.

>>61790454

Because sugar is arguably more addictive than cocaine, and it's everywhere here. We grow a fuckload of corn in the mainland, which we turn into syrup since people can only eat so much actual corn.

>>61790477

Java is gross. Don't use it unless you need it for Android or for some enterprise job.
>>
>>61790539
They are "functional programming" in that you're passing functions around, using functions in interesting ways, whatever (a callback is just a function that runs after another function returns)
Functional programming is a much broader category, and you're right, not necessarily async
>>
>>61790571
Fuck off tripidiot.
>>
>>61790571
>I use a laptop.
Oh shit. Why? They're terrible for you.

>Because sugar is arguably more addictive than cocaine
You could try replacing it with a healthier habit. Do you like hot peppers?
>>
New trippie coming through, please be nice to me!!!

More girls in coding, yay!!! (ᴗ)
>>
>>61790589
How new are you?

>>61790599
Jessica is a unisex name
>>
>>61790571
>freeze it into a solid bottle of ice and let it slowly melt

i can't stand cold stuff (or really hot stuff either)
lukewarm or bust
>>
>>61790599
pls sex me
>>
>>61790586
Then how do async callbacks in nodeJS work? Is a new thread somehow spun up every time a callback is called? They keep saying you don't have to wait for a function to return because asynchronous but I'm beginning to think no one actually understands what it's doing and they're just shitposting because I keep seeing the same stupid console.log example in the explanations.
>>
>>61790599
>girl on /g/
Nice try :^)
>>
>>61790611
>if a tripfag attention whores for long enough then it's not a bad thing that they're attention whoring
???
i will never understand this retard logic
>>
>>61790571
disregard this i suck cocks
>>
>>61790632
Ruby has a decent amount of programming knowledge from what I've seen
>>
>>61790650
Xhe's a complete autist outside of /dpt/ though, every time I look at the board there's some post by Ruby responding to either blatant sarcasm or obvious trolls and generally dragging the quality of the board down by enabling these sorts of shitposts.
>>
>>61790679
Well that's because /dpt/ is the best part of /g/ by far.
>>
>>61790598

>Why?
Because I don't want to be confined to a desk and every tablet that doesn't have Surface Pro in its name is terrible.

>hot peppers
Honestly I hate them, although cayenne pepper's alright in small amounts.

>>61790599

So what programming languages do you know? What's the most interesting thing you've programmed? Also, niceness needs to be earned. This is 4chan, not Reddit.

>>61790616

That is an odd taste. Cold makes everything better.

>>61790641

At least bother to spell everything right including the A at the end and the ! before Sempai.
>>
>>61790571
Why do you produce so much corn? I heard that you have tight control over how much sugar can be important and the government buys any excess sugar is produced. Corn syrup sounds like such a disgusting substitute for sugar.
>>
>>61790722
>Corn syrup sounds like such a disgusting substitute for sugar.
You have no idea, if you ever go to America stay far away from anything containing """"sugar""". I'm not a big fan of soda in the first place, but boy American coca-cola was a new low. Tastes like literal shit, no wonder anyone with any sort of functioning tastebuds over there imports sugary drinks/food from 1st world countries that actually use sugar.
>>
>>61790621
Look up "node event loop". There's a queue of callbacks, and each time the loop runs it goes through the queue, running any callbacks it can, and leaving the ones that can't execute yet in the queue.
Let's say your main thread does these two things (in shitty pseudocode):
get_data_from_server().then(process_that_data());
console.log('i just ran');

First, node reads line 1. It sees that get_data_from_server runs asynchronously, and it adds process_that_data() to the callback queue.
Next is line 2. We print the message to the console.
Finally, we get the data back from the server (because doing this took longer than executing line 2). So we run the callback now, and remove it from the queue.
>>
>>61790722

We grow so much fucking corn because it's just what grows in this climate, and we clearly have buyers (soda companies). Anyways, corn syrup sucks, but cane sugar isn't that much better.
>>
>>61790722
Midwest here, there is nothing wrong with growing a metric fuckton of corn
>>
>>61790803
You have sugar cane in Florida. Why does your government fucking claim they believe in shit like free market, yet does protectionist bullshit over sugar plantations or basically any product?

>>61790819
What is point of growing corn? Can't you grow something else like pumpkins or cows or some shit?
>>
>>61790722
The united states has had a communist agricultural system since the great depression. The farm czars have decided that corn is worthy to be produced.

Also the farm czars set the price of sugar. The price of sugar in the US is higher than market value.

Corn syrup is pretty close to sugar desu. It's dissolved in water and instead of sucrose you have fructose + glucose but otherwise it's the same as sugar.

>>61790571
>tap water has not much real taste
Tap water has the realest taste.
>>
>>61790833
Corn is more suitable than pumpkins and cows because it's more vertical and needs less space. But yeah sugarcane would be way better but fucking farm czars.

This is definitely not me being biased because I live in Texas where sugarcane grows really well. It grows well all along the south. Hot as fuck + humid as fuck = sugarcane.
>>
>>61790833
Corn is love, corn is life
Welcome to the cornfields motherfucker
>>
>>61790833

Because it's a bullshit government and nobody likes it. Seriously, it's almost a national pastime to bitch about the government.

>>61790833

>Can't you grow something else like pumpkins or cows or some shit?
Oh yeah, that's another reason to grow so much corn: feeding livestock. And yeah, we raise a lot of cows here.
>>
>>61790839
Isn't sucrose just fructose and glucose?
>>
File: 1474325315193.jpg (44KB, 636x616px) Image search: [Google]
1474325315193.jpg
44KB, 636x616px
Employed Haskell programmer reporting in
>>
>>61790769
Okay, I see. That's actually pretty simple. The fact that there's a queue for the callbacks pretty much explains everything. Not sure why a million blogs can't just explain it so straightforward and transparently.

Thanks anon
>>
>>61790904
Sucrose is those two bound together along a glycosidic bond. They taste a little different but about the same thing.

Don't do the fallacy of composition anon. Sugar is made out of carbon and water but you aren't going to be able to replace it by sticking coal and water in a blender.
>>
>>61790955
>you aren't going to be able to replace it by sticking coal and water in a blender
Sounds like that's Ruby's end goal.
>>
>>61790833
>yet does protectionist bullshit over sugar plantations or basically any product?
Because almost every other government has protectionist bullshit over everything too and it gives them an advantage over a nation that doesn't have any such policies. I swear libertarians are as bad as commies. It doesn't work in practice because the world is bigger than your backyard.
>>
>>61790930
I am also employed, and am also a Haskell programmer
>>
>>61790930

And where are you employed, Anon? What is your job title?

>>61790981

Nah, my end goal is to make things that taste bitter not taste bitter to me, and to stop craving sugar.
>>
>>61790985
The farming practices of the USA are not protectionist at all. It's just good old fashioned corruption. Big corn lobbies congress. Congressmen protect big corn. Congressmen magically end up with money, speeches with outrageous fees, free dinners, free golfing trips, etc.
>>
>>61791011
So things like broccoli?
>>
How do I make my game engine/framework not require hamachi just to connect to each other (peer to peer).
Other than hosting a web server obviously
>>
>>61791163
Just wondering if there's any way other than port forwarding or VPN or server
>>
>>61791107

Broccoli isn't bitter at all. It's pretty damn good.
>>
>>61791185
You still need a server but you can do:
https://en.wikipedia.org/wiki/UDP_hole_punching
The server doesn't need to host the game though. I think this is what hamachi is.
>>
>>61791290
Yeah I meant that one of the players/clients would host a lobby from their computer (which wouldn't have a public IP)
I'll give that a read thanks
>>
>>61791011

> What is your job title?

Cock sucker.
>>
>>61788130
Thanks dude
>>
>>61791372
What you do is you setup a server just for holepunching that redirects users to the player's local lobby. It's basically running your own hamachi but probably better because making users download hamachi to use your program to its fullest is shit desu.
>>
>>61791384
I ain't judging, if you can make an easy living off the fact that you happen to be gay then good for you
>>
>>61791410
Yeah that's what I figured.
Just sucks because I'm poor lmao.
Thanks :)
>>
r8 muh m8kefile
.RECIPEPREFIX = >
.PHONY: all executable objects dependencies\
clean-executable clean-objects clean-dependencies clean

EXECUTABLE = gdraw
COMPILER = g++
CFLAGS = -g -c -O0 -Wall -Wextra -Werror -Wold-style-cast -std=c++14
DFLAGS = -MM -o $@
LFLAGS = -o $(EXECUTABLE)
LIBS = -lGL -lGLU -lglut -lm
LANGUAGE = cpp
SOURCES = $(wildcard *.$(LANGUAGE))
OBJECTS = $(patsubst %.$(LANGUAGE),%.o,$(SOURCES))
DEPENDENCIES = $(patsubst %.$(LANGUAGE),%.d,$(SOURCES))

all: executable

executable: $(EXECUTABLE)

objects: $(OBJECTS)

dependencies:
> @:

$(EXECUTABLE): $(OBJECTS)
> $(COMPILER) $(LFLAGS) $(OBJECTS) $(LIBS)

%.o: %.$(LANGUAGE)
> $(COMPILER) $(CFLAGS) $<

%.d: %.$(LANGUAGE)
> $(COMPILER) $(CFLAGS) $(DFLAGS) $<

.PRECIOUS: $(DEPENDENCIES)

clean-executable:
> rm -f $(EXECUTABLE)

clean-objects:
> rm -f *.o

clean-dependencies:
> rm -f *.d

clean: clean-executable clean-objects clean-dependencies

-include $(DEPENDENCIES)
>>
File: bw.png (2MB, 1136x875px) Image search: [Google]
bw.png
2MB, 1136x875px
>>61791394
No problem.

>tfw feeling welcomed from becoming part of /dpt/ in one day of learning Python.
>>
>>61791440
You could probably get away with using your home Internet connection desu. A domain name should cost like 20 bux a year.

The amount of data that such a server needs to send is really really fucking minimal. And if not you can get away with a really low bandwidth server. There's severs that are a dollar a month.
>>
What happens if use your home desktop as a web server?
>>
>>61791512
Yeah I don't have a home internet connection lol.
Situation is complicated.
But I'll be looking at hosting in a few months.
>>
>>61791495
>g++
>-std=c++14
>-lGL
>-lGLU
>-lglut
>cpp
0/10 kill yourself
>>
File: DeepinScreenshot_20170808143944.png (834KB, 1920x1080px) Image search: [Google]
DeepinScreenshot_20170808143944.png
834KB, 1920x1080px
So in line 8, the middle statement is supposed to check something, right? what does s[i] check?
>>
>>61791660
It checks if the current char is 0 ('\0')
>>
>>61791495
>C++
>Non-standard names for standard variables
It's shit.
>>
>>61791660
'\0' which is equivalent to "null" which is falsey, terminating the loop.
>>
>>61791660
cool beans
>>
File: rightclick-polymorphism.webm (2MB, 800x608px) Image search: [Google]
rightclick-polymorphism.webm
2MB, 800x608px
Working on Minecraft clone. Added polymorphism to the right click action.
(define slab-upgrades `((,stone-slab ,stone) (,grass-slab ,grass)))
(define permeable (list air water))

(define (slab-player-place! kind world state x y z side . extras)
(if (and (equal? side TOP) (equal? (finite_getblock world x y z) kind))
(place-block! world (cadr (assoc kind slab-upgrades)) state x y z)
(let* ((coords (getneighbor_coords x y z side))
(replaced (apply finite_getblock world coords)))
(if (equal? kind replaced)
(apply place-block! world (cadr (assoc kind slab-upgrades)) state coords)
(if (member replaced permeable)
(apply place-block! world kind state coords))))))

(make-block-class stone-slab player-place!: slab-player-place!)
(make-block-class grass-slab player-place!: slab-player-place!)


And this is the class if you're wondering:
(define* (make-block-class
block-kind
(break!: break! dumb-break!)
(place!: place! dumb-place!)
(player-place!: player-place! dumb-player-place!)
(update!: update! dumb-update!)
(update/now!: update/now! dumb-update/now!))
(let ((rtn
(lambda (proc . args)
(case proc
((update/now!) (apply update/now! block-kind args))
((update!) (apply update! block-kind args))
((place!) (apply place! block-kind args))
((break!) (apply break! block-kind args))
((player-place!) (apply player-place! block-kind args))))))
(hash-table-set! block-class-table block-kind rtn)
rtn))

>inb4 oop memes
It just werks for things that are actual objects. Like blocks in a minecraft clone.

>>61791914
I hope you're a fursecutor.
>>
How do we stop this?
>Node.js Emerging as the Universal Development Framework for a Diversity of Applications
https://hackernoon.com/node-js-emerging-as-the-universal-development-framework-for-a-diversity-of-applications-c2e788290f5f
>>
>>61792033
By putting the javascriptlets out of business.

Invest heavily into wasm. After that's done, replacement "full stack" technology that isn't javascript.
>>
>>61792033
Write to the editor and tell them that they misused the word diversity.
>>
string calibornifier() {
static vector<string> const canon = {
"YALDABAOTH",
"YALDOBOB",
"YOLOBROTH",
"YODELBOOGER",
"YOGURTBONER"
};
string prefix = canon[rand()%canon.size()];
string suffix = canon[rand()%canon.size()];
return prefix.substr(0, prefix.find('B')) + suffix.substr(suffix.find('B'));
}
// YOLOBONER
// YALDOBOOGER
// YODELBAOTH
// YOGURTBOB
>>
>>61792086
This seems overengineered.
>>
>>61785213
At firsthought this is what I'dd do:
The encrypted audio has to a lot shorter then the other one
You strech the short audio so it fits the long ones length with some function in the form g(1/n * x)
Add the signals together, the distortion should be low, bc of the transformation

To extract, do it in reverse:
Subtract original audio from the one that has a meseage
Aply a function in the formnof g^-1(n*x)
You should have the original meseage audil
>>
>>61785213
You could vocode the audio reducing the amount of data you need drastically, then embed the output channels as low frequency elements of the waveform, as humans are insensitive to low frequencies.

Vocoders are proven technology for low quality signals. Not to mention the output is going to sound like kraftwerk too so that's a bonus.
>>
>>61785213
Whatever you're doing would have to make it past the psycho-acoustic model yt uses to compress the audio channels. Depending on the source material, I don't think there's enough bandwidth for you to do it in the audio channel.
However, you also have a video channel, which has a lot more bandwidth. You could perturb parts of the image stream, watermark-style, to send a low-bandwidth, redundantly-coded side channel. I don't know how much bandwidth you could get out of such a scheme, but with both the audio and video channels perturbed, it just might be sufficient for a tightly compressed mono voice channel.
>>
>>61791966
Your program is shit if it isn't programmed in Rust.
>>
>>61792351
I'd rather it be shit than programmed in Rust desu.

But if you wanna write a rust program that can dynamically load both compiled executables and source code and invoke a repl that can touch the program state, be my guest anon.
>>
>>61791966
cool
>>
>>61791966
Very nice.

Are you procedurally generating the map?
>>
>>61792526
The terrain generation is very simple and currently just 2 dimensional pink noise. Anything below the noise value is grass and anything below block that isn't grass is water.

I've mostly been focusing on adding technical features. I'm not too worried about creating a profound terrain generator right now since doing that wouldn't improve the underlying engine.
>>
>>61785103
Ada is the shit, at least for embedded / safety stuff. I much prefer Ada to C for writing code that could kill someone due to bugs.
>>
>>61792551
>anything below block that isn't grass is water
Anything below y=64 that isn't grass is water. Augh.
>>
>>61787003
Why not use the HAL? You don't need an rtos for i2c on a cortex-M.
>>
File: sieging python.png (138KB, 1911x837px) Image search: [Google]
sieging python.png
138KB, 1911x837px
>>61792657
I've been studying Python, and it's going well.
I made some parts more complicated for the purpose of reinforcing what I'm learning, and everything is still running fine. Though, I'm having trouble figuring out how to capitalize all items in a list. Would someone please give me some advice? I had to resort to adding the 'title' method to each item in advance instead of as a group.
>>
>>61792558
>Ada is shit
FTFY
>>
>>61792676
Have you not learned how to iterate over items in an array/list?
>>
How do static and inline relate in C? Why would I declare a function that is inline but not static? Are there problems with defining static inline functions in header files?
>>
>>61792797
>Why would I declare a function that is inline but not static?
You have a function that is called from many other files and overhead from the function call is limiting speed
>>
>>61792797
>Why would I declare a function that is inline but not static?
Non-static inline functions are really weird. Actually, extern inline, "plain" inline and static inline all have slightly different semantics.
- static inline
Inline the function in this translation unit; no external symbol is produced.
- "plain" inline
Create an alternative implementation of an external function for this translation unit; no external symbol is produced, and the which function gets called (the inline or external function) is unspecified.
MAYBE this could be used to create a faster/more efficient version of some function (perhaps with less error checking?), but the functions should semantically be the same.
The standards committee probably were trying to create more useful functionality when they thought this up, but it's really just unnecessarily confusing.
- extern inline
Inline the function in this translation union, but also generate a normal symbol that other translation units can use.

>Are there problems with defining static inline functions in header files?
No, it's perfectly fine. Overdoing it can lead to long compile times and possibly executable size bloat.
An inline function really should at max 3 lines long.
>>
>>61792758
I've been able to capitalize everything else so far. I'd clarify, but my post keeps getting detected as spam, and don't know what to do to circumvent it. Refer to the last line in the picture in my last post, and imagine I want to add a title method to it. That's been breaking it.
>>
>>61792888
Cheers, that clears it up nicely.
>>
I have two programs in the same git repository, a server and a client. They have some shared data they need to load, but then they also have files that are different (like config files).

I would like to make a directory for that shared data and create a symlink out of each program's run directory to it. But mklink on Windows seems to have some problems, mostly that it requires admin privileges. What could I do not to duplicate the data by copying it into the run folders of both applications?
>>
>>61792941
>I would like to make a directory for that shared data and create a symlink out of each program's run directory to it.
Just put it in some well-known location and read it from there. That's what a normal program's installation does.
>>
New thread:
>>61792971
>>61792971
>>61792971
>>
>>61792960
I don't want the installation to put anything outside of the program's own directory, and I don't want to have to intall it after every build while debugging, so I need the paths to be relative to the run directory.
>>
>>61792981
program/
├── client/
│ └── prog
├── server/
│ └── prog
└── shared_data
>>
>>61792997
But that's not the structure the program will be distributed in, so once the actual shipping build is made, all the relative paths will be different.
>>
>>61793025
Or programs*, rather. In the shipped form, I want each one of the two programs to have their executables in the root directory, and then a separate data folder. And they're distributed separately.
>>
>>61792941
Why not environment variables or command-line flags to override what will ship?
>>
>>61793037
I do use those to for example set LD_LIBRARY_PATH on Linux to the current directory. But I can't really think of a way to move link data directory into the run directory with those.
>>
>>61793077
Well, it seems like you can create directory junctions without admin privilieges, so guess I'll use those.
>>
How do you reverse-sort a list temporarily in Python? This is what I have so far, but I'm unsure of how to add the reverse argument in this case:

 

color_list = ['red', 'blue', 'green']
print("Here is the original color list:")
print(color_list)
print("Here is the temporarily sorted color list:")
print(sorted(color_list))
print("Here is the original color list once more:")
print(color_list)

>>
>>61793250
sorted(color_list)[::-1]
>>
>>61793294
So it's:
print(sorted(color_list)[::-1])

If I want to print that, right? That's what I just did, and it seemed to work. Though, the:

[::-1]


segment looked strange to me. The book just stated that temporary reverse-sorting could be done, but not how. Would you please explain that part for me briefly?
>>
>>61793360
It's list slicing.
list[x:y:z]
returns a new list where x is the starting index, y is the ending index, and z is the increment between indices.
list[3:9:2]
would get a new list comprising of the 3rd, 5th, 7th and 9th elements of the old one.
list[::-1]
uses default values of x and y (the final and first elements) and goes down in steps of 1.
>>
File: 1494580643455.jpg (26KB, 680x447px) Image search: [Google]
1494580643455.jpg
26KB, 680x447px
>>61793378
That makes perfect sense, thank you! I've snipped a picture of this for future reference.
>>
Why isn't web dev considered programming? What's the logic?
>>
>>61790477
How come?
>>
>>61793619
>>>/wdg/
And don't use php, peasant
>>
>>61793406
If you only need an iterator, though, there's always reversed().
>>
>>61793619
Because front-end is mostly decorating and UX.
And back-end is just connecting wires.
>>
>>61790027
>Mike Acton
How can a guy that looks dawny not be retarded?
>>
>>61789721
>part time work?
Is there other kinds of work?
Thread posts: 338
Thread images: 41


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