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

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

Thread replies: 255
Thread images: 22
File: gets.png (439 KB, 659x673) Image search: [Google]
gets.png
439 KB, 659x673
old /dpt/: >>51307595

What are you working on /g/?
>>
First for delicious thighs
>>
calm your tits faggot, it hasn't even dropped off the board
>>
>>51315151
Implementing an LMC in D
>>
Third for go
>>
>fuck you very much for using anime

God. Why does Germany have to be a total push over these days? Fourth reich pls
>>
How to parallel the serial
>>
>>51315151
Checked, OP
>>
>>51315202
shift register
>>
Obligatory:
https://storify.com/realtalktech/startup-ceo-s-functional-programming-isn-t-bad-it-
>>
File: 1426857463440s.jpg (10 KB, 250x242) Image search: [Google]
1426857463440s.jpg
10 KB, 250x242
I can't take it anymore.

Does anyone has a link to a recent libclang/LLVM tutorial ? I'm just trying to compile and execute C from C++

I just can't get a simple shit to link properly.

Send help.
>>
>>51315151
I actually looked that anime up.
>guy gets kidnapped and is forced into a harem with 5 sheltered brats who think he's gay

literally the most creatively bankrupt and contrived harem scenario i've ever seen
>>
>>51315273
here's a full tutorial on how to compile c from c++
>rename file from *.c to *.cpp
>use g++ instead of gcc
done desu
>>
File: 6xtUPxTX_400x400.jpg (28 KB, 400x400) Image search: [Google]
6xtUPxTX_400x400.jpg
28 KB, 400x400
https://storify.com/realtalktech/lessons-for-functional-programmers

https://storify.com/realtalktech/startup-ceo-s-functional-programming-isn-t-bad-it-

tech is going alpha. fp are worried
>>
How do you get the variable "y" in println to keep updating its self? Im trying to make it go "Player1 Player2 Player3" but its not working

            for(int y = 1; players>y;)
{
System.out.println("Player"+y+":");
y+=1;
for(int i = 0; i < cards; i++)//PRINTS SHUFFLED DECK
{
System.out.println(deck[i]);
}
System.out.println();
}
}
>>
>>51315151
51 gets
>>
How the hell do you write a lock and a corresponding function that checks if a specific thread has acquired the lock?
Sounds impossible.
>>
>>51315326
for (int y = 1; players > y; y++)
{
System.out.println("Player"+y+":");
for (int i = 0; i < cards; i++)
{
System.out.println(deck[i]);
}
System.out.println();
}
>>
>>51315289
what is it?
>>
why is this thread so misogynistic

Why can't a single day pass by without some sexist on /g/ using the female body to advertise their thread
>>
File: Capture.png (21 KB, 560x299) Image search: [Google]
Capture.png
21 KB, 560x299
>>51315361
not working
>>
>>51315390
>implying this thread isn't actually filled with a bunch of homosexuals

Homosexuals can't be sexist. Someone told me that once
>>
>>51315273

C header file (minus include guards and other shit):
#ifdef __cplusplus
extern "C" {
#endif

/* Forward declarations and shit */
void some_c_function(int);
double some_other_c_function(char*);

#ifdef __cplusplus
}
#endif


C++ source file includes the C header file, calls functions like any other C++ function.
C source file defines the functions forward declared in the C header file.

Compile like so:
clang -std=c11 -c foo.c
clang++ -std=c++14 -c bar.cpp
clang++ bar.o foo.o -o yourprogram


Or something to that extend. It's how I would do it with gcc and g++, and I know the two uses the same flags for most things.

>>51315390

How about you fuck off and just let us program without having to hear about how offended you are? It's not our job to make this place more inclusive for you. Love it or leave it.
>>
>>51315413
homosexuals are the ultimate sexists

They completely deny womyn
>>
>>51315371
the title is obscenely long
It's almost as if this anime is trying to encompass every tired anime cliche unironically.
>>
>>51315417
>How about you fuck off
wow, talk about becoming violent when somebody challenges the status quo
>>
>>51315326
>y+=1;
>>51315361

Why wouldn't y+=1; work?

>>51315417
>How about you fuck off and just let us program without having to hear about how offended you are? It's not our job to make this place more inclusive for you. Love it or leave it.

Why can't more people in the valley say that?
>>
>>51315273
Sent ;)


seriously, try asking in some IRC channel
>>
>>51315426
i'd still enjoy a name, even a ridiculously long one.

I literally just finished up a series about 20 minutes ago and am looking for something to watch.
>>
>>51315411
Post your modified code
>>
>>51315455
>I literally just finished up a series about 20 minutes ago and am looking for something to watch.

you don't watch anime, you just check off anime off your anime list and claim to have watched it
>>
>>51315359
A lock is just a boolean flag. The function for acquiring the lock does a compare-and-swap on the flag. If you want to know which thread has a lock at any time make the function, after acquiring the lock, write its ID to a shared memory location.
>>
>>51315461
for (int y = 1; players > y; ++y)
{
System.out.println("Player"+y+":");
for (int i = 0; i < cards; i++)
{
System.out.println(deck[i]);
}
System.out.println();
}
>>
File: 1442966590104.png (103 KB, 280x280) Image search: [Google]
1442966590104.png
103 KB, 280x280
>>51315473
Yup

Just admit you dont have sauce or give the sauce and stop wasting my time.
>>
>>51315502
I'm not giving you sauce.
A persistent retard like you who only "watches" anime to fit in somewhere should be able to reverse image search on google.
>>
>>51315436

I am getting sick and tired of people calling anything that offends them violence. Violence, by definition, is "behavior involving physical force intended to hurt, damage, or kill someone or something." Keyword: physical. If I kicked you in the face, that would be violence. If I told you you should fuck off, that would be an expression of an opinion.

>>51315438

Because they are Californians, and Californians are by and far, pussies and snobs. Some of them are alright, but there's enough of them that I'd rather not live and work there. That and the fact that your gun rights and other rights are severely restricted in California, and the fact that housing is so goddamn expensive that you can't expect to raise a family even on a programmer's wage there.
>>
>>51315557
>>51315539


Shit aint even done airing yet

fucking dropped until a 10-bit bluray releases

what the fuck are you kids doing with HDTV bullshit??
>>
Why does this result in an infinite loop with no output?
not even the printf gets through.

void longest_word(char *buf)
{
char *current, *candidate;
while (scanf(buf, "%s", current))
{
printf("something is happening\n");
...
>>
>>51315576
Why do you even watch anime if you just want to watch everything back to back and use it like background noise?
Do you even remember half of what you watch?
>>
>>51315438
It would

>>51315484
The mistake isn't in this code. Make sure you are compiling the right file.
>>
>>51315605
>use it like background noise

who is doing that?


I binge watch anime, but i'm not doing other things generally.

>Do you even remember half of what you watch
yup, and since I have everything i've ever watched downloaded i can easily rewatch if I really want to
>>
>>51315617
>compiling the right file
b-but its the only file i have.
>>
>>51315582
You probably meant to use sscanf and not scanf
>>
>>51315655
That works, I guess.

Also, how do I initialize a char *array to null?
>>
>>51315698
char *array = NULL;

I'm guessing you mean something else.
>>
>>51315698
You need a char array, not a char * array.
>>
>>51315749
i'm storing strings tho?
>>
>>51315649
Use this site http://ideone.com, if you have everything in one file just select Java then paste the contents. You might have to rename the class definition to "Main" instead of whatever the name of the file is on your computer.

Type 2 and enter in the stdin box to simulate entering 2 in the console.

If it compiles and you get the same output, post the link here.
>>
File: Capture.png (10 KB, 264x533) Image search: [Google]
Capture.png
10 KB, 264x533
>>51315761
Something else is happening
>>
>>51315758
That's why you need a char array. Do you need a refresher on the distinction between an array and a pointer?
>>
>>51315807
isn't char *string and char string[] identical?
>>
>>51315795
Just looks like the little segment you posted is being run more than once. Do you have it inside another loop?

It's a lot easier to help when you post all your code instead of making us guess what you meant.
>>
>>51315795
Post
Your
Entire
Code

PYEC

New acronym.
>>
Should I ignore this message? This code runs in other IDEs without error but VS2015 complains.
What does it mean?
>>
>>51315827
Not really, it's a beginners mistake, but that isn't the issue. To him you were saying char * array which make it seem like you were saying char *array[].
>>
>>51315576
>needing 10-bit color depth to watch a cartoon drawn by hand in a sweatshop
>>
>>51315827
Negative.

`char *string` is a pointer. It doesn't point to any chars until you assign it a value.

`char string[20]` is an array of 20 chars. It will automatically be converted to a `char *` that points to the first char, as needed.

`char string[]` is an incompletely-typed array, because there's nothing in the []. You generally don't need this.
>>
File: meme.jpg (310 KB, 1280x840) Image search: [Google]
meme.jpg
310 KB, 1280x840
>>51315151
Reposting from a prior thread because it's interesting.

Who else here is working on their own programming language?

I'm building something heavily inspired by Smalltalk. With additional ideas from everything from Go to Rust to Objective-C to Haskell to D to C++ to Forth to Scala. But mainly smalltalk.

Still working on the syntax for this bad boy. I've already got a good idea of how I'm going to implement it. I'll be generating C code that corresponds, which will call into most likely an Objective-C runtime, or maybe something custom. But for now Yacc and Flex are my friends.

It's really worth doing if you have even a passing knowledge of programming. With Flex and Yacc you can describe the syntax in a pretty simple language and it will create a parser for you. E.g.:

add:
VariableOrConstant '+' VariableOrConstant
;

Really, it's hard to explain just how fun it is and how much you learn. I've gained a new respect for programming language designers already.
>>
>>51315827
To get to the point. What are you actually asking for? Do you want to make a char array entire of '\0' aka NULs? (Note only one L).
>>
>>51315273

>>51315417
>>51315301

(S)he's obviously not asking about that. It's pretty clear from mentioning libclang that (s)he wants to use libclang to build some C source *at runtime* from C++.
>>
>>51315889
I dont need it, but you can't deny it is better, and since I am archiving everything I download, I want to have the highest quality available.
>>
>>51315952
No, I want a C string.
>>
>>51315999
C strings aren't text.
>>
>>51315417
>>51315955
Exactly.

Well, I guess no one on /g/ would know, this is pretty niche, and /g/ is full of fizzbuzzer.

>>51315448 is probably the closest I'd get to a response but I don't want to bother people in a chat.

Thanks anyway.
>>
>>51315999
A string in C is an array of chars. You don't seems to understand what you need to ask, so I would suggest re-reading the section on strings in whatever book you are reading to learn C.
>>
>>51316005
>>51315952
>>51315807
how am i supposed to return the largest word stored in a char buffer?
>>
>>51316045
Don't talk down to me, you mansplaining piece of shit.
>>
>>51315390
>tfw gay
get fucked feminists
>>
>>51316048
You start by creating the buffer. `char * string` doesn't create any buffers by itself.

`char string[20];` creates a 20-byte buffer that is automatically freed when the function returns.

`char * string = malloc(20);` creates a 20-byte buffer that you are responsible for freeing using `free(string)`; when you are done using it.
>>
>>51316048
Return a pointer to the start of that word. You can do that by allocating new space for the word which I would do in the function call, by using malloc. Or you can find the largest word in the buffer and return a pointer to the start of that word and change the space after the word to a NUL character.
>>
>>51315842
>>51315869
ALRIGHT GUYS HERE IT IS
my entire code

import java.util.Scanner;

public class PokerSetup
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);

System.out.print("Enter a number 2 through 8: ");
int players = scan.nextInt();//TAKES COMMANDS
System.out.println();

while(players>8 || players<2)//REPEATS IF WRONG
{
System.out.println("\nTry again.");
System.out.print("Enter a number 2 through 8: ");
players = scan.nextInt();
}

String[] suit = {"Clubs","Diamonds","Hearts","Spades"};
String[] rank = {"2","3","4","5","6","7","8","9",
"10","Jack","Queen","King","Ace"};
int SUITS = suit.length; //AVOID "HARDWIRED" CONSTANTS
int RANKS = rank.length;
int N = SUITS*RANKS;
int cards = 5;

String[] deck = new String[N];
for( int i = 0; i < RANKS; i++)
for(int j = 0; j < SUITS; j++)
deck[SUITS*i+j] = rank[i] +" of "+ suit[j];

for(int x = 0; x < players; ++x)
{
for(int i = 0; i < N; i++) //SHUFFLE
{
int r = i + (int)(Math.random()*(N-i));
String t = deck[r];
deck[r] = deck[i];
deck[i] = t;
}

for (int y = 1; players > y; ++y)
{
System.out.println("Player"+y+":");
for (int i = 0; i < cards; i++)
{
System.out.println(deck[i]);
}
System.out.println();
}
}
}
}
>>
>>51316122
>1/4 of your lines are just { or }

Fuck curly braces.
>>
>>51316122
The problem is in the last loop. You are trying to deal cards to multiple players but are using the same indexes 0->5 for all players.
>>
if you dont have your own language just off yourself 100% serious
>>
>>51316189
There is literally nothing wrong with curly braces
>>
>>51316189
it's not the official java code style convention. C# is retarded like that but not java
>>
>>51316204
>>51316204
Luckily conlangs are my hobby

Maybe I'll design a programming language one day too.
>>
>>51316022
>I don't want to bother people in a chat
they are there for a reason
>>
>>51315936
stay away from C and Obj-C if you want to implement your own Smalltalk. Obj-C is not a compiler of its own, it gets translated into C and then is compiled as pure C. The overhead of implementing a Smalltalk-like language in C is high so that it runs slow (as slow as Java). It was a necesity of the time to translate into C because there was not enough memory in computers of the time to support gc languages. Objective-C could be rewritten now as its own stand alone language and would run much faster by not translating into C.
>>
>>51316364
>java
>slow

you probably shouldn't post here
>>
Recursive function that calls its self bassed of a near infinite number of variations. To get an output that is secret.
>>
>>51315151
Arguing we a professor over the answer to a question. Can someone tell me the runtime of a piece of code. Dont know how to post code so bear with me please.

void func(NodeType*& listPtr){
if (listPtr!=NULL){
func(listPtr->next);
delete listPtr;
}
else
return;
}
>>
>>51316266
>C# is retarded

If you don't use Allman, then FUCK YOU!
>>
>>51316380
Java is very fast for a VM language, but relative to compiled languages it is slow and will always be slow
>>
File: 1443465857600.jpg (20 KB, 500x276) Image search: [Google]
1443465857600.jpg
20 KB, 500x276
>>51315390
>people still fall for this bait
>>
File: fazbaz.png (6 KB, 219x460) Image search: [Google]
fazbaz.png
6 KB, 219x460
>>51315936

I wrote a shitty language that kind of looks like MIPs.

I stole the idea from someone else. Elected to do it this way since it was super simple to parse.

Was fun/10.
>>
>>51316476
Recursively deleting a list? It's O(n). It also blows up the stack if n is large, reorder your code for proper tail-calling by deleting from the beginning.
>>
>>51316466
NP problems. Fun shit. Here's your chance to prove NP = P.
>>
>>51316477
Do you still use braces on one-liners?
>>
>>51316601
Anyone who doesn't is just asking for it.
>>
>>51316601
Not him but I do
I always write code that still works if you remove all line breaks
>>
>>51316611
lol.
>>
>>51316589
if (solution is not correct)
destroy universe
else
solution is correct
(assuming there is an infinite multiverse)
>>
>>51316601

It depends, but usually yes.
>>
>>51316563
>O(n)
thank you. This is what I said but she thinks its O(n^2). Also I couldnt do it that way because she wanted us to delete them in the same order we inserted them, since you insert to the front you have to get to the back first before deleting. In her mind each delete in O(n). and shes being to obstinate to listen to my argument.
>>
>>51316632
What? You minify your code?
>>
>>51316640
Stop oppressing her, women are the best coders
>>
>>51316640
How the fuck does one reason that deleting a single node is O(n)? It's okay anon, as long as you know.
>>
>>51316691
Oh wait, I see where she was coming from. Deleting an arbitrary node is O(n). But she's wrong because if you just traverse the list as you delete them you are only visiting each node once.
>>
>>51316691
Apparently she wants to delete in the order inserted in a singly linked list (i.e. you gotta go through the whole list each time)
>>
Any good advice about persisting C++ objects to disk storage in JSON format /g/?
>>
>>51316691
Fuck if its okay. I lost 5 points on a test that I made plenty of stupid mistakes on but this was not one of them. The find and delete process per node is O(n). She just didnt take into consideration that I could delete everything just by finding the last node keeping it O(n).
I fucking hate grade grubbing but I got a b- on this test so I need those points.
>>
>>51316723
dont fuck up
>>
>>51316716
I see, in that case she is correct, but why the hell you would do that is beyond me.
>>
>>51316640
>she
there's your problem
>>
>>51316685
only if they have a dick
>>
>>51316656
No but my auto-format script can't deal with missing brackets
And it's inconvenient if I manually reformat my code
>>
>>51316736
>dick
>woman
>>>b/lgbt/
>>
>>51316716
The problem just said is it possible to delete in the same order that you insert and whats the runtime. The code I wrote was just to prove my argument that it could be done in O(n).
>>
>>51316748
a dick in their mouth, fgt!
>>
>>51315151
I've got two sequences in F#, one of strings and one of floats, and I want to print out the first element of one, the the first element of the other, then the second element of each, and so on

How would I go about this?
>>
File: 1443584547586.jpg (51 KB, 448x717) Image search: [Google]
1443584547586.jpg
51 KB, 448x717
>>51316730
Haha k, I'll do that anon.
>>
File: 1426733967538.jpg (12 KB, 225x225) Image search: [Google]
1426733967538.jpg
12 KB, 225x225
I'm trying to figure out how the fuck to use my Twitter API key in this application I'm working on. It's not supposed to be human readable, but my application is open source.
>>
>>51316769
With that much recursion, why have a linked list? You basically store every single pointer on the way.
>>
File: most_stupid_thing_I_read.webm (1 MB, 512x288) Image search: [Google]
most_stupid_thing_I_read.webm
1 MB, 512x288
>>51315325
this gotta be satire
>>
>>51316748
>2015
>not futureproofing with traps
>>
>>51316823
who is jason anyway? i assume he's java-tier
>>
>>51316835
sorry i forgot what thread i was in
>>
>>51316828
>upvotes
:^)
>>
File: 1443580800965.jpg (32 KB, 400x507) Image search: [Google]
1443580800965.jpg
32 KB, 400x507
>>51316843
He's that guy who owns that deli--JSON's Deli. He works part-time developing web-tier grade code.
>>
Daily reminder if your language doesn't have macros, you should quit programming and re-evaluate your life.
>>
>>51316877
>Daily reminder if your use macros, you should quit programming and re-evaluate your life.*
ftfy anon
>>
>>51316876
I hear his cereal's packaging has a flaw that anyone could exploit and allows for malicious injections, is it true?
>>
will tensorflow help replacing shit programmers?
>>
>>51316877
c++ a shit
>>
>>51316890
#define your you
>>
>>51316826
I was asked if I could delete every item in a linked list and what the runtime would be. I did it in O(n). My code is the product of the fact that she didnt say she wanted every item to be deleted with a separate function call. Just if it could be done in a certain order.
>>
>>51316589

A while ago, someone came to /g/ with some Java implementation of a subset sum problem that he claimed could be done in O(n^8) or something like that. We told him to fuck off until he could come back with a more formal proof because nobody wanted to read his ugly ass code.

I've been someone following updates on his repository. He came up with this:
http://cusj-dev.journals.cdrs.columbia.edu/wp-content/uploads/sites/15/2015/04/Alston_2015_CUSJ.pdf

Obviously, it's going to need some peer review, but if this is all correct, then P=NP.
>>
>>51316929
Teacher who won't admit they wrote shitty questions are cancer.
>>
>>51316822
Isn't that what Seq.zip does?
>>
File: -youre.jpg (31 KB, 552x369) Image search: [Google]
-youre.jpg
31 KB, 552x369
>>51316905
>>
>>51316953
never gonna give you up
>>
>>51316953
he bothered /g/ too? I remember discussing this on /sci/ as well
>>
>>51316953
An anon proved P = NP. What times we live in.
>>
>>51316070

>> mansplaining
"to explain something to someone, typically a man to woman, in a manner regarded as condescending or patronizing."

also

"It was included on The New York Times' 2010 word of the year list,[5] nominated for the American Dialect Society's most creative word of the year honor in 2012,[2] and added to the online Oxford Dictionaries in 2014.[7]"

Wow, to think it's an actual word. Not even commenting on the word's sexist tone.
>>
>>51316974
>if you are use macros
u r right
>>
File: 1440412235153.gif (2 MB, 282x257) Image search: [Google]
1440412235153.gif
2 MB, 282x257
>>51316897
Thanks anon. Just when I was finally free of the botnet, you force me back into it with that post.

>>51317002
>if you're are use macros
>I saw wat u did they're anon.
>>
>>51316953
>>51316988
it started in /sci/ IIRC
>>
>>51316822
Seq.zip muhInts muhFloats
|> fun (muhInt, muhFloat) ->
printfn "%i" muhInt
printfn "%s" muhFloat
>>
>>51315151

Woah nice grill. What is it's name?

I'm learning the ICU libraries in order to have god-tier string handling at my disposal. Then I'm going to write a fully-featured, UTF-8 exclusive, generalized context-free parser library.

Shit man, the ICU library is so incredibly awesome. It is obscene. How come every single language runtime out there isn't using it? I still remember the mess ALL the current scripting languages made in their date/time STANDARD libraries and even NATIVE string support. Had they simply used ICU, all their problems would be solved -- literally non-problems.
>>
>>51316972
Didn't know about that, thanks
>>
File: uptheb.webm (2 MB, 1280x720) Image search: [Google]
uptheb.webm
2 MB, 1280x720
Anyone familiar with i/o using SDL?
I can only seem to read files that were created with SDL_RWops(). With c++ stl io I can just open notepad and write anything I want then load it into my program but SDL_RWops refuses.
Is this by design or have I overlooked something?
>>
>>51316988
>>51317022

So he came to /sci/ first? Would not surprise me. I recall seeing him in /g/ though.

>>51316890

Macros can be helpful in some areas, particularly in C, which lacks both constant expressions and templates.
>>
>>51317020
the botnet is everywhere, and keeps growing.

I asked because I fear for myself... I don't really understand this stuff, but seems like you could do lots of shit by training an AI (which, again, I don't understand what it really means or implies...), which means competent programmers just became more powerful than people like me, college dropouts and people without any formal specialized education.

on a second thought, after looking at their beginner intro, looks like I may already know some math related to this, so I guess I lose nothing if I try understanding it.
>>
>>51317135
If only C's macros were AST instead of shitty text based.
>>
>>51316890
Such a clever retort! You sure showed him with that greentext, anon.
>>
>>51315417
>How about you fuck off and just let us program without having to hear about how offended you are? It's not our job to make this place more inclusive for you. Love it or leave it.

Whoah. You used to be a much calmer person, Ruby. Have all the trollings finally broken you?
>>
Was doing some discrete homework and did the problems R^-1 * S and S^-1 * R where S and R are relations and * is composition and the resulting set was the same. Wondering if this is always the case or merely coincidence?
>>
>>51315877
B R E A K
R
E
A
K

you dumb fuk
>>
>>51317106
> unclear garbage

Do you edit the file WHILE the program is running? And what do you mean by 'refuses'? Please provide a detailed step-by-step procedure for reproducing this, including a program with a main function and no ellipsis, the expected behavior, the exact message you're seeing, non-exhaustive, just like you would in a scientific paper. If necessary, write a small program that just does the thing we are interested about instead of dumping your entire shit-tier code, in brief, put in some effort if you expect an answer. Thank you for your attention.
>>
>>51317106
wud fug
>>
Static typing a shit
>>
>>51317302
>>>/g/wdg
>>
>>51317302
please explain
>>
>>51317302
That's a roundabout way to say "I suck at static typing"
>>
>>51317149

If wishes were fishes, Anon...

I've sometimes thought about making my own systems programming language with a focus on strong typing and metaprogramming.

C++ takes C's macro system, and adds onto it templates and constant expressions, nether of which are a wholly unified system. D has its own interesting metaprogramming features, such as static if for conditional compilation. It would be like if one could use preprocessor macros with constant expressions in C++ to say, for example, if this constant expression evaluates to true, compile this section of code, and so on. Rust has fixed width integer types as a default. I would like to take some inspiration from all of these.

>>51317181

I'm normally a rather calm person. I feel though that if we keep letting bullshit pollute our thread, it's just going to encourage more. Granted, most of the people who come in here and sound like SJWs may be just trolling, but do we really want actual SJWs to come here, thinking they are in like-minded company?
>>
>>51317388
>systems programming language
>what is Go
>>
>>51317302
Why aren't languages fully dynamic with optional type annotations and inference wherever possible?

So you can have your convenience when in a REPL or something

and you can restrict the shit when you're writing a library or something in order to make compiler optimizations possible

Just have the compiler assume it's an unbounded/generic type if you didn't specify anything and it can't infer the type; when you need performance, optimization, interoperability with underlying platform and native libraries or just plain old type checking at API boundaries, just annotate the variable. Tell the compiler it's an int32 so it can generate some efficient and direct arithmetic code and fail when faggot lusers pass in anything else.
>>
>>51317388
>do we really want actual SJWs to come here
read the CoC, m8
>>
>>51317060
ICU would be really good if it didn't use pig disgusting UTF-16.
>>
>>51317426
>Why aren't languages fully dynamic with optional type annotations and inference wherever possible?
Because dynamic typing is useless

>So you can have your convenience when in a REPL or something
You don't need dynamic typing for REPL
>>
>>51317388

You needn't create your own language. Rust already exists.
>>
>>51317412
>Let me just wait for my syscall while the kernel GC's its shit.
>>
>>51317464
>2015
>doesn't know GC is faster than free()
ishyggydiggy
>>
>>51317448

It'd be the /pol/ effect 2.0. They all pretended to be neo-nazis until the real neo-nazis showed up and thought they were in good company.

It's funny, but real SJWs here would be a pain.
>>
>>51317350
There is literally no need. With proper testing the flexibility of dynamic typing greatly outweigh the drawbacks.
>>
>>51317493
enjoy your no performance, fgt
>>
Is Objective-C dynamically or statically typed?
>>
>>51316992
asking stupid questions
"to ask something, regardless of your gender, or preconceived notions of yourself, that could have been answered if you had just carefully read the documentation like everybody else who's mastered something"
>>
>>51316890
Spotted the Indian code monkey that shits out java bloatware.
>>
>>51317493
>the flexibility of dynamic typing
dynamic typing doesn't provide greater flexibility though.
>>
>>51317532
Is Common Lisp?
>>
>>51317547
It does.
>>
Dynamic > static
Strong > weak
GC you can tweak > no GC
>>
>>51317464
The kernel can do GC in a low priority system process. In fact, many kernels do exactly this.
>>
>>51317547
Most people seem to agree that it does.
>>
>>51317532
Dynamic with optional static typing. It's a strange beast.
>>
>>51317453
Yeah UTF-16 a shit

But really who gives a fuck what it uses internally? I mean it's not like the pig disgusting Win32 APIs where I get fucked sideways if I want to use anything but shitty, broken ass C++ wide strings for unicode support just because for some stupid ass reason the OS can't handle some UTF-8 encoded plain old motherfucking pure C char* buffers. I mean Jesus assraping Christ.

Compared to that, ICU's choice of internal encoding is literally invisible to me. Not only that, they give me literally the best text encoding conversion functionality available on this planet

Everything I'm writing is dealing with UTF-8 text exclusively and I couldn't care less about UTF-16

>varies with endianess

literally a non-encoding
>>
>>51317412

Go has a garbage collector, which cannot be used in a freestanding environment, and also imposes performance penalties and non-determinism on applications that are not freestanding. While garbage collectors can be fine in more robust languages that don't try to provide low level access, such as Java and C#, for a systems programming language, it's completely unacceptable.

>>51317460

Let me know when Rust's libcore is stable.
>>
>>51317388
Have you taken a gander at Nim's macro system yet? It seems to have the best one (outside of Lisp).
>>
>>51317593
Kernels are garbage collected?
>>
>>51317587
No it doesn't. What advantage does it provide?

>>51317598
So it must be true? Why is it more flexible? Because most people told you so?
>>
>>51317532
Objects in Obj-C are typless and so dynamically typed. Obj-C is trying to be like Smalltalk which is based on message passing and not objects
>>
>>51317625
>What advantage does it provide?
It's more flexible.
>>
>>51317601
What are some good books that cover efficient, optimized implementation of "hybrid" typing programming languages?

As in, everything is some top-level type like Object by default but you can manually restrict the type or the language can do mathematical proof stuff to infer the restricted type.
>>
>>51317640
How is it more flexible? Provide an example.
>>
Why does static typing have better performance? I've never really cared about these things.
>>
>>51317615
let me know when yours is stable
>>
>>51317615

It's stable.
>>
>>51317695
protip it doesnt
>>
Carmack says Racket (dynamic) is superior to Hasklel (static).

/g/ status: btfo
>>
>>51317650
http://julialang.org/
>Julia is a high-level, high-performance dynamic programming language for technical computing, with syntax that is familiar to users of other technical computing environments.

>Julia programs are organized around multiple dispatch; by defining functions and overloading them for different combinations of argument types, which can also be user-defined.

>Julia’s LLVM-based just-in-time (JIT) compiler combined with the language’s design allow it to approach and often match the performance of C
>>
>>51317703
anon...
>>
>>51317650
You're basically described Java. In Java everything is an object. You can make all your code accept and return object if you like:
function Object addNumbers(num1 : Object, num2 : Object) {
return (Interger)num1 + (Integer)num2;
}

This basically makes Java a dynamic programming language, though a very verbose one.

You might be interested in TypeScript though. It basically implements optional typing like Obj-C does.
>>
>>51317695
Because your program is much more restricted so the compiler can assume a shitton more things about your code (like "X is never going to change, I can inline X!) and can generate more efficient code
>>
>>51317695
Yes. The compiler can optimise your program much more with static typing.
>>
>>51317700

I have the stable version of Rust installed. I can't use no_std and I can't use libcore. Supposedly, they're only available in the nightly builds.

Libcore in particular is unstable enough that the Rust community would like you to not use it.
https://doc.rust-lang.org/core/
>>
>>51317619
Yes. Kernels typically cache a lot of objects in memory in the hopes that they will be used again (e.g. the dentry cache in Linux). Eventually these caches need to be cleaned of stale objects.
>>
>>51317629
>>51317601
The answer is "Both", in fact! Pure C types are statically typed. Objective-C types have both static and dynamic features. An Objective-C object can be referenced via an 'id' pointer, which has no static type information, or a pointer to a specific Obj-C type (such as 'NSString *') which does.

Method calls are dynamic, and are done using "message passing", which can be done on either type of pointer. For 'id' pointers, any message can be passed and a runtime error will occur if the method does not exist. For typed pointers, the compiler will warn you if the type does not implement the given method. NSObject provides methods for checking at runtime if the object implements a method.

For 'id' pointers, members cannot be accessed directly, but only through "property" getter/setter methods. For typed pointers, members can be accessed using C struct notation, and the struct offsets are static because they are known at compile time. Public/private/protected markers allow you to open member access to external code or prevent subclasses from accessing them, since members are protected by default.
>>
>>51317752

Alright look, ruby, you're making mountains out of molehills.. unstable molehills.
>>
>>51317729
>This basically makes Java a dynamic programming language
So C is also a dynamic language because void * addNumbers(void * num1, void * num2) ?
>>
>>51317729
>>51317710

I know both of those languages. I'm looking for material on programming language implementation. Interpreters, compilers. The algorithms that make those languages/VMs/runtimes so efficient

Java still needs type annotations all over the place

(define untyped (lambda (x y) + x y))
(define typed (lambda ((x (integer 32)) (y (integer 32)))
+ x y))
>>
>>51317664
Mainly when it comes to code reuse, grabbing snippets in isolation to use elsewhere (possibly with slight modifications).
With dynamic typing it's very easy to accommodate the imported code, you just gotta make sure it can 'behave as' the existing code expects and it's not an issue.
With static typing comes taxonomy/scaffolding baggage which must agree completely with each other - or you're forced to wrap glue code to convert these incompatible type categories - this also makes the code resistant to change because switching out a type which is built upon various traits makes the whole thing come down and you must start from scratch.
>>
>>51317788
you can do dynamic style programming in almost any statically typed language. Everyone I know of at least.

Java is not a dynamic language, but can be used like one for certain things if you really need it. Same with C.
>>
print "mark is a faggot"

hehehehe
>>
>>51317808
>With static typing comes taxonomy/scaffolding baggage which must agree completely with each other
such as? Not really sure what you mean here.

>or you're forced to wrap glue code to convert these incompatible type categories
You have to do the same for dynamically typed code. Dynamic languages still have types, they are simply evaluated at run time and will cause just as much trouble at run time as they do at compile time.

> this also makes the code resistant to change because switching out a type which is built upon various traits makes the whole thing come down and you must start from scratch.
Again, it's exactly the same in dynamic typing. In fact in my experience dynamic typing is far FAR worse for this. It's the main problem with dynamic typing. Refactoring a large code base is a nightmare. It can take a very long time to debug and be confident you've found all the bugs. In a static language most issues created by refactoring a large code base will be caught at compile time, and static typing enabled IDE tools like easily renaming a variable or method used all over the codebase automatically. Dynamic typing can't enable this.
>>
>>51317808
>waaaaaah
>muh copy pasta
>waaaaaah
anon...
>>
>>51317973
Dynamic typing have the advantage that the program will run until the error is encountered which help you with debugging and make the processes of coding easier for newbies.
>>
>>51317804
There's not many languages that try to do this. Objective-C is the only big one I know of. Most people think it's horrible, which is why it's pretty much never used outside of Apple. Even Apple realised it was a mistake and made Swift completely static typed.

TypeScript does it only out of utter necessity, since JS is completely dynamic.
>>
>>51318019
>dynamic typing is good for beginners
Oh, ok.
>>
>>51318019
>advantage that the program will run until the error is encountered
Why is this an advantage? How is this better than getting the same error at compile time, and getting generally much much better information about what caused the problem?
>>
>>51318019
And with static typing the program will compile until the error is encountered which help you with debugging and make the processes of coding easier for everyone.
>>
>>51318019
This is actually a negative.
>>
>>51318024
Typed Racket is just like the example I posted, except it was kind of put into the language afterwards instead of being there right from the beginning.
>>
>>51318044
>getting generally much much better information about what caused the problem

LOOLL hahahahaaha compilers in general suck at generating coherent error messages, especially your freetard compilers using shitty ass generated freetard parsers using the parser generator tools they learned in CS101.

Good error messages are the exceptional case here, not the rule
>>
>>51318086
(you)
>>
>>51318044
Because you can see how your code actually behave up until whatever happen. If you've gone totally of road there's generally no point in fucking around and trying to solve type errors when what you need to do is rewrite half of your shit.
>>
>>51318086
>LOOLL hahahahaaha compilers in general suck at generating coherent error messages
I can't think of a compiler error I ever got that was not useful. Can you provide an example of a incoherent error message from a statically typed language compiler?

>freetard compilers
I'm a C# and F# man myself
>>
>>51318057
no, its a positive, dynmaic typing is stronger typing than static typing, because the compiler knows more and keeps track of what type each variable/object is at runtime
>>
What is the best language for constructing an AI waifu and why is it Prolog?
>>
>>51318143
>dynmaic typing is stronger typing than static typing
>stronger
m8
>>
>>51317973
>such as?
Code for different projects will have different types, trying to reuse the typed code means you need to either import the entire type family into the new project, or rewrite it using the new types.
>You have to do the same for dynamically typed code.
No, because changes to dynamically typed code will automatically propagate throughout the code base, you eliminate the need for backtracking into the structural phase of classifying where things need to go.
>It's the main problem with dynamic typing. Refactoring a large code base is a nightmare.
It's way easier than with static typing because you get right down to the business logic instead of fiddling with structure.
>It can take a very long time to debug and be confident you've found all the bugs.
It's much faster to incrementally test code which doesn't need static types because dropping in extra instrumentation code or test environments is friction free.
>and static typing enabled IDE tools like easily renaming a variable or method used all over the codebase automatically. Dynamic typing can't enable this.
I don't see how static typing helps with that.
>>
>>51318158
>what is Go
>>
>>51318120
>Because you can see how your code actually behave up until whatever happen.
Why is this better than knowing what was going to cause a problem at compile time?

>If you've gone totally of road there's generally no point in fucking around and trying to solve type errors when what you need to do is rewrite half of your shit.
That goes without saying. That has nothing to do with dynamic or static typing though.
>>
>>51318143
>because the compiler knows more
What does it know more about?

Why are all the world's fastest programming languages static?
>>
>>51318135

C# errors are particularly good as long as it's not something happening in the thin-wrapper parts (like GDI shit)
>>
>>51318163
>trying to reuse the typed code
codeword for copy+pasta
>I don't see how static typing helps with that.
confirmed brain damage
>>
>>51318178
>Why is this better than knowing what was going to cause a problem at compile time?

Not him, but I'm sick of jumping through all of these hoops to placate the compiler, then get to finally running the thing only to find out there's some kind of logic error that the compiler would never catch.
>>
>>51318135
>I'm a C# and F# man myself

Oh then you are of course accustomed to the comfort provided by the excellent M$ compilers, which are all backed by non-shit custom parsers which were actually especially crafted to parse the actual language they are parsing, not just to generate a shitty ass source that gets built along with the compiler with the sole purpose of extracting some faggot trees out of some fucking string as quick as possible so the author can just forget about all this hard and difficult string parsing business already. The C# compiler is of particular high quality
>>
>>51318213
>only to find out there's some kind of logic error
git gud fgt
>>
>>51318201
>Why are all the world's fastest programming languages static?
The fastest language is untyped.
>>
>>51318201
dynamic languages keep track of types at runtime, compiled languages only know what you tell it at runtime, you cant predict what kind of types you will get at runtime, so you can never know more than the compiler

C is statically typed and weakly typed by design
>>
>>51318213
>I'm sick of having to fix all of these bugs before I find another bug
>>
>>51318232
You're wrong.
>>
>>51318178
>Why is this better than knowing what was going to cause a problem at compile time?
It's faster to fix.
>>
>>51318239
>you cant predict what kind of types you will get at runtime

This fucking guy.
>>
>>51318242
What language is faster than an assembly language?
>>
>>51318241
Yes! I'm sick of having to fix bugs! Why hasn't someone invented a statically-bugfree compiler that can guarantee your code contains zero bugs, and if it finds any, it just fixes them for you!!
>>
>>51318239
>dynamic languages keep track of types at runtime

sounds like reflection (and has nothing to do with dynamic typing)
>>
>>51318262
What assembly language is untyped, you stupid fuck?
>>
>>51318262
Languages can't be fast retard. Only implementations can be slow or fast. You're not even being coherent enough to be in a position of being wrong, much less right.

You're all wrong. Everyone in this thread is wrong.
>>
What is wrong with this code? It is a Bulls and Cows game.
It generates a random code and you must try to guess it; if the code you wrote contains a number of the generated code it adds a cow, if it contains a number of the generated code in the same position of the generated code it is a bull.

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

int main() {

char code1[3];
char code2[3];
int bulls = 0;
int cows = 0;

int i = 0;
int j = 0;
int r = 0;

printf("Insert code: ");
scanf("%c%c%c%c", &code1);

char symbols[] = "123456789";

for(j = 0; j < 4; j++) {

srand(time(NULL));
r = rand() % 9;
code2[j] = symbols[r];
symbols[r] = 0;

}

for(i = 0; i < 4; i++) {

if(code1[i] == code2[i]) {

bulls++;

}

else if(strchr(code1, code2[i]) != NULL) {

cows++;

}

}

printf("%d Bulls and %d Cows", bulls, cows);

return 0;

}
>>
>>51318163
>Code for different projects will have different types, trying to reuse the typed code means you need to either import the entire type family into the new project, or rewrite it using the new types.
That's also the case in dynamic languages. The difference is the static compiler will tell you if you forgot to import something.

>No, because changes to dynamically typed code will automatically propagate throughout the code base
I can think in no sense of how this is true. Dynamic languages make no difference at all to how code "propagates". Can you describe an example of what you mean?
>get right down to the business logic instead of fiddling with structure.
I'm not sure what you mean. You don't need to fiddle with structure any more in a static language than you do in a dynamic one.
>because dropping in extra instrumentation code or test environments is friction free.
Why is this any better in dynamic typing?

>I don't see how static typing helps with that.
Because static typing lets the compiler know at compile time absolutely everything in your code base that references each method and each variable. This makes it easy to provide it with tools to rename functions, fields, members, variables and what have you used all over the code base and guarantee they won't break anything. Dynamic compiler's don't know what will reference what until running, and thus dynamic languages don't have these features. Providing these features to JS was one of the main goals of TypeScript.
>>
>>51318297
fite me irl
>>
>>51318289
Pretty much all of them.
>>
>>51318264
all computer errors are type errors, its impossible to make a programming language with no type errors because of the halting problem

compile time errors only catch syntax errors, which are not computer errors but humans not writing the program correctly

logic errors on not compter errors but human errors asking the computer to do the wrong thing

type errors are the only kind of erros a compiler can make
>>
>>51318318
Again, you're wrong.
>>
>>51317142
>so I guess I lose nothing if I try understanding it.
Yea ofc. Go for it anon. Waifu Bot General will need a lot of work in this area.
>>
>>51318297
>Languages can't be fast retard.
Yes they can.
>Only implementations can be slow or fast.
Nope.
For example: a language who's semantics require bounds checking can never be faster than one which doesn't require them, or a language which requires integer overflow to be well defined means it cannot do certain loop optimization (x+1 > n cannot be transformed optimally if x+1 is allowed to overflow and say wrap around)
>>
>>51318325
>type errors are the only kind of erros a compiler can make
I forgot to add that these type errors are always runtime errors
>>
>>51316723
Anyone?
>>
>>51316553
Not picking a fight, but : before the label name is an interesting choice, because it precludes
label:   operation
forms. What was your reasoning behind this choice?
Do you consider forcing labels only on a line a feature of the language?
>>
>>51318377
>a language who's semantics require bounds checking can never be faster than one which doesn't require them
It can be just as fast.
>x+1 > n cannot be transformed optimally if x+1 is allowed to overflow
It can.
>>
>>51318178
>Why is this better than knowing what was going to cause a problem at compile time?
lolwut. if you're lucky anon you'll get only compile-time errors.
>>
>>51318325
>all computer errors are type errors
>logic errors on not computer errors but human errors
>all errors that ever occur on a computer are human errors caused by the human creators of the software and hardware
HAL9000 pls leave
>>
>>51318232
>The fastest language is untyped.
. . .
Thread replies: 255
Thread images: 22

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

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