These are chat archives for learnclang/general

29th
Dec 2014
Marcus Ottosson
@mottosso
Dec 29 2014 11:34
@agudmund Hey there, nice to see you found your way here. :)
@csaez And Cesar too! Will you be joining us? :)
Marcus Ottosson
@mottosso
Dec 29 2014 12:34
For the first project, I figure we'd start with compiling something, like a Hello World-type program we run via the console.
We could shape the https://github.com/learnclang/current repository to look like a guide on how to get set-up.
Then others can either follow along and add to the repository, like any GitHub project, or fork it and make their own implementation.
Forking could be good in cases where we'd like to try different routes; for example, if I set up the initial repository I'd be using Sublime Text and Clang, the LLVM front-end on Ubuntu, so the guide would contain instructions for how to get up and running with those components.
David Martinez
@davidmartinezanim
Dec 29 2014 12:37
So just to be clear, we would be writing the information there and the information would evolve by the comments of others that are adding stuff or tweaking things that are not clear enough and once we got it nailed, we would rename the repo?
Marcus Ottosson
@mottosso
Dec 29 2014 12:37
Someone could then come along with an alternative, e.g. using XCode on OSX. Since we're all doing the same thing, we could try and understand each others progress on various platforms and benefit from each others wisdom and research.
Something like that, yes.
Ævar Guðmundsson
@agudmund
Dec 29 2014 12:38
hola David!
David Martinez
@davidmartinezanim
Dec 29 2014 12:38
Hola Aevar! (long time no see!) - Still in Barcelona?
Ævar Guðmundsson
@agudmund
Dec 29 2014 12:38
Iceland for now, too long! yes
David Martinez
@davidmartinezanim
Dec 29 2014 12:39
sounds good to me Marcus. So should we establish the things we need first? such as plain text editor and compiler as minimum?
Marcus Ottosson
@mottosso
Dec 29 2014 12:40
Yeah
David Martinez
@davidmartinezanim
Dec 29 2014 12:40
@agudmund I'll take it that you are back home for holidays but you still work in Barcelona (I hope I can go back at some point as I miss it a lot)
Ævar Guðmundsson
@agudmund
Dec 29 2014 12:41
@davidmartinezanim lets talk on google hangout, no need to fill this chat with personal affairs :)
Marcus Ottosson
@mottosso
Dec 29 2014 12:41
@agudmund Have you got any experience with C?
Ævar Guðmundsson
@agudmund
Dec 29 2014 12:41
in short, the Company I was working for is on hiatus until next autumn so I'm messing about in Iceland determining next move
David Martinez
@davidmartinezanim
Dec 29 2014 12:42
@mottosso so in terms of compilers, I suppose that GCC for unix based systems, VS (windows specific) and MinGW covering more than one platform?
Ævar Guðmundsson
@agudmund
Dec 29 2014 12:42
@mottosso have worked with Assembly code (lighting and projector controls), done some experimental C, and have rudimentary C++ experience
David Martinez
@davidmartinezanim
Dec 29 2014 12:43
@agudmund fair enough, you are right. Let's open a window in hangouts
Ævar Guðmundsson
@agudmund
Dec 29 2014 12:43
in short, a beginner, but have done minimal professional work somehow, extending c++ and debugging it, never written a program from start
I know C# if that counts :)
David Martinez
@davidmartinezanim
Dec 29 2014 12:44
@agudmund I did try assembly ages ago and my brain almost end up bleeding after writing a hello world application.
Marcus Ottosson
@mottosso
Dec 29 2014 12:44
@agudmund Excellent, we could use your experience here I'm sure :)
@davidmartinezanim I think MinGW is a Windows port of GCC, which is a Unix compiler (I think) and that VS is Windows-only, except that they only recently announced porting it to Unix (again, I think)
And finally, XCode is using GCC (I think)
David Martinez
@davidmartinezanim
Dec 29 2014 12:45
@mottosso ah, you mean with that announcement of porting the whole .NET to Unix?
Marcus Ottosson
@mottosso
Dec 29 2014 12:45
Yeah, that was probably it
David Martinez
@davidmartinezanim
Dec 29 2014 12:45
I believe it is using GCC indeed but don't quote me on that
Ævar Guðmundsson
@agudmund
Dec 29 2014 12:45
hehehe, most assembly code is drag and drop, and the stuff I was doing was very simple relay control, think Houdini node graph, 15 years ago in a standalone application, no literal typing just assemble the code through a graph
Marcus Ottosson
@mottosso
Dec 29 2014 12:45
Maybe that didn't involve the C compiler
Assembly is drag and drop? :O
David Martinez
@davidmartinezanim
Dec 29 2014 12:46
well, maybe if you know which bits are you moving where and why
but it was bending my mind
badly
Ævar Guðmundsson
@agudmund
Dec 29 2014 12:46
around those lines yes
when you buy the equipment you get the software with it which you plug into a serial port to program the devices
Marcus Ottosson
@mottosso
Dec 29 2014 12:48
Okay, anyway here's how I'd imagine the Current repo to look once finished:
  1. One file, which is the source code for the Hello World application
  2. Documentation for how to get the file to compile
As this is the first project, the Documentation should be thorough enough for a beginner to follow from start to finish, including links to resources we find online, books and tutorials
Ævar Guðmundsson
@agudmund
Dec 29 2014 12:49
[end diversion] @mottosso you mean to place the first commit of the repo as a working file, or a template for building a working file
Marcus Ottosson
@mottosso
Dec 29 2014 12:50
I mean when the first project is complete, the repo should probably only contain these two things
A file to compile, and instructions for doing it
Ævar Guðmundsson
@agudmund
Dec 29 2014 12:50
very cool
Thanks
David Martinez
@davidmartinezanim
Dec 29 2014 12:50

include <stdio.h>

void main()
{
printf("hello, world\n");
}
?
oops
I did not expect markdown to pick up on that
well, probably using int instead of void
Marcus Ottosson
@mottosso
Dec 29 2014 12:58
You can use the triple ` and a language to format source code. :)
#include <stdio.h>
void main() {
    printf("hello, world\n");
}
David Martinez
@davidmartinezanim
Dec 29 2014 12:58
I believe that main should always return int instead of void
let me try that
#include <stdio.h>
int main() {
    printf("hello, world\n");
}
Marcus Ottosson
@mottosso
Dec 29 2014 12:59
Yes, I think so too, as a return code, right
?
David Martinez
@davidmartinezanim
Dec 29 2014 12:59
yes
Marcus Ottosson
@mottosso
Dec 29 2014 12:59
And that if you don't specify anything, it'll default to int
David Martinez
@davidmartinezanim
Dec 29 2014 13:00
that's right
Marcus Ottosson
@mottosso
Dec 29 2014 13:00
Clang throws a warning if you do though it seems, so probably best to include it
David Martinez
@davidmartinezanim
Dec 29 2014 13:00
my highlighting doesn't look correct
Marcus Ottosson
@mottosso
Dec 29 2014 13:00
You've got nicer colors then mine. :)
David Martinez
@davidmartinezanim
Dec 29 2014 13:00
:-P
Marcus Ottosson
@mottosso
Dec 29 2014 13:00
You can suffix the triple ` with c or python etc.
Mine was wrong, I used Python, now they're the same :)
But yes, that looks about right as far as source code goes
Now the tricky part is to explain how to get it to compile, and why we do it this way, and not another way
Are you up for the challenge?
David Martinez
@davidmartinezanim
Dec 29 2014 13:04
well, I don't have VS and I'm using minGW:
  • Should I explain how to do it with that setup?
  • Should I go into specifics about getting those installed and such?
Marcus Ottosson
@mottosso
Dec 29 2014 13:04
Yeah, that would be perfect
Weren't you even using Clang with MinGW?
Let's assume the reader has never compiled anything, but is familiar with Python or Lua
In fact, the reader doesn't know what the difference is between an interpreted and compiled language
David Martinez
@davidmartinezanim
Dec 29 2014 13:06
yes, although that took a little bit of back and forth and not sure I will be able to get the explanation right for a new starter. I guess that because of that it is good that we have a group of people trying to do the same, right?
Marcus Ottosson
@mottosso
Dec 29 2014 13:06
Yeah, I'd imagine it being a healthy excersize to have a few different approaches explained, that all reach the same goal
-> To compile the given source code
David Martinez
@davidmartinezanim
Dec 29 2014 13:07
should I fork the main repo and work locally?
Marcus Ottosson
@mottosso
Dec 29 2014 13:07
I'm especially curious about MinGW, as I've only been using Clang directly on Ubuntu
I'm not sure, we all have write permission to the main repo
David Martinez
@davidmartinezanim
Dec 29 2014 13:08
so that means that in your case is clang+gcc, right?
Marcus Ottosson
@mottosso
Dec 29 2014 13:08
I don't think so.. but I'm not sure, I think it's LLVM and Clang, without dependence on GCC
But I could be wrong
About forking, if we fork, then the Wiki and Issues will stick with each fork
I suppose we could keep all issues in the main repo, and wiki entries too
Alternatively, we all just pull directly from the main repo, and stay in synch with each other
The better way will probably reveal itself in time I think
David Martinez
@davidmartinezanim
Dec 29 2014 13:10
latest sounds better to me, I think
Marcus Ottosson
@mottosso
Dec 29 2014 13:10
Go for that
Fixed a spelling error above, work -> fork
David Martinez
@davidmartinezanim
Dec 29 2014 13:18
Although I appear to be an administrator on the organization, I don't seem to have permissions to write on the specific repo
Marcus Ottosson
@mottosso
Dec 29 2014 13:18
One sec
You're right, I added the group to the current repo now
Looks like it will have to be added onto each repo, I thought the organisation had access to each repo.. hmm
Marcus Ottosson
@mottosso
Dec 29 2014 13:37

Schedule

To keep some sort of schedule of where to go in the future, we could talk about where to go in this chat, and then update this list.
https://github.com/learnclang/about/wiki/Projects
David Martinez
@davidmartinezanim
Dec 29 2014 13:46
@mottosso take a look at the repo and let me know if you think it's going in the right direction
Marcus Ottosson
@mottosso
Dec 29 2014 13:48
Sure, looking now
Looks great
It leaves room for others who know how that works to fill things in.

What do you think about writing in the Wiki, instead of the README?

  1. Mainly due to the real-time preview.
  2. But also that others can edit easily, without forking first.
  3. And also, because we can add more pages. For example, a FAQ or in-depth articles.

The README could simply link folks into there.

David Martinez
@davidmartinezanim
Dec 29 2014 13:54
I'm not sure how to approach the compiling process. should we write it for gcc and then have other repos that are specific for each of the compilers? such as visual studio or XCode to go into specifics on how to get things setup? I reckon that gcc is the easiest one and hassle free for new starters.
got it. sounds good to use the WIKI instead
Marcus Ottosson
@mottosso
Dec 29 2014 13:55
We could maintain a main storyline in the guide, going through one particular compiler and OS, and then branch off with links to other pages when documenting other compilers or OSs
David Martinez
@davidmartinezanim
Dec 29 2014 13:57
also, I was thinking that it might be a good idea to create a wiki page/series of pages for basic vocabulary. things such as compiling and linking are not straight forward to people who hear those concepts for the first time and yet those are concepts that we need to address... Maybe each time we have one of those words, we can add a link to the page that contains the definition.
Marcus Ottosson
@mottosso
Dec 29 2014 13:58
Certainly
Sounds like a glossary
David Martinez
@davidmartinezanim
Dec 29 2014 13:58
exactly
Marcus Ottosson
@mottosso
Dec 29 2014 13:59
Maybe put this one in the About repository, as it relates to the whole organisation?
For particular comments/issues about a particular project, we could use issues, like this learnclang/current#1
David Martinez
@davidmartinezanim
Dec 29 2014 14:05
sounds good to me
quick question for you
when creating a wiki, is is possible to have a page to show up nested on another (on the right side section I mean). Also, how do I link one page to another?
Ævar Guðmundsson
@agudmund
Dec 29 2014 14:09
@mottosso regaring camelcase vs snake_case et al
to each his own and all that, but keep in mind there is only one naming convention which has a literal performance difference
most file systems, like Lustre, BlueArc, Open-e and so on, have extended indexing functionalities which speed up the file system considerably
works on the premise to skip all files with uppercase letters in them or lower case
so if you have a 100T server, and your production data is all named lowercase, from a file server configuration point you can speed up access by telling the server to only look for those.
such is not possible with camelcase
page 112
Marcus Ottosson
@mottosso
Dec 29 2014 15:03
I'm adding some table of contents links to it
Marcus Ottosson
@mottosso
Dec 29 2014 15:09
Ah, looks like we overwrote each other. :) Luckily, there's revision history available from within the wiki.
David Martinez
@davidmartinezanim
Dec 29 2014 15:21
Oops... Sorry about that Marcus. I'm not working on that atm. I will have lunch and I'm unsure if I'll be able to add anything this evening.
Marcus Ottosson
@mottosso
Dec 29 2014 15:24
No worries
David Martinez
@davidmartinezanim
Dec 29 2014 17:06

Ok, I've done some more changes.

Text has been moved to the WIKI and restored a way simpler main README file

Marcus Ottosson
@mottosso
Dec 29 2014 17:07
Excellent, looking good
I like that the TOC ended up on the Home page of the Wiki, I think that makes the most sense.
I also added a sidebar, to have the TOC be accessible wherever you are
David Martinez
@davidmartinezanim
Dec 29 2014 17:09
fantastic
I think that we should add a Next: link like you have in Pyblish
and edit the table of contents so it reflects the structure that we have in the TOC as well for quick navigation
Marcus Ottosson
@mottosso
Dec 29 2014 17:33
Sure, sounds good.
Would you mind if I renamed the required ? to required??
Is that a misspelling?
Added a section on how to configure a text-editor here: https://github.com/learnclang/current/wiki/What-is-required-%3F
David Martinez
@davidmartinezanim
Dec 29 2014 17:44
Not at all Marcus, go for it. :-)
Marcus Ottosson
@mottosso
Dec 29 2014 17:45
Done. :)
David Martinez
@davidmartinezanim
Dec 29 2014 17:48
all the sidebar is done now and added some information about the compilation process to it's appropriate wiki page
Marcus Ottosson
@mottosso
Dec 29 2014 17:48
Yeah, looks really good
Added some images
We've got an activity stream to the right of the chat now too
David Martinez
@davidmartinezanim
Dec 29 2014 17:51
cool
Marcus Ottosson
@mottosso
Dec 29 2014 18:20
Does anyone know what the difference is between compiling and linking?
David Martinez
@davidmartinezanim
Dec 29 2014 18:21
I don't tbh
Marcus Ottosson
@mottosso
Dec 29 2014 18:29
Okay, found something and added it to here: https://github.com/learnclang/current/wiki/Basic-workflow
David Martinez
@davidmartinezanim
Dec 29 2014 18:36
:+1:
Marcus Ottosson
@mottosso
Dec 29 2014 19:06
I'm writing a tutorial on how to get up and running using Ubuntu and GCC
David Martinez
@davidmartinezanim
Dec 29 2014 19:09

awesome! What is your plan? to repeat any steps already specified in the main wiki or do only the parts that are specific.

Once you are done, I might try and do a version for MinGW in windows

I'm going through the book as we speak
David Martinez
@davidmartinezanim
Dec 29 2014 19:21
looking good so far!
Liju Kunnummal
@ljkart
Dec 29 2014 19:39

Since we are trying to compile our code, it is good to know the things which are happening at the back-end.

  • Actually we are trying to convert the high-level language(the source-code we written) to Low-level language(Machine Language)

This process involves four stages and utilizes following 'tools'

  1. Pre-processor
  2. Compiler
  3. Assembler
  4. Loader/Linker

Pre-processor

It replaces all the include(starts with #include) files and macros(starts with #define) with the actual files.

You can try this by using gcc.

c:\>gcc -E helloworld.c > pre.c

This will create a file pre.c which removes all include and macros and replace actual include file.

[Code with #]--->[preprocessor]--->[code without #]

Compiler

Compiler actually takes the pre-processor output and generates assembly source code.
Compiler checks syntax and semantics of the code and shoot error if exists.

c:\>gcc -S helloworld.c

This will creates a "helloworld.s" assembler source code.

Assembler

It takes the assembly source code and produces an assembly listing with offsets. The assembler output is stored in an object file.

c:\>gcc -c helloworld.c

This will create the "helloworld.o" (object file) with the machine codes.

Loader/Linker

It takes one or more object files or libraries as input and combines them to produce a single (usually executable) file. In doing so, it resolves references to external symbols, assigns final addresses to procedures/functions and variables, and revises code and data to reflect new addresses (a process called relocation).

c:\>gcc helloworld.o -lm

This will link and create executable, also can provide multiple files and link them together

c:\>gcc hello1.o hello2.o hello3.o -lm

Summary

Marcus Ottosson
@mottosso
Dec 29 2014 19:51
Wuw, superb @ljkart!
If you still have the Markdown for that, we should add it to the Wiki
David Martinez
@davidmartinezanim
Dec 29 2014 19:54
damn! Now that is a great contribution!
Marcus Ottosson
@mottosso
Dec 29 2014 20:17
When we compile using Visual Studio 2010 on say Windows 7, I'm pretty sure that the result will run on Windows 8, and probably XP and others, given that they each install the redistributable for Visual Studio 2010.
But how does this work for Linux and OSX distributions? How portable are binaries?
Also, if we compile using MinGW, what are the requirements then? How portable are those binaries?
David Martinez
@davidmartinezanim
Dec 29 2014 20:57
I have no idea
Marcus Ottosson
@mottosso
Dec 29 2014 20:57
Reading up on it now, came across this which seems to look to solve the issue between Linux distributions: http://en.wikipedia.org/wiki/Linux_Standard_Base
David Martinez
@davidmartinezanim
Dec 29 2014 20:58
interesting use of gcc -o hello hello.c instead of gcc hello.c -o hello in your tutorial
Marcus Ottosson
@mottosso
Dec 29 2014 20:59
Ah, semantics :)
You would have preferred to have flags last?
David Martinez
@davidmartinezanim
Dec 29 2014 21:00
I don't know... I guess that it makes sense to me to say that I want to work with source_file.c then specify what I want -o for output and finally specify the target_file. But I guess it's just personal taste
Marcus Ottosson
@mottosso
Dec 29 2014 21:01
Yeah, I really have no preference, I just happened to type it that way this time
David Martinez
@davidmartinezanim
Dec 29 2014 21:02
It's all good. I did not know about the other way so I got to learn something new.
Marcus Ottosson
@mottosso
Dec 29 2014 21:03
In any case, what do you think of the tutorial style? Think we could do the same for other platforms/compilers?
David Martinez
@davidmartinezanim
Dec 29 2014 21:05
yeah. I really like it and I think it is really clear.
What about the virtualEnv. Would you keep that for all platforms/compilers?
I mean, if I'm explaining windows, do you think we need to explain how to setup windows in a virtualenv at all?
Marcus Ottosson
@mottosso
Dec 29 2014 21:05
Good question
I find that if we go via virtual environment, there is less room for conflicting settings in each individual's environment
Along with us being forced to provide a full description of steps to install, in cases where we already had previously installed software that was required to get things to work
The Visual Studio Re-Dist comes to mind
David Martinez
@davidmartinezanim
Dec 29 2014 21:07
so that is a yes, then. :-P
Marcus Ottosson
@mottosso
Dec 29 2014 21:07
No, not necessarily, I'm just making a point as to why I went this way. :)
David Martinez
@davidmartinezanim
Dec 29 2014 21:07
but it does make sense
Marcus Ottosson
@mottosso
Dec 29 2014 21:08
It might also make tutorials more cluttered with non-essentials
might
As we may otherwise end up guiding the user through double-checking that the configuration is correct.
David Martinez
@davidmartinezanim
Dec 29 2014 21:09
well, we could have different wiki pages for tutorials but in the TOC only show the main one. And in each of those just place some text that says Page 1/4 or something like that. (or have a link to each page like forums. << 1 2 3 4 >>
Marcus Ottosson
@mottosso
Dec 29 2014 21:10
Pages is a good idea, then we can put aside non-essentials in cases where the user is more daring and goes for his own setup.
I'll give it a try and we'll see how it looks.
David Martinez
@davidmartinezanim
Dec 29 2014 21:11
cool
Marcus Ottosson
@mottosso
Dec 29 2014 21:33
Also added the TOC to the sidebar, under the tutorial
David Martinez
@davidmartinezanim
Dec 29 2014 21:35
I like it split in different pages, although not sure about the TOC as it might be a bit heavy on the eyes after a few of those
Marcus Ottosson
@mottosso
Dec 29 2014 21:36
How about now?
David Martinez
@davidmartinezanim
Dec 29 2014 21:37
that looks more clean actually
Marcus Ottosson
@mottosso
Dec 29 2014 21:50

Did some Googling about compatibility, and it looks to be fine on most platforms of various versions, as long as libraries are bundled with the software.

learnclang/current#2

Downloader

How about this for a next project once we're done with this one, a console application that takes an address and downloads a file off the internet.

https://github.com/learnclang/about/wiki/Projects

Cesar Saez
@csaez
Dec 29 2014 21:58
Hello everyone!
I don't know if you guys are following the handmadehero project, I think we could put a link in the resource section (first week was one of the best intro to C I've ever seen).
https://forums.handmadehero.org/index.php?option=com_content&view=article&id=6
David Martinez
@davidmartinezanim
Dec 29 2014 22:02
Is there a specific reason to do that? I mean to take an address and downloads a file off the internet?
@csaez Que pasa campeon? I do know about the project given the link that you posted on G+. Even though the introduction was good I felt that VS requires a lot of setup before you do anything. That's not necessarily a bad thing but it did feel a bit long when I watched the video before he actually 'made something'.
now don't get me wrong, I'm not against what he was doing. Quite the opposite! It's just my take on what I saw, really. :-)
Cesar Saez
@csaez
Dec 29 2014 22:35
@davidmartinezanim Hi David! I'm not a big fan of VS neither (actually it's not even an option for me, I use Linux at home), but he's using it as a GUI debugger only, code is done in emacs.