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

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: 317
Thread images: 21

File: 1334682645405.jpg (475KB, 1024x1076px) Image search: [Google]
1334682645405.jpg
475KB, 1024x1076px
Old /dpt/ at >>51491564

What are you working on?
>>
>>51494191

Daily reminder that if you aren't using Neovim, you a shit.
>>
>>51494207
why not just use classic vi?
>>
Project Euler
>>
Hey, /g/, wanna get #rekt by a big dick playa?
Again?
>>
>>51494207
why should I switch if I have a working vim install?
>>
>>51494191
int average(int a, int b)
{
return a % 1; // this typo triggers people
}
>>
why do you care if an integer is bigger than 64 bits?

what edge cases are we looking for?
>>
>>51494227
you're retarded

>>51494258
you shouldn't for now
>>
>>51494258
neomake is enough for me
>>
>>51494191
Building a back-end for my pepe evaluator.
It collects pepes and people can see how rare their pepes are by checking the image hashes in a database.
Very mature project.
>>
>>51494267
only incompetents care; the rest write correct code
>>
on an EXT2 file system using the DIR struct after I delete a DIR node from my parent how do I shift the other DIR entries left to fill the fucking hole left by deleting that DIR entry?

mycurrent code for looking through entries involves a buffer[1024]

char *cp = buffer;
(DIR) dir = (DIR *)cp;

while(cp + dir->rec_len < buffer + 1024)
{

char *cp += dir->rec_len;
(DIR) dir = (DIR *)cp;

}
>>
>>51494292
what does it do for you?
>>
>>51494289
you didn't answer my question dumbass, why not just use classic vi?
>>
>>51494296
Why not based on image similarity?
>>
import int
import IntegerMathematics
import IntegerStandardUtilities
import addition

static void const pure maybe int average(in const a int, in pure free const int b int)
{
return classes.mathematical.int.utils.average(a, b);
}
>>
>>51494301
I mean, a fucking trillion is like 10 or 20 numbers.
64 integers number is fucking huge, I believe even astrophysics use smaller numbers unless they're counting the atoms of the universe.

I don't buy the it will overflow meme.

what cases will need integers bigger than 64 bits?
>>
>>51494321
like :make but it doesn't stop the world while it builds

also shows errors like syntastic
>>
>>51494322
you're not entitled to one, and they probably didn't mean to answer you
>>
>>51494344
>which cases will need integers bigger than 64 bits

Even Apollo 11 had more than 64 bits of non-volatile memory
>>
i haven't written ANYTHING in like two years, and i've forgotten almost all my bash and vim and ANSI C.

what's a good book / guide on vim?
right now i'm using nano until i get back into the swing of it...
>>
>>51494339
>>51494284
>>51494242
samefag?
>>
Working on something with my arduino but my C Programming skills are very low.
Currently trying to control a 4-digit alphanumeric display.
Is it possible to put ascii into a functions argument? like this:

void function(char variable)
{
do something;
}

and then in the main function just to use
function('V');

Would this work?
>>
>>51494390
Yes
>>
>>51494390
holy shit
>>
>>51494335
I'm thinking about how to implement that properly too.
The first check will be to see if the hash exists in the database, and if not, a similarity check should definitely be used.
>>
>>51494371
like I said, if you need such cases, just use a 128 bits integer or bigger.

what's the point of developing better hardware if not have bigger resources.
>>
>>51494322
because you're using an inferior tool just to be a tryhard

>>51494344
>what cases will need integers bigger than 64 bits?
have you tried multiplying two really big integers of N bits? In many cases you'll need 2N bits to hold the product

>>51494375
>what's a good book / guide on vim?
I suggest Practical Vim, but there's more: http://it-ebooks.info/search/?q=vim&type=title
>>
>>51494390
>Would this work?
yes.

please use [ code ] [ /code ] tags next time (without the intersperse spaces)

If the function and main are in the same file you should also give the function static linkage:
static void function() {
//do something
}
>>
>>51494403
>>51494403
Thank you :)
>>
>>51494409
Take a look into SIFT
>>
>>51494375

There's some tutorials on youtube
>>
So what was the overall purpose of SICP?

I watched all the lectures on youtube, not exactly sure how learning the algorithm of calculating a derivative in lisp will be useful

guess i fell for this shit meme
>>
>>51494527
cashing in on book sales
>>
>>51494472
Thanks, I will. I experimented with OpenCV in Python a little, so I should be able to do something with it.
>>
>>51494472
Thanks, I will. I experimented a bit with OpenCV in Python, so I should be able to do this.
>>
I need project ideas to fluff my portfolio.
When I Google "programming project ideas" I just get a bunch of links like "projects for kids" and "projects to learn programming."

I've used Java at work for the last 5 years, and I applied for for a job that requires C++ experience. I know C++, I took a few classes in college, but I don't have any projects in C++ to show.
>>
<!DOCTYPE html>
<html>
<body>
<p> Hello Darkness my old friend. </p>
</body>
</html>
>>
>>51494266

Your butthurt is showing
>>
>>51494711

This is a Java thread, not a HTML thread
>>
I read that linked lists can be faster than hash tables for low values of n, but what is considered a low value of n?
>>
>>51494727
>uses &1
>"endian"?
>>
>>51494710

try some multi-threading projects

one I did was dequeue and enqueue a million+ nodes without a crash and without any form of thread controls like lock etc.
>>
How would I go about making a quadtree with an array implementation?

Not homework its for vidyagems
>>
>>51494764
About tree fiddy
>>
>>51494764
1 or 2
>>
>>51494711
>>>/g/wdg
>>
>>51494774
>endian
Read the standard. & 1 gives you the LSB.
>>
>>51494788
Implement it normally, use an array as a backing store for a pool allocator.
>>
>>51494764
When calculating the hash is more expensive than iterating a list.
>>
Why aren't you using the tranny thread? Are you transphobic? Everyone post your social media so I can alert your employers.
>>
File: java.png (131KB, 748x1562px) Image search: [Google]
java.png
131KB, 748x1562px
wew
>>
>>51494782
Done already
https://github.com/enfiskutensykkel/lamport
>>
>>51494390
yup, or with a string
void function(char *str)
{
str[0]; // element 0 (or 1)
str[1]; // element 1 (or 2)
str[2]; // element 2 (or 3)
str[3]; // element 3 (or 4)
// str[x] is then the same as a char
char a = str[0];
// to run through them with a for loop do
int i;
for (i = 0; str[i] != '\0'; ++i) {
// do shit. e.g.:
a = str[i];
}
}
>>
>>51494863
why
>>
>>51494527
SICP was created to teach programming to incoming CS freshman at MIT.
>>
>>51494863
thanks based java
>>
>>51494863
but java is a meme, why is it beating C?
>>
File: bjarne.jpg (95KB, 1920x1080px) Image search: [Google]
bjarne.jpg
95KB, 1920x1080px
>>51494710
>I know C++
>I took a few classes in college
>>
>>51494527
>not exactly sure how learning the algorithm of calculating a derivative in lisp will be useful

Youre one of those people that say "Pfff Trig, when am I ever gonna use THAT lmao" arent you.
>>
>>51494863
why the big drop in most languages after 2015?
>>
>>51494933
JUST
>>
>>51494863
java is based beyond belief
>>
>>51494863
>C - 17%
>C++ - 6%
C++ BTFO
>>
>>51494941
*2014
>>
>>51494941
TIOBE changed how they were gathering data.

anyway TIOBE is an utter shite index. Use oloh black duck of whatever
>>
>>51494925
phones
web
cross platform without recompiling or making any compatibility changes
easy as fuck

basically because people are lazy and don't really care
>>
>>51494951
KEK
>>
>>51494925
"java is a meme" is a meme

there is nothing wrong with java
>>
>>51494969
KEK desu senpai

Thank you Hiroshima Nagasaki for the word filters
>>
>>51494984
is a meme
>>
>>51494527
>not exactly sure how learning the algorithm of calculating a derivative
you know how to calculate a derivative from high-school, so it's a good candidate to use in an introductory course.
>in lisp
it oculd be in any other language.
And derivatives are used in a fuckload of things in real life, things like graphics, finance, computer vision, etc...

>>51494710
if people are using C++ for a given job they're usually concerned about performance, so try to implement a fast web server, some graphics thingy or some stock exchange simulator. I'm not the creative type so, I'll let you decide
>>
File: Vanilla-Ice.jpg (129KB, 400x470px) Image search: [Google]
Vanilla-Ice.jpg
129KB, 400x470px
>>51494863
>assembly grew by 200%
nice

also
>people unironically shilling for Java
I thought you were better than this /dpt/
>>
>>51494867

you could try developing a rudimentary AI
>>
Where do you guys store your repositories?
I have been using github for a while now but I am required to use private repositories now.
Is gitlab the way to go? (Their server, not selfhosted)
>>
>>51495056
$HOME/src
:^)
>>
>>51495056
bitbucket and gitlab are good
I prefer bitbucket's UI
>>
>>51495056
have you tried self hosting your own git server?
>>
int average(int a, int b, int (*avg)(int,int))
{
return avg(a,b); // completely portable
}
>>
>>51495056
I'm on github, but as soon as FSF publishes their acceptable repos for free software list https://www.gnu.org/software/repo-criteria.html I'll probably be switching.
>>
>>51495173
>listening to the free jewish foundation
>>
>>51495159
what's the point?
>>
>>51495254
that's the same question i have about lambda expressions
>>
>>51495056
>can't afford 7 dollars
why live?
>>
>>51495159
>not accepting void types
what are you even doing m8
>>
>>51495361
void average(int a, int b, void (*avg)(int,int))
{
avg(a,b);
}
>>
>>51495056
>I am required to use private repositories now

why?
>>
>>51495384
a and b need to be void too
this is just stupid tho

I mean, it's fine for shit like qsort, but a generic avg function?
>>
>>51495347
>supporting jew keks
it's a matter of principle
>>
>>51494448
thanks
>>
How can I use the .Contains function in C# with more than one argument? It doesn't seem to like ||
>>
>>51495433
did you miss the last thread
>>
>>51495482
No, I was there.
I didn't read most of the posts because it was pure autism
>>
>>51495339
Lambda expressions allow you to write small, simple pieces of code which are not big enough to warrant putting in a separate function. They are especially useful in languages without good support for function composition and currying.
>>
>>51495480

You don't, because it only takes a single argument. Write an extension method.
>>
>>51495505
Why wouldn't you just write a function that holds function pointers to other small utility functions?
>>
>>51495527
There's no reason to define a whole new function just to pass a predicate to a list comprehension, dude.
>>
>>51495480
[arg1, arg2 ... argN].All(x => collection.Contains(x));
>>
>>51495523
Sorry, I'm very new to programming, at the moment I have some ridiculous if statement of
if (string[i].Contains("0") || string[i].Contains("1") || ... .Contains ("9"))
How can I shorten this? I've never used extension methods
>>
>>51495583

LINQ will be eradicated. LINQers will be eradicated.
>>
>>51495480
create a variadic function with a with a for loop that runs through it x number of times times
>>
>>51494320
Move each non-deleted entry as you process it, using memmove(). You need separate src/dst pointers which initially both point to the start of the buffer. src>=dst always. If src!=dst (i.e. you've deleted at least one entry), and you aren't deleting the record, then memove(dst,src,d->d_reclen). If you aren't deleting the record, advance both pointers by d->d_reclen. If you're deleting the entry, don't memove() and and only advance src, not don't advance dst.

Also, it's "struct dirent", not DIR. DIR is an opaque type; a DIR* is just a handle to the open directory.
>>
>>51495596

See here: >>51495583

Pretty short and sweet if you don't feel like writing an extension method.

If you're still interested, here's a good page: http://www.dotnetperls.com/extension
>>
>>51495583
So that's pretty much just map? Doesn't that give an array of results? You would have to reduce it afterwards?
>>
>>51495616
>>51495583
I'll give it a go, thanks
>>
>>51495596
regex
/[0-9]/
>>
>>51495654
"All" is true iff all the conditions are true.
"Any" is what you're looking, it's true if at least one condition is true.
>>
>>51495505
map['lol'] = lambda(x) return x * x

func addFactory(x)
return lambda(y) return y + x
end
>>
>>51495654
All returns a bool. Something like this should work as an extension method.

public static class MyExtensions
{
public static bool ContainsAll<T>(this IEnumerable<T> collection, params T[] values)
{
return values.All(x => collection.Contains(x));
}
}
>>
>>51495729

His is a sequence of OR, actually. You'd want Any.
>>
>>51495690
Oh, so it's not map, it's a quantifier. That's pretty cool I guess. I'm building a library for Lua that wraps up some cool convenience functions, completely overlooked quantifiers, I'll add that.
>>
>>51495654
map is obsolete. C# LINQ improves on those dusty old lisp macros in literally every single way possible.
>>
>>51495773
LINQ select is exactly the same as map.
>>
>>51495442
>I'm poor
>>
Hey dpg. I've mostly worked with C++ and Java in the past, and in at least one of those languages, you could construct strings as such:

string sampleString;
sampleString = "This is a "+testFunction()+" function.";

where testFunction returns another string. Essentially you could combine strings in one line.

I'm working with Arduino and I'm trying to create a string (from input, function returns, etc.) and display it on an LCD screen but as I'm finding out now, strings in C are arrays of chars and it's not as easy to do the above. Does anyone have any resources or advice for dealing with strings?
>>
>>51495442
Not parting with money is very Jewish behavior. /g/ is full of hypocrite's I guess.
>>
>>51495787
map has no type checking
>>
>>51495837
That depends entirely on the language implementing it.

https://en.wikipedia.org/wiki/Map_%28higher-order_function%29#Language_comparison
>>
Working with ASP.NET MVC and C#
I have charts that I'm making from my database and displaying them on one of my links.
I want to make a button which will display the called graph on the same page. I can only get it to display the graph on the original page and not on the same one where my button is located. Just for a reference I was able to display the graph on a page with content by calling the original page where the chart is generated.

My view code :
 <input type="button" value="Create" onclick="location.href='@Url.Action("DrawChart")'" /> 
>>
>>51495810
Learn the C strings library.
http://www.cplusplus.com/reference/cstring/
>>
>>51495797
>i'm a consumerist
>>
File: 1430853197680.png (331KB, 474x432px) Image search: [Google]
1430853197680.png
331KB, 474x432px
>>51495505
>function composition and currying
nicely memed
>>
>>51495820
good goy
>>
>>51495918
Function composition is a mathematical concept, how is it a meme?
>>
>>51495942
>mathematical concepts in programming
>not memes

nice imaginary numbers
>>
>>51495918
>something useful to programming is a meme
wew lad
>>51494737
>this is a java thread
welp, I'm out
>>
>>51495891
This is how I originally display my graphs on that cshtml.
<img src="@Url.Action("DrawChart")"/>

So maybe the better question would be how do I combine the img src and input type tags ?
>>
File: menu.png (588KB, 814x637px) Image search: [Google]
menu.png
588KB, 814x637px
Still working on my VN, but it's going slower than I'd like because of University.

I'm also running pretty low on ideas, and I want to know what direction /g/ thinks I should go.

Any suggestions?

Repo: https://github.com/gitgood/Living-in-the-fast-Lain/
>>
>>51495892

thank you kindly, anon. :)
>>
>>51495963
>functional composition
>currying
>useful
>>
File: lain.jpg (37KB, 1014x274px) Image search: [Google]
lain.jpg
37KB, 1014x274px
Also, 666.
>>
Is Erlang/Elixir a professional language, or is it mostly just academic?
>>
>>51495995
What's functional composition? Do you mean function composition? I wouldn't be surprised if you think arithmetic and numbers are useless too.
>>
>>51495995
I mean you could write all the boilerplate to accomplish the same thing yourself if you wanted to, but why go to all the effort when lambdas make it simple? I'm sure most imperative programmers working with Java, C#, JavaScript, C++, D, etc. use lambdas regularly
>>51496029
It's almost entirely professional and not really academic at all. It was made by Ericsson for professional purposes and started out with 0 academic backing.
>>
>>51496046
Currying is fucking retarded. Just make the function take 2 arguements you wanker
>>
I have a really, really big problem guys.
Is there any way to make Code::Blocks syntax highlighting the same as Visual Studio, or at least force it to highlight all classes?
As is, I currently have to add each class manually to a list. This is killing me.
>>
File: syntaxon.jpg (46KB, 600x291px) Image search: [Google]
syntaxon.jpg
46KB, 600x291px
>>51496110
>using syntax highlighting
>>
>>51496072
Arguements are fucking retarded. Just make the function use 2 globals you wanker
>>
>>51496141

Why even use functions?
>>
>>51496128
More like
the left picture is in color
>>
>2015
>using functions
>not using coroutines
>>
>>51496170
>1975
>using coroutines
>not using continuations
>>
>>51496156
Grayscale isn't color
>>
>>51496072
I can do that, too. It's just less useful.
let curried x y = x + y
let uncurried (x, y) = x + y

(* Add one to each number in the list *)
List.map (curried 1) [0; 1; 2; 3; 4]
List.map (fun x -> uncurried (1, x)) [0; 1; 2; 3; 4]

So I _could_ make it take 2 arguments, but then it would be inconvenient to use later on. Why is it a problem that I'm using currying to you anyways?
>>
>>51496181
>0x7b4
>using continuations
>not using
COMEFROM
>>
I'm a trap
>>
>>51496271
Are you an integer overflow trap or a float division by zero trap?
>>
>>51494925
because there's nothing better
>C/C++
Too low level
>C#
no linux
>Python
Slow and there's no guard rails to protect you from Indian programmers.
>Insert hipster language here
Not enough library support and none of your employees know it.
>>
>>51496170
>>51496181
>>51496261
[current year]
NOT USING GOTO
HAHA PLEBS
>>
>>51496284
C# has excellent linux support
>>
>>51496223
Or just do
for (int i = 0; i < 4; i++) {
list[i] += 1;
}


like a normal person.
>>
>>51495968
>>51495891
So nobody here works with ASP.NET or I just came in some stupid time ?
>>
>>51496287
Continuations are actually a more abstract concept than goto. Gotos can be created using continuations as primitives, but continuations cannot be created using gotos as primitives.
>>
>>51494527
Have any of you ever used LOVE before, what do you think about it?
>>
>>51496291
it was only recently microsoft added official support. 3rd party support isn't good enough for companies to jump in enthusiastically. Everythings already in Java and there's no point in switching.
>>
>>51496284
>>C#
>no linux

You must've been out of the loop for the past 2 years.
>>
>>51496309
>cannot be created using goto as primitives
I'm calling bullshit
>>
>>51496293
array[:4] += 1


Numpy a best.
>>
>>51496282
I'm a human trap! http://www.urbandictionary.com/define.php?term=Trap&defid=5223239
>>
>>51496293
>i++

Why do you hate semantics?
>>
>>51496333
>I'm a human trap!
You're... a user error?
>>
>>51496324
Too little wayyyyyy too late. Every company has already been using Java for years. All their programmers know Java now
>>
>>51496322
There's no point in switching from Java anyways if that where your code base is. But if you're starting fresh, why not use mono?
>>
>>51496365
>Every company has already been using Java for years.
>The company I work in used Java for everything
>I presume C# gets used no where
C# is pretty popular too m8. Even before good linux support.
>>
>>51496365
I don't think the intent of C# was to replace all enterprise code. It was to facilitate devs quickly producing consumer applications for Windows.
>>
>>51496405
>I don't think the intent of C# was to replace all enterprise code.
Wrong. It's widely used for enterprise shit. It just happens to be good for a lot of consumer stuff lately too.
>>
File: highlight.png (552KB, 963x291px) Image search: [Google]
highlight.png
552KB, 963x291px
>>51496128
>not using syntax highlighting
>>
>>51496365
>All their programmers know Java now

Good thing it's an easy transition. :)
>>
>>51496436
Not really, very small enterprise market share compared to Java. Like I said, it was never intended to replace all enterprise code.
>>
>>51496455
Of course not, but it was targetted at that.
>>
>>51496440
I'm not shilling for any language, I actually hate Java myself. But what are the advantages of C#?
>>
File: fruit-salad.jpg (110KB, 1007x545px) Image search: [Google]
fruit-salad.jpg
110KB, 1007x545px
>>51496439
>(global-font-lock-mode 1)
>>
>>51496502
.NET
>>
>>51496405
The purpose of C# was to ensure that Java didn't steal Microsoft's lunch (by fostering the creation of mainstream software which didn't need Windows).

In the end, Java is mostly used for bespoke server code, which doesn't have much impact upon the Windows ecosystem. So it doesn't particularly matter to Microsoft whether C# gets used or not. The main reason for its continued existence is to replace VB with something resembling a real language.
>>
>>51496502
Good generics
properties
good enum implementation
signed integers
async/await keywords
var keyword
structs
pointers
superior dev tools
generally lots of nice little useful features
generally feels very well thought out
well supported on all mobile platforms via Xamarin

probably a good few other things too
>>
>>51496502

Reified generics, actual value-type structs, operator overloading, LINQ, etc.

Lots of really gud things
>>
>>51496550
In other words, a sane type system.
>>
>>51496550
>properties
>good enum implementation
>signed integers
>async/await keywords
>pointers

Thanks, I missed these. Breddy gud shit, m9.
>>
>>51496550
unsigned integers rather
>>
>>51496570
pretty much yeah.
>>51496575
thanks m80
>>
>>51496550
also
very easy native code interop.
SIMD
Good GUI libs on windows.
Pretty good support for native UI's on mac and linux (Cocoa and GTK+)
>>
>>51496515
Of course, you have to get a good theme too.
>>
>>51496626
>very easy native code interop.

This is a big one, too. Pinvoke (even on Ganoo/Lingus) is seriously godlike.
>>
Started learning C, moving here from learning java which i was at an intermediate to advanced level at.

Not only i want to learn it, i feel i must learn it. To me, C is a language every dev must have some proficiency at.
>>
>>51496704
Agreed. I've only needed it a couple of times, but my god it's handy to have. Makes you feel like you're not boxed inside the CLR, like I feel like on the JVM. You can pull in native assemblies from anywhere with ease.

The biggest benefit I find it that it means premade .NET wrappers for native assemblies are easy to come by, like SlimDX for example. Which is pretty excellent.
>>
>>51496550
Really IMO C# only needs better cross-platform ability, which thankfully is being worked on.
I know there's mono, but I'm glad microsoft is working on porting it to OSX/Linux
>>
>>51496550
>>51496559
>>51496570

>good generics
>no specialisation
pick one
>>
>>51496753
You can use JNI for that
>>
>>51496753
>Makes you feel like you're not boxed inside the CLR, like I feel like on the JVM.

Which, to be fair, Java has JNI, but the C# setup is LEAGUES better. It is incredibly good.

If I had to sum it up with a famous quote: "It just works" - Todd Howard

>The biggest benefit I find it that it means premade .NET wrappers for native assemblies are easy to come by

And when they're not, it's typically a piece of cake to write one yourself if you know how the library works (from using it in its native language, etc).
>>
>>51496796
>good generics
Compared to Java, yes.

>>51496766
Mono is pretty great. CoreCLR is RC now. MS are making a BIG deal about ASP.NET 5 working as a first class citizen on OS X and Linux. The new VS Code is in RC too now, which now supports full intellisense and debugging on all platforms. Things are changing quick.

>>51496820
I know. My point is JNI is very painful to use, whereas PInvoke is very straight forward.
>>
>>51496872
>compared to Java
shit argument
>>
>>51497004
I was responding to this post originally m8. No need to spaz out. The integrity of your favourite language is secure.
>>51496502
>>
>>51495980
will this teach me SICP
>>
>>51494191
Anyone here have done stuff with QML and Qt Quick ? I had one or two questions regarding those two things.
Is it normal that I find this "language" garbage and non productive ? The documentation isn't very great, there's no tutorials, and making a simple program like a RSS reader is painful. Is it me or just the language ?
>>
>>51497050
sorry any mention of java triggers me
>>
>>51497104
QML is literally javascript
>>
>>51497141
but its the #1 language right now
>>
>>51497141
You are forgiven. It's a natural tendency among decent programmers.
>>
>>51497170
#1 meme language
>>
>>51497196
nah thats node.js and possibly javascript as a whole
>>
>>51497215
no they're the best languages, not the best meme languages
>>
>>51495009
>I'm not the creative type
Neither am I. That's why I have no projects in my portfolio.
>>
>>51497310
>That's why I have no projects in my portfolio.
That doesn't mean you're not creative. That just means you can't code for shit.
>>
>>51497412
>That just means you can't code for shit.
Everything I've done for the last several years has been for work. I signed a NDA and an IP ownership agreement, so I can't show any of the work I have done.
Plus all of the stuff I wrote for personal use was done in Java and Scala, which doesn't help since the company I'm applying for asked for C++ experience.
>>
>>51497169
Seriously ? I have done javascript 2 years ago, but I don't remember it being that shit.
>>
.jar files are literally the worst library.executable format in the world
>>
>tfw no programmer bf
>>
>>51497554
LONDON
O
N
D
O
N
>>
>>51497554
gay
>>
characterArrayTest.c:14:26: warning: passing argument 1 of 'getline' from incompatible pointer type
while ((len = getline(line,MAXLINE)) > 0)

I know what a pointer is, I'm just not familiar how to manipulate them and their syntax yet. Can anyone help me with this error? It's valid C code from the 1978 edition of the C book. From my vague research, I feel like I'm missing a prototype for the function maybe? I'm not familiar with those but apparently that's something that has changed about C since the first edition of this book.
>>
File: d.jpg (66KB, 591x456px) Image search: [Google]
d.jpg
66KB, 591x456px
>>
>>51497487
I remember a while back when I wanted to help a friend with his Java homework, I tried to compile and run my Java stuff from the command line. That was fun.

There was also a long period where the "java.exe something.jar" style of starting a program messed with Windows program search. I think it's fixed now though yeah?

I've never looked at the actual way Java goes from 0 to VM, I can only assume it does some wonky stuff too.
>>
>>51497956
D!
>>
>>51497907
>it's valid C code
>from
>the
>1978
>edition
>>
>>51497907
First parameter to getline() is a char**. You're probably passing a char*. Try using:
while ((len = getline(&line,MAXLINE)) > 0)
>>
>>51497554
FAKE & GAY
A
K
E
&
G
A
Y
>>
>>51497998
stdio.h:37:9: note: expected 'char **' but argument is of type 'char (*)[1000]'
ssize_t _EXFUN(getline, (char **, size_t *, FILE *));


I'll probably just come back to this when I have a better understanding, thank you though.
>>
File: 1371256645613.gif (2MB, 257x359px) Image search: [Google]
1371256645613.gif
2MB, 257x359px
Could someone please explain to me why C programs, when compiled and then disassembled, seem to begin close to memory location 0x400000?

I looked online, and people said the code doesn't start at zero because 0x0 is the NULL pointer, and starting code there would throw things off, but why isn't code started at 0x1, then? Why is there 4MB of wasted space before the program starts? Is there anything important in those upper regions?
>>
>>51498199
Compiler writers know better than you.
End of story, weeb.
>>
>>51498223
Just curious, friendo

There is never anything important before the start of the text section anyways, because the heap comes after .text and stack is mapped all the way at the highest memory.
>>
Is there a programming drinking challenge?
>>
>>51498104
w-what would it take to convince you it's not?
>>
>>51498263
drink every time your code doesn't compile
>>
>>51498263
drink for every segfault
>>
>>51498263
write C with -ansi -pedantic
drink every time you get a compiler warning
>>
what is the equivalent of "K&R" book for assembly, something that's not too ancient
>>
C has the best native code interop.
>>
>>51498199
'Cause paging.
>>
>>51498223
It's not the compiler writers idiot, it's the linker and OS writers who take care of that shit, normie.
>>
>>51494191
>>51494246
I'm trying to solve the first problem of PE with a language still in development for a theoretical type of computer... Progress has been slow so far, just finished having either the number returned or a zero (y0 on first, n0 on second). Logic gates can be fully simulated with the language so I'm assuming it's Turing complete.
Two ways of doing it atm
A:1 <- n ~ Number
@:2 <- (y3) ~ +3
@:3 <- (y5) ~ +5
@:4 <- (%) ~ Remainder 3
@:5 <- (%) ~ Remainder 5
@:6 <- (y0) ~ +0
@:7 <- (/) ~ 0/0=1, else/0 = INF
@:8 <- (/) ~ 0/0=1, else/0 = INF
@:9 <- (^) ~ Get INF or 1
@:10 <- (/) ~ n/1=n else n/yc = y0
\\ 1,2 -> 4
\\ 1,3 -> 5
\\ 4,6 -> 7
\\ 5,6 -> 8
\\ 7,8 -> 9
\\ 1,9 -> 10

and
A:1 <- n ~ Number
@:2 <- (y3) ~ +3
@:3 <- (y5) ~ +5
@:4 <- (%) ~ Remainder 3
@:5 <- (%) ~ Remainder 5
@:6 <- (y0) ~ +0
@:7 <- (=) ~ yc else n0
@:8 <- (=) ~ yc else n0
@:9 <- (&) ~ number or n0
@:10 <- (&) ~ number or n0
@:11 <- (|) ~ number or n0
\\ 1,2 -> 4
\\ 1,3 -> 5
\\ 4,6 -> 7
\\ 5,6 -> 8
\\ 1,7 -> 9
\\ 1,8 -> 10
\\ 9,10 -> 11
>>
>>51498391
Fuck off with your shit architecture.
>>
with which language can i make nice / modern GUIs? guessing JavaFX
>>
>>51498391
gross
>>
>>51498391
Even with logic something could lack turing completeness (i.e. it could be impossible to have an infinite loop).
>>
>>51498420
C
>>
>>51498366
Could you elaborate on that, please?
I looked a bit more into it, and it seems that the linker dictates where the text section starts (as >>51498384 also said).

What effect does memory paging have on this? If I tell the linker to start the text section at, say, 0x200000, will there be any downsides?
>>
>>51498420
C
>>
>>51498427
Have an infinite loop
A:1 <- (y1)
A:2 <- (+)
\\ 1,1 -> 2
\\ 1,2 -> 2 # 2 $ A
>>
>>51498420
Swing if you want it to look like a native application.
JavaFX if you want a custom look with CSS styling.
>>
>>51498420
Anything with a Qt library.
>>
>>51498455
Look up virtual memory and paging, seriously.
OSDev is a good resource.

Basically your OS allocates memory in pages (on x86 pages are 4kb) so the minimum amount of memory you can allocate is 4kb.
Sections in an executable are typically loaded at page boundaries (i mean you COULD offset it but that's just wasted space in the executable).
If you loaded your text section at 0x1, the OS would still have to allocate the page at 0x0 -> 0x1000, so a de reference of a null pointer would not be caught because segfaults happen when accessing a page that is not mapped in.
I have to leave soon so i did not explain that very well, just look it up and you will understand. Actually here i will look it up for you:
http://wiki.osdev.org/Category:Memory_management
http://wiki.osdev.org/Paging
http://wiki.osdev.org/Memory_management
http://wiki.osdev.org/Page_Tables
>>
File: Loop.png (24KB, 1152x566px) Image search: [Google]
Loop.png
24KB, 1152x566px
>>51498467
>>51498408
To soon to tell whether it is shit, it could very well be, however, linking registers together and giving them their own logic units is an interesting idea nonetheless.
>>
>>51498557
Btw, you may be wandering my you can allocate blocks much smaller than 4kb using malloc, that's because malloc initially requests pages from the OS and then applies its own algorithm to give out smaller blocks of those pages to callers.
>>
>>51498557
Thanks for the links, I'll take a look at those.
>>
how many e-penis length increase would I gain by reverse engineering Apple Quartz and porting it to lunix?
>>
File: 1374868022267.gif (983KB, 323x224px) Image search: [Google]
1374868022267.gif
983KB, 323x224px
Is it normal to spend 10x more time debugging code than writing it?

>class assignment is to write a custom memory allocator
>write the first version in an hour
>spent 2 days so far just trying to handle edge cases, and things still don't work 100%

Is it supposed to be this way, or am I just too retarded?
>>
>>51498740
Use Haskell :^)
>>
>>51498740
generally yes
>>
Dear C experts,

Have you ever experienced a pointer value to change without any assignment to it? I have a pretty complex project i'm working on and for some reason there's one instance where my pointer changes from NULL to 0x1000000.

I've debugged the range in which this happens to just ~5 lines in which the value magically changes during it.

It's also a malloc'd pointer so I don't see how it would be getting destroyed by some stack operations from other operations in that ~5 line radius.

It's consistently doing it too and only changed it to 0x1000000 every time.

For now i'm just going to account for it since I'm dumbfounded as to how it's changing, but i just wanted to see if anyone ever had this happen before.
>>
>>51498846
With dynamic allocation, it has only happened to me when I wrote more data to a slot then I requested.

malloc won't overwrite any requested data for you, just reserve a certain chunk for you. If you run malloc(10) twice, and it happens to give you two 10-byte slots that are back-to-back, and you write more than 10 bytes into the first one, it may overrun into the second slot, causing things to mess up.

Are you absolutely sure that you aren't overwriting a nearby slot with something else?

Could you post the effected code here?
>>
>>51498885
I absolutely am sure nothing around it is being written to.

The basic scheme of what's happening is:

//Lets call X my magical pointer
fun1(); // At the end of fun1 X is NULL for sure

if(...) { // this if fails and never gets taken
}

fun2(); //At the start of fun2 X is now 0x10000000


There's quite literally no memory write operations between the two, and the strange thing is it's only happening with one of my test cases while other similar ones don't seem to have this issue.

my hack around it seems to work; however, i would fear if this 0x1000000 is machine specific.
>>
>>51494191
doods plshelp, I'm trying to make an application in Java and I need to get the information (from a mysql database) whether a user has privilege to do X or not, so rs being my ResultSet:
while (rs.next()){
if ( rs.getString('privilege').equals("1") )sw=true;
else sw=false;
}


but I get an error on the if and subsequently the else, saying a ; is expected and that there's an unclosed character literal

I'm dumb can anyone help pls?
>>
>>51498964
Watch it in a debugger.
>>
>>51498846
Use a debugger and set a memory breakpoint (break on write) on the pointer value.
>>
>>51498964
What happens if you comment out everything between the two function calls?

Try putting a
printf("pointer: %p\n", X);
right before the return statement of the first function, after the first function call, before the second function call, and right at the beginning of the second function body, so something like

void fun1() {
// stuff
printf("pointer: %p\n", X);
return;
}

void fun2() {
printf("pointer: %p\n", X);
// stuff
return;
}

int main() {
printf("pointer: %p\n", X);
fun1();
printf("pointer: %p\n", X);

// commented out stuff

printf("pointer: %p\n", X);
fun2();
printf("pointer: %p\n", X);
}


I think this would help find out if anything weird is going on with your stack.
Is X a local variable?
>>
>>51496223
0 1 2 3 4+1

Checkmate, atheists.
>>
File: lambda-star-red-flag.png (23KB, 1920x1080px) Image search: [Google]
lambda-star-red-flag.png
23KB, 1920x1080px
>>51494191
Building a Lisp, implemented in the following way with the help of Objective-C, YaCC, Lex, and itself:

This Lisp is called Valutron. It is architected as an integrated compiler-VM; essentially, this means that code, when entered at the REPL, is first converted into Cons trees, and then mapped down to primitive operations at the stage of evaluation. These primitive operations control a register VM, which operates on Cons cells and Objective-C objects representing Lisp values, and which is implemented as threaded code for maximum performance.

This form was chosen to make it possible to implement continuations easily and to promote good performance. At this point I have described how it implements a basic Scheme-esque Lisp. The VM, as I explained, operates natively on Cons cells. Implemented in Valutron itself are more extensible versions of some primitives like eval; these functions are registered with the VM and, from there on, replace the primitives with themselves.

Here is where Valutron offers a feature called V-expressions. V-expressions are an alternative to S-expression notation for code. They are low in the number of brackets characteristic of S-expressions, and are instead primarily algebraic-style infix.

The pièce de résistance is an object model inspired by the CL Object System, the first ever standardised object-oriented system, which was designed as part of Common Lisp. This is implemented in terms of the Objective-C runtime and hence the full dynamism of Smalltalk, Objective-C, and CLOS are available. The Objective-C runtime used was extended in order to support double dispatch, making available CLOS' characteristic multi-methods.
>>
File: 1443448342317.jpg (182KB, 639x960px) Image search: [Google]
1443448342317.jpg
182KB, 639x960px
>>51499143
>The pièce de résistance is an object model inspired by the CL Object System, the first ever standardised object-oriented system, which was designed as part of Common Lisp.
>>
File: 1407788838945.jpg (65KB, 900x900px) Image search: [Google]
1407788838945.jpg
65KB, 900x900px
>>51499143
>and are instead primarily algebraic-style infix

fucking normie gtfo
>>
>>51499003
hold on I've just realized how much of a fucking idiot I am, good night
>tfw column index is a string
>>
>>51498310
bump
>>
okay faggots, I'm back.

did you virgins discovered how to average two integers in C or you realize you're simply webdev millenials?
>>
>>51499478
Is there some kind of operator restriction here?
You literally just add and divide, language has nothing to do with it.
>>
>>51499549
Overflow.
>>
>>51499549
integer overflow
>>
>>51499549
dunno, some troll posted it like three threads ago and /dpt/ haven't been able to solve it.
>>
>>51499584
There were multiple correct solutions in the last thread. Some guy even posted a sorta clever set of branchless solutions.
>>
>>51499478
a/2 + b/2 + ((a%2) + (b%2))/2
>>
>>51499580
>>51499583
Does C allow you to access the processor's overflow bit?
>>
>>51499647
No.
>>
>>51499647
With inline assembly, yes.
>>
>>51499679
inline assembly is not part of the C standard
>>
>>51499580
>>51499583
>+ is the incorrect operator for addition because it could cause overflow
So how come people use +? Right, because they aren't autistic.
>>
Learning javascript. Kinda stuck on this recursion problem . How does the code "know" to || to the second solution? Wont it just throw a null once it encounters a solution that's too large? How does the program backstep to an earlier value?


function findSolution(target) {
function find(start, history) {
if (start == target)
return history;
else if (start > target)
return null;
else
return find(start + 5, "(" + history + " + 5)") ||
find(start * 3, "(" + history + " * 3)");
}
return find(1, "1");
}

console.log(findSolution(24));
// → (((1 * 3) + 5) * 3)



Here's the explanation of the stack:

 

find(1, "1")
find(6, "(1 + 5)")
find(11, "((1 + 5) + 5)")
find(16, "(((1 + 5) + 5) + 5)")
too big
find(33, "(((1 + 5) + 5) * 3)")
too big
find(18, "((1 + 5) * 3)")
too big
find(3, "(1 * 3)")
find(8, "((1 * 3) + 5)")
find(13, "(((1 * 3) + 5) + 5)")
found!




Thanks friends.
>>
>hide post bringing up that horrible flamewar again
>suddenly 12 stubs in a row
>>
>>51499703
+ is the correct operator for addition, but for code that is bug-free, you need to understand the full semantics of it. Most of the time (a+b)/2 will be fine, and most of the time you don't even need to average integers (you'll be using doubles), but if you don't verify that overflow is impossible due to restricted input size, your code has a bug.

In C, plus may overflow in a platform-dependent way (though much code exists that assumes twos complement).

In Python, + doesn't overflow. Instead, it switches to a bignum transparently.

Most languages either error, overflow in a platform-dependent way, overflow in a well-defined way, or do something like Python.
>>
>>51499720
uh, you print out the stack
you know exactly how it works?
what's your question, or are you just dumb?
>>
>>51499621
Could you please explain the purpose of the "((a%2) + (b%2))/2" part?

Why isn't the "a/2 + b/2" sufficient?
>>
>>51499621
>>51499791
Never mind, I'm retarded
>>
>>51499143

>Here is where Valutron offers a feature called V-expressions. V-expressions are an alternative to S-expression notation for code. They are low in the number of brackets characteristic of S-expressions, and are instead primarily algebraic-style infix.

>no S-expressions
gay as fuck senpai
>>
File: 1444251589777.jpg (57KB, 567x561px) Image search: [Google]
1444251589777.jpg
57KB, 567x561px
>>51499790
>>
>>51499759
>In C, plus may overflow in a platform-dependent way
In C, signed overflow is undefined and unsigned overflow will wrap to zero.
>>
>>51499904
Correct. Signed overflow being undefined is due to different platforms representing signed numbers in different ways. Most use twos complement.
>>
>>51499925
That's not what undefined behaviour means in C.
It may actually wrap to the most negative value on real computers, but on the abstract C machine: it does not.
Your compiler will assume it will never happen and could possibly optimise out overflow checks.
>>
>>51499965
True. If you want to avoid this, you should pass -fwrapv for GCC and Clang: https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Code-Gen-Options.html
>>
>>51500075
Or you could just not have undefined behaviour in your program.
>>
could someone answer this question about polymorphism?
when you set a variable of the base class to an instance of the derived class, can the derived class still access all its functions and data not defined in the base class?
>>
>>51499925
>Most use twos complement.
Do any machines not use two's complement?
>>
>>51500124
Not any that matter, as far as I know. Many new languages make twos-complement wrapping part of the spec.
>>
>>51500115
I feel like this would take about 30 seconds to write up and test.
>>
>>51500248
Going to repost this shit so it's actually kind of readable

So, something is happening to my code, and I feel it isn't correct. I have several functions that are calling other functions in a row. For instance:

clickHandler(takes click) {determines what coordinate was clicked} -> 

clickedPiece(gridCoordinate from click handler) {determines if a piece was clicked} ->

movementBuilder(piece object from clickedPiece) {builds array of positions that a piece can move} ->

drawPiece(positionArray from movemenetBuilder) {draws an overlay over the passed in coordinates}


99% sure this isn't correct
>>
>>51500269
What is the actual problem?
>>
File: tfspray.jpg (13KB, 256x256px) Image search: [Google]
tfspray.jpg
13KB, 256x256px
>>51500269
>this isn't code
>>
>>51500356
I feel like functions aren't supposed to be chained like that, but I don't know enough to tell if it's completely wrong

clickHandler(event) 
{
gridCoordinate = //logic

drawPiece(movementBuilder(clickedPiece(gridCoordinate)));
}


Is functionally identical to what I have
>>
>>51500240
I have tested and it didn't work which is why im asking if its supposed to.
>>
>>51500269
>movementBuilder
the fuck
>>
>>51500457
It's actually buildMovement()

It's not a builder. I just fucked up the name
>>
>>51500269
what the fuck is this shit?
>>
>>51500545
haven't you heard of JavaXD you noob?
>>
>>51500564
Sorry pajeet i'm not a code monkey
>>
>>51500588
>taking the bait
good job monkeyboy
>>
>>51500564
>XD
Kill yourself
>>
>>51500691
XD to be honest
>>
>>51500115
Yes, because the derived object always knows that it's of the derived class.
>>
File: Wedding_crashers_poster.jpg (28KB, 296x438px) Image search: [Google]
Wedding_crashers_poster.jpg
28KB, 296x438px
>>51494191
I have that c++ book. It's at my parents house. Is it good or just a meme book?
>>
>>51500793
thanks, I just have a bug then and not a misunderstanding of the idea
>>
>>51500824
>for dummies
>good
sure champ, go for it
>>
someone pls explain what is machine learning to a javakid.
>>
>>51494863

>When someone says Javascript is a dying language
>>
/!\ A L E R T /!\

new thread
>>51500924
>>51500924
>>51500924

/!\ A L E R T /!\
>>
>>51497453
"I'm not creative" isn't an excuse for not having any C++ experience. Besides, they probably would prefer creative programmers over lazy ones
>>
>>51500896
When has anyone ever said Javascript is dying?
>>
>>51501312>>51501312>>51501312>>51501312>>51501312>>51501312>>51501312>>51501312>>51501312>>51501312>>51501312>>51501312>>51501312

BEST THREAD!
ANIME FREE!
WEEBOO SPOOKER!
TOP KEK!

yay for html :>)
>>
File: W0QgS4N.png (394KB, 1024x1024px) Image search: [Google]
W0QgS4N.png
394KB, 1024x1024px
>>51500835
Eh, I just light the Yule log with it.
>>
>>51500115
I get a stackoverflow when I run this. Why?
public class In { 

public Ex ex = new Ex();

public int getInt() { return 2;}

public static void main (String[] args) {
In in = new In();
System.out.println(in.ex.getInherited());
}

}

class Ex extends In {

public int getInherited() { return 3; }

}
>>
>>51498846
Post code.
Thread posts: 317
Thread images: 21


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